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.

597 lines
29 KiB

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