using Newtonsoft.Json; using Swift.API.Common; using Swift.API.Common.Enum; using Swift.API.TPAPIs; using Swift.DAL.OnlineAgent; using Swift.web.Library; using System; using System.Collections.Generic; using System.Data; using System.Text; namespace Swift.web.MobileRemit.Admin.Reports { public partial class CustomerRegistrationStatus : System.Web.UI.Page { private string ViewFunctionId = "41501000"; private readonly RemittanceLibrary _sl = new RemittanceLibrary(); private readonly StaticDataDdl _sdd = new StaticDataDdl(); private readonly OnlineCustomerDao _cd = new OnlineCustomerDao(); protected void Page_Load(object sender, EventArgs e) { Authenticate(); //btnUpdate.Enabled = true; btnReset.Enabled = true; btnActivate.Enabled = false; if (!IsPostBack) { PopulateDdl(); cusData.Visible = false; moreData.Visible = false; kycData.Visible = false; registrationTypeDiv.Visible = false; } } private void Authenticate() { _sl.CheckAuthentication(ViewFunctionId); } private void PopulateDdl() { _sdd.SetDDL(ref ddlCustomerType, "exec proc_sendPageLoadData @flag='search-cust-by-for-status'", "VALUE", "TEXT", "", ""); } protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e) { PopulateCustomerData(); } private void PopulateCustomerData() { string[] customer = txtSearchData.Value.Split('|'); var customerId = customer[0]; var customerSource = customer[1]; //var membershipId = txtSearchData.Value["membershipId"].ToString(); //var source = txtSearchData. DataSet ds = _cd.GetCustomerRegistrationStatusReport(GetStatic.GetUser(), customerId, customerSource); if (ds != null) { var customerDetails = ds.Tables[0]; var details = ds.Tables[1]; if (customerDetails.Rows.Count > 0) { PopulateCustomerDetails(customerDetails); } else { custDetails.InnerHtml = ""; } if (details.Rows.Count > 0) { PopulateDetails(details); } if (ds.Tables.Count > 1) { var kycDetails = ds.Tables[2]; if (kycDetails.Rows.Count >= 1) { PopulateKycDetails(kycDetails); } else { tblKycDetail.InnerHtml = ""; } } } } private void PopulateDetails(DataTable customerDetails) { email.Text = customerDetails.Rows[0]["email"].ToString(); idType.Text = customerDetails.Rows[0]["detailTitle"].ToString(); idNumber.Text = customerDetails.Rows[0]["idNumber"].ToString(); membershipId.Text = customerDetails.Rows[0]["membershipId"].ToString(); if (customerDetails.Rows[0]["registrationType"] != DBNull.Value) { rbKycType.SelectedValue = customerDetails.Rows[0]["registrationType"].ToString(); } cusData.Visible = true; registrationTypeDiv.Visible = true; if ((customerDetails.Rows[0]["createdFrom"].ToString() == "C") || (customerDetails.Rows[0]["createdFrom"].ToString() == "O")) { if (customerDetails.Rows[0]["mobileApprovedDate"].ToString() == "") { btnActivate.Enabled = true; } } else { btnActivate.Enabled = false; } if (customerDetails.Rows[0]["approvedBy"].ToString() != "") { //btnUpdate.Enabled = false; btnReset.Enabled = false; } else if (customerDetails.Rows[0]["customerSource"].ToString() == "temp") { btnReset.Enabled = false; } else { //btnUpdate.Enabled = true; btnReset.Enabled = true; } } private void PopulateCustomerDetails(DataTable customerDetails) { moreData.Visible = true; var str = new StringBuilder(""); var sn = 1; foreach (DataRow dr in customerDetails.Rows) { str.Append(""); str.Append("" + sn + ""); str.Append("" + dr["PARTICULARS"].ToString() + ""); str.Append("" + dr["COMPLETE"].ToString() + ""); str.Append("" + dr["DT"].ToString() + ""); str.Append(""); sn++; } custDetails.InnerHtml = str.ToString(); } private void PopulateKycDetails(DataTable kycDetails) { kycData.Visible = true; var str = new StringBuilder(""); var str1 = new StringBuilder(""); var sn = 1; var r = kycDetails.Rows[0]; str1.Append(""); str1.Append("Plans Selected At" + "" + r["planSelectedDate"].ToString() + ""); str1.Append("Document Submitted At" + "" + r["accepteddate"].ToString() + ""); str1.Append("Accepted At" + "" + r["documentSubmittedDate"].ToString() + ""); str1.Append("Comparision Data At" + "" + r["ekycSubmittedDate"].ToString() + ""); str1.Append(""); Tbody2.InnerHtml = str1.ToString(); foreach (DataRow dr in kycDetails.Rows) { str.Append(""); str.Append("" + sn + ""); str.Append("" + dr["TrustDocId"].ToString() + ""); str.Append("" + dr["verificationType"].ToString() + ""); str.Append("" + dr["state"].ToString() + ""); //str.Append("" + dr["planSelectedDate"].ToString() + ""); //str.Append("" + dr["accepteddate"].ToString() + ""); //str.Append("" + dr["documentSubmittedDate"].ToString() + ""); //str.Append("" + dr["ekycSubmittedDate"].ToString() + ""); str.Append(""); sn++; } tblKycDetail.InnerHtml = str.ToString(); } //protected void update_Click(object sender, EventArgs e) //{ // string customerId = txtSearchData.Value.Split('|')[0]; // string customerSource = txtSearchData.Value.Split('|')[1]; // string kycType = rbKycType.SelectedValue; // var dbResult = _cd.UpdateKycType(customerId, kycType, customerSource, GetStatic.GetUser()); // GetStatic.AlertMessage(this.Page, dbResult.Msg); //} protected void reset_Click(object sender, EventArgs e) { string customerId = txtSearchData.Value.Split('|')[0]; // string customerSource = txtSearchData.Value.Split('|')[1]; var dbResult = _cd.ClearCustomerKYC(customerId, GetStatic.GetUser()); if (dbResult.ErrorCode == "1") { GetStatic.AlertMessage(this.Page, dbResult.Msg); } else { GetStatic.AlertMessage(this.Page, "Customer KYC has been successfully cleared."); } } protected void activate_Click(object sender, EventArgs e) { string customerId = txtSearchData.Value.Split('|')[0]; var custompass = PasswordGenerator.GenerateRandomNumericPassword(); var membershipId = Request.Form["membershipId"]; var dbRes = _cd.ActivateMobileLogin(GetStatic.GetUser(), customerId, custompass, membershipId); if (dbRes.ErrorCode == "0") { DataRow result = _cd.GetDetailsWithPinNo(customerId, GetStatic.GetUser()); //CustomerDetails cd = _cd.GetUserDetails(selecteduserId); var email = result["userName"].ToString(); List bodyMappings = new List(); bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = result["FullName"].ToString() }); bodyMappings.Add(new Mapping() { SValue = "CustomerId", SText = customerId }); bodyMappings.Add(new Mapping() { SValue = "Address", SText = result["Address1"].ToString() }); bodyMappings.Add(new Mapping() { SValue = "EMAIL_ID", SText = email }); bodyMappings.Add(new Mapping() { SValue = "PASS_WORD", SText = result["Password"].ToString() }); bodyMappings.Add(new Mapping() { SValue = "PIN_NO", SText = result["PinNo"].ToString() }); SendNotificationRequestMobile request = new SendNotificationRequestMobile() { IsBulkNotification = false, UserName = email, ProcessId = Guid.NewGuid().ToString(), ProviderId = NotifyTemplate.PIN_PASSWORD_EMAIL.ToString(), NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(), Template = NotifyTemplate.PIN_PASSWORD_EMAIL, Recipients = new List() { new RecipientViewModel() { NotificationContent = new NotificationDTO() { Body = JsonConvert.SerializeObject(bodyMappings), //Title will be set by mapping json }, Address= email } } }; var res = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL); txtSearchData.Text = ""; cusData.Visible = false; registrationTypeDiv.Visible = false; GetStatic.AlertMessage(this, dbRes.Msg); } else { GetStatic.AlertMessage(this, dbRes.Msg); } } } }