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.

808 lines
41 KiB

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