Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

KitLabelsController.asp 4.7KB

8 miesięcy temu
8 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/KitLabelsViewModels.asp"-->
  4. <%
  5. Class KitLabelsController
  6. Public Model
  7. Public Sub Index
  8. dim page_size : page_size = 10
  9. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  10. dim page_count, record_count
  11. set Model = new PagedIndex_ViewModel_Class
  12. Model.Title = "KitLabels"
  13. set Model.KitLabels = KitLabelsRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count)
  14. Model.CurrentPageNumber = page_num
  15. Model.PageSize = page_size
  16. Model.PageCount = page_count
  17. Model.RecordCount = record_count
  18. %> <!--#include file="../../Views/KitLabels/Index.asp"--> <%
  19. End Sub
  20. Public Sub Search
  21. dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
  22. dim page_size : page_size = 10
  23. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  24. dim page_count, record_count
  25. set Model = new PagedIndex_ViewModel_Class
  26. Model.Title = "KitLabels"
  27. set Model.KitLabels = KitLabelsRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","KitId","%" & searchValue & "%","OutboundSerial","%" & searchValue & "%","InBoundSerial","%" & searchValue & "%","OutboundIMB","%" & searchValue & "%","InBoundIMB","%" & searchValue & "%","OutboundIMBDigits","%" & searchValue & "%","InBoundIMBDigits","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count)
  28. Model.CurrentPageNumber = page_num
  29. Model.PageSize = page_size
  30. Model.PageCount = page_count
  31. Model.RecordCount = record_count
  32. %> <!--#include file="../../Views/KitLabels/Index.asp"--> <%
  33. End Sub
  34. Public Sub Edit
  35. dim id : id = Request.QueryString("Id")
  36. set Model = new Edit_ViewModel_Class
  37. set Model.KitLabels = KitLabelsRepository.FindByID(id)
  38. Model.Title = "Edit KitLabels"
  39. HTMLSecurity.SetAntiCSRFToken "KitLabelsEditForm"
  40. %> <!--#include file="../../Views/KitLabels/Edit.asp"--> <%
  41. Flash.Success = "KitLabels Updated."
  42. End Sub
  43. Public Sub EditPost
  44. MVC.RequirePost
  45. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitLabelsEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  46. dim ID : ID = Request.Form("Id")
  47. dim model : set model = KitLabelsRepository.FindByID(ID)
  48. set model = Automapper.AutoMap(Request.Form, model)
  49. 'model.Validate
  50. 'If model.Validator.HasErrors then
  51. FormCache.SerializeForm "EditKitLabels", Request.Form
  52. ' Flash.Errors = model.Validator.Errors
  53. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  54. 'Else
  55. KitLabelsRepository.Update model
  56. FormCache.ClearForm "EditKitLabels"
  57. Flash.Success = "KitLabels updated."
  58. MVC.RedirectToAction "Index"
  59. 'End If
  60. End Sub
  61. Public Sub Create
  62. dim form_params : set form_params = FormCache.DeserializeForm("NewKitLabels")
  63. If Not form_params Is Nothing then
  64. set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  65. Else
  66. set Model = new Create_ViewModel_Class
  67. End If
  68. HTMLSecurity.SetAntiCSRFToken "KitLabelsCreateForm"
  69. %> <!--#include file="../../Views/KitLabels/Create.asp"--> <%
  70. End Sub
  71. Public Sub CreatePost
  72. MVC.RequirePost
  73. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitLabelsCreateForm", Request.Form("nonce"), "Create"
  74. dim new_KitLabels_model : set new_KitLabels_model = Automapper.AutoMap(Request.Form, new KitLabelsModel_Class)
  75. 'new_KitLabels_model.Validator.Validate
  76. 'If new_KitLabels_model.Validator.HasErrors then
  77. ' FormCache.SerializeForm "NewKitLabels", Request.Form
  78. ' Flash.Errors = new_KitLabels_model.Validator.Errors
  79. ' MVC.RedirectToAction "Create"
  80. 'Else
  81. KitLabelsRepository.AddNew new_KitLabels_model
  82. ' FormCache.ClearForm "NewKitLabels"
  83. Flash.Success = "KitLabels added."
  84. MVC.RedirectToAction "Index"
  85. 'End If
  86. End Sub
  87. Public Sub Delete
  88. dim id : id = Request.QueryString("Id")
  89. set Model = new Delete_ViewModel_Class
  90. set Model.KitLabels = KitLabelsRepository.FindByID(id)
  91. Model.Title = "Delete KitLabels"
  92. HTMLSecurity.SetAntiCSRFToken "KitLabelsDeleteForm"
  93. %> <!--#include file="../../Views/KitLabels/Delete.asp"--> <%
  94. End Sub
  95. Public Sub DeletePost
  96. MVC.RequirePost
  97. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitLabelsDeleteForm", Request.Form("nonce"), "Create"
  98. dim id : id = Request.Form("Id")
  99. KitLabelsRepository.Delete id
  100. Flash.Success = "KitLabels deleted."
  101. MVC.RedirectToAction "Index"
  102. End Sub
  103. End Class
  104. MVC.Dispatch
  105. %>

Powered by TurnKey Linux.