using Swift.DAL.OnlineAgent; using Swift.web.Component.Grid; using Swift.web.Component.Grid.gridHelper; using Swift.web.Library; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; using System.Web.Helpers; using System.Web.UI; using System.Web.UI.WebControls; namespace Swift.web.Remit.EnableDisableCustomer { public partial class List : System.Web.UI.Page { //private readonly ReceiverInformationDAO _receiver = new ReceiverInformationDAO(); private const string GridName = "grid_Beneficiarylist"; private const string ViewFunctionId = "20370000"; private const string EnableDisableFunctionId = "20370010"; 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(); if (!IsPostBack) { antiForgery.InnerHtml = AntiForgery.GetHtml().ToString(); HideSearchDiv(); PopulateDDL(); GetStatic.PrintMessage(Page); } if (getCustomerId() != "") { LoadGrid(); } } private void HideSearchDiv() { string hide = GetStatic.ReadQueryString("hideSearchDiv", "").ToString(); if (hide == "true") { displayOnlyOnEdit.Visible = false; hideSearchDiv.Value = "true"; } } private void Authenticate() { swiftLibrary.CheckAuthentication(ViewFunctionId); } private void LoadGrid() { if (IsPostBack) { AntiForgery.Validate(); } string customerId = getCustomerId(); hideCustomerId.Value = customerId; var result = _cd.GetCustomerDetails(customerId, GetStatic.GetUser()); if (result != null) { txtMembershipId.InnerText = result["membershipId"].ToString(); customerName.InnerText = result["firstName"].ToString() + ' ' + result["middleName"].ToString() + ' ' + result["lastName1"].ToString(); } _grid.FilterList = new List { }; _grid.ColumnList = new List { new GridColumn("SN", "SN", "", "T"), new GridColumn("FullName", "Name", "", "T"), new GridColumn("address", "Address", "", "T"), new GridColumn("dob", "DOB", "", "D"), new GridColumn("nativeCountry", "Country", "", "T"), new GridColumn("mobile", "Mobile", "", "T"), new GridColumn("idtype", "Id Type", "", "T"), new GridColumn("idNumber","Id Number","","T"), new GridColumn("createdFrom","CreatedFrom","","T"), new GridColumn("status","Status","","T"), }; _grid.GridType = 1; _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB; _grid.GridName = GridName; _grid.ShowPagingBar = true; _grid.AllowEdit = false; _grid.AlwaysShowFilterForm = true; _grid.ShowFilterForm = true; _grid.SortOrder = "ASC"; _grid.RowIdField = "customerId"; _grid.ThisPage = "List.aspx"; _grid.InputPerRow = 4; _grid.GridMinWidth = 700; _grid.GridWidth = 100; _grid.IsGridWidthInPercent = true; _grid.AllowCustomLink = true; var editLink = swiftLibrary.HasRight(EnableDisableFunctionId) ? "Enable/Disable" : ""; _grid.CustomLinkText = editLink; _grid.CustomLinkVariables = "customerId,fullName,isActive"; string sql = "EXEC [proc_online_core_customerSetup] @flag = 'customerdetailForEnableDisable',@customerId=" + customerId + " "; _grid.SetComma(); rpt_grid.InnerHtml = _grid.CreateGrid(sql); } private void PopulateDDL() { swiftLibrary.SetDDL(ref ddlSearchBy, "exec proc_sendPageLoadData @flag='search-cust-by'", "VALUE", "TEXT", "", ""); } public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin) { return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent; } private string getCustomerId() { var qCustomerId = GetStatic.ReadQueryString("customerId", ""); if (hideCustomerId.Value != "") { qCustomerId = hideCustomerId.Value; } else { hideCustomerId.Value = qCustomerId; } if (qCustomerId != "") { string custoInfo = qCustomerId + "," + GetCustomerName(qCustomerId); GetStatic.CallBackJs1(Page, "Populate Autocomplete", "PopulateAutocomplete('" + custoInfo + "')"); } return hideCustomerId.Value; } protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e) { LoadGrid(); } protected string GetCustomerName(string custId) { OnlineCustomerDao _cd1 = new OnlineCustomerDao(); DataRow res = _cd1.GetCustomerDetails(custId, GetStatic.GetUser()); if (res != null) { string fullName = res["fullName"].ToString(); return fullName; } else { return ""; } } protected void btnUpdate_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(isActive.Value)) { var dbResult = _cd.EnableDisable(getCustomerId(), GetStatic.GetUser(), isActive.Value); GetStatic.SetMessage(dbResult); Response.Redirect("List.aspx"); } } } }