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.

113 lines
3.7 KiB

  1. using System;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using Swift.DAL.SwiftDAL;
  5. using Swift.web.Library;
  6. using System.Data;
  7. using Swift.DAL.BL.Remit.OFACManagement;
  8. namespace Swift.web.Remit.OFACManagement
  9. {
  10. public partial class Manage : Page
  11. {
  12. private const string ViewFunctionId = "2019800";
  13. private const string AddEditFunctionId = "2019810";
  14. private const string DeleteFunctionId = "2019820";
  15. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  16. private readonly OFACManagementDao obj = new OFACManagementDao();
  17. protected void Page_Load(object sender, EventArgs e)
  18. {
  19. Authenticate();
  20. if (!IsPostBack)
  21. {
  22. if (GetOfacId() > 0)
  23. PopulateDataById();
  24. else
  25. PopulateDdl(null);
  26. }
  27. }
  28. private void Authenticate()
  29. {
  30. _sdd.CheckAuthentication(ViewFunctionId);
  31. bntSubmit.Visible = _sdd.HasRight(AddEditFunctionId);
  32. }
  33. protected long GetOfacId()
  34. {
  35. return GetStatic.ReadNumericDataFromQueryString("rowId");
  36. }
  37. private void PopulateDdl(DataRow dr)
  38. {
  39. LoadCountry(ref Country, GetStatic.GetRowData(dr, "Country"));
  40. }
  41. private void LoadCountry(ref DropDownList ddl, string defaultValue)
  42. {
  43. string sql = "EXEC proc_countryMaster @flag = 'l'";
  44. _sdd.SetDDL(ref ddl, sql, "countryName", "countryName", defaultValue, "Select");
  45. }
  46. protected void bntSubmit_Click(object sender, EventArgs e)
  47. {
  48. Update();
  49. }
  50. private void Update()
  51. {
  52. DbResult dbResult = obj.Update(GetStatic.GetUser()
  53. , GetOfacId().ToString()
  54. , entNum.Text
  55. , Name.Text
  56. , vesselType.SelectedValue
  57. , Address.Text
  58. , City.Text
  59. , State.Text
  60. , Zip.Text
  61. , Country.SelectedItem.Text
  62. , Remarks.Text
  63. , DataSource.Text
  64. );
  65. lblMsg.Text = dbResult.Msg;
  66. ManageMessage(dbResult);
  67. }
  68. private void ManageMessage(DbResult dbResult)
  69. {
  70. GetStatic.SetMessage(dbResult);
  71. if (dbResult.ErrorCode == "0")
  72. {
  73. Response.Redirect("List.aspx");
  74. }
  75. else
  76. {
  77. GetStatic.PrintMessage(Page);
  78. }
  79. }
  80. private void PopulateDataById()
  81. {
  82. DataRow dr = obj.SelectById(GetStatic.GetUser(), GetOfacId().ToString());
  83. if (dr == null)
  84. return;
  85. entNum.Text = dr["entNum"].ToString();
  86. Name.Text = dr["name"].ToString();
  87. vesselType.SelectedValue = dr["vesselType"].ToString();
  88. Address.Text = dr["address"].ToString();
  89. City.Text = dr["city"].ToString();
  90. State.Text = dr["state"].ToString();
  91. Zip.Text = dr["zip"].ToString();
  92. Remarks.Text = dr["remarks"].ToString();
  93. DataSource.Text = dr["dataSource"].ToString();
  94. PopulateDdl(dr);
  95. }
  96. protected void Button1_Click(object sender, EventArgs e)
  97. {
  98. Response.Redirect("List.aspx");
  99. }
  100. }
  101. }