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.

159 lines
6.2 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 UserGroupMaping : System.Web.UI.Page
  16. {
  17. private const string GridName = "grd_appUsrGrpMaping";
  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. GetStatic.SetActiveMenu(ViewFunctionId);
  30. if (GetId() > 0)
  31. {
  32. PopulateDataById();
  33. }
  34. else
  35. {
  36. var sql = "select typeID, typeDesc from staticDataType where typeID BETWEEN 6600 AND 6900 ";
  37. _sdd.SetDDL(ref DDLGroupCat, sql, "typeID", "typeDesc", "", "Select Group Category");
  38. sql = "select valueid, detailDesc from staticDataValue where typeID = " + _sdd.FilterString(DDLGroupCat.Text) + " ORDER BY detailDesc ASC";
  39. _sdd.SetDDL(ref DDLGroupDetail, sql, "valueid", "detailDesc", "", "Select Group Detail");
  40. }
  41. }
  42. DeleteRow();
  43. LoadGrid();
  44. }
  45. private void PopulateDataById()
  46. {
  47. DataRow dr = _obj.SelectById(GetStatic.GetUser(), GetId().ToString());
  48. if (dr == null)
  49. return;
  50. var sql = "SELECT typeID, typeDesc FROM staticDataType WHERE typeID BETWEEN 6600 AND 6900";
  51. _sdd.SetDDL(ref DDLGroupCat, sql, "typeID", "typeDesc", dr["groupCat"].ToString(), "Select Group Category");
  52. sql = "SELECT valueId, detailDesc FROM staticDataValue WHERE typeID = " + _sdd.FilterString(DDLGroupCat.Text) + " ORDER BY detailDesc ASC";
  53. _sdd.SetDDL(ref DDLGroupDetail, sql, "valueid", "detailDesc", dr["groupDetail"].ToString(), "Select Group Detail");
  54. }
  55. private void Authenticate()
  56. {
  57. _sl.CheckAuthentication(ViewFunctionId);
  58. }
  59. protected long GetMode()
  60. {
  61. return GetStatic.ReadNumericDataFromQueryString("mode");
  62. }
  63. protected long GetId()
  64. {
  65. return GetStatic.ReadNumericDataFromQueryString("rowId");
  66. }
  67. protected long GetAgent()
  68. {
  69. return GetStatic.ReadNumericDataFromQueryString("agentId");
  70. }
  71. protected long GetUserId()
  72. {
  73. return GetStatic.ReadNumericDataFromQueryString("userId");
  74. }
  75. protected string GetUserName()
  76. {
  77. return GetStatic.ReadQueryString("userName", "");
  78. }
  79. protected void DDLGroupCat_SelectedIndexChanged(object sender, EventArgs e)
  80. {
  81. var sql = "select valueid, detailDesc from staticDataValue where typeID = " + _sdd.FilterString(DDLGroupCat.Text);
  82. _sdd.SetDDL(ref DDLGroupDetail, sql, "valueid", "detailDesc", "", "Select Group Detail");
  83. }
  84. private void ManageMessage(DbResult dbResult)
  85. {
  86. GetStatic.SetMessage(dbResult);
  87. if (dbResult.ErrorCode == "0")
  88. {
  89. Response.Redirect("UserGroupMaping.aspx?userId=" + GetUserId() + "&userName=" + GetUserName());
  90. }
  91. else
  92. {
  93. GetStatic.PrintMessage(Page);
  94. }
  95. }
  96. private void Update()
  97. {
  98. DbResult dbResult = _obj.Update(GetStatic.GetUser(), GetId().ToString(), GetUserId().ToString(), DDLGroupCat.Text,
  99. DDLGroupDetail.Text, GetUserName());
  100. ManageMessage(dbResult);
  101. }
  102. private void DeleteRow()
  103. {
  104. string id = grid.GetCurrentRowId(GridName);
  105. if (string.IsNullOrEmpty(id))
  106. return;
  107. DbResult dbResult = _obj.Delete(GetStatic.GetUser(), id);
  108. ManageMessage(dbResult);
  109. }
  110. private void LoadGrid()
  111. {
  112. grid.ColumnList = new List<GridColumn>
  113. {
  114. new GridColumn("GroupCat", "Group Category", "", "T"),
  115. new GridColumn("SubGroup", "Group Detail", "", "T"),
  116. new GridColumn("userName", "User Name", "", "T"),
  117. new GridColumn("createdBy", "Created By", "", "T"),
  118. new GridColumn("createdDate", "Created Date", "", "T")
  119. };
  120. grid.GridName = GridName;
  121. grid.GridType = 1;
  122. grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  123. grid.DisableJsFilter = true;
  124. grid.DisableSorting = true;
  125. grid.ShowAddButton = true;
  126. grid.ShowFilterForm = false;
  127. grid.ShowPagingBar = true;
  128. // grid.AllowApprove = true;
  129. grid.AddButtonTitleText = "Add New ";
  130. grid.RowIdField = "rowId";
  131. grid.AddPage = "UserGroupMaping.aspx?userId=" + GetUserId() + "&userName=" + GetUserName();
  132. grid.AllowEdit = true;
  133. grid.AllowDelete = true;
  134. //grid.AllowDelete = _sdd.HasRight(DeleteFunctionId);
  135. grid.GridWidth = 1020;
  136. string sql = "EXEC proc_userGroupMapping @flag = 's', @userId = " + GetUserId();
  137. grid.SetComma();
  138. rpt_grid.InnerHtml = grid.CreateGrid(sql);
  139. }
  140. protected void bntSubmit_Click(object sender, EventArgs e)
  141. {
  142. Update();
  143. }
  144. protected void btnDelete_Click(object sender, EventArgs e)
  145. {
  146. DDLGroupCat.Text = "";
  147. DDLGroupDetail.Items.Clear();
  148. }
  149. }
  150. }