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.

134 lines
5.6 KiB

  1. using Swift.DAL.Remittance.ReferralSetup;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Component.Grid;
  4. using Swift.web.Component.Grid.gridHelper;
  5. using Swift.web.Library;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. namespace Swift.web.Remit.ReferralSetup
  13. {
  14. public partial class CommissionRuleList : System.Web.UI.Page
  15. {
  16. private const string GridName = "referralGrid_list";
  17. private string ViewFunctionId = "20201700";
  18. private string AddEditFunctionId = "20201710";
  19. private string DeleteFunctionId = "20201720";
  20. private readonly SwiftGrid _grid = new SwiftGrid();
  21. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  22. private readonly ReferralSetupDao _refDao = new ReferralSetupDao();
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. Authenticate();
  26. GetStatic.PrintMessage(this.Page);
  27. if (!IsPostBack)
  28. {
  29. GetStatic.PrintMessage(Page);
  30. }
  31. DeleteRow();
  32. LoadGrid();
  33. string reqMethod = Request.Form["MethodName"];
  34. if (reqMethod == "GetSetupList")
  35. {
  36. GetSetupList();
  37. }
  38. else if (reqMethod == "FinalSaveData")
  39. {
  40. FinalSaveData();
  41. }
  42. }
  43. private void FinalSaveData()
  44. {
  45. string isFirstTranFree = Request.Form["IsFirstTranFree"];
  46. string isOtherTranFree = Request.Form["IsOtherTranFree"];
  47. string otherTranCount = Request.Form["OtherTranCount"];
  48. DbResult dbResult = _refDao.FinalSaveData(GetStatic.GetUser(), GetReferralCode(), isFirstTranFree, isOtherTranFree, otherTranCount);
  49. GetStatic.JsonResponse(dbResult, this.Page);
  50. }
  51. private void GetSetupList()
  52. {
  53. DbResult dbResult = _refDao.GetSetupList(GetStatic.GetUser(), GetReferralCode());
  54. GetStatic.JsonResponse(dbResult, this.Page);
  55. }
  56. private void Authenticate()
  57. {
  58. _sl.CheckAuthentication(ViewFunctionId);
  59. }
  60. private void LoadGrid()
  61. {
  62. _grid.FilterList = new List<GridFilter>
  63. {
  64. //new GridFilter("branchId", "Branch", "1: EXEC PROC_REFERALSETUP @flag = 'branchNameForFilter'"),
  65. //new GridFilter("referralTypeCode", "Referral Type", "1: EXEC PROC_REFERALSETUP @flag = 'referalType'"),
  66. //new GridFilter("referralName", "Referral Name", "T"),
  67. //new GridFilter("referralCode", "Referral code", "T")
  68. };
  69. _grid.ColumnList = new List<GridColumn>
  70. {
  71. new GridColumn("REFERRAL_NAME", "Referral Name", "100", "T"),
  72. new GridColumn("agentName", "Branch Name", "100", "T"),
  73. new GridColumn("COMM_PCNT", "Registration Point", "100", "M"),
  74. //ew GridColumn("FX_PCNT", "Forex Income/Loss Percent", "", "M"),
  75. //new GridColumn("APPLY_FX_PERCENT_ON", "Apply FX % on", "", "T"),
  76. new GridColumn("FLAT_TXN_WISE", "Transaction Point", "", "M"),
  77. //new GridColumn("NEW_CUSTOMER", "New Customer", "", "M"),
  78. // new GridColumn("DEDUCT_P_COMM_ON_SC", "Deduct PComm On SC", "", "T"),
  79. // new GridColumn("DEDUCT_TAX_ON_SC", "Deduct Tax On SC", "", "T"),
  80. new GridColumn("EFFECTIVE_FROM", "Effective From", "", "D"),
  81. new GridColumn("IS_ACTIVE", "Is Active", "", "T"),
  82. };
  83. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  84. _grid.GridType = 1;
  85. _grid.GridName = GridName;
  86. _grid.ShowPagingBar = true;
  87. _grid.ShowAddButton = true;
  88. _grid.AllowEdit = false;
  89. _grid.AllowDelete = false;
  90. _grid.AddPage = "CommisionRuleSetup.aspx?referralCode=" + GetReferralCode();
  91. _grid.AllowDelete = false;
  92. _grid.AlwaysShowFilterForm = false;
  93. _grid.ShowFilterForm = false;
  94. _grid.AllowCustomLink = true;
  95. _grid.SortOrder = "ASC";
  96. _grid.RowIdField = "referral_id";
  97. _grid.ThisPage = "CommmissionRuleList.aspx";
  98. _grid.InputPerRow = 5;
  99. string sql = "EXEC [PROC_REFERALSETUP] @flag = 'S-commList',@referral_code = " + GetReferralCode() + "";
  100. var link = "&nbsp;<a title=\"Edit\" onclick=\"CommissionRuleSetup('@referral_id','@REFERRAL_CODE','@AGENTID', '@ROW_ID')\" class=\"btn btn-xs btn-primary\"><i class=\"fa fa-edit\"></i></a>";
  101. _grid.CustomLinkText = link;
  102. _grid.CustomLinkVariables = "referral_id,REFERRAL_CODE,AGENTID,ROW_ID";
  103. _grid.SetComma();
  104. rpt_grid.InnerHtml = _grid.CreateGrid(sql);
  105. }
  106. private void DeleteRow()
  107. {
  108. string rowId = _grid.GetCurrentRowId(GridName);
  109. if (rowId == "")
  110. return;
  111. var user = GetStatic.GetUser();
  112. DbResult dbResult = _refDao.Delete(GetStatic.GetUser(), rowId);
  113. GetStatic.SetMessage(dbResult);
  114. Response.Redirect("List.aspx");
  115. }
  116. private string GetReferralCode()
  117. {
  118. return GetStatic.ReadQueryString("referralCode", "");
  119. }
  120. }
  121. }