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.

100 lines
3.3 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 ManageLocation : 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. PopulateDDL();
  25. saveData.Visible = _sl.HasRight(AddEditFunctionId);
  26. if (GetId() != "")
  27. {
  28. PopulateForm();
  29. }
  30. }
  31. }
  32. private void Authenticate()
  33. {
  34. _sl.CheckAuthentication(ViewFunctionId);
  35. }
  36. protected void PopulateForm()
  37. {
  38. var dr = _settingDao.GetPartnerDetails(GetId(), GetStatic.GetUser());
  39. if (null != dr)
  40. {
  41. countryDDL.SelectedValue = dr["countryId"].ToString();
  42. PopulateServiceType(dr["countryId"].ToString(), dr["serviceTypeId"].ToString());
  43. partnerLocation.Text = dr["location"].ToString();
  44. partnerLocationCode.Text = dr["partnerLocationId"].ToString();
  45. isActive.SelectedValue = dr["isActive"].ToString();
  46. }
  47. }
  48. protected void PopulateDDL()
  49. {
  50. _sl.SetDDL(ref countryDDL, "EXEC proc_online_dropDownList @flag='allCountrylist'", "countryId", "countryName", "", "Select Partner Country");
  51. }
  52. protected void countryDDL_SelectedIndexChanged(object sender, EventArgs e)
  53. {
  54. PopulateServiceType(countryDDL.SelectedValue);
  55. }
  56. private void PopulateServiceType(string countryId, string serviceTypeId = "")
  57. {
  58. if (string.IsNullOrEmpty(countryId))
  59. {
  60. serviceTypeDDL.Items.Add("Not defined");
  61. return;
  62. }
  63. serviceTypeDDL.Items.Clear();
  64. _sl.SetDDL(ref serviceTypeDDL, "EXEC proc_tpLocationSetup @flag='serviceType', @countryId = " + countryId, "serviceTypeId", "serviceTypeName", serviceTypeId, "All");
  65. }
  66. protected void saveData_Click(object sender, EventArgs e)
  67. {
  68. Update();
  69. }
  70. private void Update()
  71. {
  72. DbResult dbResult = _settingDao.InsertUpdateSetup(GetId(), GetStatic.GetUser(), countryDDL.SelectedValue, serviceTypeDDL.SelectedValue, partnerLocation.Text, partnerLocationCode.Text, isActive.SelectedValue);
  73. if (dbResult.ErrorCode == "0")
  74. {
  75. GetStatic.SetMessage(dbResult);
  76. Response.Redirect("List.aspx");
  77. return;
  78. }
  79. else
  80. {
  81. GetStatic.AlertMessage(this, dbResult.Msg);
  82. return;
  83. }
  84. }
  85. private string GetId()
  86. {
  87. return GetStatic.ReadQueryString("rowId", "");
  88. }
  89. }
  90. }