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.

81 lines
3.1 KiB

  1. using Swift.DAL.GridAutoDemo;
  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.Linq;
  9. using System.Web;
  10. using System.Web.UI;
  11. using System.Web.UI.WebControls;
  12. namespace Swift.web.GridAutoDemo
  13. {
  14. public partial class List : System.Web.UI.Page
  15. {
  16. public const string GridName = "employeeGrid";
  17. private const string ViewFunctionId = "40120000";
  18. private const string AddEditFunctionId = "40120010";
  19. private readonly SwiftGrid _grid = new SwiftGrid();
  20. private readonly EmployeeDetailsDao detailsDao = new EmployeeDetailsDao();
  21. protected void Page_Load(object sender, EventArgs e)
  22. {
  23. LoadGrid();
  24. DeleteRow();
  25. }
  26. private void LoadGrid()
  27. {
  28. _grid.FilterList = new List<GridFilter>
  29. {
  30. new GridFilter("Name", "Name", "T"),
  31. new GridFilter("MobileNo", "Mobile", "T"),
  32. new GridFilter("Email", "Email", "T"),
  33. new GridFilter("DepartName", "Native Country", "T")
  34. };
  35. _grid.ColumnList = new List<GridColumn>
  36. {
  37. new GridColumn("Name", "Name", "", "T"),
  38. new GridColumn("Address", "Address", "", "T"),
  39. new GridColumn("Email", "Email", "", "T"),
  40. new GridColumn("MobileNo", "Mobile", "", "T"),
  41. new GridColumn("DepartName", "Depart Name", "", "T"),
  42. new GridColumn("DOB", "DOB", "", "D"),
  43. new GridColumn("CompanyJoinDate", "Join Date", "", "D")
  44. };
  45. _grid.GridType = 1;
  46. _grid.GridDataSource = SwiftGrid.GridDS.RemittanceDB;
  47. _grid.GridName = GridName;
  48. _grid.ShowFilterForm = true;
  49. _grid.AlwaysShowFilterForm = false;
  50. _grid.EnableFilterCookie = false;
  51. _grid.ShowPagingBar = true;
  52. _grid.SortOrder = "desc";
  53. _grid.RowIdField = "Id";
  54. _grid.InputPerRow = 2;
  55. _grid.AllowEdit = true;
  56. _grid.AllowDelete = true;
  57. _grid.ShowAddButton = true;
  58. _grid.AddPage = "InsertDemo.aspx";
  59. _grid.AllowCustomLink = true;
  60. string sql = "EXEC Pro_EmployeeDetails @flag = 'Employee-List'";
  61. _grid.CustomLinkVariables = "id";
  62. var link = "&nbsp;<a href=\"DirectApprove.aspx?customerId=@id&verify=y\" class=\"btn btn-xs btn-success\"><i class=\"fa fa-check\"></i></a>&nbsp;<a href=\"PrintForm.aspx?customerId=@id&class=\"btn btn-xs btn-success\"><i class=\"fa fa-print\" aria-hidden=\"true\"></i></a>";
  63. _grid.CustomLinkText = link;
  64. _grid.SetComma();
  65. employeeGrid.InnerHtml = _grid.CreateGrid(sql);
  66. }
  67. private void DeleteRow()
  68. {
  69. string id = _grid.GetCurrentRowId(GridName);
  70. if (string.IsNullOrEmpty(id))
  71. return;
  72. DbResult dbResult = detailsDao.Delete(id);
  73. GetStatic.SetMessage(dbResult);
  74. GetStatic.PrintMessage(Page);
  75. }
  76. }
  77. }