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.

122 lines
4.5 KiB

  1. using Swift.DAL.BL.SwiftSystem;
  2. using Swift.DAL.SwiftDAL;
  3. using Swift.web.Component.Grid;
  4. using Swift.web.Component.Grid.gridHelper;
  5. using Swift.web.Library;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.UI;
  12. using System.Web.UI.WebControls;
  13. namespace Swift.web.SwiftSystem.UserManagement.AdminUserSetup
  14. {
  15. public partial class UserZoneMapping : System.Web.UI.Page
  16. {
  17. private const string GridName = "grd_user_zone";
  18. private const string ViewFunctionId = "10101300";
  19. private readonly SwiftGrid grid = new SwiftGrid();
  20. private readonly UserGroupMappingDao _obj = new UserGroupMappingDao();
  21. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  22. private readonly StaticDataDdl _sdd = new StaticDataDdl();
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. Authenticate();
  26. if (!IsPostBack)
  27. {
  28. GetStatic.PrintMessage(Page);
  29. PopulateDdl(null);
  30. if (GetId() > 0)
  31. {
  32. PopulateDataById();
  33. }
  34. }
  35. DeleteRow();
  36. LoadGrid();
  37. }
  38. private void PopulateDdl(DataRow dr)
  39. {
  40. string sql = "EXEC proc_countryStateMaster @flag = 'csl', @countryId = '151'";
  41. _sdd.SetDDL(ref zone, sql, "stateName", "stateName", GetStatic.GetRowData(dr, "zoneName"), "Select");
  42. }
  43. private void PopulateDataById()
  44. {
  45. DataRow dr = _obj.SelectByIdUserZone(GetStatic.GetUser(), GetId().ToString());
  46. if (dr == null)
  47. return;
  48. PopulateDdl(dr);
  49. }
  50. private void Authenticate()
  51. {
  52. _sl.CheckAuthentication(ViewFunctionId);
  53. }
  54. protected long GetId()
  55. {
  56. return GetStatic.ReadNumericDataFromQueryString("id");
  57. }
  58. protected long GetUserId()
  59. {
  60. return GetStatic.ReadNumericDataFromQueryString("userId");
  61. }
  62. protected string GetUserName()
  63. {
  64. return GetStatic.ReadQueryString("userName", "");
  65. }
  66. private void ManageMessage(DbResult dbResult)
  67. {
  68. GetStatic.SetMessage(dbResult);
  69. if (dbResult.ErrorCode == "0")
  70. Response.Redirect("UserZoneMapping.aspx?userId=" + GetUserId() + "&userName=" + GetUserName());
  71. else
  72. GetStatic.AlertMessage(Page);
  73. }
  74. private void Update()
  75. {
  76. DbResult dbResult = _obj.UpdateUserZone(GetStatic.GetUser(), GetId().ToString(), zone.Text, GetUserName());
  77. ManageMessage(dbResult);
  78. }
  79. private void DeleteRow()
  80. {
  81. string id = grid.GetCurrentRowId(GridName);
  82. if (string.IsNullOrEmpty(id))
  83. return;
  84. DbResult dbResult = _obj.DeleteUserZone(GetStatic.GetUser(), id);
  85. ManageMessage(dbResult);
  86. }
  87. private void LoadGrid()
  88. {
  89. grid.ColumnList = new List<GridColumn>
  90. {
  91. new GridColumn("userFullName", "User Full Name", "", "T"),
  92. new GridColumn("userName", "UserName", "", "T"),
  93. new GridColumn("zoneName", "Zone", "", "T"),
  94. new GridColumn("createdBy", "Created By", "", "T"),
  95. new GridColumn("createdDate", "Created Date", "", "T")
  96. };
  97. grid.GridName = GridName;
  98. grid.GridType = 1;
  99. grid.DisableJsFilter = true;
  100. grid.DisableSorting = true;
  101. grid.ShowAddButton = true;
  102. grid.ShowFilterForm = false;
  103. grid.ShowPagingBar = true;
  104. grid.AddButtonTitleText = "Add New";
  105. grid.RowIdField = "id";
  106. grid.AddPage = "UserZoneMapping.aspx?userId=" + GetUserId() + "&userName=" + _sl.FilterString(GetUserName());
  107. grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  108. grid.AllowEdit = true;
  109. grid.AllowDelete = true;
  110. grid.GridWidth = 1020;
  111. string sql = "EXEC proc_userZoneMapping @flag = 's', @userName = " + _sl.FilterString(GetUserName());
  112. grid.SetComma();
  113. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  114. }
  115. protected void bntSubmit_Click(object sender, EventArgs e)
  116. {
  117. Update();
  118. }
  119. }
  120. }