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.

629 lines
31 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
  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. GetStatic.PrintMessage(Page);
  35. ////displayOnlyOnEdit.Visible = CheckAddOrEdit();
  36. //addEditPanel.Attributes.Add("style", "display:" + (CheckAddOrEdit() ? "none" : ""));
  37. //displayCounterVisit.Visible = !CheckAddOrEdit();
  38. //if (GetStatic.ReadQueryString("hdnId", "").ToString() != "")
  39. //{
  40. // ShowPrintLink(GetStatic.ReadQueryString("hdnId", "").ToString());
  41. //}
  42. //else
  43. //{
  44. // //linkDiv.Visible = false;
  45. //}
  46. var MethodName = Request.Form["MethodName"];
  47. if (!IsPostBack)
  48. {
  49. PopulateDdl();
  50. //Authenticate();
  51. switch (MethodName)
  52. {
  53. case "GetAddressDetailsByZipCode":
  54. GetAddressDetailsByZipCode();
  55. break;
  56. case "GetCustomerDetails":
  57. GetCustomerDetails();
  58. break;
  59. case "PaymentModePcountry":
  60. LoadPaymentModeFromAjax();
  61. break;
  62. case "PopulatePaymentMode":
  63. LoadPaymentModeDDL();
  64. break;
  65. case "PopulatePayoutPartner":
  66. LoadPayoutPartner();
  67. break;
  68. case "GetBankBranch":
  69. GetBankBranch();
  70. break;
  71. case "":
  72. SaveCustomerDetails();
  73. break;
  74. }
  75. }
  76. }
  77. private void SaveCustomerDetails()
  78. {
  79. var paymentmode = Request.Form["paymentmode"];
  80. }
  81. private void PopulateDdl()
  82. {
  83. //customerDdl
  84. _sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  85. _sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "");
  86. _sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  87. _sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  88. _sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='IdTypeWithDetails',@user='" + GetStatic.GetUser() + "',@countryId='" + countryList.SelectedValue + "'", "valueId", "detailTitle", "", "Select..");
  89. _sl.SetDDL(ref ddSourceOfFound, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3900", "valueId", "detailTitle", "", "Select..");
  90. _sl.SetDDL(ref ddlEmployeeBusType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7004", "valueId", "detailTitle", "", "");
  91. _sl.SetDDL(ref ddlVisaStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7005", "valueId", "detailTitle", "", "Select..");
  92. _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", "", "Select..");
  93. _sdd.SetStaticDdl(ref ddlDocType, "7009", "", "Select");
  94. //receiverDDl
  95. _sl.SetDDL(ref recDdlIdType, "EXEC proc_online_dropDownList @flag='idType',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
  96. _sl.SetDDL(ref recDdlCountry, "EXEC proc_online_dropDownList @flag='allCountrylistWithCode',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  97. _sl.SetDDL(ref recDdlNativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
  98. _sl.SetDDL(ref recDdlRelationship, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=2100", "valueId", "detailTitle", "", "Select..");
  99. _sl.SetDDL(ref recDdlPurposeOfRemitance, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3800", "valueId", "detailTitle", "8060", "Select..");
  100. _sl.SetDDL(ref recDdlBenificiaryType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=4700", "valueId", "detailTitle", recDdlBenificiaryType.SelectedValue, "");
  101. }
  102. private void Authenticate()
  103. {
  104. //if (CheckAddOrEdit())
  105. // _sl.CheckAuthentication(GetFunctionIdByUserType(EditViewFunctionIdAgent, EditViewFunctionId));
  106. //else
  107. // _sl.CheckAuthentication(GetFunctionIdByUserType(AddViewFunctionIdAgent, AddViewFunctionId));
  108. //string eId = GetStatic.ReadQueryString("customerId", "");
  109. //var hasRight = false;
  110. //if (eId == "")
  111. //{
  112. // hasRight = _sl.HasRight(GetFunctionIdByUserType(AddFunctionIdAgent, AddFunctionId));
  113. // register.Enabled = hasRight;
  114. // register.Visible = hasRight;
  115. //}
  116. //else
  117. //{
  118. // hasRight = _sl.HasRight(GetFunctionIdByUserType(EditFunctionIdAgent, EditFunctionId));
  119. // register.Enabled = hasRight;
  120. // register.Visible = hasRight;
  121. //}
  122. }
  123. private bool CheckAddOrEdit()
  124. {
  125. //if (isEdit)
  126. //{
  127. // customerType.Attributes.Add("hidden", "hidden");
  128. //}
  129. //else
  130. //{
  131. // customerType.Attributes.Remove("hidden");
  132. //}
  133. //return isEdit;
  134. return true;
  135. }
  136. private void PopulateForm(string eId)
  137. {
  138. var dr = _customerServices.GetCustomerDetails(eId, GetStatic.GetUser());
  139. if (null != dr)
  140. {
  141. hdnCustomerId.Value = dr["customerId"].ToString();
  142. firstName.Text = dr["firstName"].ToString();
  143. middleName.Text = dr["middleName"].ToString();
  144. lastName.Text = dr["lastName1"].ToString();
  145. genderList.SelectedValue = dr["gender"].ToString();
  146. countryList.SelectedValue = dr["country"].ToString();
  147. zipCode.Text = dr["zipCode"].ToString();
  148. city.Text = dr["city"].ToString();
  149. email.Text = dr["email"].ToString();
  150. hddOldEmailValue.Value = dr["email"].ToString();
  151. phoneNumber.Text = dr["telNo"].ToString();
  152. mobile.Text = dr["mobile"].ToString();
  153. nativeCountry.SelectedItem.Text = dr["nativeCountry"].ToString();
  154. nativeCountry.SelectedItem.Value = dr["nativeCountryId"].ToString();
  155. dob.Value = dr["dob"].ToString();
  156. occupation.Text = dr["occupation"].ToString();
  157. IssueDate.Value = dr["idIssueDate"].ToString();
  158. ExpireDate.Value = dr["idExpiryDate"].ToString();
  159. idType.SelectedValue = dr["idType"].ToString();
  160. verificationTypeNo.Text = dr["idNumber"].ToString();
  161. hddIdNumber.Value = dr["homePhone"].ToString();
  162. hdnMembershipNo.Value = dr["membershipId"].ToString();
  163. txtStreet.Text = dr["street"].ToString();
  164. txtAdditionalAddress.Text = dr["additionalAddress"].ToString();
  165. txtNameofEmployeer.Text = dr["nameOfEmployeer"].ToString();
  166. rbRemitanceAllowed.SelectedValue = (dr["remittanceAllowed"].ToString().ToLower() == "true" ? "Enabled" : "Disabled");
  167. rbOnlineLogin.SelectedValue = (dr["onlineUser"].ToString() == "Y" ? "Enabled" : "Disabled");
  168. txtRemarks.Text = dr["remarks"].ToString();
  169. txtSSnNo.Text = dr["SSNNO"].ToString();
  170. ddlSalary.SelectedValue = dr["monthlyIncome"].ToString();
  171. ddlVisaStatus.SelectedValue = dr["visaStatus"].ToString();
  172. ddSourceOfFound.SelectedValue = dr["sourceOfFund"].ToString();
  173. setStateDll(countryList.SelectedValue, zipCode.Text, dr["state"].ToString());
  174. email.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
  175. hddTxnsMade.Value = dr["isTxnMade"].ToString();
  176. if (dr["isTxnMade"].ToString() == "Y")
  177. {
  178. //msgDiv.Visible = true;
  179. //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.";
  180. }
  181. if (dr["idType"].ToString() == "8008")
  182. {
  183. expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4 hidden");
  184. }
  185. else
  186. {
  187. expiryDiv.Attributes.Remove("class");
  188. expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4");
  189. }
  190. //membershipDiv.Visible = true;
  191. }
  192. }
  193. public void ShowPrintLink(string membershipId)
  194. {
  195. //linkDiv.Visible = true;
  196. //printLink.Attributes["href"] = "PrintDetails.aspx?membershipId=" + membershipId;
  197. //printLink.InnerText = "Print Details of " + membershipId + "";
  198. }
  199. public class CustomerAddress
  200. {
  201. public string errrorCode { get; set; }
  202. public string msg { get; set; }
  203. public string State { get; set; }
  204. public string City { get; set; }
  205. public string Street { get; set; }
  206. }
  207. private void GetAddressDetailsByZipCode()
  208. {
  209. string zipCode = Request.Form["zipCode"];
  210. string rowID = Request.Form["RowID"];
  211. var dr = _customerServices.GetAddressByZipCodeNew(zipCode, GetStatic.GetUser(), rowID);
  212. var json = GetStatic.DataTableToJson(dr);
  213. GetStatic.JsonResponse(json, this);
  214. Response.End();
  215. }
  216. private void GetCustomerDetails()
  217. {
  218. string eId = Request.Form["Id"];
  219. var dt = _customerServices.GetDetailsForEditCustomer(eId, GetStatic.GetUser());
  220. Response.ContentType = "text/plain";
  221. var json = DataTableToJson(dt);
  222. Response.Write(json);
  223. Response.End();
  224. }
  225. public static string DataTableToJson(DataTable table)
  226. {
  227. if (table == null)
  228. return "";
  229. var list = new List<Dictionary<string, object>>();
  230. foreach (DataRow row in table.Rows)
  231. {
  232. var dict = new Dictionary<string, object>();
  233. foreach (DataColumn col in table.Columns)
  234. {
  235. dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
  236. }
  237. list.Add(dict);
  238. }
  239. var serializer = new JavaScriptSerializer();
  240. string json = serializer.Serialize(list);
  241. return json;
  242. }
  243. private void setStateDll(string countryId, string zipCode, string stateId)
  244. {
  245. if (countryId != "")
  246. {
  247. _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", stateId, "Select..");
  248. }
  249. }
  250. public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
  251. {
  252. return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
  253. }
  254. protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e)
  255. {
  256. string eId = hdnCustomerId.Value;
  257. if (eId != "")
  258. {
  259. PopulateForm(eId);
  260. }
  261. }
  262. protected void registerCustomerAndReceiver_Click(object sender, EventArgs e)
  263. {
  264. try
  265. {
  266. //checked file extention
  267. HttpFileCollection fileCollectionNew = Request.Files;
  268. string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", "");
  269. for (int i = 0; i < fileCollectionNew.AllKeys.Length; i++)
  270. {
  271. HttpPostedFile file = fileCollectionNew[i];
  272. string fileExtension = new FileInfo(file.FileName).Extension;
  273. if (!documentExtension.ToLower().Contains(fileExtension.ToLower()))
  274. {
  275. GetStatic.AlertMessage(this, "Invalid File Extenstion");
  276. return;
  277. }
  278. }
  279. if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString())))
  280. {
  281. GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!");
  282. return;
  283. }
  284. //if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value)))
  285. //{
  286. // GetStatic.AlertMessage(this, "Customer signature or customer password is required!");
  287. // return;
  288. //}
  289. OnlineCustomerModel customerModel = PrepareCutomerData();
  290. BenificiaryModel benificiaryModel = PrepareBenificiaryData();
  291. var dbResult = _customerServices.RegisterCustomerAndReceiver(customerModel, benificiaryModel);
  292. if (dbResult.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value))
  293. {
  294. var result = dbResult.Id.Split('|');
  295. var customerId = result[0];
  296. var membershipId = result[1];
  297. var registerDate = result[2];
  298. string signatureName = GetStatic.UploadSignatureImage(hddImgURL.Value, registerDate, membershipId, customerId);
  299. if (signatureName != "1")
  300. {
  301. _customerServices.AddCustomerSignature(customerId, GetStatic.GetUser(), signatureName, "agent-upload", customerId);
  302. }
  303. }
  304. GetStatic.SetMessage(dbResult.ErrorCode, dbResult.Msg);
  305. if (dbResult.ErrorCode == "0")
  306. {
  307. saveCustomerDocument(dbResult);
  308. var url = "PrintDetails.aspx?membershipId=" + dbResult.Id.Split('|')[1] + "&receiverId=" + dbResult.Id.Split('|')[3] + "";
  309. Response.Redirect(url);
  310. }
  311. Page_Load(sender, e);
  312. return;
  313. }
  314. catch (Exception ex)
  315. {
  316. GetStatic.AlertMessage(this.Page, ex.Message);
  317. }
  318. }
  319. private void LoadPaymentModeFromAjax()
  320. {
  321. var pCountry = Request.Form["pCountry"];
  322. var dt = _customerServices.LoadDataPaymentModeDdl(GetStatic.ReadWebConfig("domesticCountryId", ""), pCountry, "", null, "recModeByCountry", GetStatic.GetUser());
  323. Response.ContentType = "text/plain";
  324. var json = DataTableToJson(dt);
  325. Response.Write(json);
  326. Response.End();
  327. }
  328. private void LoadPaymentModeDDL()
  329. {
  330. var country = Request.Form["country"];
  331. var sql = "EXEC proc_online_sendPageLoadData @flag='payoutMethods'";
  332. sql += ",@country=" + _sl.FilterString(country.Split('(')[0]);
  333. var paymentList = _sl.ExecuteDataTable(sql);
  334. var paymentDdl = Mapper.DataTableToClass<DropDownModel>(paymentList);
  335. var jsonString = JsonConvert.SerializeObject(paymentDdl);
  336. Response.ContentType = "application/json";
  337. Response.Write(jsonString);
  338. Response.End();
  339. }
  340. private void LoadPayoutPartner()
  341. {
  342. var countryId = Request.Form["country"].Split('(')[0];
  343. var paymentModeVal = Request.Form["paymentMode"];
  344. var sql = "EXEC proc_sendPageLoadData @flag='recAgentByRecModeAjaxagentAndCountry', @countryId = '" + GetStatic.ReadWebConfig("domesticCountryId", "") + "',@pCountryId='" + countryId + "',@param = '" + paymentModeVal + "',@agentId='" + GetStatic.GetAgentId() + "',@user = '" + GetStatic.GetUser() + "'";
  345. var payoutPartnerList = _sl.ExecuteDataTable(sql);
  346. var payoutPartnerDdl = Mapper.DataTableToClass<DropDownModel>(payoutPartnerList);
  347. var jsonString = JsonConvert.SerializeObject(payoutPartnerDdl);
  348. Response.ContentType = "application/json";
  349. Response.Write(jsonString);
  350. Response.End();
  351. }
  352. public void GetBankBranch()
  353. {
  354. string bankId = Request.Form["bankId"];
  355. string countryId = Request.Form["countryId"];
  356. string pMode = Request.Form["pMode"];
  357. string branchId = Request.Form["branchId"];
  358. if (pMode == "2")
  359. recReceiverAccountNo.Attributes.Remove("hidden");
  360. var dtResult = _sendTxnServices.GetPayoutPartner(GetStatic.GetUser(), countryId, pMode);
  361. string partnerId = dtResult.Rows[0][0].ToString();
  362. var dao = new RemittanceDao();
  363. string sql = "";
  364. if (partnerId == GetStatic.ReadWebConfig("transfast", "") || partnerId == GetStatic.ReadWebConfig("jmeNepal", ""))
  365. {
  366. sql = "EXEC PROC_API_BANK_BRANCH_SETUP @FLAG='getBranchByAgentIdForDDL',@bankId=" + dao.FilterString(bankId) + ",@PAYMENT_TYPE = " + dao.FilterString(pMode);
  367. }
  368. else
  369. {
  370. sql = "EXEC proc_dropDownLists @flag = 'pickBranchById', @agentId=" + dao.FilterString(bankId);
  371. }
  372. var paymentDdl = Mapper.DataTableToClass<DropDownModel>(_sl.ExecuteDataTable(sql));
  373. var jsonString = JsonConvert.SerializeObject(paymentDdl);
  374. Response.ContentType = "application/json";
  375. Response.Write(jsonString);
  376. Response.End();
  377. }
  378. protected string GetReceiverId()
  379. {
  380. return GetStatic.ReadQueryString("receiverId", "");
  381. }
  382. public OnlineCustomerModel PrepareCutomerData()
  383. {
  384. string trimmedfirstName = firstName.Text.Trim() == "" ? null : firstName.Text.Trim();
  385. string trimmedMiddleName = middleName.Text.Trim() == "" ? null : middleName.Text.Trim();
  386. string trimmedlastName = lastName.Text.Trim() == "" ? null : lastName.Text.Trim();
  387. string area = Request.Form["ctl00$MainContent$txtStreet"];
  388. string occupationVal = occupationHidden.Value;
  389. OnlineCustomerModel customerModel = new OnlineCustomerModel();
  390. customerModel.flag = "register-customer-and-receiver";
  391. customerModel.firstName = trimmedfirstName;
  392. customerModel.middleName = trimmedMiddleName;
  393. customerModel.lastName1 = trimmedlastName;
  394. customerModel.gender = genderList.SelectedValue;
  395. customerModel.country = countryList.Text;
  396. customerModel.zipCode = zipCode.Text;
  397. customerModel.city = cityHidden.Value;
  398. customerModel.state = ddlStateHidden.Value;
  399. customerModel.street = Request.Form["ctl00$MainContent$txtStreet"];
  400. customerModel.AdditionalAddress = txtAdditionalAddress.Text;
  401. customerModel.email = email.Text;
  402. customerModel.homePhone = phoneNumber.Text;
  403. customerModel.mobile = mobile.Text;
  404. customerModel.visaStatus = ddlVisaStatus.SelectedValue;
  405. customerModel.employeeBusinessType = ddlEmployeeBusType.SelectedValue;
  406. customerModel.nativeCountry = nativeCountry.SelectedValue;
  407. customerModel.dob = dob.Value;
  408. //customerModel.dob = "1995-05-02";
  409. customerModel.ssnNo = txtSSnNo.Text;
  410. customerModel.sourceOfFound = ddSourceOfFound.SelectedValue;
  411. customerModel.occupation = occupationVal;
  412. customerModel.telNo = phoneNumber.Text;
  413. customerModel.ipAddress = GetStatic.GetIp();
  414. customerModel.createdBy = GetStatic.GetUser();
  415. //customerModel.createdBy = GetStatic.GetUser();
  416. customerModel.idNumber = verificationTypeNo.Text;
  417. customerModel.idIssueDate = IssueDate.Value;
  418. customerModel.idExpiryDate = ExpireDate.Value;
  419. //customerModel.idIssueDate = "2020-01-02";
  420. //customerModel.idExpiryDate = "2021-05-02";
  421. customerModel.idType = idType.Text.Split('|')[0].ToString();
  422. customerModel.remitanceAllowed = (rbRemitanceAllowed.SelectedValue == "Enabled" ? true : false);
  423. customerModel.onlineUser = (rbOnlineLogin.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 = "Alien Registration Card(Front)";
  536. documentType = "11054";
  537. }
  538. else
  539. {
  540. documentTypeName = "Alien Registration Card(Back)";
  541. documentType = "11055";
  542. }
  543. string fileName = (!string.IsNullOrWhiteSpace(file.FileName) ? UploadDocument(file, customerId, documentTypeName, membershipId, registerDate, out fileType) : UploadDocument(file, customerId, documentType, membershipId, registerDate, out fileType));
  544. CustomerDocument cm = new CustomerDocument();
  545. cm.customerId = result[0];
  546. cm.fileDescription = "";
  547. cm.documentType = documentType;
  548. cm.fileUrl = fileName;
  549. cm.fileType = fileType;
  550. var res = _customerServices.UpdateCustomerDocument("", customerId, fileName, documentTypeName, fileType, documentType, GetStatic.GetUser());
  551. }
  552. }
  553. }
  554. private string UploadDocument(HttpPostedFile doc, string customerId, string documentType, string membershipId, string registeredDate, out string fileType)
  555. {
  556. fileType = "";
  557. string fName = "";
  558. try
  559. {
  560. fileType = doc.ContentType;
  561. string fileExtension = new FileInfo(doc.FileName).Extension;
  562. string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", "");
  563. if (documentExtension.ToLower().Contains(fileExtension.ToLower()))
  564. {
  565. string fileName = customerId + "_" + documentType + "_" + DateTime.Now.Hour.ToString() + DateTime.Now.Millisecond.ToString() + "_" + registeredDate.Replace("-", "_") + fileExtension;
  566. string path = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + registeredDate.Replace("-", "\\") + "\\" + membershipId;
  567. if (!Directory.Exists(path))
  568. Directory.CreateDirectory(path);
  569. doc.SaveAs(path + "/" + fileName);
  570. fName = fileName;
  571. }
  572. else
  573. {
  574. fName = "notValid";
  575. }
  576. }
  577. catch (Exception ex)
  578. {
  579. fName = "";
  580. }
  581. return fName;
  582. }
  583. }
  584. }