您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

KitController.asp 9.7KB

8 个月前
8 个月前
8 个月前
8 个月前
8 个月前
8 个月前
8 个月前
8 个月前
8 个月前
8 个月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/KitViewModels.asp"-->
  4. <%
  5. Class KitController
  6. Public Model
  7. Public Sub SwitchBoardIndex
  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 = "Tracking Kits"
  13. set Model.Kit = KitRepository.PagedIndexView(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/Kit/SwitchBoardIndex.asp"--> <%
  19. End Sub
  20. Public Sub SwitchBoardPurpleEnvelopsIndex
  21. dim page_size : page_size = 10
  22. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  23. dim page_count, record_count
  24. set Model = new SwitchBoard_PurpleEnvelopesViewModel_Class
  25. Model.Title = "Purple Envelope Kits"
  26. set Model.Kit = KitRepository.PagedPurpleEnvelopsIndexView(page_size, page_num, page_count, record_count)
  27. Model.CurrentPageNumber = page_num
  28. Model.PageSize = page_size
  29. Model.PageCount = page_count
  30. Model.RecordCount = record_count
  31. %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeIndex.asp"--> <%
  32. End Sub
  33. Public Sub SwitchBoardPurpleEnvelopeEditPost
  34. MVC.RequirePost
  35. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  36. dim ID : ID = Request.Form("Id")
  37. dim model : set model = KitRepository.FindByID(ID)
  38. set model = Automapper.AutoMap(Request.Form, model)
  39. if Request.Form("InBoundTracking") = "on" Then
  40. model.InboundSTID = SettingsRepository.FindByName("Inbound STID")
  41. end if
  42. model.Status = "Ready to Assign Labels"
  43. 'model.Validate
  44. 'If model.Validator.HasErrors then
  45. FormCache.SerializeForm "EditKit", Request.Form
  46. ' Flash.Errors = model.Validator.Errors
  47. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  48. 'Else
  49. KitRepository.Update model
  50. FormCache.ClearForm "EditKit"
  51. Flash.Success = "Kit updated."
  52. MVC.RedirectToAction "Index"
  53. 'End If
  54. End Sub
  55. Public Sub SwitchBoardPurpleEnvelopeEdit
  56. dim id : id = Request.QueryString("Id")
  57. set Model = new SwitchBoard_ViewModel_Class
  58. set Model.Kit = KitRepository.SwitchBoardPurpleEnvelopeEditFindById(id)
  59. set Model.Labels = InkjetRecordsRepository.Find(Array("KitId =?",id),empty)
  60. set Model.StidDropDown = SettingsRepository.GetStidDropDownRS()
  61. Model.Title = "Purple Envelopes for "
  62. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  63. %> <!--#include file="../../Views/Kit/SwitchBoardPurpleEnvelopeEdit.asp"--> <%
  64. End Sub
  65. Public Sub Index
  66. dim page_size : page_size = 10
  67. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  68. dim page_count, record_count
  69. set Model = new PagedIndex_ViewModel_Class
  70. Model.Title = "Tracking Kits"
  71. set Model.Kit = KitRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count)
  72. Model.CurrentPageNumber = page_num
  73. Model.PageSize = page_size
  74. Model.PageCount = page_count
  75. Model.RecordCount = record_count
  76. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  77. End Sub
  78. Public Sub Search
  79. dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))
  80. dim page_size : page_size = 10
  81. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  82. dim page_count, record_count
  83. set Model = new PagedIndex_ViewModel_Class
  84. Model.Title = "Kit"
  85. set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count)
  86. Model.CurrentPageNumber = page_num
  87. Model.PageSize = page_size
  88. Model.PageCount = page_count
  89. Model.RecordCount = record_count
  90. %> <!--#include file="../../Views/Kit/Index.asp"--> <%
  91. End Sub
  92. Public Sub SwitchBoardEdit
  93. dim id : id = Request.QueryString("Id")
  94. set Model = new SwitchBoard_ViewModel_Class
  95. set Model.Kit = KitRepository.SwitchBoardEditFindById(id)
  96. set Model.Labels = KitLabelsRepository.Find(Array("KitId =?",id),empty)
  97. Model.Title = "Kit for "
  98. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  99. %> <!--#include file="../../Views/Kit/SwitchBoardEdit.asp"--> <%
  100. End Sub
  101. Public Sub DownloadTrackingkitSnailWorks
  102. dim id : id = Request.QueryString("Id")
  103. dim Labels : Set Labels = KitLabelsRepository.Find(Array("KitID=?",id),empty)
  104. 'Response.Buffer = False
  105. Dim objStream:Set objStream = Server.CreateObject("ADODB.Stream")
  106. objStream.Type = 1 'adTypeBinary
  107. objStream.Open
  108. objStream.LoadFromFile(server.mappath("/uploads/MI Jurisdictions with IMB.csv"))
  109. 'Response.Flush
  110. Response.ContentType = "application/octet-stream"
  111. Response.Addheader "Content-Disposition", "attachment; filename=" & "MI Jurisdictions with IMB.csv"
  112. Response.BinaryWrite objStream.Read
  113. 'Response.End
  114. objStream.Close
  115. Set objStream = Nothing
  116. End Sub
  117. Public Sub Edit
  118. dim id : id = Request.QueryString("Id")
  119. set Model = new Edit_ViewModel_Class
  120. set Model.Kit = KitRepository.FindByID(id)
  121. Model.Title = "Edit Kit"
  122. HTMLSecurity.SetAntiCSRFToken "KitEditForm"
  123. %> <!--#include file="../../Views/Kit/Edit.asp"--> <%
  124. Flash.Success = "Kit Updated."
  125. End Sub
  126. Public Sub EditPost
  127. MVC.RequirePost
  128. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  129. dim ID : ID = Request.Form("Id")
  130. dim model : set model = KitRepository.FindByID(ID)
  131. set model = Automapper.AutoMap(Request.Form, model)
  132. 'model.Validate
  133. 'If model.Validator.HasErrors then
  134. FormCache.SerializeForm "EditKit", Request.Form
  135. ' Flash.Errors = model.Validator.Errors
  136. ' MVC.RedirectToActionExt "Edit", Array("Id",ID)
  137. 'Else
  138. KitRepository.Update model
  139. FormCache.ClearForm "EditKit"
  140. Flash.Success = "Kit updated."
  141. MVC.RedirectToAction "Index"
  142. 'End If
  143. End Sub
  144. Public Sub CreateTrackingKit
  145. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  146. dim ID : ID = Request.QueryString("Id")
  147. dim model : set model = new Create_ViewModel_Class
  148. model.Title = "Create Kit "
  149. model.JCode = ID
  150. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  151. set model.Jurisdiction = ugh.pop()
  152. 'If Not form_params Is Nothing then
  153. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  154. 'Else
  155. ' set Model = new Create_ViewModel_Class
  156. 'End If
  157. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  158. %> <!--#include file="../../Views/Kit/CreateTrackingKit.asp"--> <%
  159. End Sub
  160. Public Sub Create
  161. dim form_params : set form_params = FormCache.DeserializeForm("NewKit")
  162. dim ID : ID = Request.QueryString("Id")
  163. dim model : set model = new Create_ViewModel_Class
  164. model.Title = "Create Kit "
  165. model.JCode = ID
  166. dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty)
  167. set model.Jurisdiction = ugh.pop()
  168. 'If Not form_params Is Nothing then
  169. ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  170. 'Else
  171. ' set Model = new Create_ViewModel_Class
  172. 'End If
  173. HTMLSecurity.SetAntiCSRFToken "KitCreateForm"
  174. %> <!--#include file="../../Views/Kit/Create.asp"--> <%
  175. End Sub
  176. Public Sub CreatePost
  177. MVC.RequirePost
  178. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  179. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  180. 'new_Kit_model.Validator.Validate
  181. 'If new_Kit_model.Validator.HasErrors then
  182. ' FormCache.SerializeForm "NewKit", Request.Form
  183. ' Flash.Errors = new_Kit_model.Validator.Errors
  184. ' MVC.RedirectToAction "Create"
  185. 'Else
  186. KitRepository.AddNew new_Kit_model
  187. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  188. ' FormCache.ClearForm "NewKit"
  189. Flash.Success = "Kit added."
  190. MVC.RedirectToAction "Index"
  191. 'End If
  192. End Sub
  193. Public Sub CreateTrackingKitPost
  194. MVC.RequirePost
  195. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create"
  196. dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class)
  197. 'new_Kit_model.Validator.Validate
  198. 'If new_Kit_model.Validator.HasErrors then
  199. ' FormCache.SerializeForm "NewKit", Request.Form
  200. ' Flash.Errors = new_Kit_model.Validator.Errors
  201. ' MVC.RedirectToAction "Create"
  202. 'Else
  203. KitRepository.AddNew new_Kit_model
  204. KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount")
  205. ' FormCache.ClearForm "NewKit"
  206. Flash.Success = "Kit added."
  207. MVC.RedirectToAction "Index"
  208. 'End If
  209. End Sub
  210. Public Sub Delete
  211. dim id : id = Request.QueryString("Id")
  212. set Model = new Delete_ViewModel_Class
  213. set Model.Kit = KitRepository.FindByID(id)
  214. Model.Title = "Delete Kit"
  215. HTMLSecurity.SetAntiCSRFToken "KitDeleteForm"
  216. %> <!--#include file="../../Views/Kit/Delete.asp"--> <%
  217. End Sub
  218. Public Sub DeletePost
  219. MVC.RequirePost
  220. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create"
  221. dim id : id = Request.Form("Id")
  222. KitRepository.Delete id
  223. Flash.Success = "Kit deleted."
  224. MVC.RedirectToAction "Index"
  225. End Sub
  226. End Class
  227. MVC.Dispatch
  228. %>

Powered by TurnKey Linux.