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.

293 lines
13 KiB

  1. using Swift.DAL.OnlineAgent;
  2. using Swift.web.Library;
  3. using System;
  4. using System.IO;
  5. using System.Web.UI.WebControls;
  6. namespace Swift.web.AgentPanel.OnlineAgent.CustomerControls
  7. {
  8. public partial class ManageCustomer : System.Web.UI.Page
  9. {
  10. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  11. private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
  12. private const string ViewFunctionId = "20111500";
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. _sl.CheckSession();
  16. if (!IsPostBack)
  17. {
  18. Authenticate();
  19. PopulateDdl();
  20. string eId = GetStatic.ReadQueryString("id", "");
  21. if (eId != "")
  22. {
  23. PopulateForm(eId);
  24. }
  25. }
  26. }
  27. private void PopulateForm(string eId)
  28. {
  29. var dr = _cd.GetCustomerDetailsForEdit(eId, GetStatic.GetUser());
  30. if (null != dr)
  31. {
  32. hdnCustomerId.Value = dr["customerId"].ToString();
  33. firstName.Text = dr["firstName"].ToString();
  34. genderList.SelectedValue = dr["gender"].ToString();
  35. countryList.Text = dr["country"].ToString();
  36. addressLine1.Text = dr["address"].ToString();
  37. city.Text = dr["city"].ToString();
  38. email.Text = dr["email"].ToString();
  39. emailConfirm.Text = dr["email"].ToString();
  40. phoneNumber.Text = dr["telNo"].ToString();
  41. mobile.Text = dr["mobile"].ToString();
  42. nativeCountry.SelectedValue = dr["nativeCountry"].ToString();
  43. dob.Text = dr["dob"].ToString();
  44. occupation.Text = dr["occupation"].ToString();
  45. IssueDate.Text = dr["idIssueDate"].ToString();
  46. ExpireDate.Text = dr["idExpiryDate"].ToString();
  47. ddlBankName.SelectedValue = dr["bankName"].ToString();
  48. accountNumber.Text = dr["bankAccountNo"].ToString();
  49. idType.Text = dr["idType"].ToString();
  50. verificationTypeNo.Text = dr["idNumber"].ToString();
  51. hddIdNumber.Value = dr["homePhone"].ToString();
  52. //the value of homePhone is same as idNumber but for record id 1-92 homePhone is mobile number , bcoz of FolderName
  53. if (dr["verifyDoc1"].ToString() != "")
  54. verfDoc1.ImageUrl = "/AgentPanel/OnlineAgent/CustomerSetup/GetDocumentView.ashx?imageName=" + dr["verifyDoc1"] + "&idNumber=" + dr["homePhone"];
  55. if (dr["verifyDoc2"].ToString() != "")
  56. verfDoc2.ImageUrl = "/AgentPanel/OnlineAgent/CustomerSetup/GetDocumentView.ashx?imageName=" + dr["verifyDoc2"] + "&idNumber=" + dr["homePhone"];
  57. if (dr["verifyDoc3"].ToString() != "")
  58. verfDoc3.ImageUrl = "/AgentPanel/OnlineAgent/CustomerSetup/GetDocumentView.ashx?imageName=" + dr["verifyDoc3"] + "&idNumber=" + dr["homePhone"];
  59. if (dr["verifyDoc4"].ToString() != "")
  60. verfDoc4.ImageUrl = "/AgentPanel/OnlineAgent/CustomerSetup/GetDocumentView.ashx?imageName=" + dr["verifyDoc4"] + "&idNumber=" + dr["homePhone"];
  61. hdnVerifyDoc1.Value = dr["verifyDoc1"].ToString();
  62. hdnVerifyDoc2.Value = dr["verifyDoc2"].ToString();
  63. hdnVerifyDoc3.Value = dr["verifyDoc3"].ToString();
  64. hdnVerifyDoc4.Value = dr["verifyDoc4"].ToString();
  65. //email.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
  66. //emailConfirm.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
  67. if (dr["isTxnMade"].ToString() == "Y")
  68. {
  69. msgDiv.Visible = true;
  70. msgLabel.Text = "Note: The customer has already made transactions in JME system, so please refer with HO to modify transactions.";
  71. }
  72. if (dr["idType"].ToString() == "8008")
  73. {
  74. expiryDiv.Attributes.Add("style", "display:none;");
  75. //expiryDiv.Visible = false;
  76. }
  77. else
  78. {
  79. expiryDiv.Attributes.Add("style", "display:block;");
  80. //expiryDiv.Visible = true;
  81. }
  82. //email.ReadOnly = true;
  83. //emailConfirm.ReadOnly = true;
  84. //mobile.ReadOnly = true;
  85. hddIsApproved.Value = dr["isApproved"].ToString();
  86. }
  87. }
  88. private void Authenticate()
  89. {
  90. _sl.CheckAuthentication(ViewFunctionId);
  91. }
  92. private void PopulateDdl()
  93. {
  94. _sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList'", "valueId", "detailTitle", "", "Select..");
  95. _sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist'", "countryId", "countryName", "", "Select..");
  96. _sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist'", "countryId", "countryName", "", "Select..");
  97. _sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList'", "valueId", "detailTitle", "", "Select..");
  98. _sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='idType'", "valueId", "detailTitle", "", "Select..");
  99. _sl.SetDDL(ref ddlBankName, "EXEC proc_dropDownList @flag='banklist'", "value", "text", "", "Select..");
  100. }
  101. protected void register_Click(object sender, EventArgs e)
  102. {
  103. if (email.Text.Equals(emailConfirm.Text))
  104. {
  105. string verDoc1 = UploadDocument(VerificationDoc1, hddIdNumber.Value, 1000);
  106. if (verDoc1 == "invalidSize")
  107. {
  108. GetStatic.AlertMessage(this, "File size exceeded for Alien Reg ID Front. Please upload image of size less than 2mb.");
  109. return;
  110. }
  111. string verDoc2 = UploadDocument(VerificationDoc2, hddIdNumber.Value, 2000);
  112. if (verDoc2 == "invalidSize")
  113. {
  114. GetStatic.AlertMessage(this, "File size exceeded for Alien Reg ID Back. Please upload image of size less than 2mb.");
  115. return;
  116. }
  117. string verDoc3 = UploadDocument(VerificationDoc3, hddIdNumber.Value, 3000);
  118. if (verDoc3 == "invalidSize")
  119. {
  120. GetStatic.AlertMessage(this, "File size exceeded for Passbook. Please upload image of size less than 2mb.");
  121. return;
  122. }
  123. string verDoc4 = UploadDocument(VerificationDoc4, hddIdNumber.Value, 4000);
  124. if (verDoc4 == "invalidSize")
  125. {
  126. GetStatic.AlertMessage(this, "File size exceeded for Passbook. Please upload image of size less than 2mb.");
  127. return;
  128. }
  129. OnlineCustomerModel customerModel = new OnlineCustomerModel()
  130. {
  131. flag = "customer-modify",
  132. customerId = hdnCustomerId.Value,
  133. firstName = firstName.Text,
  134. gender = genderList.SelectedValue,
  135. country = countryList.Text,
  136. address = addressLine1.Text,
  137. zipCode = postalCode.Text,
  138. city = city.Text,
  139. email = email.Text,
  140. homePhone = phoneNumber.Text,
  141. mobile = mobile.Text,
  142. nativeCountry = nativeCountry.SelectedValue,
  143. dob = dob.Text,
  144. occupation = occupation.Text,
  145. postalCode = postalCode.Text,
  146. idIssueDate = IssueDate.Text,
  147. idExpiryDate = ExpireDate.Text,
  148. idType = idType.Text,
  149. idNumber = verificationTypeNo.Text,
  150. telNo = phoneNumber.Text,
  151. ipAddress = GetStatic.GetIp(),
  152. createdBy = GetStatic.GetUser(),
  153. verifyDoc1 = verDoc1,
  154. verifyDoc2 = verDoc2,
  155. verifyDoc3 = verDoc3,
  156. verifyDoc4 = verDoc4,
  157. bankId = ddlBankName.SelectedValue,
  158. accountNumber = accountNumber.Text
  159. };
  160. if (verDoc1 == "")
  161. customerModel.verifyDoc1 = hdnVerifyDoc1.Value;
  162. if (verDoc2 == "")
  163. customerModel.verifyDoc2 = hdnVerifyDoc2.Value;
  164. if (verDoc3 == "")
  165. customerModel.verifyDoc3 = hdnVerifyDoc3.Value;
  166. if (verDoc4 == "")
  167. customerModel.verifyDoc4 = hdnVerifyDoc4.Value;
  168. var dbResult = _cd.ModifyCustomer(customerModel);
  169. if (dbResult.ErrorCode == "0")
  170. {
  171. //if (!hddIdNumber.Value.Equals(verificationTypeNo.Text))
  172. //{
  173. // if (string.IsNullOrEmpty(verDoc1))
  174. // {
  175. // MoveFilesToNewFolder(hddIdNumber.Value, verificationTypeNo.Text, hdnVerifyDoc1.Value);
  176. // }
  177. // if (string.IsNullOrEmpty(verDoc2))
  178. // {
  179. // MoveFilesToNewFolder(hddIdNumber.Value, verificationTypeNo.Text, hdnVerifyDoc2.Value);
  180. // }
  181. // if (string.IsNullOrEmpty(verDoc3))
  182. // {
  183. // MoveFilesToNewFolder(hddIdNumber.Value, verificationTypeNo.Text, hdnVerifyDoc3.Value);
  184. // }
  185. // if (string.IsNullOrEmpty(verDoc4))
  186. // {
  187. // MoveFilesToNewFolder(hddIdNumber.Value, verificationTypeNo.Text, hdnVerifyDoc4.Value);
  188. // }
  189. // DeleteOldFolder(hddIdNumber.Value);
  190. //}
  191. GetStatic.SetMessage(dbResult);
  192. Response.Redirect("ManageList.aspx");
  193. return;
  194. }
  195. else
  196. {
  197. GetStatic.AlertMessage(this, dbResult.Msg);
  198. return;
  199. }
  200. }
  201. else
  202. {
  203. GetStatic.AlertMessage(this, "Email and verify email are not same!");
  204. return;
  205. }
  206. }
  207. private void DeleteOldFolder(string folderName)
  208. {
  209. string dirPath = GetStatic.GetAppRoot() + "CustomerDocument\\" + folderName;
  210. if (Directory.Exists(dirPath))
  211. Directory.Delete(dirPath, true);
  212. }
  213. protected void MoveFilesToNewFolder(string oldFolderName, string newFolderName, string oldFileName)
  214. {
  215. string newFilePath = GetStatic.GetAppRoot() + "CustomerDocument\\" + newFolderName;
  216. if (!Directory.Exists(newFilePath))
  217. Directory.CreateDirectory(newFilePath);
  218. string oldFilePath = GetStatic.GetAppRoot() + "CustomerDocument\\" + oldFolderName + "\\" + oldFileName;
  219. FileInfo fileInfo = new FileInfo(oldFilePath);
  220. if (fileInfo.Exists)
  221. File.Move(oldFilePath, newFilePath + "/" + oldFileName);
  222. }
  223. private string UploadDocument(FileUpload doc, string customerId, int prefixNum)
  224. {
  225. if (!doc.HasFile)
  226. {
  227. return "";
  228. }
  229. var maxFileSize = GetStatic.ReadWebConfig("csvFileSize", "2097152");
  230. string fName = "";
  231. try
  232. {
  233. var fileType = doc.PostedFile.ContentType;
  234. if (fileType == "image/jpeg" || fileType == "image/png" || fileType == "application/pdf")
  235. {
  236. if (doc.PostedFile.ContentLength > Convert.ToDouble(maxFileSize))
  237. {
  238. fName = "invalidSize";
  239. }
  240. else
  241. {
  242. string extension = Path.GetExtension(doc.PostedFile.FileName);
  243. string fileName = customerId + "_" + prefixNum.ToString() + extension;
  244. string path = GetStatic.GetAppRoot() + "CustomerDocument\\" + customerId;
  245. if (!Directory.Exists(path))
  246. Directory.CreateDirectory(path);
  247. doc.SaveAs(path + "/" + fileName);
  248. fName = fileName;
  249. }
  250. }
  251. else
  252. {
  253. fName = "";
  254. }
  255. }
  256. catch (Exception ex)
  257. {
  258. fName = "";
  259. }
  260. return fName;
  261. }
  262. public static string GetTimestamp(DateTime value)
  263. {
  264. var timeValue = value.ToString("hhmmssffffff");
  265. return timeValue + DateTime.Now.Ticks;
  266. }
  267. }
  268. }