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.

103 lines
3.2 KiB

  1. using Swift.DAL.GeneralDataSettings;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Data;
  6. namespace Swift.web.GeneralSetting.GeneralData
  7. {
  8. public partial class Manage : System.Web.UI.Page
  9. {
  10. private string title = null;
  11. private const string ViewFunctionId = "10101700";
  12. private const string AddEditFunctionId = "10101710";
  13. private readonly GeneralSettingsSubGridDao _obj = new GeneralSettingsSubGridDao();
  14. private readonly SwiftLibrary _sdd = new SwiftLibrary();
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. title = GetTitle();
  18. header.Text = GetTitle().ToUpper();
  19. labelHead.Text = GetTitle();
  20. _sdd.CheckSession();
  21. if (!IsPostBack)
  22. {
  23. Authenticate();
  24. if (!string.IsNullOrEmpty(GetId()))
  25. {
  26. PopulateDataById();
  27. }
  28. }
  29. }
  30. protected string GetId()
  31. {
  32. return GetStatic.ReadQueryString("id", "");
  33. }
  34. protected string Getrefid()
  35. {
  36. return GetStatic.ReadQueryString("refid", "");
  37. }
  38. protected string GetTitle()
  39. {
  40. return GetStatic.ReadQueryString("title", "");
  41. }
  42. private void Authenticate()
  43. {
  44. _sdd.CheckAuthentication(ViewFunctionId + "," + AddEditFunctionId);
  45. btnSubmit.Visible = _sdd.HasRight(AddEditFunctionId);
  46. }
  47. private void PopulateDataById()
  48. {
  49. DataRow dr = new DataTable().NewRow();
  50. dr = _obj.SelectById(GetStatic.GetUser(), Getrefid().ToString());
  51. if (dr == null)
  52. return;
  53. createdBy.Text = dr["CREATED_BY"].ToString();
  54. createdDate.Text = dr["CREATED_DATE"].ToString();
  55. modifiedBy.Text = dr["MODIFIED_BY"].ToString();
  56. modifiedDate.Text = dr["MODIFIED_DATE"].ToString();
  57. createdByLabel.Visible = true;
  58. createdBy.Visible = true;
  59. createdDate.Visible = true;
  60. createdDateLabel.Visible = true;
  61. modifiedBy.Visible = true;
  62. modifiedByLabel.Visible = true;
  63. modifiedDate.Visible = true;
  64. modifiedDateLabel.Visible = true;
  65. labelHead.Text = dr["title"].ToString();
  66. header.Text = dr["title"].ToString().ToUpper();
  67. code.Text = dr["ref_code"].ToString();
  68. description.Text = dr["ref_desc"].ToString();
  69. }
  70. private void Update()
  71. {
  72. DbResult dbResult = _obj.Update(GetStatic.GetUser(), Getrefid().ToString(), GetId().ToString(), code.Text, description.Text);
  73. ManageMessage(dbResult);
  74. }
  75. private void ManageMessage(DbResult dbResult)
  76. {
  77. if (dbResult.ErrorCode == "0")
  78. {
  79. GetStatic.SetMessage(dbResult);
  80. Response.Redirect("List.aspx");
  81. }
  82. else
  83. {
  84. GetStatic.PrintMessage(Page);
  85. }
  86. }
  87. protected void btnSumit_Click(object sender, EventArgs e)
  88. {
  89. Update();
  90. }
  91. }
  92. }