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.

801 lines
41 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. using Business.Configuration;
  2. using Business.Customer;
  3. using Business.SendTransaction;
  4. using Common.Helper;
  5. using Common.Model.BenificiaryModel;
  6. using Common.Model.CustomerModel;
  7. using Common.Utility;
  8. using JMEAgentSystem.Library;
  9. using JMEAgentSystem.Library.Remittance;
  10. using Newtonsoft.Json;
  11. using Repository.DAO;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Data;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Reflection;
  18. using System.Web;
  19. using System.Web.Script.Serialization;
  20. using System.Web.UI.WebControls;
  21. namespace JMEAgentSystem.WebPages.CustomerRegistration
  22. {
  23. public partial class Manage : System.Web.UI.Page
  24. {
  25. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  26. private readonly ICustomerServices _customerServices = AutoFacContainer.Resolve<ICustomerServices>();
  27. private readonly ISendTransactionServices _sendTxnServices = AutoFacContainer.Resolve<ISendTransactionServices>();
  28. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  29. protected void Page_Load(object sender, EventArgs e)
  30. {
  31. //signatureDiv.Visible = !CheckAddOrEdit() && _sl.HasRight(SignatureFunctionId);
  32. //isDisplaySignature.Value = !CheckAddOrEdit() && _sl.HasRight(SignatureFunctionId) ? "true" : "false";
  33. //agreementDiv.Visible = !CheckAddOrEdit();
  34. ////displayOnlyOnEdit.Visible = CheckAddOrEdit();
  35. //addEditPanel.Attributes.Add("style", "display:" + (CheckAddOrEdit() ? "none" : ""));
  36. //displayCounterVisit.Visible = !CheckAddOrEdit();
  37. //if (GetStatic.ReadQueryString("hdnId", "").ToString() != "")
  38. //{
  39. // ShowPrintLink(GetStatic.ReadQueryString("hdnId", "").ToString());
  40. //}
  41. //else
  42. //{
  43. // //linkDiv.Visible = false;
  44. //}
  45. var MethodName = Request.Form["MethodName"];
  46. if (!IsPostBack)
  47. {
  48. PopulateDdl();
  49. //Authenticate();
  50. switch (MethodName)
  51. {
  52. case "GetAddressDetailsByZipCode":
  53. GetAddressDetailsByZipCode();
  54. break;
  55. case "GetCustomerDetails":
  56. GetCustomerDetails();
  57. break;
  58. case "PaymentModePcountry":
  59. LoadPaymentModeFromAjax();
  60. break;
  61. case "PopulatePaymentMode":
  62. LoadPaymentModeDDL();
  63. break;
  64. case "PopulatePayoutPartner":
  65. LoadPayoutPartner();
  66. break;
  67. case "GetBankBranch":
  68. GetBankBranch();
  69. break;
  70. case "SaveCustomerAndReceiver":
  71. SaveCustomerAndReceiver();
  72. break;
  73. }
  74. }
  75. }
  76. private void PopulateDdl()
  77. {
  78. //customerDdl
  79. _sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  80. _sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "");
  81. _sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  82. _sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  83. _sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='IdTypeWithDetails',@user='" + GetStatic.GetUser() + "',@countryId='" + countryList.SelectedValue + "'", "valueId", "detailTitle", "", "Select..");
  84. _sl.SetDDL(ref ddSourceOfFound, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3900", "valueId", "detailTitle", "", "Select..");
  85. _sl.SetDDL(ref ddlEmployeeBusType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7004", "valueId", "detailTitle", "", "");
  86. _sl.SetDDL(ref ddlVisaStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7005", "valueId", "detailTitle", "", "Select..");
  87. _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", "", "Select..");
  88. _sdd.SetStaticDdl(ref ddlDocType, "7009", "", "Select");
  89. //receiverDDl
  90. _sl.SetDDL(ref recDdlIdType, "EXEC proc_online_dropDownList @flag='idType',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  91. _sl.SetDDL(ref recDdlCountry, "EXEC proc_online_dropDownList @flag='allCountrylistWithCode',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  92. _sl.SetDDL(ref recDdlNativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  93. _sl.SetDDL(ref recDdlRelationship, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=2100", "valueId", "detailTitle", "", "Select..");
  94. _sl.SetDDL(ref recDdlPurposeOfRemitance, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3800", "valueId", "detailTitle", "8060", "Select..");
  95. _sl.SetDDL(ref recDdlBenificiaryType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=4700", "valueId", "detailTitle", recDdlBenificiaryType.SelectedValue, "");
  96. }
  97. private void Authenticate()
  98. {
  99. //if (CheckAddOrEdit())
  100. // _sl.CheckAuthentication(GetFunctionIdByUserType(EditViewFunctionIdAgent, EditViewFunctionId));
  101. //else
  102. // _sl.CheckAuthentication(GetFunctionIdByUserType(AddViewFunctionIdAgent, AddViewFunctionId));
  103. //string eId = GetStatic.ReadQueryString("customerId", "");
  104. //var hasRight = false;
  105. //if (eId == "")
  106. //{
  107. // hasRight = _sl.HasRight(GetFunctionIdByUserType(AddFunctionIdAgent, AddFunctionId));
  108. // register.Enabled = hasRight;
  109. // register.Visible = hasRight;
  110. //}
  111. //else
  112. //{
  113. // hasRight = _sl.HasRight(GetFunctionIdByUserType(EditFunctionIdAgent, EditFunctionId));
  114. // register.Enabled = hasRight;
  115. // register.Visible = hasRight;
  116. //}
  117. }
  118. private bool CheckAddOrEdit()
  119. {
  120. //if (isEdit)
  121. //{
  122. // customerType.Attributes.Add("hidden", "hidden");
  123. //}
  124. //else
  125. //{
  126. // customerType.Attributes.Remove("hidden");
  127. //}
  128. //return isEdit;
  129. return true;
  130. }
  131. private void PopulateForm(string eId)
  132. {
  133. var dr = _customerServices.GetCustomerDetails(eId, GetStatic.GetUser());
  134. if (null != dr)
  135. {
  136. hdnCustomerId.Value = dr["customerId"].ToString();
  137. firstName.Text = dr["firstName"].ToString();
  138. middleName.Text = dr["middleName"].ToString();
  139. lastName.Text = dr["lastName1"].ToString();
  140. genderList.SelectedValue = dr["gender"].ToString();
  141. countryList.SelectedValue = dr["country"].ToString();
  142. zipCode.Text = dr["zipCode"].ToString();
  143. city.Text = dr["city"].ToString();
  144. email.Text = dr["email"].ToString();
  145. hddOldEmailValue.Value = dr["email"].ToString();
  146. phoneNumber.Text = dr["telNo"].ToString();
  147. mobile.Text = dr["mobile"].ToString();
  148. nativeCountry.SelectedItem.Text = dr["nativeCountry"].ToString();
  149. nativeCountry.SelectedItem.Value = dr["nativeCountryId"].ToString();
  150. dob.Value = dr["dob"].ToString();
  151. occupation.Text = dr["occupation"].ToString();
  152. IssueDate.Value = dr["idIssueDate"].ToString();
  153. ExpireDate.Value = dr["idExpiryDate"].ToString();
  154. idType.SelectedValue = dr["idType"].ToString();
  155. verificationTypeNo.Text = dr["idNumber"].ToString();
  156. hddIdNumber.Value = dr["homePhone"].ToString();
  157. hdnMembershipNo.Value = dr["membershipId"].ToString();
  158. txtStreet.Text = dr["street"].ToString();
  159. txtAdditionalAddress.Text = dr["additionalAddress"].ToString();
  160. txtNameofEmployeer.Text = dr["nameOfEmployeer"].ToString();
  161. rbRemitanceAllowed.SelectedValue = (dr["remittanceAllowed"].ToString().ToLower() == "true" ? "Enabled" : "Disabled");
  162. rbOnlineLogin.SelectedValue = (dr["onlineUser"].ToString() == "Y" ? "Enabled" : "Disabled");
  163. txtRemarks.Text = dr["remarks"].ToString();
  164. txtSSnNo.Text = dr["SSNNO"].ToString();
  165. ddlSalary.SelectedValue = dr["monthlyIncome"].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. hddTxnsMade.Value = dr["isTxnMade"].ToString();
  171. if (dr["isTxnMade"].ToString() == "Y")
  172. {
  173. //msgDiv.Visible = true;
  174. //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.";
  175. }
  176. if (dr["idType"].ToString() == "8008")
  177. {
  178. expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4 hidden");
  179. }
  180. else
  181. {
  182. expiryDiv.Attributes.Remove("class");
  183. expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4");
  184. }
  185. //membershipDiv.Visible = true;
  186. }
  187. }
  188. public void ShowPrintLink(string membershipId)
  189. {
  190. //linkDiv.Visible = true;
  191. //printLink.Attributes["href"] = "PrintDetails.aspx?membershipId=" + membershipId;
  192. //printLink.InnerText = "Print Details of " + membershipId + "";
  193. }
  194. public class CustomerAddress
  195. {
  196. public string errrorCode { get; set; }
  197. public string msg { get; set; }
  198. public string State { get; set; }
  199. public string City { get; set; }
  200. public string Street { get; set; }
  201. }
  202. private void GetAddressDetailsByZipCode()
  203. {
  204. string zipCode = Request.Form["zipCode"];
  205. string rowID = Request.Form["RowID"];
  206. var dr = _customerServices.GetAddressByZipCodeNew(zipCode, GetStatic.GetUser(), rowID);
  207. var json = GetStatic.DataTableToJson(dr);
  208. GetStatic.JsonResponse(json, this);
  209. Response.End();
  210. }
  211. private void GetCustomerDetails()
  212. {
  213. string eId = Request.Form["Id"];
  214. var dt = _customerServices.GetDetailsForEditCustomer(eId, GetStatic.GetUser());
  215. Response.ContentType = "text/plain";
  216. var json = DataTableToJson(dt);
  217. Response.Write(json);
  218. Response.End();
  219. }
  220. public static string DataTableToJson(DataTable table)
  221. {
  222. if (table == null)
  223. return "";
  224. var list = new List<Dictionary<string, object>>();
  225. foreach (DataRow row in table.Rows)
  226. {
  227. var dict = new Dictionary<string, object>();
  228. foreach (DataColumn col in table.Columns)
  229. {
  230. dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
  231. }
  232. list.Add(dict);
  233. }
  234. var serializer = new JavaScriptSerializer();
  235. string json = serializer.Serialize(list);
  236. return json;
  237. }
  238. private void setStateDll(string countryId, string zipCode, string stateId)
  239. {
  240. if (countryId != "")
  241. {
  242. _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", stateId, "Select..");
  243. }
  244. }
  245. public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
  246. {
  247. return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
  248. }
  249. protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e)
  250. {
  251. string eId = hdnCustomerId.Value;
  252. if (eId != "")
  253. {
  254. PopulateForm(eId);
  255. }
  256. }
  257. protected void registerCustomerAndReceiver_Click(object sender, EventArgs e)
  258. {
  259. try
  260. {
  261. //checked file extention
  262. HttpFileCollection fileCollectionNew = Request.Files;
  263. string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", "");
  264. for (int i = 0; i < fileCollectionNew.AllKeys.Length; i++)
  265. {
  266. HttpPostedFile file = fileCollectionNew[i];
  267. string fileExtension = new FileInfo(file.FileName).Extension;
  268. if (!documentExtension.ToLower().Contains(fileExtension.ToLower()))
  269. {
  270. GetStatic.AlertMessage(this, "Invalid File Extenstion");
  271. return;
  272. }
  273. }
  274. if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString())))
  275. {
  276. GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!");
  277. return;
  278. }
  279. //if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value)))
  280. //{
  281. // GetStatic.AlertMessage(this, "Customer signature or customer password is required!");
  282. // return;
  283. //}
  284. OnlineCustomerModel customerModel = PrepareCutomerData();
  285. BenificiaryModel benificiaryModel = PrepareBenificiaryData();
  286. var dbResult = _customerServices.RegisterCustomerAndReceiver(customerModel, benificiaryModel);
  287. if (dbResult.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value))
  288. {
  289. var result = dbResult.Id.Split('|');
  290. var customerId = result[0];
  291. var membershipId = result[1];
  292. var registerDate = result[2];
  293. string signatureName = GetStatic.UploadSignatureImage(hddImgURL.Value, registerDate, membershipId, customerId);
  294. if (signatureName != "1")
  295. {
  296. _customerServices.AddCustomerSignature(customerId, GetStatic.GetUser()
  297. , signatureName, "Staff Visit - Customer Register(Customer Signature)", customerId);
  298. }
  299. }
  300. GetStatic.SetMessage(dbResult.ErrorCode, dbResult.Msg);
  301. if (dbResult.ErrorCode == "0")
  302. {
  303. saveCustomerDocument(dbResult);
  304. var url = "PrintDetails.aspx?customerId=" + dbResult.Id.Split('|')[0] + "&membershipId=" + dbResult.Id.Split('|')[1] + "&receiverId=" + dbResult.Id.Split('|')[3] + "";
  305. Response.Redirect(url);
  306. }
  307. Page_Load(sender, e);
  308. return;
  309. }
  310. catch (Exception ex)
  311. {
  312. GetStatic.AlertMessage(this.Page, ex.Message);
  313. }
  314. }
  315. private void LoadPaymentModeFromAjax()
  316. {
  317. var pCountry = Request.Form["pCountry"];
  318. var dt = _customerServices.LoadDataPaymentModeDdl(GetStatic.ReadWebConfig("domesticCountryId", ""), pCountry, "", null, "recModeByCountry", GetStatic.GetUser());
  319. Response.ContentType = "text/plain";
  320. var json = DataTableToJson(dt);
  321. Response.Write(json);
  322. Response.End();
  323. }
  324. private void LoadPaymentModeDDL()
  325. {
  326. var country = Request.Form["country"];
  327. var sql = "EXEC proc_online_sendPageLoadData @flag='payoutMethods'";
  328. sql += ",@country=" + _sl.FilterString(country.Split('(')[0]);
  329. var paymentList = _sl.ExecuteDataTable(sql);
  330. var paymentDdl = Mapper.DataTableToClass<DropDownModel>(paymentList);
  331. var jsonString = JsonConvert.SerializeObject(paymentDdl);
  332. Response.ContentType = "application/json";
  333. Response.Write(jsonString);
  334. Response.End();
  335. }
  336. private void LoadPayoutPartner()
  337. {
  338. var countryId = Request.Form["country"].Split('(')[0];
  339. var paymentModeVal = Request.Form["paymentMode"];
  340. var sql = "EXEC proc_sendPageLoadData @flag='recAgentByRecModeAjaxagentAndCountry', @countryId = '" + GetStatic.ReadWebConfig("domesticCountryId", "") + "',@pCountryId='" + countryId + "',@param = '" + paymentModeVal + "',@agentId='" + GetStatic.GetAgentId() + "',@user = '" + GetStatic.GetUser() + "'";
  341. var payoutPartnerList = _sl.ExecuteDataTable(sql);
  342. var payoutPartnerDdl = Mapper.DataTableToClass<DropDownModel>(payoutPartnerList);
  343. var jsonString = JsonConvert.SerializeObject(payoutPartnerDdl);
  344. Response.ContentType = "application/json";
  345. Response.Write(jsonString);
  346. Response.End();
  347. }
  348. public void GetBankBranch()
  349. {
  350. string bankId = Request.Form["bankId"];
  351. string countryId = Request.Form["countryId"];
  352. string pMode = Request.Form["pMode"];
  353. string branchId = Request.Form["branchId"];
  354. if (pMode == "2")
  355. recReceiverAccountNo.Attributes.Remove("hidden");
  356. var dtResult = _sendTxnServices.GetPayoutPartner(GetStatic.GetUser(), countryId, pMode);
  357. string partnerId = dtResult.Rows[0][0].ToString();
  358. var dao = new RemittanceDao();
  359. string sql = "";
  360. if (partnerId == GetStatic.ReadWebConfig("transfast", "") || partnerId == GetStatic.ReadWebConfig("jmeNepal", ""))
  361. {
  362. sql = "EXEC PROC_API_BANK_BRANCH_SETUP @FLAG='getBranchByAgentIdForDDL',@bankId=" + dao.FilterString(bankId) + ",@PAYMENT_TYPE = " + dao.FilterString(pMode);
  363. }
  364. else
  365. {
  366. sql = "EXEC proc_dropDownLists @flag = 'pickBranchById', @agentId=" + dao.FilterString(bankId);
  367. }
  368. var paymentDdl = Mapper.DataTableToClass<DropDownModel>(_sl.ExecuteDataTable(sql));
  369. var jsonString = JsonConvert.SerializeObject(paymentDdl);
  370. Response.ContentType = "application/json";
  371. Response.Write(jsonString);
  372. Response.End();
  373. }
  374. protected string GetReceiverId()
  375. {
  376. return GetStatic.ReadQueryString("receiverId", "");
  377. }
  378. public OnlineCustomerModel PrepareCutomerData()
  379. {
  380. string trimmedfirstName = firstName.Text.Trim() == "" ? null : firstName.Text.Trim();
  381. string trimmedMiddleName = middleName.Text.Trim() == "" ? null : middleName.Text.Trim();
  382. string trimmedlastName = lastName.Text.Trim() == "" ? null : lastName.Text.Trim();
  383. string area = Request.Form["ctl00$MainContent$txtStreet"];
  384. string occupationVal = occupationHidden.Value;
  385. OnlineCustomerModel customerModel = new OnlineCustomerModel();
  386. customerModel.flag = "register-customer-and-receiver";
  387. customerModel.firstName = trimmedfirstName;
  388. customerModel.middleName = trimmedMiddleName;
  389. customerModel.lastName1 = trimmedlastName;
  390. customerModel.gender = genderList.SelectedValue;
  391. customerModel.country = countryList.Text;
  392. customerModel.zipCode = zipCode.Text;
  393. customerModel.city = cityHidden.Value;
  394. customerModel.state = ddlStateHidden.Value;
  395. customerModel.street = Request.Form["ctl00$MainContent$txtStreet"];
  396. customerModel.AdditionalAddress = txtAdditionalAddress.Text;
  397. customerModel.email = email.Text;
  398. customerModel.homePhone = phoneNumber.Text;
  399. customerModel.mobile = mobile.Text;
  400. customerModel.visaStatus = ddlVisaStatus.SelectedValue;
  401. customerModel.employeeBusinessType = ddlEmployeeBusType.SelectedValue;
  402. customerModel.nativeCountry = nativeCountry.SelectedValue;
  403. customerModel.dob = dob.Value;
  404. //customerModel.dob = "1995-05-02";
  405. customerModel.ssnNo = txtSSnNo.Text;
  406. customerModel.sourceOfFound = ddSourceOfFound.SelectedValue;
  407. customerModel.occupation = occupationVal;
  408. customerModel.telNo = phoneNumber.Text;
  409. customerModel.ipAddress = GetStatic.GetIp();
  410. customerModel.createdBy = GetStatic.GetUser();
  411. //customerModel.createdBy = GetStatic.GetUser();
  412. customerModel.idNumber = verificationTypeNo.Text;
  413. customerModel.idIssueDate = IssueDate.Value;
  414. customerModel.idExpiryDate = ExpireDate.Value;
  415. //customerModel.idIssueDate = "2020-01-02";
  416. //customerModel.idExpiryDate = "2021-05-02";
  417. customerModel.idType = idType.Text.Split('|')[0].ToString();
  418. customerModel.remitanceAllowed = (rbRemitanceAllowed.SelectedValue == "Enabled" ? true : false);
  419. customerModel.onlineUser = (rbOnlineLogin.SelectedValue == "Enabled" ? true : false);
  420. customerModel.remarks = txtRemarks.Text;
  421. customerModel.nameofEmployeer = txtNameofEmployeer.Text;
  422. customerModel.MonthlyIncome = ddlSalary.SelectedValue;
  423. customerModel.customerPassword = customerPassword.Text;
  424. //customerModel.agentId = Int32.Parse(GetStatic.GetAgent());
  425. customerModel.DocumentType = ddlDocType.SelectedValue;
  426. customerModel.occupationOther = occupationText.Text;
  427. return customerModel;
  428. }
  429. public BenificiaryModel PrepareBenificiaryData()
  430. {
  431. string receiverId = GetStatic.ReadQueryString("receiverId", "");
  432. var trimmedReceiverFName = recTxtReceiverFName.Text.ToString().ToUpper().Trim() == "" ? null : recTxtReceiverFName.Text.ToString().ToUpper().Trim();
  433. var trimmedReceiverMName = recTxtReceiverMName.Text.ToString().ToUpper().Trim() == "" ? null : recTxtReceiverMName.Text.ToString().ToUpper().Trim();
  434. var trimmedReceiverLName = recTxtReceiverLName.Text.ToString().ToUpper().Trim() == "" ? null : recTxtReceiverLName.Text.ToString().ToUpper().Trim();
  435. BenificiaryModel benificiar = new BenificiaryModel();
  436. string Country = recDdlCountry.SelectedValue;
  437. benificiar.Country = recDdlCountry.SelectedItem.Text.Split('(')[0];
  438. benificiar.NativeCountry = recDdlNativeCountry.SelectedValue;
  439. benificiar.BenificiaryType = recDdlBenificiaryType.SelectedValue;
  440. benificiar.Email = recTxtEmail.Text;
  441. benificiar.ReceiverFName = trimmedReceiverFName;
  442. benificiar.ReceiverMName = trimmedReceiverMName;
  443. benificiar.ReceiverLName = trimmedReceiverLName;
  444. benificiar.ReceiverAddress = recTxtReceiverAddress.Text;
  445. benificiar.ReceiverCity = recTxtReceiverCity.Text;
  446. benificiar.ContactNo = recTxtContactNo.Text;
  447. benificiar.SenderMobileNo = recTxtRecMobileNo.Text;
  448. benificiar.Relationship = recDdlRelationship.SelectedValue;
  449. benificiar.PlaceOfIssue = recTxtPlaceOfIssue.Text;
  450. benificiar.TypeId = recDdlIdType.SelectedValue;
  451. benificiar.TypeValue = recTxtIdValue.Text;
  452. benificiar.PurposeOfRemitance = recDdlPurposeOfRemitance.SelectedValue;
  453. benificiar.OtherPurpose = purposeOther.Text;
  454. benificiar.PaymentMode = hddPaymentMode.Value;
  455. benificiar.PayoutPatner = hddBankId.Value;
  456. benificiar.BenificaryAc = recTxtBenificaryAc.Text;
  457. benificiar.BankLocation = HddBankBranchId.Value;
  458. benificiar.Remarks = recTxtRemarksRec.Text;
  459. benificiar.OtherRelationDescription = recOtherRelationshipTextBox.Text;
  460. benificiar.branchText = branch_manual.Text;
  461. return benificiar;
  462. }
  463. public static class Mapper
  464. {
  465. public static IList<T> DataTableToClass<T>(DataTable Table) where T : class, new()
  466. {
  467. var dataList = new List<T>(Table.Rows.Count);
  468. Type classType = typeof(T);
  469. IList<PropertyInfo> propertyList = classType.GetProperties();
  470. if (propertyList.Count == 0)
  471. return new List<T>();
  472. List<string> columnNames = Table.Columns.Cast<DataColumn>().Select(column => column.ColumnName).ToList();
  473. try
  474. {
  475. foreach (DataRow dataRow in Table.AsEnumerable().ToList())
  476. {
  477. var classObject = new T();
  478. foreach (PropertyInfo property in propertyList)
  479. {
  480. if (property != null && property.CanWrite)
  481. {
  482. if (columnNames.Contains(property.Name))
  483. {
  484. if (dataRow[property.Name] != System.DBNull.Value)
  485. {
  486. object propertyValue = System.Convert.ChangeType(
  487. dataRow[property.Name],
  488. property.PropertyType
  489. );
  490. property.SetValue(classObject, propertyValue, null);
  491. }
  492. }
  493. }
  494. }
  495. dataList.Add(classObject);
  496. }
  497. return dataList;
  498. }
  499. catch
  500. {
  501. return new List<T>();
  502. }
  503. }
  504. }
  505. public class DropDownModel
  506. {
  507. public string Key { get; set; }
  508. public string Value { get; set; }
  509. public string bankId { get; set; }
  510. public string AGENTNAME { get; set; }
  511. public string agentId { get; set; }
  512. public string agentName { get; set; }
  513. }
  514. private void saveCustomerDocument(DbResult dbresult)
  515. {
  516. var result = dbresult.Id.Split('|');
  517. var customerId = result[0];
  518. var membershipId = result[1];
  519. var registerDate = result[2];
  520. HttpFileCollection fileCollection = Request.Files;
  521. for (int i = 0; i < fileCollection.AllKeys.Length; i++)
  522. {
  523. HttpPostedFile file = fileCollection[i];
  524. if (file != null)
  525. {
  526. string documentTypeName = "";
  527. string documentType = "";
  528. string fileType = "";
  529. if (i == 0)
  530. {
  531. documentTypeName = "ID_Front";
  532. documentType = "11054";
  533. }
  534. else
  535. {
  536. documentTypeName = "ID_Back";
  537. documentType = "11055";
  538. }
  539. string fileName = (!string.IsNullOrWhiteSpace(file.FileName) ? UploadDocument(file, customerId, documentTypeName, membershipId, registerDate, out fileType) : UploadDocument(file, customerId, documentType, membershipId, registerDate, out fileType));
  540. CustomerDocument cm = new CustomerDocument();
  541. cm.customerId = result[0];
  542. cm.fileDescription = "";
  543. cm.documentType = documentType;
  544. cm.fileUrl = fileName;
  545. cm.fileType = fileType;
  546. var res = _customerServices.UpdateCustomerDocument("", customerId, fileName, documentTypeName, fileType, documentType, GetStatic.GetUser());
  547. }
  548. }
  549. }
  550. private string UploadDocument(HttpPostedFile doc, string customerId, string documentType, string membershipId, string registeredDate, out string fileType)
  551. {
  552. fileType = "";
  553. string fName = "";
  554. try
  555. {
  556. fileType = doc.ContentType;
  557. string fileExtension = new FileInfo(doc.FileName).Extension;
  558. string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", "");
  559. if (documentExtension.ToLower().Contains(fileExtension.ToLower()))
  560. {
  561. string fileName = documentType + "_" + GetStatic.GetDateTimeStamp() + "_" + GetStatic.GetUser() + "_" + fileExtension;
  562. string path = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + registeredDate.Replace("-", "\\") + "\\" + membershipId;
  563. if (!Directory.Exists(path))
  564. Directory.CreateDirectory(path);
  565. doc.SaveAs(path + "/" + fileName);
  566. fName = fileName;
  567. }
  568. else
  569. {
  570. fName = "notValid";
  571. }
  572. }
  573. catch (Exception ex)
  574. {
  575. fName = "";
  576. }
  577. return fName;
  578. }
  579. public void SaveCustomerAndReceiver()
  580. {
  581. var dbResult = new DbResult();
  582. try
  583. {
  584. var jsonString = "";
  585. //checked file extention
  586. HttpFileCollection fileCollectionNew = Request.Files;
  587. string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", "");
  588. for (int i = 0; i < fileCollectionNew.AllKeys.Length; i++)
  589. {
  590. HttpPostedFile file = fileCollectionNew[i];
  591. string fileExtension = new FileInfo(file.FileName).Extension;
  592. if (!documentExtension.ToLower().Contains(fileExtension.ToLower()))
  593. {
  594. DbResult response = new DbResult()
  595. {
  596. ErrorCode = "1",
  597. Msg = "Invalid File Extension!!"
  598. };
  599. jsonString = JsonConvert.SerializeObject(response);
  600. Response.ContentType = "application/json";
  601. Response.Write(jsonString);
  602. Response.End();
  603. }
  604. }
  605. if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString())))
  606. {
  607. GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!");
  608. return;
  609. }
  610. //if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value)))
  611. //{
  612. // GetStatic.AlertMessage(this, "Customer signature or customer password is required!");
  613. // return;
  614. //}
  615. OnlineCustomerModel customerModel = PrepareCutomerDataFromAjax();
  616. BenificiaryModel benificiaryModel = PrepareBenificiaryDataFromAjax();
  617. dbResult = _customerServices.RegisterCustomerAndReceiver(customerModel, benificiaryModel);
  618. var hddImgURL = Request.Form["hddImgURL"].ToString();
  619. if (dbResult.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL) && !string.IsNullOrWhiteSpace(hddImgURL))
  620. {
  621. var result = dbResult.Id.Split('|');
  622. var customerId = result[0];
  623. var membershipId = result[1];
  624. var registerDate = result[2];
  625. string signatureName = GetStatic.UploadSignatureImage(hddImgURL, registerDate, membershipId, customerId);
  626. if (signatureName != "1")
  627. {
  628. _customerServices.AddCustomerSignature(customerId, GetStatic.GetUser(), signatureName, "Staff Visit - Customer Register(Customer Signature)", customerId);
  629. }
  630. }
  631. if (dbResult.ErrorCode == "0")
  632. {
  633. saveCustomerDocument(dbResult);
  634. }
  635. }
  636. catch (Exception ex)
  637. {
  638. dbResult = new DbResult()
  639. {
  640. ErrorCode = "1",
  641. Msg = ex.Message
  642. };
  643. }
  644. var jsonString1 = JsonConvert.SerializeObject(dbResult);
  645. Response.ContentType = "application/json";
  646. Response.Write(jsonString1);
  647. Response.End();
  648. }
  649. public OnlineCustomerModel PrepareCutomerDataFromAjax()
  650. {
  651. string fname = Request.Form["firstName"].ToString();
  652. string mName = Request.Form["middleName"].ToString();
  653. string lName = Request.Form["lastName"].ToString();
  654. string trimmedfirstName = fname.Trim() == "" ? null : fname.Trim();
  655. string trimmedMiddleName = mName.Trim() == "" ? null : mName.Trim();
  656. string trimmedlastName = lName.Trim() == "" ? null : lName.Trim();
  657. OnlineCustomerModel customerModel = new OnlineCustomerModel();
  658. customerModel.flag = "register-customer-and-receiver";
  659. customerModel.firstName = trimmedfirstName;
  660. customerModel.middleName = trimmedMiddleName;
  661. customerModel.lastName1 = trimmedlastName;
  662. customerModel.gender = Request.Form["genderList"].ToString();
  663. customerModel.country = Request.Form["countryList"].ToString();
  664. customerModel.zipCode = Request.Form["zipCode"].ToString();
  665. customerModel.state = Request.Form["state"].ToString();
  666. customerModel.city = Request.Form["city"].ToString();
  667. customerModel.street = Request.Form["street"].ToString();
  668. customerModel.AdditionalAddress = Request.Form["txtAdditionalAddress"].ToString();
  669. customerModel.email = Request.Form["email"].ToString();
  670. customerModel.homePhone = Request.Form["phoneNumber"].ToString();
  671. customerModel.mobile = Request.Form["mobile"].ToString();
  672. customerModel.visaStatus = Request.Form["ddlVisaStatus"].ToString();
  673. customerModel.employeeBusinessType = Request.Form["ddlEmployeeBusType"].ToString();
  674. customerModel.nativeCountry = Request.Form["nativeCountry"].ToString();
  675. customerModel.dob = Request.Form["dob"].ToString();
  676. //customerModel.dob = "1995-05-02";
  677. customerModel.sourceOfFound = Request.Form["ddSourceOfFound"].ToString();
  678. customerModel.occupation = Request.Form["occupation"].ToString();
  679. customerModel.telNo = Request.Form["phoneNumber"].ToString();
  680. customerModel.ipAddress = GetStatic.GetIp();
  681. customerModel.createdBy = GetStatic.GetUser();
  682. //customerModel.createdBy = GetStatic.GetUser();
  683. customerModel.idNumber = Request.Form["verificationTypeNo"].ToString();
  684. customerModel.idIssueDate = Request.Form["IssueDate"].ToString();
  685. customerModel.idExpiryDate = Request.Form["ExpireDate"].ToString();
  686. //customerModel.idIssueDate = "2020-01-02";
  687. //customerModel.idExpiryDate = "2021-05-02";
  688. customerModel.idType = Request.Form["idType"].ToString();
  689. customerModel.remitanceAllowed = Request.Form["rbRemitanceAllowed"].ToString() == "Enabled" ? true : false;
  690. customerModel.onlineUser = Request.Form["rbOnlineLogin"].ToString() == "Enabled" ? true : false;
  691. customerModel.remarks = Request.Form["txtRemarks"].ToString();
  692. customerModel.nameofEmployeer = Request.Form["txtNameofEmployeer"].ToString();
  693. customerModel.MonthlyIncome = Request.Form["ddlSalary"].ToString();
  694. //customerModel.agentId = Int32.Parse(GetStatic.GetAgent());
  695. customerModel.DocumentType = Request.Form["ddlDocType"].ToString();
  696. customerModel.occupationOther = Request.Form["occupationText"].ToString();
  697. return customerModel;
  698. }
  699. public BenificiaryModel PrepareBenificiaryDataFromAjax()
  700. {
  701. string receiverId = GetStatic.ReadQueryString("receiverId", "");
  702. var rfName = Request.Form["recTxtReceiverFName"].ToString();
  703. var rMName = Request.Form["recTxtReceiverMName"].ToString();
  704. var rLName = Request.Form["recTxtReceiverLName"].ToString();
  705. var trimmedReceiverFName = rfName.ToString().ToUpper().Trim() == "" ? null : rfName.ToString().ToUpper().Trim();
  706. var trimmedReceiverMName = rMName.ToString().ToUpper().Trim() == "" ? null : rMName.ToString().ToUpper().Trim();
  707. var trimmedReceiverLName = rLName.ToString().ToUpper().Trim() == "" ? null : rLName.ToString().ToUpper().Trim();
  708. BenificiaryModel benificiar = new BenificiaryModel();
  709. string Country = Request.Form["recDdlCountry"].ToString();
  710. benificiar.Country = Request.Form["recDdlCountry"].ToString();
  711. benificiar.NativeCountry = Request.Form["recDdlNativeCountry"].ToString();
  712. benificiar.BenificiaryType = Request.Form["recDdlBenificiaryType"].ToString();
  713. benificiar.Email = Request.Form["recTxtEmail"].ToString();
  714. benificiar.ReceiverFName = trimmedReceiverFName;
  715. benificiar.ReceiverMName = trimmedReceiverMName;
  716. benificiar.ReceiverLName = trimmedReceiverLName;
  717. benificiar.ReceiverAddress = Request.Form["recTxtReceiverAddress"].ToString();
  718. benificiar.ReceiverCity = Request.Form["recTxtReceiverCity"].ToString();
  719. benificiar.ContactNo = Request.Form["recTxtContactNo"].ToString();
  720. benificiar.SenderMobileNo = Request.Form["recTxtRecMobileNo"].ToString();
  721. benificiar.Relationship = Request.Form["recDdlRelationship"].ToString();
  722. benificiar.PlaceOfIssue = Request.Form["recTxtPlaceOfIssue"].ToString();
  723. benificiar.TypeId = Request.Form["recDdlIdType"].ToString();
  724. benificiar.TypeValue = Request.Form["recTxtIdValue"].ToString();
  725. benificiar.PurposeOfRemitance = Request.Form["recDdlPurposeOfRemitance"].ToString();
  726. benificiar.OtherPurpose = Request.Form["purposeOther"].ToString();
  727. benificiar.PaymentMode = Request.Form["recDdlPaymentMode"].ToString();
  728. benificiar.PayoutPatner = Request.Form["recDdlPayoutPatner"].ToString();
  729. benificiar.BenificaryAc = Request.Form["recTxtBenificaryAc"].ToString();
  730. benificiar.BankLocation = Request.Form["recDDLBankBranch"].ToString();
  731. benificiar.Remarks = Request.Form["recTxtRemarksRec"].ToString();
  732. benificiar.OtherRelationDescription = Request.Form["recOtherRelationshipTextBox"].ToString();
  733. benificiar.branchText = Request.Form["branch_manual"].ToString();
  734. return benificiar;
  735. }
  736. }
  737. }