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.

176 lines
6.5 KiB

  1. using Swift.DAL.OnlineAgent;
  2. using Swift.web.Component.Grid;
  3. using Swift.web.Component.Grid.gridHelper;
  4. using Swift.web.Library;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.Helpers;
  11. using System.Web.UI;
  12. using System.Web.UI.WebControls;
  13. namespace Swift.web.Remit.EnableDisableCustomer
  14. {
  15. public partial class List : System.Web.UI.Page
  16. {
  17. //private readonly ReceiverInformationDAO _receiver = new ReceiverInformationDAO();
  18. private const string GridName = "grid_Beneficiarylist";
  19. private const string ViewFunctionId = "20370000";
  20. private const string EnableDisableFunctionId = "20370010";
  21. private readonly SwiftGrid _grid = new SwiftGrid();
  22. private readonly RemittanceLibrary swiftLibrary = new RemittanceLibrary();
  23. private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. Authenticate();
  27. if (!IsPostBack)
  28. {
  29. antiForgery.InnerHtml = AntiForgery.GetHtml().ToString();
  30. HideSearchDiv();
  31. PopulateDDL();
  32. GetStatic.PrintMessage(Page);
  33. }
  34. if (getCustomerId() != "")
  35. {
  36. LoadGrid();
  37. }
  38. }
  39. private void HideSearchDiv()
  40. {
  41. string hide = GetStatic.ReadQueryString("hideSearchDiv", "").ToString();
  42. if (hide == "true")
  43. {
  44. displayOnlyOnEdit.Visible = false;
  45. hideSearchDiv.Value = "true";
  46. }
  47. }
  48. private void Authenticate()
  49. {
  50. swiftLibrary.CheckAuthentication(ViewFunctionId);
  51. }
  52. private void LoadGrid()
  53. {
  54. if (IsPostBack)
  55. {
  56. AntiForgery.Validate();
  57. }
  58. string customerId = getCustomerId();
  59. hideCustomerId.Value = customerId;
  60. var result = _cd.GetCustomerDetails(customerId, GetStatic.GetUser());
  61. if (result != null)
  62. {
  63. txtMembershipId.InnerText = result["membershipId"].ToString();
  64. customerName.InnerText = result["firstName"].ToString() + ' ' + result["middleName"].ToString() + ' ' + result["lastName1"].ToString();
  65. }
  66. _grid.FilterList = new List<GridFilter>
  67. {
  68. };
  69. _grid.ColumnList = new List<GridColumn>
  70. {
  71. new GridColumn("SN", "SN", "", "T"),
  72. new GridColumn("FullName", "Name", "", "T"),
  73. new GridColumn("address", "Address", "", "T"),
  74. new GridColumn("dob", "DOB", "", "D"),
  75. new GridColumn("nativeCountry", "Country", "", "T"),
  76. new GridColumn("mobile", "Mobile", "", "T"),
  77. new GridColumn("idtype", "Id Type", "", "T"),
  78. new GridColumn("idNumber","Id Number","","T"),
  79. new GridColumn("createdFrom","CreatedFrom","","T"),
  80. new GridColumn("status","Status","","T"),
  81. };
  82. _grid.GridType = 1;
  83. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  84. _grid.GridName = GridName;
  85. _grid.ShowPagingBar = true;
  86. _grid.AllowEdit = false;
  87. _grid.AlwaysShowFilterForm = true;
  88. _grid.ShowFilterForm = true;
  89. _grid.SortOrder = "ASC";
  90. _grid.RowIdField = "customerId";
  91. _grid.ThisPage = "List.aspx";
  92. _grid.InputPerRow = 4;
  93. _grid.GridMinWidth = 700;
  94. _grid.GridWidth = 100;
  95. _grid.IsGridWidthInPercent = true;
  96. _grid.AllowCustomLink = true;
  97. var editLink = swiftLibrary.HasRight(EnableDisableFunctionId) ? "<a href=\"javascript:void(0);\" onclick=\"EnableDisable('@customerId','@fullName','@isActive');\" class=\"btn btn-xs btn-primary\">Enable/Disable</a>" : "";
  98. _grid.CustomLinkText = editLink;
  99. _grid.CustomLinkVariables = "customerId,fullName,isActive";
  100. string sql = "EXEC [proc_online_core_customerSetup] @flag = 'customerdetailForEnableDisable',@customerId=" + customerId + " ";
  101. _grid.SetComma();
  102. rpt_grid.InnerHtml = _grid.CreateGrid(sql);
  103. }
  104. private void PopulateDDL()
  105. {
  106. swiftLibrary.SetDDL(ref ddlSearchBy, "exec proc_sendPageLoadData @flag='search-cust-by'", "VALUE", "TEXT", "", "");
  107. }
  108. public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
  109. {
  110. return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
  111. }
  112. private string getCustomerId()
  113. {
  114. var qCustomerId = GetStatic.ReadQueryString("customerId", "");
  115. if (hideCustomerId.Value != "")
  116. {
  117. qCustomerId = hideCustomerId.Value;
  118. }
  119. else
  120. {
  121. hideCustomerId.Value = qCustomerId;
  122. }
  123. if (qCustomerId != "")
  124. {
  125. string custoInfo = qCustomerId + "," + GetCustomerName(qCustomerId);
  126. GetStatic.CallBackJs1(Page, "Populate Autocomplete", "PopulateAutocomplete('" + custoInfo + "')");
  127. }
  128. return hideCustomerId.Value;
  129. }
  130. protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e)
  131. {
  132. LoadGrid();
  133. }
  134. protected string GetCustomerName(string custId)
  135. {
  136. OnlineCustomerDao _cd1 = new OnlineCustomerDao();
  137. DataRow res = _cd1.GetCustomerDetails(custId, GetStatic.GetUser());
  138. if (res != null)
  139. {
  140. string fullName = res["fullName"].ToString();
  141. return fullName;
  142. }
  143. else
  144. {
  145. return "";
  146. }
  147. }
  148. protected void btnUpdate_Click(object sender, EventArgs e)
  149. {
  150. if (!string.IsNullOrEmpty(isActive.Value))
  151. {
  152. var dbResult = _cd.EnableDisable(getCustomerId(), GetStatic.GetUser(), isActive.Value);
  153. GetStatic.SetMessage(dbResult);
  154. Response.Redirect("List.aspx");
  155. }
  156. }
  157. }
  158. }