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.

95 lines
3.0 KiB

  1. using Swift.DAL.Remittance.TPSetup;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Library;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. namespace Swift.web.Remit.TPSetup.ServiceWiseLocation
  11. {
  12. public partial class ManageSubLocation : System.Web.UI.Page
  13. {
  14. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  15. private readonly TPSetupDao _settingDao = new TPSetupDao();
  16. private const string ViewFunctionId = "20174000";
  17. private const string AddEditFunctionId = "20174010";
  18. protected void Page_Load(object sender, EventArgs e)
  19. {
  20. Authenticate();
  21. if (!IsPostBack)
  22. {
  23. GetStatic.PrintMessage(Page);
  24. saveData.Visible = _sl.HasRight(AddEditFunctionId);
  25. locName.Text = GetLocName();
  26. if (GetId() != "")
  27. {
  28. PopulateForm();
  29. }
  30. }
  31. }
  32. private void Authenticate()
  33. {
  34. _sl.CheckAuthentication(ViewFunctionId);
  35. }
  36. public string GetLocName()
  37. {
  38. return GetStatic.ReadQueryString("locName", "");
  39. }
  40. protected void PopulateForm()
  41. {
  42. var dr = _settingDao.GetSubLocationDetails(GetId(), GetStatic.GetUser());
  43. if (null != dr)
  44. {
  45. partnerSubLocation.Text = dr["subLocation"].ToString();
  46. partnerLocationCode.Text = dr["partnerSubLocationId"].ToString();
  47. isActive.SelectedValue = dr["isActive"].ToString();
  48. }
  49. }
  50. protected void saveData_Click(object sender, EventArgs e)
  51. {
  52. Update();
  53. }
  54. private void Update()
  55. {
  56. DbResult dbResult = new DbResult();
  57. if (string.IsNullOrEmpty(GetLocationId()))
  58. {
  59. dbResult.ErrorCode = "1";
  60. dbResult.Msg = "No location found, please try again!";
  61. GetStatic.SetMessage(dbResult);
  62. Response.Redirect("List.aspx");
  63. }
  64. dbResult = _settingDao.InsertUpdateSubLocation(GetId(), GetStatic.GetUser(), partnerSubLocation.Text, partnerLocationCode.Text, isActive.SelectedValue, GetLocationId());
  65. if (dbResult.ErrorCode == "0")
  66. {
  67. GetStatic.SetMessage(dbResult);
  68. Response.Redirect("SubLocationList.aspx?locId=" + GetLocationId() + "&locName=" + GetStatic.ReadQueryString("locName", ""));
  69. return;
  70. }
  71. else
  72. {
  73. GetStatic.AlertMessage(this, dbResult.Msg);
  74. return;
  75. }
  76. }
  77. public string GetLocationId()
  78. {
  79. return GetStatic.ReadQueryString("locId", "");
  80. }
  81. public string GetId()
  82. {
  83. return GetStatic.ReadQueryString("rowId", "");
  84. }
  85. }
  86. }