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.

183 lines
7.1 KiB

  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using Swift.DAL.BL.Remit.DomesticOperation.CommissionSetup;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Component.Grid;
  7. using Swift.web.Library;
  8. namespace Swift.web.Remit.DomesticOperation.CommissionGroupMapping
  9. {
  10. public partial class CommissionGroup : System.Web.UI.Page
  11. {
  12. private const string ViewFunctionId = "20131400";
  13. private const string AddEditFunctionId = "20131410";
  14. private const string DeleteFunctionId = "20131420";
  15. protected const string GridName = "grd_CommMappGrp";
  16. private readonly CommGroupMappingDao _commGrpMap = new CommGroupMappingDao();
  17. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20. Authenticate();
  21. if (!IsPostBack)
  22. {
  23. GetStatic.PrintMessage(Page);
  24. PopulateDdl();
  25. if (GetGroupId() != "0")
  26. {
  27. LoadGrids();
  28. }
  29. }
  30. }
  31. private string GetGroupId()
  32. {
  33. return GetStatic.ReadQueryString("groupId", "0");
  34. }
  35. private void PopulateDdl()
  36. {
  37. _sdd.SetStaticDdl(ref group, "6600", GetGroupId(), "Select");
  38. }
  39. private void Authenticate()
  40. {
  41. _sdd.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId + "," + DeleteFunctionId);
  42. }
  43. private void LoadGrids()
  44. {
  45. var ds = _commGrpMap.PackageDisplay(GetStatic.GetUser(), group.Text);
  46. if (ds.Tables.Count > 0)
  47. {
  48. var dt = ds.Tables[0];
  49. LoadDomesticPackage(dt);
  50. }
  51. if (ds.Tables.Count > 1)
  52. {
  53. var dt = ds.Tables[1];
  54. LoadInternationalPackage(dt);
  55. }
  56. }
  57. private void LoadDomesticPackage(DataTable dt)
  58. {
  59. domestic.Visible = true;
  60. int cols = dt.Columns.Count;
  61. var str = new StringBuilder("<table width=\"100%\" border=\"0\" class=\"gridTable\" cellpadding=\"5\" cellspacing=\"0\" align=\"center\">");
  62. str.Append("<tr><td colspan=\"" + cols + "\"><div align=\"right\"><a href=\"PackageAdd.aspx?type=D&groupId=" + group.Text + "\"><img src=\"../../../images/add.gif\"/></a></div></td></tr>");
  63. str.Append("<tr class='hdtitle'>");
  64. for (int i = 3; i < cols; i++)
  65. {
  66. str.Append("<th class=\"headingTH\"><div align=\"left\">" + dt.Columns[i].ColumnName + "</div></th>");
  67. }
  68. str.Append("<th align=\"left\"></th>");
  69. str.Append("</tr>");
  70. var j = 0;
  71. foreach (DataRow dr in dt.Rows)
  72. {
  73. str.Append(++j % 2 == 1 ? "<tr class=\"oddbg\">" : "<tr class=\"evenbg\">");
  74. for (int i = 3; i < cols; i++)
  75. {
  76. str.Append("<td align=\"left\">" + dr[i].ToString() + "</td>");
  77. }
  78. str.Append("<td align=\"left\"><img style=\"cursor:pointer;\" onclick = \"IsDelete('" + dr["id"].ToString() + "')\" border = '0' title = \"Confirm Delete\" src=\"../../../images/delete.gif\" /></td>");
  79. str.Append("</tr>");
  80. }
  81. str.Append("</table>");
  82. rpt_domestic.InnerHtml = str.ToString();
  83. }
  84. private void LoadInternationalPackage(DataTable dt)
  85. {
  86. international.Visible = true;
  87. int cols = dt.Columns.Count;
  88. var str = new StringBuilder("<table width=\"100%\" border=\"0\" class=\"gridTable\" cellpadding=\"5\" cellspacing=\"0\" align=\"center\">");
  89. str.Append("<tr><td colspan=\"" + cols + "\"><div align=\"right\"><a href=\"PackageAdd.aspx?type=I&groupId=" + group.Text + "\"><img src=\"../../../images/add.gif\"/></a></div></td></tr>");
  90. str.Append("<tr class='hdtitle'>");
  91. for (int i = 3; i < cols; i++)
  92. {
  93. str.Append("<th class=\"headingTH\"><div align=\"left\">" + dt.Columns[i].ColumnName + "</div></th>");
  94. }
  95. str.Append("<th align=\"left\"></th>");
  96. str.Append("</tr>");
  97. var j = 0;
  98. foreach (DataRow dr in dt.Rows)
  99. {
  100. str.Append(++j % 2 == 1 ? "<tr class=\"oddbg\">" : "<tr class=\"evenbg\">");
  101. for (int i = 3; i < cols; i++)
  102. {
  103. str.Append("<td align=\"left\">" + dr[i].ToString() + "</td>");
  104. }
  105. str.Append("<td align=\"left\"><img style=\"cursor:pointer;\" onclick = \"IsDelete('" + dr["id"].ToString() + "')\" border = '0' title = \"Confirm Delete\" src=\"../../../images/delete.gif\" /></td>");
  106. str.Append("</tr>");
  107. }
  108. str.Append("</table>");
  109. rpt_intl.InnerHtml = str.ToString();
  110. }
  111. protected void btnSearch_Click(object sender, EventArgs e)
  112. {
  113. LoadGrids();
  114. }
  115. private void DeleteRow()
  116. {
  117. DbResult dbResult = _commGrpMap.DeleteGroup(GetStatic.GetUser(), hdnId.Value);
  118. ManageMessage(dbResult);
  119. LoadGrids();
  120. }
  121. private void ManageMessage(DbResult dbResult)
  122. {
  123. GetStatic.SetMessage(dbResult);
  124. GetStatic.PrintMessage(Page);
  125. }
  126. protected void btnDeleteRecord_Click(object sender, EventArgs e)
  127. {
  128. DeleteRow();
  129. }
  130. /*
  131. private void LoadGrid()
  132. {
  133. grid.FilterList = new List<GridFilter>
  134. {
  135. new GridFilter("groupName", "Group Name", "LT"),
  136. new GridFilter("packageName", "Package Name", "LT")
  137. };
  138. grid.ColumnList = new List<GridColumn>
  139. {
  140. new GridColumn("groupId", "Group ID", "", "T"),
  141. new GridColumn("groupName", "Group Name", "", "T"),
  142. new GridColumn("packageName", "Package Name", "", "T"),
  143. new GridColumn("createdBy", "Created By", "", "T"),
  144. new GridColumn("createdDate", "Created Date", "", "D")
  145. };
  146. grid.GridType = 1;
  147. grid.GridName = GridName;
  148. grid.ShowFilterForm = true;
  149. grid.ShowPagingBar = true;
  150. grid.GridWidth = 600;
  151. grid.RowIdField = "id";
  152. grid.CallBackFunction = "GridCallBack()";
  153. grid.ThisPage = "CommissionGroup.aspx";
  154. grid.ShowCheckBox = true;
  155. grid.SelectionCheckBoxList = grid.GetRowId();
  156. grid.AllowEdit = false;
  157. grid.AllowDelete = swiftLibrary.HasRight(DeleteFunctionId);
  158. string sql = "EXEC proc_commissionGroupMapping @flag = 'sg'";
  159. grid.SetComma();
  160. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  161. }
  162. * */
  163. }
  164. }