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
5.7 KiB

  1. using Swift.DAL.Remittance.CashAndVault;
  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. namespace Swift.web.Remit.CashAndVault
  8. {
  9. public partial class ManageUserWiseLimit : System.Web.UI.Page
  10. {
  11. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  12. protected const string GridName = "cashAndVault";
  13. private string ViewFunctionId = "20178000";
  14. private const string AddFunctionId = "20178030";
  15. private const string EditFunctionId = "20178010";
  16. private const string ApproveFunctionId = "20178050";
  17. private const string ActiveInActiveFunctionId = "20178040";
  18. //private const string AddFunctionId = "20111310";
  19. //private const string EditFunctionId = "20111320";
  20. //private const string ApproveFunctionId = "20178040";
  21. private readonly SwiftGrid _grid = new SwiftGrid();
  22. private CashAndVaultDao cavDao = new CashAndVaultDao();
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. Authenticate();
  26. if (!IsPostBack)
  27. {
  28. GetStatic.PrintMessage(Page);
  29. H4.InnerText = "Assign Limit Userwise: " + GetSelectedAgentName();
  30. }
  31. LoadGrid();
  32. }
  33. private void Authenticate()
  34. {
  35. _sl.CheckAuthentication(ViewFunctionId);
  36. }
  37. private void LoadGrid()
  38. {
  39. _grid.FilterList = new List<GridFilter>
  40. {
  41. };
  42. _grid.ColumnList = new List<GridColumn>
  43. {
  44. new GridColumn("SN", "SN", "", "T"),
  45. new GridColumn("UserName", "Username", "", "T"),
  46. new GridColumn("IS_ACTIVE", "Is Active", "", "T"),
  47. new GridColumn("RULE_TYPE", "Rule Type", "", "T"),
  48. new GridColumn("cashHoldLimit", "Cash Hold Limit", "", "M"),
  49. };
  50. _grid.GridType = 1;
  51. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  52. _grid.GridName = GridName;
  53. _grid.AllowApprove = true;
  54. _grid.ShowPagingBar = false;
  55. _grid.ShowAddButton = _sl.HasRight(AddFunctionId);
  56. _grid.AllowEdit = _sl.HasRight(EditFunctionId);
  57. _grid.AlwaysShowFilterForm = false;
  58. _grid.AllowApprove = _sl.HasRight(ApproveFunctionId);
  59. _grid.ApproveFunctionId = ApproveFunctionId;
  60. _grid.ShowFilterForm = false;
  61. _grid.SortOrder = "ASC";
  62. _grid.RowIdField = "cashHoldLimitId";
  63. _grid.ThisPage = "UserWiseLimitList.aspx";
  64. _grid.InputPerRow = 4;
  65. _grid.GridMinWidth = 700;
  66. _grid.GridWidth = 100;
  67. _grid.IsGridWidthInPercent = true;
  68. _grid.AllowEdit = false;
  69. _grid.AddPage = "ManageUserWiseLimit.aspx";
  70. _grid.CustomLinkVariables = "cashHoldLimitId";
  71. var userWiseLink = "<span class=\"action-icon\"> <btn class=\"btn btn-xs btn-default\" data-toggle=\"tooltip\" data-placement=\"top\" title = \"Assign Limit User Wise\"> <a href =\"ManageUserWiseLimit.aspx?cashHoldLimitId=" + GetBranchRuleId() + "&cashHoldLimitUserId=@cashHoldLimitId&agentId=" + GetAgentId() + "&userId=@userId&selectedUserName=@UserName\"><i class=\"fa fa-pencil\"></i></a></btn></span>";
  72. _grid.CustomLinkText = userWiseLink;
  73. _grid.AllowCustomLink = true;
  74. _grid.CustomLinkVariables = "cashHoldLimitId,userId,UserName";
  75. string sql = "EXEC PROC_CASHANDVAULT_USERWISE @flag = 'getBranchUser',@agentId='" + GetAgentId() + "',@cashHoldLimitBranchId='" + GetBranchRuleId() + "'";
  76. _grid.SetComma();
  77. rpt_grid.InnerHtml = _grid.CreateGrid(sql);
  78. }
  79. protected string GetBranchRuleId()
  80. {
  81. string id = GetStatic.ReadQueryString("cashHoldLimitId", "");
  82. if (!string.IsNullOrEmpty(id))
  83. {
  84. return id;
  85. }
  86. else
  87. {
  88. var res = cavDao.InsertBranchRuleId(GetStatic.GetUser(), GetAgentId());
  89. return res.Id;
  90. }
  91. }
  92. protected string GetAgentId()
  93. {
  94. return GetStatic.ReadQueryString("agentId", "");
  95. }
  96. protected string GetSelectedAgentName()
  97. {
  98. return GetStatic.ReadQueryString("selectedAgentName", "");
  99. }
  100. protected void btnUpdate_Click(object sender, EventArgs e)
  101. {
  102. var status = hddisActive.Value.ToString();
  103. var cashholdLimitIdVal = hddcashHoldLimitId.Value.ToString();
  104. var res = cavDao.UpdateActiveInActiveStatus(GetStatic.GetUser(), status, cashholdLimitIdVal, "U");
  105. if (res.ErrorCode == "0")
  106. {
  107. GetStatic.AlertMessage(this.Page, res.Msg);
  108. Response.Redirect("UserWiseLimitList.aspx?cashHoldLimitId=" + GetCashHoldLimitId() + "&agentId=" + GetAgentId() + "&selectedAgentName=" + GetselectedAgentName());
  109. }
  110. else
  111. {
  112. GetStatic.AlertMessage(this.Page, res.Msg);
  113. }
  114. }
  115. private string GetCashHoldLimitId()
  116. {
  117. return GetStatic.ReadQueryString("cashHoldLimitId", "");
  118. }
  119. private string GetagentId()
  120. {
  121. return GetStatic.ReadQueryString("agentId", "");
  122. }
  123. private string GetselectedAgentName()
  124. {
  125. return GetStatic.ReadQueryString("selectedAgentName", "");
  126. }
  127. }
  128. }