You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

601 lines
28 KiB

  1. using Newtonsoft.Json;
  2. using Swift.API.Common;
  3. using Swift.API.Common.SyncModel;
  4. using Swift.API.ThirdPartyApiServices;
  5. using Swift.DAL.BL.System.Utility;
  6. using Swift.DAL.OnlineAgent;
  7. using Swift.DAL.SwiftDAL;
  8. using Swift.web.Library;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.IO;
  13. using System.Net;
  14. using System.Text.RegularExpressions;
  15. using System.Web;
  16. using System.Web.Script.Serialization;
  17. using System.Web.Services;
  18. using System.Web.UI.WebControls;
  19. namespace Swift.web.Remit.Administration.CustomerRegistration
  20. {
  21. public partial class Manage : System.Web.UI.Page
  22. {
  23. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  24. private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
  25. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  26. private const string AddViewFunctionId = "20212000";
  27. private const string EditViewFunctionId = "20212020";
  28. private const string AddFunctionId = "20212010";
  29. private const string EditFunctionId = "20212020";
  30. private const string SignatureFunctionId = "20212030";
  31. private bool isEdit = Convert.ToBoolean(GetStatic.ReadQueryString("edit", "false"));
  32. protected void Page_Load(object sender, EventArgs e)
  33. {
  34. Authenticate();
  35. signatureDiv.Visible = !CheckAddOrEdit() && _sl.HasRight(SignatureFunctionId);
  36. isDisplaySignature.Value = !CheckAddOrEdit() && _sl.HasRight(SignatureFunctionId) ? "true" : "false";
  37. agreementDiv.Visible = !CheckAddOrEdit();
  38. GetStatic.PrintMessage(Page);
  39. displayOnlyOnEdit.Visible = CheckAddOrEdit();
  40. addEditPanel.Attributes.Add("style", "display:" + (CheckAddOrEdit() ? "none" : ""));
  41. //displayCounterVisit.Visible = !CheckAddOrEdit();
  42. if (GetStatic.ReadQueryString("hdnId", "").ToString() != "")
  43. {
  44. ShowPrintLink(GetStatic.ReadQueryString("hdnId", "").ToString());
  45. }
  46. else
  47. {
  48. linkDiv.Visible = false;
  49. }
  50. //string eId = GetStatic.ReadQueryString("customerId", "");
  51. //if(eId != "")
  52. //{
  53. // PopulateForm(eId);
  54. //}
  55. var MethodName = Request.Form["MethodName"];
  56. if (!IsPostBack)
  57. {
  58. //if (GetStatic.ReadQueryString("customerId", "") != "" || GetStatic.ReadQueryString("edit", "") == "true")
  59. // divUploadImage.Visible = false;
  60. //else
  61. // divUploadImage.Visible = true;
  62. PopulateDdl();
  63. if (MethodName == "GetCustomerDetails")
  64. {
  65. GetCustomerDetails();
  66. }
  67. string methodName = GetStatic.ReadQueryString("MethodName", "");
  68. if (methodName == "GetCustomerDetailsForEdit")
  69. {
  70. string eId = GetStatic.ReadQueryString("customerId", "");
  71. PopulateForm(eId);
  72. }
  73. if (IsCallFromList().ToLower() == "true")
  74. {
  75. if (GetStatic.ReadQueryString("customerId", "") != "")
  76. {
  77. GetStatic.CallJSFunction(this, "CallFromListPage('" + GetStatic.ReadQueryString("customerId", "") + "')");
  78. }
  79. }
  80. }
  81. }
  82. private string IsCallFromList()
  83. {
  84. return GetStatic.ReadQueryString("isCallFromList", "False");
  85. }
  86. public void ShowPrintLink(string membershipId)
  87. {
  88. linkDiv.Visible = true;
  89. printLink.Attributes["href"] = "PrintDetails.aspx?membershipId=" + membershipId;
  90. printLink.InnerText = "Print Details of " + membershipId + "";
  91. }
  92. private void Authenticate()
  93. {
  94. if (CheckAddOrEdit())
  95. _sl.CheckAuthentication(EditViewFunctionId);
  96. else
  97. _sl.CheckAuthentication(AddViewFunctionId);
  98. string eId = GetStatic.ReadQueryString("customerId", "");
  99. var hasRight = true;
  100. if (eId == "")
  101. {
  102. hasRight = _sl.HasRight(AddFunctionId);
  103. register.Enabled = hasRight;
  104. register.Visible = hasRight;
  105. }
  106. else
  107. {
  108. hasRight = _sl.HasRight(EditFunctionId);
  109. register.Enabled = hasRight;
  110. register.Visible = hasRight;
  111. }
  112. }
  113. private bool CheckAddOrEdit()
  114. {
  115. if (isEdit)
  116. {
  117. customerType.Attributes.Add("hidden", "hidden");
  118. }
  119. else
  120. {
  121. customerType.Attributes.Remove("hidden");
  122. }
  123. return isEdit;
  124. }
  125. private void PopulateForm(string eId)
  126. {
  127. var dr = _cd.GetCustomerDetails(eId, GetStatic.GetUser());
  128. if (null != dr)
  129. {
  130. hdnCustomerId.Value = dr["customerId"].ToString();
  131. firstName.Text = dr["firstName"].ToString();
  132. middleName.Text = dr["middleName"].ToString();
  133. lastName.Text = dr["lastName1"].ToString();
  134. txtCompanyName.Text = dr["firstName"].ToString();
  135. genderList.SelectedValue = dr["gender"].ToString();
  136. countryList.SelectedValue = dr["country"].ToString();
  137. address1.Text = dr["address"].ToString();
  138. zipCode.Text = dr["zipCode"].ToString();
  139. city.Text = dr["city"].ToString();
  140. email.Text = dr["email"].ToString();
  141. hddOldEmailValue.Value = dr["email"].ToString();
  142. emailConfirm.Text = dr["email"].ToString();
  143. phoneNumber.Text = dr["telNo"].ToString();
  144. mobile.Text = dr["mobile"].ToString();
  145. nativeCountry.SelectedValue = dr["nativeCountryId"].ToString();
  146. //nativeCountry.SelectedItem.Value = dr["nativeCountryId"].ToString();
  147. dob.Text = dr["dob"].ToString();
  148. occupation.Text = dr["occupation"].ToString();
  149. IssueDate.Text = dr["idIssueDate"].ToString();
  150. ExpireDate.Text = dr["idExpiryDate"].ToString();
  151. idType.SelectedValue = dr["idType"].ToString();
  152. verificationTypeNo.Text = dr["idNumber"].ToString();
  153. hddIdNumber.Value = dr["homePhone"].ToString();
  154. txtMembershipId.Text = dr["membershipId"].ToString();
  155. hdnMembershipNo.Value = dr["membershipId"].ToString();
  156. txtMembershipId.Attributes.Add("readonly", "readonly");
  157. txtRegistrationNo.Text = dr["registerationNo"].ToString();
  158. txtAdditionalAddress.Text = dr["additionalAddress"].ToString();
  159. txtDateOfIncorporation.Text = dr["dateofIncorporation"].ToString();
  160. txtNameofAuthoPerson.Text = dr["nameOfAuthorizedPerson"].ToString();
  161. //txtStreet.Text = dr["street"].ToString();
  162. txtsenderCityjapan.Text = dr["cityUnicode"].ToString();
  163. //txtstreetJapanese.Text = dr["streetUnicode"].ToString();
  164. txtNameofEmployeer.Text = dr["nameOfEmployeer"].ToString();
  165. rbRemitanceAllowed.SelectedValue = (dr["remittanceAllowed"].ToString().ToLower() == "true" ? "Enabled" : "Disabled");
  166. rbOnlineLogin.SelectedValue = (dr["onlineUser"].ToString() == "Y" ? "Enabled" : "Disabled");
  167. rbMobileLogin.SelectedValue = (dr["mobileUser"].ToString() == "Y" ? "Enabled" : "Disabled");
  168. txtRemarks.Text = dr["remarks"].ToString();
  169. txtSSnNo.Text = dr["SSNNO"].ToString();
  170. //ddlSalary.Text = dr["monthlyIncome"].ToString();
  171. ddlDocType.SelectedValue = dr["documentType"].ToString();
  172. //rbKycType.SelectedValue = dr["RegistrationType"].ToString();
  173. if (!string.IsNullOrEmpty(dr["customerType"].ToString()) && !string.IsNullOrWhiteSpace(dr["customerType"].ToString()))
  174. {
  175. ddlCustomerType.SelectedValue = dr["customerType"].ToString();
  176. }
  177. if (!string.IsNullOrEmpty(dr["employeeBusinessType"].ToString()) && !string.IsNullOrWhiteSpace(dr["employeeBusinessType"].ToString()))
  178. {
  179. ddlEmployeeBusType.SelectedValue = dr["employeeBusinessType"].ToString();
  180. }
  181. if (!string.IsNullOrEmpty(dr["natureOfCompany"].ToString()) && !string.IsNullOrWhiteSpace(dr["natureOfCompany"].ToString()))
  182. {
  183. ddlnatureOfCompany.SelectedValue = dr["natureOfCompany"].ToString();
  184. }
  185. if (!string.IsNullOrEmpty(dr["organizationType"].ToString()) && !string.IsNullOrWhiteSpace(dr["organizationType"].ToString()))
  186. {
  187. ddlOrganizationType.SelectedValue = dr["organizationType"].ToString();
  188. }
  189. ddlPosition.SelectedValue = dr["position"].ToString();
  190. //ddlVisaStatus.SelectedValue = dr["visaStatus"].ToString();
  191. ddSourceOfFound.SelectedValue = dr["sourceOfFund"].ToString();
  192. //setStateDll(countryList.SelectedValue, zipCode.Text, dr["state"].ToString());
  193. email.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
  194. emailConfirm.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
  195. hddTxnsMade.Value = dr["isTxnMade"].ToString();
  196. if (dr["isTxnMade"].ToString() == "Y")
  197. {
  198. msgDiv.Visible = true;
  199. msgLabel.Text = "Note: The customer has already made transactions in JME system, so the email can not be modified. For more info please contact HO.";
  200. }
  201. if (dr["idType"].ToString() == "8008")
  202. {
  203. expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4 hidden");
  204. }
  205. else
  206. {
  207. expiryDiv.Attributes.Remove("class");
  208. expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4");
  209. }
  210. membershipDiv.Visible = true;
  211. }
  212. }
  213. private void PopulateDdl()
  214. {
  215. _sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  216. _sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "");
  217. _sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  218. _sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  219. _sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='IdTypeWithDetails',@user='" + GetStatic.GetUser() + "',@countryId='" + countryList.SelectedValue + "'", "valueId", "detailTitle", "", "Select..");
  220. _sl.SetDDL(ref ddlCustomerType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=4700", "valueId", "detailTitle", ddlCustomerType.SelectedValue, "");
  221. _sl.SetDDL(ref ddlOrganizationType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7002", "valueId", "detailTitle", "", "Select..");
  222. _sl.SetDDL(ref ddlnatureOfCompany, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7003", "valueId", "detailTitle", "", "Select..");
  223. _sl.SetDDL(ref ddSourceOfFound, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3900", "valueId", "detailTitle", "", "Select..");
  224. _sl.SetDDL(ref ddlEmployeeBusType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7004", "valueId", "detailTitle", "", "");
  225. // _sl.SetDDL(ref ddlVisaStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7005", "valueId", "detailTitle", "", "Select..");
  226. _sl.SetDDL(ref ddlPosition, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7006", "valueId", "detailTitle", "", "Select..");
  227. //_sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", "", "Select..");
  228. _sdd.SetDDL(ref ddlSearchBy, "exec proc_sendPageLoadData @flag='search-cust-by'", "VALUE", "TEXT", "", "");
  229. _sdd.SetStaticDdl(ref ddlDocType, "7009", "", "Select");
  230. }
  231. protected void register_Click(object sender, EventArgs e)
  232. {
  233. string eId = GetStatic.ReadQueryString("customerId", "");
  234. //if (eId == "")
  235. //{
  236. // if (!_sl.HasRight(GetFunctionIdByUserType(AddFunctionIdAgent, AddFunctionId)))
  237. // {
  238. // GetStatic.AlertMessage(this, "You are not authorized to Add Customer!");
  239. // return;
  240. // }
  241. //}
  242. //else
  243. //{
  244. // if (!_sl.HasRight(GetFunctionIdByUserType(EditFunctionIdAgent, EditFunctionId)))
  245. // {
  246. // GetStatic.AlertMessage(this, "You are not authorized to Edit Customer!");
  247. // return;
  248. // }
  249. //}
  250. if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString())))
  251. {
  252. GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!");
  253. return;
  254. }
  255. if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value)))
  256. {
  257. GetStatic.AlertMessage(this, "Customer signature or customer password is required!");
  258. return;
  259. }
  260. string trimmedfirstName = firstName.Text.Trim() == "" ? null : firstName.Text.Trim();
  261. string trimmedMiddleName = middleName.Text.Trim() == "" ? null : middleName.Text.Trim();
  262. string trimmedlastName = lastName.Text.Trim() == "" ? null : lastName.Text.Trim();
  263. string occupationVal = occupationHidden.Value;
  264. string additionalAddress = hdnAdditionalAddress.Value;
  265. string city = cityHidden.Value;
  266. OnlineCustomerModel customerModel = new OnlineCustomerModel()
  267. {
  268. flag = "customer-register-core",
  269. firstName = trimmedfirstName,
  270. middleName = trimmedMiddleName,
  271. lastName1 = trimmedlastName,
  272. gender = genderList.SelectedValue,
  273. customerType = ddlCustomerType.SelectedValue,
  274. country = countryList.Text,
  275. AdditionalAddress = additionalAddress, //txtAdditionalAddress.Text,
  276. address = additionalAddress,
  277. zipCode = zipCode.Text,
  278. street = hf_editable_townArea.Value,
  279. city = city, //cityHidden.Value,
  280. //state = ddlStateHidden.Value,
  281. senderCityjapan = txtsenderCityjapan.Text,
  282. email = email.Text,
  283. streetJapanese = Request.Form["txtStreet"],
  284. homePhone = phoneNumber.Text,
  285. mobile = mobile.Text,
  286. // visaStatus = ddlVisaStatus.SelectedValue,
  287. employeeBusinessType = ddlEmployeeBusType.SelectedValue,
  288. nativeCountry = nativeCountry.SelectedValue,
  289. dob = dob.Text,
  290. ssnNo = txtSSnNo.Text,
  291. sourceOfFound = ddSourceOfFound.SelectedValue,
  292. occupation = occupationVal,
  293. telNo = phoneNumber.Text,
  294. ipAddress = GetStatic.GetIp(),
  295. createdBy = GetStatic.GetUser(),
  296. idNumber = verificationTypeNo.Text,
  297. idIssueDate = IssueDate.Text,
  298. idExpiryDate = ExpireDate.Text,
  299. idType = idType.Text.Split('|')[0].ToString(),
  300. membershipId = txtMembershipId.Text,
  301. remitanceAllowed = (rbRemitanceAllowed.SelectedValue == "Enabled" ? true : false),
  302. onlineUser = (rbOnlineLogin.SelectedValue == "Enabled" ? true : false),
  303. mobileUser = (rbMobileLogin.SelectedValue == "Enabled" ? true : false),
  304. remarks = txtRemarks.Text,
  305. registrationNo = txtRegistrationNo.Text,
  306. natureOfCompany = ddlnatureOfCompany.Text,
  307. organizationType = ddlOrganizationType.SelectedValue,
  308. dateOfIncorporation = txtDateOfIncorporation.Text,
  309. position = ddlPosition.SelectedValue,
  310. nameofAuthoPerson = txtNameofAuthoPerson.Text,
  311. nameofEmployeer = txtNameofEmployeer.Text,
  312. companyName = txtCompanyName.Text,
  313. //MonthlyIncome = ddlSalary.Text.ToUpper(),
  314. IsCounterVisited = customerCounterVisit.Checked ? "Y" : "N",
  315. customerPassword = customerPassword.Text,
  316. DocumentType = ddlDocType.SelectedValue,
  317. agentId = GetStatic.GetAgent().ToInt(),
  318. occupationOther = occupationText.Text,
  319. ReferralId = referralText.Value,
  320. otherIdNumber = otherVerificationTypeNo.Text,
  321. serviceUsedFor = Request.Form["chkSkip"],
  322. //RegistrationType = rbKycType.SelectedValue
  323. };
  324. if (hdnCustomerId.Value != "")
  325. {
  326. customerModel.customerId = hdnCustomerId.Value;
  327. customerModel.flag = "customer-editeddata";
  328. }
  329. else
  330. {
  331. var custom = PasswordGenerator.GenerateRandomPassword();
  332. customerModel.password = custom;
  333. }
  334. var dbResult = _cd.RegisterCustomerNew(customerModel);
  335. if (dbResult.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value))
  336. {
  337. var customerDetails = _cd.GetRequiredCustomerDetails(dbResult.Id, GetStatic.GetUser());
  338. string membershipId = Convert.ToString(customerDetails["membershipId"]);
  339. string registrationDate = Convert.ToString(customerDetails["createdDate"]);
  340. var verificationCode = dbResult.Id;
  341. var customerId = dbResult.Id;
  342. var fileCollection = Request.Files;
  343. if (UploadSignatureImage(hddImgURL.Value, registrationDate, membershipId, customerId) == 0)
  344. {
  345. _cd.AddCustomerSignature(customerId, GetStatic.GetUser(), customerId + "_signature.png");
  346. }
  347. }
  348. GetStatic.SetMessage(dbResult.ErrorCode, dbResult.Msg);
  349. if (dbResult.ErrorCode == "0")
  350. {
  351. saveCustomerDocument(dbResult);
  352. string memberId = "";
  353. if (dbResult.Msg.Split(':').Length > 1)
  354. {
  355. memberId = dbResult.Msg.Split(':')[1].Trim();
  356. }
  357. hdnCustomerId.Value = null;
  358. if (IsCallFromList().ToLower() == "true")
  359. {
  360. Response.Redirect("/Remit/Administration/CustomerSetup/List.aspx");
  361. }
  362. else
  363. {
  364. if (CheckAddOrEdit())
  365. {
  366. Response.Redirect("Manage.aspx?edit=true&hdnId=" + memberId + "");
  367. }
  368. else
  369. {
  370. Response.Redirect("Manage.aspx?hdnId=" + memberId + "");
  371. }
  372. }
  373. }
  374. Page_Load(sender, e);
  375. return;
  376. }
  377. private void saveCustomerDocument(DbResult dbresult)
  378. {
  379. var result = dbresult.Extra.Split('|');
  380. var customerId = result[0];
  381. var membershipId = result[1];
  382. var registerDate = result[2];
  383. HttpFileCollection fileCollection = Request.Files;
  384. for (int i = 0; i < fileCollection.AllKeys.Length; i++)
  385. {
  386. HttpPostedFile file = fileCollection[i];
  387. if (file != null)
  388. {
  389. string documentTypeName = "";
  390. string documentType = "";
  391. string fileType = "";
  392. var keyName = fileCollection.AllKeys[i];
  393. if (keyName.ToLower().Equals("reg_front_id"))
  394. {
  395. documentTypeName = "ID_Front";
  396. documentType = "11394";//11386
  397. }
  398. if (keyName.ToLower().Equals("reg_back_id"))
  399. {
  400. documentTypeName = "ID_Back";
  401. documentType = "11395";//"11387";
  402. }
  403. if (keyName.ToLower().Equals("add_id_front"))
  404. {
  405. documentTypeName = "Additional_ID_Front";
  406. documentType = "11396";// "11389";
  407. }
  408. if (keyName.ToLower().Equals("add_id_back"))
  409. {
  410. documentTypeName = "Additional_ID_Back";
  411. documentType = "11397";// "11395";
  412. }
  413. if (keyName.ToLower().Equals("other_document"))
  414. {
  415. documentTypeName = "Other_Document";
  416. documentType = "11398";// "11390";
  417. }
  418. if (keyName.ToLower().Equals("reg_form"))
  419. {
  420. documentTypeName = "Registration_Form";
  421. documentType = "11399";// "11393";
  422. }
  423. string fileName = (!string.IsNullOrWhiteSpace(file.FileName) ? GetStatic.UploadDocument(file, customerId, documentTypeName, membershipId, registerDate, out fileType) : GetStatic.UploadDocument(file, customerId, documentType, membershipId, registerDate, out fileType));
  424. CustomerDocument cm = new CustomerDocument();
  425. if (!string.IsNullOrEmpty(fileName) && fileName.ToLower() != "notvalid")
  426. _cd.UpdateCustomerDocument("", customerId, fileName, documentTypeName, fileType, documentType, GetStatic.GetUser());
  427. }
  428. }
  429. }
  430. public int UploadSignatureImage(string imageData, string registerDate, string membershipId, string customerId)
  431. {
  432. int errorCode = 0;
  433. try
  434. {
  435. string path = GetStatic.ReadWebConfig("customerDocPath", "") + "CustomerDocument\\" + registerDate.Replace("-", "\\") + "\\" + membershipId;
  436. if (!Directory.Exists(path))
  437. Directory.CreateDirectory(path);
  438. string fileName = path + "\\" + customerId + "_signature" + ".png";
  439. using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
  440. {
  441. using (BinaryWriter bw = new BinaryWriter(fs))
  442. {
  443. byte[] data = Convert.FromBase64String(imageData);
  444. bw.Write(data);
  445. bw.Close();
  446. }
  447. }
  448. }
  449. catch (Exception)
  450. {
  451. errorCode = 1;
  452. }
  453. return errorCode;
  454. }
  455. public class CustomerAddress
  456. {
  457. public string errrorCode { get; set; }
  458. public string msg { get; set; }
  459. public string State { get; set; }
  460. public string City { get; set; }
  461. public string Street { get; set; }
  462. }
  463. [WebMethod]
  464. public static string GetAddressByPostCode(string zipCode)
  465. {
  466. var postCode = zipCode.ToUpper();
  467. string ProcessId = Guid.NewGuid().ToString().Replace("-", "") + ":" + postCode;
  468. string methodType = Utility.ReadWebConfig("methodType", "");
  469. string countryName = "United Kingdom";
  470. AddressRequest requestObj = new AddressRequest()
  471. {
  472. CountryIsoCode = countryName,
  473. ProviderId = ProcessId,
  474. MethodType = methodType,
  475. TownName = postCode,
  476. };
  477. SyncStateCityTownService serviceObj = new SyncStateCityTownService();
  478. var response = serviceObj.GetAddressList(requestObj);
  479. string jsonResponse = JsonConvert.SerializeObject(response);
  480. return jsonResponse;
  481. }
  482. private void GetAddressDetailsByZipCode()
  483. {
  484. string customerId = Request.Form["customerId"];
  485. string zipCode = Request.Form["zipCode"];
  486. string rowID = Request.Form["RowID"];
  487. string action = Request.Form["action"];
  488. var dr = _cd.GetAddressByZipCodeAdmin(zipCode, GetStatic.GetUser(), rowID, customerId, action);
  489. var json = GetStatic.DataTableToJson(dr);
  490. GetStatic.JsonResponse(json, this);
  491. }
  492. private void GetCustomerDetails()
  493. {
  494. string eId = Request.Form["Id"];
  495. var dt = _cd.GetDetailsForEditCustomer(eId, GetStatic.GetUser());
  496. Response.ContentType = "text/plain";
  497. var json = DataTableToJson(dt);
  498. Response.Write(json);
  499. Response.End();
  500. }
  501. private void GetCustomerDetailsForEdit()
  502. {
  503. string eId = GetStatic.ReadQueryString("customerId", "");
  504. var dt = _cd.GetDetailsForEditCustomer(eId, GetStatic.GetUser());
  505. Response.ContentType = "text/plain";
  506. var json = DataTableToJson(dt);
  507. Response.Write(json);
  508. Response.End();
  509. }
  510. public static string DataTableToJson(DataTable table)
  511. {
  512. if (table == null)
  513. return "";
  514. var list = new List<Dictionary<string, object>>();
  515. foreach (DataRow row in table.Rows)
  516. {
  517. var dict = new Dictionary<string, object>();
  518. foreach (DataColumn col in table.Columns)
  519. {
  520. dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
  521. }
  522. list.Add(dict);
  523. }
  524. var serializer = new JavaScriptSerializer();
  525. string json = serializer.Serialize(list);
  526. return json;
  527. }
  528. //private void setStateDll(string countryId, string zipCode, string stateId)
  529. //{
  530. // if (countryId != "")
  531. // {
  532. // _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", stateId, "Select..");
  533. // }
  534. //}
  535. public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
  536. {
  537. return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
  538. }
  539. protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e)
  540. {
  541. string eId = hdnCustomerId.Value;
  542. if (eId != "")
  543. {
  544. PopulateForm(eId);
  545. }
  546. }
  547. }
  548. }