using Newtonsoft.Json; using Swift.DAL.BL.AgentPanel.Send; using Swift.DAL.Common; using Swift.DAL.OnlineAgent; using Swift.DAL.SwiftDAL; using Swift.web.Library; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Reflection; using System.Web; using System.Web.Script.Serialization; using System.Web.UI.WebControls; namespace Swift.web.AgentNew.Administration.CustomerSetup.CustomerRegistration { public partial class CustomerRegistrationNew : System.Web.UI.Page { private readonly RemittanceLibrary _sl = new RemittanceLibrary(); private readonly OnlineCustomerDao _cd = new OnlineCustomerDao(); private SendTranIRHDao st = new SendTranIRHDao(); private readonly StaticDataDdl _sdd = new StaticDataDdl(); protected void Page_Load(object sender, EventArgs e) { Authenticate(); //signatureDiv.Visible = !CheckAddOrEdit() && _sl.HasRight(SignatureFunctionId); //isDisplaySignature.Value = !CheckAddOrEdit() && _sl.HasRight(SignatureFunctionId) ? "true" : "false"; //agreementDiv.Visible = !CheckAddOrEdit(); GetStatic.PrintMessage(Page); ////displayOnlyOnEdit.Visible = CheckAddOrEdit(); //addEditPanel.Attributes.Add("style", "display:" + (CheckAddOrEdit() ? "none" : "")); //displayCounterVisit.Visible = !CheckAddOrEdit(); //if (GetStatic.ReadQueryString("hdnId", "").ToString() != "") //{ // ShowPrintLink(GetStatic.ReadQueryString("hdnId", "").ToString()); //} //else //{ // //linkDiv.Visible = false; //} var MethodName = Request.Form["MethodName"]; if (!IsPostBack) { PopulateDdl(); switch (MethodName) { case "GetAddressDetailsByZipCode": GetAddressDetailsByZipCode(); break; case "GetCustomerDetails": GetCustomerDetails(); break; case "PaymentModePcountry": LoadPaymentModeFromAjax(); break; case "PopulatePaymentMode": LoadPaymentModeDDL(); break; case "PopulatePayoutPartner": LoadPayoutPartner(); break; case "GetBankBranch": GetBankBranch(); break; case "SaveCustomerAndReceiver": SaveCustomerAndReceiver(); break; } } } private void PopulateDdl() { //customerDdl _sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", ""); _sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select.."); _sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='IdTypeWithDetails',@user='" + GetStatic.GetUser() + "',@countryId='" + countryList.SelectedValue + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddSourceOfFound, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3900", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlEmployeeBusType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7004", "valueId", "detailTitle", "", ""); _sl.SetDDL(ref ddlVisaStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7005", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", "", "Select.."); _sdd.SetStaticDdl(ref ddlDocType, "7009", "", "Select"); //receiverDDl _sl.SetDDL(ref recDdlIdType, "EXEC proc_online_dropDownList @flag='idType',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref recDdlCountry, "EXEC proc_online_dropDownList @flag='allCountrylistWithCode',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select.."); _sl.SetDDL(ref recDdlNativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select.."); _sl.SetDDL(ref recDdlRelationship, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=2100", "valueId", "detailTitle", "", "Select.."); _sl.SetDDL(ref recDdlPurposeOfRemitance, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3800", "valueId", "detailTitle", "8060", "Select.."); _sl.SetDDL(ref recDdlBenificiaryType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=4700", "valueId", "detailTitle", recDdlBenificiaryType.SelectedValue, ""); } private void Authenticate() { //if (CheckAddOrEdit()) // _sl.CheckAuthentication(GetFunctionIdByUserType(EditViewFunctionIdAgent, EditViewFunctionId)); //else // _sl.CheckAuthentication(GetFunctionIdByUserType(AddViewFunctionIdAgent, AddViewFunctionId)); //string eId = GetStatic.ReadQueryString("customerId", ""); //var hasRight = false; //if (eId == "") //{ // hasRight = _sl.HasRight(GetFunctionIdByUserType(AddFunctionIdAgent, AddFunctionId)); // register.Enabled = hasRight; // register.Visible = hasRight; //} //else //{ // hasRight = _sl.HasRight(GetFunctionIdByUserType(EditFunctionIdAgent, EditFunctionId)); // register.Enabled = hasRight; // register.Visible = hasRight; //} } private bool CheckAddOrEdit() { //if (isEdit) //{ // customerType.Attributes.Add("hidden", "hidden"); //} //else //{ // customerType.Attributes.Remove("hidden"); //} //return isEdit; return true; } private void PopulateForm(string eId) { var dr = _cd.GetCustomerDetails(eId, GetStatic.GetUser()); if (null != dr) { hdnCustomerId.Value = dr["customerId"].ToString(); firstName.Text = dr["firstName"].ToString(); middleName.Text = dr["middleName"].ToString(); lastName.Text = dr["lastName1"].ToString(); genderList.SelectedValue = dr["gender"].ToString(); countryList.SelectedValue = dr["country"].ToString(); zipCode.Text = dr["zipCode"].ToString(); city.Text = dr["city"].ToString(); email.Text = dr["email"].ToString(); hddOldEmailValue.Value = dr["email"].ToString(); phoneNumber.Text = dr["telNo"].ToString(); mobile.Text = dr["mobile"].ToString(); nativeCountry.SelectedItem.Text = dr["nativeCountry"].ToString(); nativeCountry.SelectedItem.Value = dr["nativeCountryId"].ToString(); dob.Value = dr["dob"].ToString(); occupation.Text = dr["occupation"].ToString(); IssueDate.Value = dr["idIssueDate"].ToString(); ExpireDate.Value = dr["idExpiryDate"].ToString(); idType.SelectedValue = dr["idType"].ToString(); verificationTypeNo.Text = dr["idNumber"].ToString(); hddIdNumber.Value = dr["homePhone"].ToString(); hdnMembershipNo.Value = dr["membershipId"].ToString(); txtStreet.Text = dr["street"].ToString(); txtAdditionalAddress.Text = dr["additionalAddress"].ToString(); txtNameofEmployeer.Text = dr["nameOfEmployeer"].ToString(); rbRemitanceAllowed.SelectedValue = (dr["remittanceAllowed"].ToString().ToLower() == "true" ? "Enabled" : "Disabled"); rbOnlineLogin.SelectedValue = (dr["onlineUser"].ToString() == "Y" ? "Enabled" : "Disabled"); rbMobileLogin.SelectedValue = (dr["mobileUSer"].ToString() == "Y" ? "Enabled" : "Disabled"); txtRemarks.Text = dr["remarks"].ToString(); txtSSnNo.Text = dr["SSNNO"].ToString(); ddlSalary.SelectedValue = dr["monthlyIncome"].ToString(); ddlVisaStatus.SelectedValue = dr["visaStatus"].ToString(); ddSourceOfFound.SelectedValue = dr["sourceOfFund"].ToString(); setStateDll(countryList.SelectedValue, zipCode.Text, dr["state"].ToString()); email.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true; hddTxnsMade.Value = dr["isTxnMade"].ToString(); if (dr["isTxnMade"].ToString() == "Y") { //msgDiv.Visible = true; //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."; } if (dr["idType"].ToString() == "8008") { expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4 hidden"); } else { expiryDiv.Attributes.Remove("class"); expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4"); } //membershipDiv.Visible = true; } } public void ShowPrintLink(string membershipId) { //linkDiv.Visible = true; //printLink.Attributes["href"] = "PrintDetails.aspx?membershipId=" + membershipId; //printLink.InnerText = "Print Details of " + membershipId + ""; } public class CustomerAddress { public string errrorCode { get; set; } public string msg { get; set; } public string State { get; set; } public string City { get; set; } public string Street { get; set; } } private void GetAddressDetailsByZipCode() { string zipCode = Request.Form["zipCode"]; string rowID = Request.Form["RowID"]; string customerId = GetCustomerId(); var dr = _cd.GetAddressByZipCodeNew(zipCode, GetStatic.GetUser(), rowID, customerId); var json = GetStatic.DataTableToJson(dr); GetStatic.JsonResponse(json, this); Response.End(); } private void GetCustomerDetails() { string eId = Request.Form["Id"]; var dt = _cd.GetDetailsForEditCustomer(eId, GetStatic.GetUser()); Response.ContentType = "text/plain"; var json = DataTableToJson(dt); Response.Write(json); Response.End(); } protected string GetCustomerId() { return GetStatic.ReadQueryString("customerId", ""); } public static string DataTableToJson(DataTable table) { if (table == null) return ""; var list = new List>(); foreach (DataRow row in table.Rows) { var dict = new Dictionary(); foreach (DataColumn col in table.Columns) { dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col]; } list.Add(dict); } var serializer = new JavaScriptSerializer(); string json = serializer.Serialize(list); return json; } private void setStateDll(string countryId, string zipCode, string stateId) { if (countryId != "") { _sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", stateId, "Select.."); } } public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin) { return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent; } protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e) { string eId = hdnCustomerId.Value; if (eId != "") { PopulateForm(eId); } } protected void registerCustomerAndReceiver_Click(object sender, EventArgs e) { try { //checked file extention HttpFileCollection fileCollectionNew = Request.Files; string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", ""); for (int i = 0; i < fileCollectionNew.AllKeys.Length; i++) { HttpPostedFile file = fileCollectionNew[i]; string fileExtension = new FileInfo(file.FileName).Extension; if (!documentExtension.ToLower().Contains(fileExtension.ToLower())) { GetStatic.AlertMessage(this, "Invalid File Extenstion"); return; } } if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString()))) { GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!"); return; } //if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value))) //{ // GetStatic.AlertMessage(this, "Customer signature or customer password is required!"); // return; //} OnlineCustomerModel customerModel = PrepareCutomerData(); BenificiaryModel benificiaryModel = PrepareBenificiaryData(); var dbResult = _cd.RegisterCustomerAndReceiver(customerModel, benificiaryModel); if (dbResult.ErrorCode == "0" && !string.IsNullOrEmpty(hddImgURL.Value) && !string.IsNullOrWhiteSpace(hddImgURL.Value)) { var result = dbResult.Id.Split('|'); var customerId = result[0]; var membershipId = result[1]; var registerDate = result[2]; string signatureName = GetStatic.UploadSignatureImage(hddImgURL.Value, registerDate, membershipId, customerId); if (signatureName != "1") { _cd.AddCustomerSignature(customerId, GetStatic.GetUser(), signatureName, "agent-upload", customerId); } } GetStatic.SetMessage(dbResult.ErrorCode, dbResult.Msg); if (dbResult.ErrorCode == "0") { saveCustomerDocument(dbResult); var url = "PrintDetailsNew.aspx?membershipId=" + dbResult.Id.Split('|')[1] + "&receiverId=" + dbResult.Id.Split('|')[3] + ""; Response.Redirect(url); } Page_Load(sender, e); return; } catch (Exception ex) { GetStatic.AlertMessage(this.Page, ex.Message); } } private void LoadPaymentModeFromAjax() { var pCountry = Request.Form["pCountry"]; var dt = _cd.LoadDataPaymentModeDdl(GetStatic.ReadWebConfig("domesticCountryId", ""), pCountry, "", null, "recModeByCountry", GetStatic.GetUser()); Response.ContentType = "text/plain"; var json = DataTableToJson(dt); Response.Write(json); Response.End(); } private void LoadPaymentModeDDL() { var country = Request.Form["country"]; var sql = "EXEC proc_online_sendPageLoadData @flag='payoutMethods'"; sql += ",@country=" + _sl.FilterString(country.Split('(')[0]); var paymentList = _sl.ExecuteDataTable(sql); var paymentDdl = Mapper.DataTableToClass(paymentList); var jsonString = JsonConvert.SerializeObject(paymentDdl); Response.ContentType = "application/json"; Response.Write(jsonString); Response.End(); } private void LoadPayoutPartner() { var countryId = Request.Form["country"].Split('(')[0]; var paymentModeVal = Request.Form["paymentMode"]; var sql = "EXEC proc_sendPageLoadData @flag='recAgentByRecModeAjaxagentAndCountry', @countryId = '" + GetStatic.ReadWebConfig("domesticCountryId", "") + "',@pCountryId='" + countryId + "',@param = '" + paymentModeVal + "',@agentId='" + GetStatic.GetAgentId() + "',@user = '" + GetStatic.GetUser() + "'"; var payoutPartnerList = _sl.ExecuteDataTable(sql); var payoutPartnerDdl = Mapper.DataTableToClass(payoutPartnerList); var jsonString = JsonConvert.SerializeObject(payoutPartnerDdl); Response.ContentType = "application/json"; Response.Write(jsonString); Response.End(); } public void GetBankBranch() { string bankId = Request.Form["bankId"]; string countryId = Request.Form["countryId"]; string pMode = Request.Form["pMode"]; string branchId = Request.Form["branchId"]; if (pMode == "2") recReceiverAccountNo.Attributes.Remove("hidden"); var dtResult = st.GetPayoutPartner(GetStatic.GetUser(), countryId, pMode); string partnerId = dtResult.Rows[0][0].ToString(); var dao = new RemittanceDao(); string sql = ""; if (partnerId == GetStatic.ReadWebConfig("transfast", "") || partnerId == GetStatic.ReadWebConfig("jmeNepal", "")) { sql = "EXEC PROC_API_BANK_BRANCH_SETUP @FLAG='getBranchByAgentIdForDDL',@bankId=" + dao.FilterString(bankId) + ",@PAYMENT_TYPE = " + dao.FilterString(pMode); } else { sql = "EXEC proc_dropDownLists @flag = 'pickBranchById', @agentId=" + dao.FilterString(bankId); } var paymentDdl = Mapper.DataTableToClass(_sl.ExecuteDataTable(sql)); var jsonString = JsonConvert.SerializeObject(paymentDdl); Response.ContentType = "application/json"; Response.Write(jsonString); Response.End(); } protected string GetReceiverId() { return GetStatic.ReadQueryString("receiverId", ""); } public OnlineCustomerModel PrepareCutomerData() { string trimmedfirstName = firstName.Text.Trim() == "" ? null : firstName.Text.Trim(); string trimmedMiddleName = middleName.Text.Trim() == "" ? null : middleName.Text.Trim(); string trimmedlastName = lastName.Text.Trim() == "" ? null : lastName.Text.Trim(); string area = Request.Form["ctl00$MainContent$txtStreet"]; string occupationVal = occupationHidden.Value; OnlineCustomerModel customerModel = new OnlineCustomerModel(); customerModel.flag = "register-customer-and-receiver"; customerModel.firstName = trimmedfirstName; customerModel.middleName = trimmedMiddleName; customerModel.lastName1 = trimmedlastName; customerModel.gender = genderList.SelectedValue; customerModel.country = countryList.Text; customerModel.zipCode = zipCode.Text; customerModel.city = cityHidden.Value; customerModel.state = ddlStateHidden.Value; customerModel.street = Request.Form["ctl00$MainContent$txtStreet"]; customerModel.AdditionalAddress = txtAdditionalAddress.Text; customerModel.email = email.Text; customerModel.homePhone = phoneNumber.Text; customerModel.mobile = mobile.Text; customerModel.visaStatus = ddlVisaStatus.SelectedValue; customerModel.employeeBusinessType = ddlEmployeeBusType.SelectedValue; customerModel.nativeCountry = nativeCountry.SelectedValue; customerModel.dob = dob.Value; //customerModel.dob = "1995-05-02"; customerModel.ssnNo = txtSSnNo.Text; customerModel.sourceOfFound = ddSourceOfFound.SelectedValue; customerModel.occupation = occupationVal; customerModel.telNo = phoneNumber.Text; customerModel.ipAddress = GetStatic.GetIp(); customerModel.createdBy = GetStatic.GetUser(); //customerModel.createdBy = GetStatic.GetUser(); customerModel.idNumber = verificationTypeNo.Text; customerModel.idIssueDate = IssueDate.Value; customerModel.idExpiryDate = ExpireDate.Value; //customerModel.idIssueDate = "2020-01-02"; //customerModel.idExpiryDate = "2021-05-02"; customerModel.idType = idType.Text.Split('|')[0].ToString(); customerModel.remitanceAllowed = (rbRemitanceAllowed.SelectedValue == "Enabled" ? true : false); customerModel.onlineUser = (rbOnlineLogin.SelectedValue == "Enabled" ? true : false); customerModel.mobileUser = (rbMobileLogin.SelectedValue == "Enabled" ? true : false); customerModel.remarks = txtRemarks.Text; customerModel.nameofEmployeer = txtNameofEmployeer.Text; customerModel.MonthlyIncome = ddlSalary.SelectedValue; //customerModel.agentId = Int32.Parse(GetStatic.GetAgent()); customerModel.DocumentType = ddlDocType.SelectedValue; customerModel.occupationOther = occupationText.Text; return customerModel; } public BenificiaryModel PrepareBenificiaryData() { string receiverId = GetStatic.ReadQueryString("receiverId", ""); var trimmedReceiverFName = recTxtReceiverFName.Text.ToString().ToUpper().Trim() == "" ? null : recTxtReceiverFName.Text.ToString().ToUpper().Trim(); var trimmedReceiverMName = recTxtReceiverMName.Text.ToString().ToUpper().Trim() == "" ? null : recTxtReceiverMName.Text.ToString().ToUpper().Trim(); var trimmedReceiverLName = recTxtReceiverLName.Text.ToString().ToUpper().Trim() == "" ? null : recTxtReceiverLName.Text.ToString().ToUpper().Trim(); BenificiaryModel benificiar = new BenificiaryModel(); string Country = recDdlCountry.SelectedValue; benificiar.Country = recDdlCountry.SelectedItem.Text.Split('(')[0]; benificiar.NativeCountry = recDdlNativeCountry.SelectedValue; benificiar.BenificiaryType = recDdlBenificiaryType.SelectedValue; benificiar.Email = recTxtEmail.Text; benificiar.ReceiverFName = trimmedReceiverFName; benificiar.ReceiverMName = trimmedReceiverMName; benificiar.ReceiverLName = trimmedReceiverLName; benificiar.ReceiverAddress = recTxtReceiverAddress.Text; benificiar.ReceiverCity = recTxtReceiverCity.Text; benificiar.ContactNo = recTxtContactNo.Text; benificiar.SenderMobileNo = recTxtRecMobileNo.Text; benificiar.Relationship = recDdlRelationship.SelectedValue; benificiar.PlaceOfIssue = recTxtPlaceOfIssue.Text; benificiar.TypeId = recDdlIdType.SelectedValue; benificiar.TypeValue = recTxtIdValue.Text; benificiar.PurposeOfRemitance = recDdlPurposeOfRemitance.SelectedValue; benificiar.OtherPurpose = purposeOther.Text; benificiar.PaymentMode = hddPaymentMode.Value; benificiar.PayoutPatner = hddBankId.Value; benificiar.BenificaryAc = recTxtBenificaryAc.Text; benificiar.BankLocation = HddBankBranchId.Value; benificiar.Remarks = recTxtRemarksRec.Text; benificiar.OtherRelationDescription = recOtherRelationshipTextBox.Text; benificiar.branchText = branch_manual.Text; return benificiar; } public static class Mapper { public static IList DataTableToClass(DataTable Table) where T : class, new() { var dataList = new List(Table.Rows.Count); Type classType = typeof(T); IList propertyList = classType.GetProperties(); if (propertyList.Count == 0) return new List(); List columnNames = Table.Columns.Cast().Select(column => column.ColumnName).ToList(); try { foreach (DataRow dataRow in Table.AsEnumerable().ToList()) { var classObject = new T(); foreach (PropertyInfo property in propertyList) { if (property != null && property.CanWrite) { if (columnNames.Contains(property.Name)) { if (dataRow[property.Name] != System.DBNull.Value) { object propertyValue = System.Convert.ChangeType( dataRow[property.Name], property.PropertyType ); property.SetValue(classObject, propertyValue, null); } } } } dataList.Add(classObject); } return dataList; } catch { return new List(); } } } public class DropDownModel { public string Key { get; set; } public string Value { get; set; } public string bankId { get; set; } public string AGENTNAME { get; set; } public string agentId { get; set; } public string agentName { get; set; } } private void saveCustomerDocument(DbResult dbresult) { var result = dbresult.Id.Split('|'); var customerId = result[0]; var membershipId = result[1]; var registerDate = result[2]; HttpFileCollection fileCollection = Request.Files; for (int i = 0; i < fileCollection.AllKeys.Length; i++) { HttpPostedFile file = fileCollection[i]; if (file != null) { string documentTypeName = ""; string documentType = ""; string fileType = ""; if (i == 0) { documentTypeName = "ID_Front"; documentType = "11386"; } else if (i == 1) { documentTypeName = "ID_Back"; documentType = "11387"; } else if (i == 2) { documentTypeName = "Additional_ID_Front"; documentType = "11389"; } else if (i == 3) { documentTypeName = "Additional_ID_Back"; documentType = "11395"; } else { documentTypeName = "Other_Document"; documentType = "11390"; } string fileName = (!string.IsNullOrWhiteSpace(file.FileName) ? UploadDocument(file, customerId, documentTypeName, membershipId, registerDate, out fileType) : UploadDocument(file, customerId, documentType, membershipId, registerDate, out fileType)); if (!string.IsNullOrEmpty(fileName) && fileName.ToLower() != "notvalid") _cd.UpdateCustomerDocument("", customerId, fileName, documentTypeName, fileType, documentType, GetStatic.GetUser()); } } } private string UploadDocument(HttpPostedFile doc, string customerId, string documentTypeName, string membershipId, string registeredDate, out string fileType) { fileType = ""; string fName = ""; try { fileType = doc.ContentType; string fileExtension = new FileInfo(doc.FileName).Extension; string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", ""); if (documentExtension.ToLower().Contains(fileExtension.ToLower())) { string fileName = documentTypeName + "_" + GetStatic.GetDateTimeStamp() + "_" + GetStatic.GetUser() + "_" + fileExtension; string path = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + registeredDate.Replace("-", "\\") + "\\" + membershipId; if (!Directory.Exists(path)) Directory.CreateDirectory(path); doc.SaveAs(path + "/" + fileName); fName = fileName; } else { fName = "notValid"; } } catch (Exception ex) { fName = ""; } return fName; } public void SaveCustomerAndReceiver() { var jsonString = ""; //checked file extention HttpFileCollection fileCollectionNew = Request.Files; string documentExtension = GetStatic.ReadWebConfig("customerDocFileExtension", ""); for (int i = 0; i < fileCollectionNew.AllKeys.Length; i++) { HttpPostedFile file = fileCollectionNew[i]; string fileExtension = new FileInfo(file.FileName).Extension; if (!documentExtension.ToLower().Contains(fileExtension.ToLower())) { DbResult response = new DbResult() { ErrorCode = "1", Msg = "Invalid File Extension!!" }; jsonString = JsonConvert.SerializeObject(response); Response.ContentType = "application/json"; Response.Write(jsonString); Response.End(); } } if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString()))) { GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!"); return; } //if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value))) //{ // GetStatic.AlertMessage(this, "Customer signature or customer password is required!"); // return; //} OnlineCustomerModel customerModel = PrepareCutomerDataFromAjax(); BenificiaryModel benificiaryModel = PrepareBenificiaryDataFromAjax(); var dbResult = _cd.RegisterCustomerAndReceiverNew(customerModel, benificiaryModel, GetStatic.GetAgent()); GetStatic.SetMessage(dbResult.ErrorCode, dbResult.Msg); if (dbResult.ErrorCode == "0") { saveCustomerDocument(dbResult); jsonString = JsonConvert.SerializeObject(dbResult); Response.ContentType = "application/json"; Response.Write(jsonString); Response.End(); return; } //try //{ //} //catch (Exception ex) //{ // DbResult dbResult = new DbResult() // { // ErrorCode = "1", // Msg = ex.Message.ToString() // }; // var jsonString = JsonConvert.SerializeObject(dbResult); // Response.ContentType = "application/json"; // Response.Write(jsonString); // Response.End(); //} } public OnlineCustomerModel PrepareCutomerDataFromAjax() { string fname = Request.Form["firstName"].ToString(); string mName = Request.Form["middleName"].ToString(); string lName = Request.Form["lastName"].ToString(); string trimmedfirstName = fname.Trim() == "" ? null : fname.Trim(); string trimmedMiddleName = mName.Trim() == "" ? null : mName.Trim(); string trimmedlastName = lName.Trim() == "" ? null : lName.Trim(); OnlineCustomerModel customerModel = new OnlineCustomerModel(); customerModel.flag = "register-customer-and-receiver"; customerModel.firstName = trimmedfirstName; customerModel.middleName = trimmedMiddleName; customerModel.lastName1 = trimmedlastName; customerModel.gender = Request.Form["genderList"].ToString(); customerModel.country = Request.Form["countryList"].ToString(); customerModel.zipCode = Request.Form["zipCode"].ToString(); customerModel.state = Request.Form["state"].ToString(); customerModel.city = Request.Form["city"].ToString(); customerModel.street = Request.Form["street"].ToString(); customerModel.AdditionalAddress = Request.Form["txtAdditionalAddress"].ToString(); customerModel.email = Request.Form["email"].ToString(); customerModel.homePhone = Request.Form["phoneNumber"].ToString(); customerModel.mobile = Request.Form["mobile"].ToString(); customerModel.visaStatus = Request.Form["ddlVisaStatus"].ToString(); customerModel.employeeBusinessType = Request.Form["ddlEmployeeBusType"].ToString(); customerModel.nativeCountry = Request.Form["nativeCountry"].ToString(); customerModel.dob = Request.Form["dob"].ToString(); //customerModel.dob = "1995-05-02"; customerModel.sourceOfFound = Request.Form["ddSourceOfFound"].ToString(); customerModel.occupation = Request.Form["occupation"].ToString(); customerModel.telNo = Request.Form["phoneNumber"].ToString(); customerModel.ipAddress = GetStatic.GetIp(); customerModel.createdBy = GetStatic.GetUser(); //customerModel.createdBy = GetStatic.GetUser(); customerModel.idNumber = Request.Form["verificationTypeNo"].ToString(); customerModel.idIssueDate = Request.Form["IssueDate"].ToString(); customerModel.idExpiryDate = Request.Form["ExpireDate"].ToString(); //customerModel.idIssueDate = "2020-01-02"; //customerModel.idExpiryDate = "2021-05-02"; customerModel.idType = Request.Form["idType"].ToString(); customerModel.remitanceAllowed = Request.Form["rbRemitanceAllowed"].ToString() == "Enabled" ? true : false; customerModel.onlineUser = Request.Form["rbOnlineLogin"].ToString() == "Enabled" ? true : false; customerModel.mobileUser = Request.Form["rbMobileLogin"].ToString() == "Enabled" ? true : false; customerModel.remarks = Request.Form["txtRemarks"].ToString(); customerModel.nameofEmployeer = Request.Form["txtNameofEmployeer"].ToString(); customerModel.MonthlyIncome = Request.Form["ddlSalary"].ToString(); //customerModel.agentId = Int32.Parse(GetStatic.GetAgent()); customerModel.DocumentType = Request.Form["ddlDocType"].ToString(); customerModel.occupationOther = Request.Form["occupationText"].ToString(); customerModel.loginUser = GetStatic.GetUser(); return customerModel; } public BenificiaryModel PrepareBenificiaryDataFromAjax() { string receiverId = GetStatic.ReadQueryString("receiverId", ""); var rfName = Request.Form["recTxtReceiverFName"].ToString(); var rMName = Request.Form["recTxtReceiverMName"].ToString(); var rLName = Request.Form["recTxtReceiverLName"].ToString(); var trimmedReceiverFName = rfName.ToString().ToUpper().Trim() == "" ? null : rfName.ToString().ToUpper().Trim(); var trimmedReceiverMName = rMName.ToString().ToUpper().Trim() == "" ? null : rMName.ToString().ToUpper().Trim(); var trimmedReceiverLName = rLName.ToString().ToUpper().Trim() == "" ? null : rLName.ToString().ToUpper().Trim(); BenificiaryModel benificiar = new BenificiaryModel(); string Country = Request.Form["recDdlCountry"].ToString(); benificiar.Country = Request.Form["recDdlCountry"].ToString(); benificiar.NativeCountry = Request.Form["recDdlNativeCountry"].ToString(); benificiar.BenificiaryType = Request.Form["recDdlBenificiaryType"].ToString(); benificiar.Email = Request.Form["recTxtEmail"].ToString(); benificiar.ReceiverFName = trimmedReceiverFName; benificiar.ReceiverMName = trimmedReceiverMName; benificiar.ReceiverLName = trimmedReceiverLName; benificiar.ReceiverAddress = Request.Form["recTxtReceiverAddress"].ToString(); benificiar.ReceiverCity = Request.Form["recTxtReceiverCity"].ToString(); benificiar.ContactNo = Request.Form["recTxtContactNo"].ToString(); benificiar.SenderMobileNo = Request.Form["recTxtRecMobileNo"].ToString(); benificiar.Relationship = Request.Form["recDdlRelationship"].ToString(); benificiar.PlaceOfIssue = Request.Form["recTxtPlaceOfIssue"].ToString(); benificiar.TypeId = Request.Form["recDdlIdType"].ToString(); benificiar.TypeValue = Request.Form["recTxtIdValue"].ToString(); benificiar.PurposeOfRemitance = Request.Form["recDdlPurposeOfRemitance"].ToString(); benificiar.OtherPurpose = Request.Form["purposeOther"].ToString(); benificiar.PaymentMode = Request.Form["recDdlPaymentMode"].ToString(); benificiar.PayoutPatner = Request.Form["recDdlPayoutPatner"].ToString(); benificiar.BenificaryAc = Request.Form["recTxtBenificaryAc"].ToString(); benificiar.BankLocation = Request.Form["recDDLBankBranch"].ToString(); benificiar.Remarks = Request.Form["recTxtRemarksRec"].ToString(); benificiar.OtherRelationDescription = Request.Form["recOtherRelationshipTextBox"].ToString(); benificiar.branchText = Request.Form["branch_manual"].ToString(); return benificiar; } } }