using Newtonsoft.Json; using Swift.API.Common.TrustDoc; using Swift.API.TPAPIs; using Swift.DAL.OnlineAgent; using Swift.DAL.SwiftDAL; using Swift.web.Component.Grid; using Swift.web.Component.Grid.gridHelper; using Swift.web.Library; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Swift.web.MobileRemit.Admin.Operation { public partial class VerifyMobileCustomer : System.Web.UI.Page { private const string GridName = "grid_list"; private const string ViewFunctionId = "30490000"; private const string ApproveFunctionId = "30490010"; private const string DeleteFunctionId = "30490111"; private const string ReuploadFunctionId = "30490110"; private readonly SwiftGrid _grid = new SwiftGrid(); private readonly RemittanceLibrary swiftLibrary = new RemittanceLibrary(); private readonly OnlineCustomerDao _cd = new OnlineCustomerDao(); protected void Page_Load(object sender, EventArgs e) { Authenticate(); var methodName = Request.Form["MethodName"]; if (!IsPostBack) { if (methodName == "reuploadData") { ClearKYC(); } if (methodName == "deleteCustomer") { DeleteCust(); } GetStatic.PrintMessage(Page); } LoadGrid(); DeleteRow(); } private void Authenticate() { swiftLibrary.CheckAuthentication(ViewFunctionId); } private void LoadGrid() { _grid.FilterList = new List { new GridFilter("searchCriteria", "Search By", "1:" + "EXEC [proc_online_approve_Customer] @flag = 'searchCriteria'"), new GridFilter("searchValue", "Search Value", "T"), new GridFilter("fromDate", "Registered From", "d"), new GridFilter("toDate", "Registered To", "d"), }; _grid.ColumnList = new List { new GridColumn("SN", "SN", "", "T"), new GridColumn("fullName", "Customer Name", "", "T"), new GridColumn("createdDate","Regd. Date","","D"), new GridColumn("membershipId", "Membership ID", "", "T"), new GridColumn("email", "Email", "", "T"), new GridColumn("mobile", "Mobile", "", "T"), new GridColumn("country", "Native Country", "", "T"), new GridColumn("idNumber", "ID No", "", "T"), new GridColumn("verificationCode", "KYC Status", "", "T"), new GridColumn("lawsonCardNo", "Registration Type", "", "T"), }; _grid.GridType = 1; _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB; _grid.GridName = GridName; _grid.CustomLinkColumnHeader = "Action"; _grid.ShowPagingBar = true; _grid.AllowEdit = false; _grid.AllowReject = false; _grid.AlwaysShowFilterForm = true; _grid.ShowFilterForm = true; _grid.SortBy = "createdDate"; _grid.SortOrder = "DESC"; _grid.RowIdField = "customerId"; _grid.ThisPage = "ApproveMobileCustomer.aspx"; ; _grid.InputPerRow = 4; _grid.AllowCustomLink = true; _grid.ShowAddButton = false; _grid.RejectAlertText = "Are you sure you want to reject the selected customer ?"; // _grid.AddPage = "/AgentNew/Transaction/ApproveCustomerFromMobile/Manage.aspx"; _grid.GridMinWidth = 700; _grid.GridWidth = 100; _grid.IsGridWidthInPercent = true; _grid.CustomLinkVariables = "customerId"; var customLinkText = new StringBuilder(); var kycStatus = Request.QueryString["kycStatus"]; if (kycStatus == "NOT_COMPLETED" || kycStatus == "PROCESSING") { customLinkText.Append(" "); } _grid.CustomLinkText = customLinkText.ToString(); string sql = "EXEC [proc_customerKYC] @flag = 'filterByKycStatus',@kycStatus='" + Request.QueryString["kycStatus"] + "' "; _grid.SetComma(); rpt_grid.InnerHtml = _grid.CreateGrid(sql); } private void DeleteRow() { string id = _grid.GetCurrentRowId(GridName); if (id == "") return; var user = GetStatic.GetUser(); DbResult dbResult = _cd.DeleteCustomerFromMobile(id, user); if (dbResult.ErrorCode == "0") { LoadGrid(); GetStatic.AlertMessage(this, dbResult.Msg); } else { HttpContext.Current.Session["message"] = dbResult; GetStatic.AlertMessage(this, dbResult.Msg); } } private void ClearKYC() { var customerId = Request.Form["customerId"]; var user = GetStatic.GetUser(); DbResult dbResult = _cd.ClearCustomerKYC(customerId, user); Response.ContentType = "text/plain"; Response.Write(JsonConvert.SerializeObject(dbResult)); Response.End(); } private void DeleteCust() { var customerId = Request.Form["customerId"]; var user = GetStatic.GetUser(); DbResult dbResult = _cd.deleteCustomer(customerId, user); if (dbResult.ErrorCode == "0" && dbResult.Extra == "EKYC") { DeleteCustomerTrustDoc(dbResult.Id, dbResult.Extra2); } Response.ContentType = "text/plain"; Response.Write(JsonConvert.SerializeObject(dbResult)); Response.End(); } private void DeleteCustomerTrustDoc(string customerId, string trustdocId) { TrustdocAPI trustdocAPI = new TrustdocAPI(); var deleteDoc = trustdocAPI.DeleteTrustDoc(trustdocId, GetStatic.GetUser(), customerId); string response = string.Empty; if (deleteDoc.ResponseCode.ToString() == "0") { UpdateTrustDoc(trustdocId, GetStatic.GetUser()); } else { GetStatic.AlertMessage(this, $"TrustDoc Error: { deleteDoc.Msg}"); } } private void UpdateTrustDoc(string trustdocId, string user) { DbResult dbResult = _cd.updateTrustdoc(trustdocId, user); if (dbResult.ErrorCode != "0") { GetStatic.AlertMessage(this, dbResult.Msg); } } } }