using Swift.DAL.OnlineAgent; using Swift.web.Library; using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Net; using System.Text.RegularExpressions; using System.Web; namespace Swift.web.AgentNew.Customer { public partial class AddCustomer : System.Web.UI.Page { private readonly RemittanceLibrary _sl = new RemittanceLibrary(); private readonly OnlineCustomerDao _cd = new OnlineCustomerDao(); private const string ViewFunctionId = "20202000"; private const string AddFunctionId = "20202010"; private const string SignatureFunctionId = "20202020"; protected void Page_Load(object sender, EventArgs e) { signatureDiv.Visible = _sl.HasRight(SignatureFunctionId); isDisplaySignature.Value = _sl.HasRight(SignatureFunctionId) ? "true" : "false"; _sl.CheckSession(); GetStatic.PrintMessage(this); var MethodName = Request.Form["MethodName"]; if (!IsPostBack) { Authenticate(); PopulateDdl(); if (MethodName == "GetAddressDetailsByZipCode") { GetAddressDetailsByZipCode(); } } } private void Authenticate() { _sl.CheckAuthentication(ViewFunctionId); string eId = GetStatic.ReadQueryString("customerId", ""); var hasRight = false; hasRight = _sl.HasRight(AddFunctionId); register.Enabled = hasRight; register.Visible = hasRight; } public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin) { return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent; } private void PopulateDdl() { _sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", ""); _sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select.."); _sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='IdTypeWithDetails',@user='" + GetStatic.GetUser() + "',@countryId='" + countryList.SelectedValue + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlCustomerType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=4700", "valueId", "detailTitle", ddlCustomerType.SelectedValue, ""); _sl.SetDDL(ref ddlOrganizationType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7002", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlnatureOfCompany, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7003", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddSourceOfFound, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3900", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlEmployeeBusType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7004", "valueId", "detailTitle", "", ""); _sl.SetDDL(ref ddlVisaStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7005", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlPosition, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7006", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", "", "Select.."); } private void GetAddressDetailsByZipCode() { string zipCode = Request.Form["zipCode"]; if (!Regex.Match(zipCode, @"^\d{7}?$").Success) { GetStatic.JsonResponse(false, Page); }; HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://yubin.senmon.net/en/" + zipCode + ".html"); myRequest.Method = WebRequestMethods.Http.Get; WebResponse response = myRequest.GetResponse(); string json = null; using (Stream stream = response.GetResponseStream()) { json = (new StreamReader(stream)).ReadToEnd(); } int length = (json.Length) / 4; int indexOfTable = json.IndexOf("