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.

104 lines
3.9 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web.UI;
  4. using Swift.DAL.BL.Remit.OFACManagement;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Component.Grid;
  7. using Swift.web.Component.Grid.gridHelper;
  8. using Swift.web.Library;
  9. namespace Swift.web.Remit.OFACManagement
  10. {
  11. public partial class List : Page
  12. {
  13. private const string ViewFunctionId = "2019800";
  14. private const string AddEditFunctionId = "2019810";
  15. private const string DeleteFunctionId = "2019820";
  16. private const string GridName = "grd_blacklist";
  17. private readonly SwiftGrid grid = new SwiftGrid();
  18. private readonly OFACManagementDao obj = new OFACManagementDao();
  19. private readonly SwiftLibrary swiftLibrary = new SwiftLibrary();
  20. protected void Page_Load(object sender, EventArgs e)
  21. {
  22. Authenticate();
  23. if (!IsPostBack)
  24. {
  25. GetStatic.PrintMessage(Page);
  26. }
  27. DeleteRow();
  28. LoadGrid();
  29. }
  30. private void LoadGrid()
  31. {
  32. grid.FilterList = new List<GridFilter>
  33. {
  34. new GridFilter("name", "NAME","T"),
  35. new GridFilter("country", "Country","T"),
  36. new GridFilter("entNum", "Ent Num","T"),
  37. new GridFilter("dataSource", "Data Source", "T")
  38. };
  39. grid.ColumnList = new List<GridColumn>
  40. {
  41. new GridColumn("entNum", "Ent No.", "", "T"),
  42. new GridColumn("name", "Name", "", "T"),
  43. new GridColumn("vesselType", "vessel Type", "", "T"),
  44. new GridColumn("address", "Address", "", "T"),
  45. new GridColumn("city", "City", "", "T"),
  46. new GridColumn("state", "State", "", "T"),
  47. new GridColumn("country", "Country", "", "T"),
  48. new GridColumn("createdDate", "Created Date", "", "z"),
  49. new GridColumn("createdBy", "Created By", "", "T")
  50. };
  51. bool allowAddEdit = swiftLibrary.HasRight(AddEditFunctionId);
  52. grid.GridName = GridName;
  53. grid.GridType = 1;
  54. grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  55. grid.ShowAddButton = allowAddEdit;
  56. grid.ShowFilterForm = true;
  57. grid.ShowPagingBar = true;
  58. grid.AddButtonTitleText = "Add New ";
  59. grid.RowIdField = "rowId";
  60. grid.AddPage = "Manage.aspx";
  61. grid.InputPerRow = 4;
  62. grid.AlwaysShowFilterForm = true;
  63. grid.AllowEdit = allowAddEdit;
  64. grid.AllowDelete = swiftLibrary.HasRight(DeleteFunctionId);
  65. string sql = "EXEC [proc_OFACManualEntry] @flag = 'a'";
  66. grid.SetComma();
  67. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  68. }
  69. private void Authenticate()
  70. {
  71. swiftLibrary.CheckAuthentication(ViewFunctionId);
  72. }
  73. private void DeleteRow()
  74. {
  75. string id = grid.GetCurrentRowId(GridName);
  76. if (string.IsNullOrEmpty(id))
  77. return;
  78. DbResult dbResult = obj.Delete(GetStatic.GetUser(), id);
  79. ManageMessage(dbResult);
  80. }
  81. private void ManageMessage(DbResult dbResult)
  82. {
  83. GetStatic.SetMessage(dbResult);
  84. if (dbResult.ErrorCode == "0")
  85. {
  86. Response.Redirect("List.aspx");
  87. }
  88. else
  89. {
  90. GetStatic.PrintMessage(Page);
  91. }
  92. }
  93. }
  94. }