Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 0 0
  1. @using (Html.BeginForm("Index", "Certificates", FormMethod.Post, new { }))
  2. {
  3. {
  4. VAILCertificates.DAL.Entities.User Users = (VAILCertificates.DAL.Entities.User)Session["User"];
  5.  
  6. if (Users.UserGroupID == 1 || Users.UserRoleName == "admin")
  7. {
  8. @Html.Label("Clients", htmlAttributes: new { @class = "control-label col-md-1" })
  9. @Html.DropDownListFor(model => model.SearchInspectionReport.Client_ID, new SelectList(ViewBag.ClientsList, "ID", "Name"),
  10. "-Select-",
  11. new { @class = "form-control" })
  12. }
  13. }
  14.  
  15. <table id="tblCertificates" style="width:100%" class="table table-bordered table-hover mt-2">
  16. <thead>
  17. <tr class="GridHeading">
  18. <td>Certification No.</td>
  19. <td>File Name</td>
  20. <td>Issue Date</td>
  21. <td>Details</td>
  22. <td>Client</td>
  23. <td>Workshop</td>
  24. <td>Added By</td>
  25. <td>Office</td>
  26. <td>Station</td>
  27. <td>File</td>
  28. </tr>
  29. </thead>
  30. <tbody>
  31. @foreach (var certificate in this.Model.CertificatesList)
  32. {
  33. <tr>
  34. <td>@certificate.CertificationNo</td>
  35. <td>@certificate.FileName</td>
  36. <td>@certificate.IssueDate</td>
  37. <td>@certificate.Details</td>
  38. <td>@certificate.Client</td>
  39. <td>@certificate.Workshop</td>
  40. <td>@certificate.UserName</td>
  41. <td>@certificate.Office</td>
  42. <td>@certificate.Station</td>
  43. <td class="text-center">
  44. @*<a href="../Downloads/Certificates/@certificate.FileName" target="_blank">
  45.  
  46. <i class="fa fa-file-text"></i>
  47. </a>*@
  48. <button class="btn btn-info btn-sm" type="submit" id="btnReview" name="btnDownload" formaction='@Url.Action("GetInspectionReportDetails", "InspectionReport", new { InspectionReportID = @certificate.InspectionReportID})'>Download</button>
  49. </td>
  50. </tr>
  51. }
  52. </tbody>
  53. </table>
  54.  
  55. CertificatesDAL certificatesDAL;
  56.  
  57. [HttpGet]
  58. public ActionResult Index()
  59. {
  60. User userSession = (User)Session["User"];
  61.  
  62. if (userSession == null || userSession.UserType == (int) UserTypes.RedirectedFromCTR)
  63. {
  64. return RedirectToAction("Login", "Home");
  65. }
  66.  
  67. certificatesDAL = new CertificatesDAL();
  68. CertificatesViewModel certificatesViewModel = new CertificatesViewModel();
  69.  
  70. VAILCertificates.DAL.Entities.User user = new User();
  71. VAILCertificates.DAL.UserDAL userDAL = new DAL.UserDAL();
  72. user = userDAL.ValidateUser(userSession.UserName, userSession.Password);
  73.  
  74. if (user != null)
  75. {
  76. certificatesViewModel.CertificatesList = certificatesDAL.GetCertificatesListFiltered("", user.ClientName, (user.UserGroupID == 1 || user.UserRoleName == "admin" || user.UserRoleName == "Admin") ? true : false); // 1 = admin
  77. }
  78.  
  79. ClientsDAL clientsDAL = new ClientsDAL();
  80. ViewBag.ClientsList = clientsDAL.GetClientsList();
  81.  
  82. //List<Certificates> l= certificatesDAL.GetClientsList();
  83.  
  84. return View(certificatesViewModel);
  85. }
  86.  
  87. <script type="text/javascript">
  88. $('#tblCertificates').DataTable({
  89. responsive: true,
  90. searching: true,
  91. ordering: false,
  92.  
  93. });
  94.  
  95. $("#SearchInspectionReport_Client_ID").change(function () {
  96.  
  97. var ID = $("#SearchInspectionReport_Client_ID").val(); //Client ID
  98.  
  99. data = { 'ID': ID } //Client ID
  100.  
  101. table = $("#tblCertificates").DataTable();
  102.  
  103. $('#tblCertificates tbody').empty()
  104. $.get("/CertificatesNew/FillCertificates", data);
  105.  
  106. });
  107. </script>
  108. }
  109.  
  110. [HttpGet]
  111. [OutputCache(NoStore = true, Duration = 0)]
  112. public ActionResult FillCertificates(int ID)
  113. {
  114. InspectionReportsViewModel InspectionReportsViewModel = new InspectionReportsViewModel();
  115.  
  116. try
  117. {
  118.  
  119. InspectionReportDAL InspectionReportDAL = new DAL.InspectionReportDAL();
  120. InspectionReportsViewModel.InspectionReportList = InspectionReportDAL.GetInspectionReportListFilteredByClientID(ID);
  121.  
  122. ClientsDAL clientsDAL = new ClientsDAL();
  123.  
  124. ViewBag.ClientsList = clientsDAL.GetClientsList();
  125.  
  126. return View("Index", InspectionReportsViewModel);
  127. }
  128. catch
  129. {
  130. return View();
  131. }
  132.  
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement