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.

208 lines
6.8 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using Swift.DAL.BL.Remit.DomesticOperation.CommissionSetup;
  4. using Swift.DAL.SwiftDAL;
  5. using Swift.web.Component.Grid;
  6. using Swift.web.Component.Grid.gridHelper;
  7. using Swift.web.Library;
  8. namespace Swift.web.Remit.DomesticOperation.CommissionGroupMapping
  9. {
  10. public partial class RuleAdd : System.Web.UI.Page
  11. {
  12. private string GridName = "";
  13. private const string ViewFunctionId = "20131400";
  14. private readonly SwiftGrid grid = new SwiftGrid();
  15. private readonly RemittanceLibrary swiftLibrary = new RemittanceLibrary();
  16. private CommGroupMappingDao _commGrp = new CommGroupMappingDao();
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. Authenticate();
  20. if (!IsPostBack)
  21. {
  22. GetStatic.PrintMessage(Page);
  23. }
  24. SetGrid(GetFlag());
  25. }
  26. private void SetGrid(string flag)
  27. {
  28. if (flag == "sc")
  29. {
  30. GridName = "grid_scAdd";
  31. }
  32. if (flag == "cp")
  33. {
  34. GridName = "grid_cpAdd";
  35. }
  36. if (flag == "cs")
  37. {
  38. GridName = "grid_csAdd";
  39. }
  40. if (flag == "ds")
  41. {
  42. GridName = "grid_dsAdd";
  43. }
  44. LoadGrid(flag);
  45. }
  46. private string GetRowIdField(string flag)
  47. {
  48. string rowId = null;
  49. if (flag == "sc")
  50. {
  51. rowId = "sscMasterId";
  52. }
  53. if (flag == "cp")
  54. {
  55. rowId = "scPayMasterId";
  56. }
  57. if (flag == "cs")
  58. {
  59. rowId = "scSendMasterId";
  60. }
  61. if (flag == "ds")
  62. {
  63. rowId = "scMasterId";
  64. }
  65. return rowId;
  66. }
  67. private void Authenticate()
  68. {
  69. swiftLibrary.CheckAuthentication(ViewFunctionId);
  70. }
  71. private string GetFlag()
  72. {
  73. return GetStatic.ReadQueryString("flag", "ds");
  74. }
  75. private string GetPackageId()
  76. {
  77. return GetStatic.ReadQueryString("packageId", "");
  78. }
  79. private string GetType()
  80. {
  81. return GetStatic.ReadQueryString("type", "");
  82. }
  83. ////private void LoadSCGrid(string flag)
  84. ////{
  85. //// grid.FilterList = new List<GridFilter>
  86. //// {
  87. //// new GridFilter("Code", "Code", "LT")
  88. //// };
  89. //// grid.ColumnList = new List<GridColumn>
  90. //// {
  91. //// new GridColumn("Code", "Code", "", "T"),
  92. //// new GridColumn("description", "Description", "", "T")
  93. //// };
  94. //// grid.GridType = 1;
  95. //// grid.GridName = GridName;
  96. //// grid.ShowAddButton = false;
  97. //// grid.ShowFilterForm = true;
  98. //// grid.AlwaysShowFilterForm = false;
  99. //// grid.MultiSelect = true;
  100. //// grid.ShowPagingBar = true;
  101. //// grid.RowIdField = "sscMasterId";
  102. //// grid.ThisPage = "RuleAdd.aspx";
  103. //// grid.AllowEdit = false;
  104. //// grid.GridWidth = 800;
  105. //// string sql = "[proc_commissionRuleAdd] @flag =" + grid.FilterString(flag);
  106. //// grid.SetComma();
  107. //// rpt_grid.InnerHtml = grid.CreateGrid(sql);
  108. ////}
  109. ////private void LoadCPGrid(string flag)
  110. ////{
  111. //// grid.FilterList = new List<GridFilter>
  112. //// {
  113. //// new GridFilter("Code", "Code", "LT")
  114. //// };
  115. //// grid.ColumnList = new List<GridColumn>
  116. //// {
  117. //// new GridColumn("Code", "Code", "", "T"),
  118. //// new GridColumn("description", "Description", "", "T")
  119. //// };
  120. //// grid.GridType = 1;
  121. //// grid.GridName = GridName;
  122. //// grid.ShowAddButton = false;
  123. //// grid.ShowFilterForm = true;
  124. //// grid.AlwaysShowFilterForm = false;
  125. //// grid.MultiSelect = true;
  126. //// grid.ShowPagingBar = true;
  127. //// grid.RowIdField = "scPayMasterId";
  128. //// grid.ThisPage = "RuleAdd.aspx";
  129. //// grid.AllowEdit = false;
  130. //// grid.GridWidth = 800;
  131. //// string sql = "[proc_commissionRuleAdd] @flag =" + grid.FilterString(flag);
  132. //// grid.SetComma();
  133. //// rpt_grid.InnerHtml = grid.CreateGrid(sql);
  134. ////}
  135. private void LoadGrid(string flag)
  136. {
  137. grid.FilterList = new List<GridFilter>
  138. {
  139. new GridFilter("Code", "Code", "LT")
  140. };
  141. grid.ColumnList = new List<GridColumn>
  142. {
  143. new GridColumn("Code", "Code", "", "T"),
  144. new GridColumn("description", "Description", "", "T")
  145. };
  146. grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  147. grid.GridType = 1;
  148. grid.GridName = GridName;
  149. grid.ShowAddButton = false;
  150. grid.ShowFilterForm = true;
  151. grid.AlwaysShowFilterForm = false;
  152. grid.MultiSelect = true;
  153. grid.ShowCheckBox = true;
  154. grid.ShowPagingBar = true;
  155. grid.RowIdField = GetRowIdField(flag);
  156. grid.ThisPage = "RuleAdd.aspx";
  157. grid.AllowEdit = false;
  158. grid.GridWidth = 800;
  159. string sql = "[proc_commissionRuleAdd] @flag =" + grid.FilterString(flag) + ",@packageId=" + GetPackageId();
  160. grid.SetComma();
  161. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  162. }
  163. protected void btnAdd_Click(object sender, EventArgs e)
  164. {
  165. string rsList = grid.GetRowId(GridName);
  166. DbResult dbResult = _commGrp.AddCommissionRule(GetStatic.GetUser(), GetPackageId().ToString(), rsList, GetFlag());
  167. ManageMessage(dbResult);
  168. }
  169. private void ManageMessage(DbResult dbResult)
  170. {
  171. GetStatic.SetMessage(dbResult);
  172. if (dbResult.ErrorCode == "0")
  173. {
  174. Response.Redirect("CommissionPackage.aspx?packageId=" + GetPackageId() + "&type=" + GetType());
  175. }
  176. else
  177. {
  178. GetStatic.PrintMessage(Page);
  179. //GetStatic.AlertMessageBox(Page);
  180. }
  181. }
  182. }
  183. }