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.

141 lines
3.9 KiB

  1. using Swift.DAL.BL.Remit.CreditRiskManagement.BalanceTopUp;
  2. using Swift.DAL.Remittance.CashAndVault;
  3. using Swift.DAL.SwiftDAL;
  4. using Swift.web.Component.Grid;
  5. using Swift.web.Component.Grid.gridHelper;
  6. using Swift.web.Library;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Web;
  12. using System.Web.UI;
  13. using System.Web.UI.WebControls;
  14. namespace Swift.web.Remit.CashAndVault.CashHoldLimitTopUp
  15. {
  16. public partial class Approve : System.Web.UI.Page
  17. {
  18. private const string GridName = "approveCashHoldLimitTopUp";
  19. private const string ViewFunctionId = "2020000";
  20. private const string ApproveFunctionId = "2020010";
  21. private readonly SwiftGrid grid = new SwiftGrid();
  22. private readonly CashHoldLimitTopUpDao obj = new CashHoldLimitTopUpDao();
  23. private readonly RemittanceLibrary sl = new RemittanceLibrary();
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. if (!IsPostBack)
  27. {
  28. Authenticate();
  29. GetStatic.PrintMessage(Page);
  30. }
  31. LoadGrid();
  32. }
  33. #region method
  34. protected string GetAgentName()
  35. {
  36. return "Agent Name : " + sl.GetAgentName(GetAgentId().ToString());
  37. }
  38. protected long GetAgentId()
  39. {
  40. return GetStatic.ReadNumericDataFromQueryString("agentId");
  41. }
  42. private void LoadGrid()
  43. {
  44. grid.FilterList = new List<GridFilter>
  45. {
  46. new GridFilter("agentName", "Agent Name", "LT")
  47. };
  48. grid.ColumnList = new List<GridColumn>
  49. {
  50. new GridColumn("agentName", "Agent", "", "T"),
  51. new GridColumn("amount", "Top Up Amount", "", "M"),
  52. new GridColumn("createdBy", "Requested By", "", "T"),
  53. new GridColumn("createdDate", "Requested Date", "", "T"),
  54. };
  55. grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  56. grid.GridType = 1;
  57. grid.GridName = GridName;
  58. grid.AlwaysShowFilterForm = true;
  59. grid.ShowFilterForm = true;
  60. grid.EnableFilterCookie = false;
  61. grid.ShowPagingBar = true;
  62. grid.SortBy = "agentName";
  63. grid.RowIdField = "btId";
  64. grid.InputPerRow = 4;
  65. grid.AllowCustomLink = sl.HasRight(ApproveFunctionId);
  66. var customLinkText = new StringBuilder();
  67. customLinkText.Append("<input type=\"button\" class='btn btn-primary m-t-25' onclick = \"Approve(@btId)\" value=\"Approve\"/>&nbsp;");
  68. customLinkText.Append("<input type=\"button\" class='btn btn-primary m-t-25' onclick=\"Reject(@btId);\" value=\"Reject\"/>");
  69. grid.CustomLinkText = customLinkText.ToString();
  70. grid.CustomLinkVariables = "btId";
  71. string sql = "[Proc_CashHoldLimitTopUp] @flag = 'al'";
  72. grid.SetComma();
  73. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  74. }
  75. //private void DeleteRow()
  76. //{
  77. // string id = grid.GetCurrentRowId(GridName);
  78. // if (string.IsNullOrEmpty(id))
  79. // return;
  80. // DbResult dbResult = obj.Delete(GetStatic.GetUser(), id);
  81. // PrintMessage(dbResult);
  82. //}
  83. private void PrintMessage(DbResult dbResult)
  84. {
  85. string data = GetStatic.ParseResultJsPrint(dbResult);
  86. string function = "printMessage('" + data + "')";
  87. GetStatic.CallBackJs1(this, "print", function);
  88. }
  89. private void Authenticate()
  90. {
  91. sl.CheckAuthentication(ViewFunctionId);
  92. }
  93. #endregion
  94. private void ManageMessage(DbResult dbResult)
  95. {
  96. GetStatic.SetMessage(dbResult);
  97. if (dbResult.ErrorCode != "0")
  98. {
  99. GetStatic.PrintMessage(Page);
  100. }
  101. else
  102. {
  103. Response.Redirect("Approve.aspx");
  104. }
  105. }
  106. protected void btnCallBack_Click(object sender, EventArgs e)
  107. {
  108. LoadGrid();
  109. }
  110. protected void btnApprove_Click(object sender, EventArgs e)
  111. {
  112. if (string.IsNullOrEmpty(hdnId.Value))
  113. return;
  114. var dbResult = obj.Approve(GetStatic.GetUser(), hdnId.Value);
  115. ManageMessage(dbResult);
  116. }
  117. protected void btnReject_Click(object sender, EventArgs e)
  118. {
  119. if (string.IsNullOrEmpty(hdnId.Value))
  120. return;
  121. var dbResult = obj.Reject(GetStatic.GetUser(), hdnId.Value);
  122. ManageMessage(dbResult);
  123. }
  124. }
  125. }