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.

144 lines
5.0 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using Swift.web.Library;
  8. using Swift.DAL.SwiftDAL;
  9. using System.Data;
  10. using Swift.web.Component.Grid;
  11. using Swift.web.Component.Grid.gridHelper;
  12. using Swift.DAL.BL.Remit.RiskBaseAnalysis;
  13. namespace Swift.web.Remit.RiskBaseAnalysis.RBACriteria
  14. {
  15. public partial class AddHighRiskCountry : System.Web.UI.Page
  16. {
  17. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  18. private RBACriteriaDao obj = new RBACriteriaDao();
  19. private string ViewFunctionId = "20191300";
  20. private string AddEditFunctionId = "20191310";
  21. protected const string GridName = "grid_HighRiskCountryList";
  22. private readonly SwiftGrid grid = new SwiftGrid();
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. _sl.CheckSession();
  26. var type = GetStatic.ReadQueryString("type", "").ToLower();
  27. if (!IsPostBack)
  28. {
  29. Authenticate();
  30. if (type == "edit" || type == "delete")
  31. {
  32. var id = GetStatic.ReadQueryString("id", "").ToLower();
  33. if (type == "edit")
  34. {
  35. LoadData(id);
  36. }
  37. else
  38. {
  39. Delete(id);
  40. }
  41. }
  42. }
  43. LoadGrid();
  44. }
  45. private void Authenticate()
  46. {
  47. _sl.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId);
  48. }
  49. protected void btnAddCountry_Click(object sender, EventArgs e)
  50. {
  51. if (!string.IsNullOrWhiteSpace(country.Text))
  52. {
  53. r1.Visible = false;
  54. var dbResult = obj.SaveHighRiskCountry(GetStatic.GetUser(), country.Value, country.Text, chkBlockCountry.Checked);
  55. ManageMessage(dbResult, "AddHighRiskCountry.aspx");
  56. }
  57. else
  58. {
  59. r1.Visible = true;
  60. }
  61. }
  62. private void LoadGrid()
  63. {
  64. grid.FilterList = new List<GridFilter>
  65. {
  66. new GridFilter("countryName", "Country", "T"),
  67. };
  68. grid.ColumnList = new List<GridColumn>
  69. {
  70. new GridColumn("sn", "SN", "4", "T"),
  71. new GridColumn("countryName", "Country", "", "T"),
  72. new GridColumn("blocked","Is Blocked","","T"),
  73. new GridColumn("customlink", "", "190", "T")
  74. };
  75. grid.GridType = 1;
  76. grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  77. grid.GridName = GridName;
  78. grid.ShowPagingBar = true;
  79. grid.ThisPage = "AddHighRiskCountry.aspx";
  80. grid.RowIdField = "rowId";
  81. grid.SortBy = "rowId";
  82. grid.ShowFilterForm = true;
  83. grid.InputPerRow = 3;
  84. grid.SetComma();
  85. string sql = "EXEC proc_RBA @flag = 's-hrc'";
  86. grid.SetComma();
  87. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  88. }
  89. private void Delete(string id)
  90. {
  91. if (string.IsNullOrEmpty(id) || id == "0")
  92. return;
  93. var dbResult = obj.Delete(GetStatic.GetUser(), id);
  94. ManageMessage(dbResult, "AddHighRiskCountry.aspx");
  95. }
  96. private void ManageMessage(DbResult dbResult, string url)
  97. {
  98. GetStatic.CallJSFunction(this, string.Format("CallBackSave('{0}','{1}", dbResult.ErrorCode, dbResult.Msg.Replace("'", "") + "','" + url + "')"));
  99. }
  100. void LoadData(string id)
  101. {
  102. if (string.IsNullOrEmpty(id) || id == "0")
  103. return;
  104. var drow = obj.GetDataByID(GetStatic.GetUser(), id);
  105. if (drow != null)
  106. {
  107. country.Value = drow["countryId"].ToString();
  108. country.Text = drow["countryName"].ToString();
  109. chkBlockCountry.Checked = (drow["isBlocked"].ToString() == "1" || drow["isBlocked"].ToString().ToLower() == "true") ? true : false;
  110. btnAddCountry.Visible = false;
  111. btnUpdateCountry.Visible = true;
  112. }
  113. }
  114. protected void btnUpdateCountry_Click(object sender, EventArgs e)
  115. {
  116. if (!string.IsNullOrWhiteSpace(country.Text))
  117. {
  118. r1.Visible = false;
  119. var id = GetStatic.ReadQueryString("id", "").ToLower();
  120. var dbResult = obj.UpdateHighRiskCountry(GetStatic.GetUser(), country.Value, country.Text, chkBlockCountry.Checked, id);
  121. ManageMessage(dbResult, "AddHighRiskCountry.aspx");
  122. }
  123. else
  124. {
  125. r1.Visible = true;
  126. }
  127. }
  128. }
  129. }