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.

327 lines
12 KiB

  1. using Newtonsoft.Json;
  2. using Swift.DAL.OnlineAgent;
  3. using Swift.DAL.SwiftDAL;
  4. using Swift.web.Library;
  5. using System;
  6. using System.Data;
  7. using System.IO;
  8. using System.Web.Script.Serialization;
  9. using System.Web.UI.WebControls;
  10. namespace Swift.web.AgentPanel.OnlineAgent.CustomerControls
  11. {
  12. public partial class ModifyBank : System.Web.UI.Page
  13. {
  14. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  15. private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
  16. private const string ViewFunctionIdAdmin = "20111700";
  17. private const string ViewFunctionIdAgent = "40120200";
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20. Authenticate();
  21. if (!IsPostBack)
  22. {
  23. PopulateDDL();
  24. acNameInBank.Attributes.Add("readonly", "readonly");
  25. }
  26. }
  27. private void Authenticate()
  28. {
  29. if (GetStatic.GetUserType() == "HO")
  30. {
  31. _sdd.CheckAuthentication(ViewFunctionIdAdmin);
  32. }
  33. else
  34. {
  35. _sdd.CheckAuthentication(ViewFunctionIdAgent);
  36. }
  37. }
  38. protected void PopulateDDL()
  39. {
  40. _sdd.SetDDL(ref newBank, "EXEC proc_customerBankModify @flag='DDL'", "bankCode", "BankName", "", "Select..");
  41. }
  42. protected void searchButton_Click(object sender, EventArgs e)
  43. {
  44. DataRow _dr = null;
  45. if (!string.IsNullOrEmpty(searchValue.Text))
  46. {
  47. _dr = _cd.GetCustomerDetailForBankUpdate(searchBy.SelectedValue, GetStatic.GetUser(), searchValue.Text);
  48. }
  49. if (_dr != null)
  50. {
  51. if (_dr["errorCode"].ToString() == "0")
  52. {
  53. hideDivSearch.Visible = true;
  54. hiddenDivCheck.Visible = false;
  55. hddCustomerId.Value = _dr["customerId"].ToString();
  56. fullName.Text = _dr["fullName"].ToString();
  57. oldAccNumber.Text = _dr["bankAccountNo"].ToString();
  58. alienNationId.Text = _dr["idNumber"].ToString();
  59. oldBank.Text = _dr["BankName"].ToString();
  60. hddHomePhone.Value = _dr["homePhone"].ToString();
  61. hddImageName.Value = _dr["verifyDoc3"].ToString();
  62. if (_dr["verifyDoc3"].ToString() != "")
  63. verfDoc3.ImageUrl = "/AgentPanel/OnlineAgent/CustomerSetup/GetDocumentView.ashx?imageName=" + _dr["verifyDoc3"] + "&idNumber=" + _dr["homePhone"];
  64. /*
  65. * @Max-2018.09
  66. * */
  67. hddBankCode.Value = _dr["bankCode"].ToString();
  68. hddIdType.Value = _dr["idType"].ToString();
  69. hddDob.Value = _dr["dob"].ToString();
  70. hddCountryCode.Value = _dr["nativeCountryCode"].ToString();
  71. hddGender.Value = _dr["genderCode"].ToString();
  72. }
  73. else
  74. {
  75. hiddenDivCheck.Visible = false;
  76. hideDivSearch.Visible = false;
  77. GetStatic.AlertMessage(this, _dr["msg"].ToString());
  78. }
  79. }
  80. else
  81. {
  82. hiddenDivCheck.Visible = false;
  83. hideDivSearch.Visible = false;
  84. GetStatic.AlertMessage(this, "No data Found!");
  85. }
  86. }
  87. protected void checkBtn_Click(object sender, EventArgs e)
  88. {
  89. if (!string.IsNullOrEmpty(newAccountNumber.Text) && !string.IsNullOrEmpty(newBank.SelectedValue))
  90. {
  91. /*
  92. * @Max-2018.09
  93. *
  94. * */
  95. //var response = KJBankAPIConnection.GetAccountDetailKJBank(newAccountNumber.Text, newBank.SelectedValue);
  96. var requestObj = new RealNameRequest()
  97. {
  98. institution = newBank.SelectedValue,
  99. no = newAccountNumber.Text
  100. };
  101. var idNumber = alienNationId.Text.Replace("-", "");
  102. //주민번호
  103. if (hddIdType.Value == "8008")
  104. {
  105. requestObj.realNameDivision = "01";
  106. requestObj.realNameNo = idNumber;
  107. }
  108. //외국인등록번호
  109. else if (hddIdType.Value == "1302")
  110. {
  111. requestObj.realNameDivision = "02";
  112. requestObj.realNameNo = idNumber;
  113. }
  114. //여권번호는 조합주민번호로 변경
  115. else if (hddIdType.Value == "10997")
  116. {
  117. requestObj.realNameDivision = "04";
  118. //조합주민번호(생년월일-성별-국적-여권번호(마지막5자리))
  119. requestObj.realNameNo = String.Format("{0}{1}{2}{3}",
  120. hddDob.Value,
  121. hddGender.Value,
  122. hddCountryCode.Value,
  123. idNumber.Substring(idNumber.Length - 5));
  124. }
  125. string requestBody = JsonConvert.SerializeObject(requestObj);
  126. var response = KJBankAPIConnection.GetRealNameCheck(requestBody);
  127. if (response.ErrorCode == "0")
  128. {
  129. hiddenDivCheck.Visible = true;
  130. response.Msg = response.Msg.Split(':')[1];
  131. response.Msg = response.Msg.Replace("}", "");
  132. response.Msg = response.Msg.Trim();
  133. acNameInBank.Text = response.Msg;
  134. }
  135. else
  136. {
  137. hiddenDivCheck.Visible = false;
  138. GetStatic.AlertMessage(this, "Bank Account Number is wrong, you can not modify the bank details!");
  139. }
  140. }
  141. else
  142. {
  143. GetStatic.AlertMessage(this, "Please input all data first!");
  144. }
  145. }
  146. protected void Modify_Click(object sender, EventArgs e)
  147. {
  148. if (!string.IsNullOrEmpty(hddCustomerId.Value) || !string.IsNullOrWhiteSpace(acNameInBank.Text))
  149. {
  150. string verDoc4 = UploadDocument(VerificationDoc3, hddHomePhone.Value, 4000);
  151. if (verDoc4 == "invalidSize")
  152. {
  153. GetStatic.AlertMessage(this, "File size exceeded for Passbook. Please upload image of size less than 2mb.");
  154. return;
  155. }
  156. DbResult _dbRes = new DbResult();
  157. _dbRes = _cd.UpdateCustomerBankDetail(GetStatic.GetUser(), hddCustomerId.Value, newBank.SelectedValue, newAccountNumber.Text, acNameInBank.Text, verDoc4);
  158. if (_dbRes.ErrorCode != "0")
  159. {
  160. hiddenDivCheck.Visible = false;
  161. hideDivSearch.Visible = false;
  162. searchValue.Text = "";
  163. GetStatic.AlertMessage(this, _dbRes.Msg);
  164. return;
  165. }
  166. //push to kj bank
  167. var dr = _cd.GetCustomerForModification(GetStatic.GetUser(), hddCustomerId.Value);
  168. /*
  169. * @Max-2018.09
  170. *
  171. * */
  172. var requestObj = new PartnerServiceAccountRequest()
  173. {
  174. processDivision = "02",
  175. institution = dr["bankCode"].ToString(),
  176. depositor = dr["CustomerBankName"].ToString(),
  177. no = dr["bankAccountNo"].ToString(),
  178. virtualAccountNo = dr["walletAccountNo"].ToString(),
  179. obpId = dr["obpId"].ToString()
  180. };
  181. /*
  182. * @Max
  183. * */
  184. var idNumber = dr["idNumber"].ToString().Replace("-", "");
  185. //주민번호
  186. if (dr["idType"].ToString() == "8008")
  187. {
  188. requestObj.realNameDivision = "01";
  189. requestObj.realNameNo = idNumber;
  190. }
  191. //외국인등록번호
  192. else if (dr["idType"].ToString() == "1302")
  193. {
  194. requestObj.realNameDivision = "02";
  195. requestObj.realNameNo = idNumber;
  196. }
  197. //여권번호는 조합주민번호로 변경
  198. else if (dr["idType"].ToString() == "10997")
  199. {
  200. requestObj.realNameDivision = "04";
  201. //조합주민번호(생년월일-성별-국적-여권번호(마지막5자리))
  202. requestObj.realNameNo = String.Format("{0}{1}{2}{3}",
  203. dr["dobYMD"].ToString(),
  204. dr["genderCode"].ToString(),
  205. dr["nativeCountryCode"].ToString(),
  206. idNumber.Substring(idNumber.Length - 5));
  207. }
  208. requestObj.depositor = acNameInBank.Text;
  209. _dbRes = SendNotificationToKjBank(requestObj);
  210. if (!string.IsNullOrWhiteSpace(_dbRes.Id))
  211. {
  212. ManageSaved();
  213. GetStatic.AlertMessage(Page, "Customer Detail updated");
  214. }
  215. else
  216. {
  217. GetStatic.AlertMessage(Page, "Customer detail not pushed to KJ Bank, please contact HO!");
  218. }
  219. }
  220. else
  221. {
  222. GetStatic.AlertMessage(Page, "Invalid account details, you can not modify this customer!");
  223. hiddenDivCheck.Visible = false;
  224. hideDivSearch.Visible = false;
  225. searchValue.Text = "";
  226. }
  227. }
  228. private void ManageSaved()
  229. {
  230. searchBy.SelectedValue = "idNumber";
  231. searchValue.Text = "";
  232. fullName.Text = "";
  233. alienNationId.Text = "";
  234. oldBank.Text = "";
  235. oldAccNumber.Text = "";
  236. newBank.SelectedValue = "";
  237. newAccountNumber.Text = "";
  238. acNameInBank.Text = "";
  239. verfDoc3.ImageUrl = "";
  240. hiddenDivCheck.Visible = false;
  241. hideDivSearch.Visible = false;
  242. }
  243. private string UploadDocument(FileUpload doc, string customerId, int prefixNum)
  244. {
  245. var maxFileSize = GetStatic.ReadWebConfig("csvFileSize", "2097152");
  246. string fName = "";
  247. try
  248. {
  249. var fileType = doc.PostedFile.ContentType;
  250. if (fileType == "image/jpeg" || fileType == "image/png" || fileType == "application/pdf")
  251. {
  252. if (doc.PostedFile.ContentLength > Convert.ToDouble(maxFileSize))
  253. {
  254. fName = "invalidSize";
  255. }
  256. else
  257. {
  258. string extension = Path.GetExtension(doc.PostedFile.FileName);
  259. string fileName = customerId + "_" + prefixNum.ToString() + extension;
  260. string path = GetStatic.GetAppRoot() + "CustomerDocument\\" + customerId;
  261. if (!Directory.Exists(path))
  262. Directory.CreateDirectory(path);
  263. doc.SaveAs(path + "/" + fileName);
  264. fName = fileName;
  265. }
  266. }
  267. else
  268. {
  269. fName = "";
  270. }
  271. }
  272. catch (Exception ex)
  273. {
  274. fName = "";
  275. }
  276. return fName;
  277. }
  278. public static string GetTimestamp(DateTime value)
  279. {
  280. var timeValue = value.ToString("hhmmssffffff");
  281. return timeValue + DateTime.Now.Ticks;
  282. }
  283. /*
  284. * @Max-2018.09
  285. *
  286. * */
  287. private DbResult SendNotificationToKjBank(PartnerServiceAccountRequest obj)
  288. {
  289. string body = new JavaScriptSerializer().Serialize((obj));
  290. var resp = KJBankAPIConnection.CustomerRegistration(body);
  291. return resp;
  292. }
  293. }
  294. }