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.

121 lines
4.1 KiB

  1. using Swift.DAL.ExchangeSystem.LedgerSetup;
  2. using Swift.web.Library;
  3. using System;
  4. namespace Swift.web.include
  5. {
  6. public partial class AddGL : System.Web.UI.Page
  7. {
  8. private LedgerDao _obj = new LedgerDao();
  9. private readonly SwiftLibrary _sl = new SwiftLibrary();
  10. protected void Page_Load(object sender, EventArgs e)
  11. {
  12. _sl.CheckSession();
  13. if (!IsPostBack)
  14. {
  15. breadCrumb.InnerHtml = "Add Ledger Group";
  16. frmTitle.InnerHtml = "Add Ledger Group";
  17. btnUpdate.Visible = false;
  18. GLCode.Text = GetParentId();
  19. GetMapName();
  20. if (!string.IsNullOrEmpty(GetRowId()))
  21. {
  22. breadCrumb.InnerHtml = "Edit Ledger Sub Group";
  23. frmTitle.InnerHtml = "Edit Ledger Sub Group";
  24. PopulateData();
  25. }
  26. }
  27. }
  28. private void PopulateData()
  29. {
  30. var dr = _obj.GetGLData(GetRowId());
  31. if (dr == null)
  32. return;
  33. GLCode.Text = GetRowId();
  34. GLMap.SelectedValue = dr["p_id"].ToString();
  35. GLMap.Enabled = false;
  36. description.Text = dr["gl_desec"].ToString();
  37. accountPrifix.Text = dr["acc_Prefix"].ToString();
  38. ConditionDDl.SelectedValue = "";
  39. addNewGL.Visible = false;
  40. btnUpdate.Visible = true;
  41. }
  42. protected void addNewGL_Click(object sender, EventArgs e)
  43. {
  44. string code = GLCode.Text;
  45. string desc = description.Text;
  46. if (desc == "")
  47. {
  48. GetStatic.AlertMessage(this, "* fields are required !");
  49. return;
  50. }
  51. string map = GLMap.Text;
  52. string id = GetRowId();
  53. string user = GetStatic.GetUser();
  54. string accPrifix = accountPrifix.Text;
  55. var dbResult = _obj.InsertLedger(id, user, map, desc, code, accPrifix);
  56. if (dbResult.ErrorCode == "0")
  57. {
  58. GetStatic.AlertMessage(this, dbResult.Msg);
  59. return;
  60. }
  61. else
  62. {
  63. GetStatic.AlertMessage(this, dbResult.Msg);
  64. return;
  65. }
  66. }
  67. protected void btnUpdate_Click(object sender, EventArgs e)
  68. {
  69. string desc = description.Text;
  70. if (desc == "")
  71. {
  72. GetStatic.AlertMessage(this, "* fields are required !");
  73. return;
  74. }
  75. string id = GetRowId();
  76. var dbResult = _obj.UpdateLedger(id, desc, accountPrifix.Text);
  77. GetStatic.AlertMessage(this, dbResult.Msg);
  78. }
  79. private string GetRowId()
  80. {
  81. return GetStatic.ReadQueryString("Rowid", "");
  82. }
  83. private string GetParentId()
  84. {
  85. return GetStatic.ReadQueryString("ParentID", "");
  86. }
  87. private string GetId()
  88. {
  89. return GetStatic.ReadQueryString("id", "");
  90. }
  91. private void GetMapName()
  92. {
  93. if (!GetParentId().Contains("r"))
  94. {
  95. //string a = "";
  96. //int length = 1;
  97. //for (int i = 0; i < length; i++)
  98. //{
  99. // if (i == 0)
  100. // a = _sl.GetSingleResult("select P_id from gl_group WITH(NOLOCK) where gl_code = '" + GetParentId() + "'");
  101. // else
  102. // a = _sl.GetSingleResult("select P_id from gl_group WITH(NOLOCK) where gl_code = '" + a + "'");
  103. // if (!a.Contains("r"))
  104. // length++;
  105. //}
  106. _sl.SetDDL(ref GLMap, "select gl_name lable,gl_code reportid from gl_group WITH(NOLOCK) where gl_code ='" + GetParentId() + "'", "reportId", "lable", "", "");
  107. }
  108. else
  109. _sl.SetDDL(ref GLMap, "SELECT lable,reportid FROM report_format WITH(NOLOCK) WHERE reportid=REPLACE('" + GetParentId() + "','r','')", "reportId", "lable", "", "");
  110. }
  111. }
  112. }