25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.8KB

  1. <% Option Explicit %>
  2. <!--#include file="../../include_all.asp"-->
  3. <!--#include file="../../ViewModels/JurisdictionViewModels.asp"-->
  4. <%
  5. Class JurisdictionController
  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 = "Jurisdiction"
  13. set Model.Jurisdiction = JurisdictionRepository.FindPaged(empty, "JCode", 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/Jurisdiction/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 = "Jurisdiction"
  27. set Model.Jurisdiction = JurisdictionRepository.SearchTablePaged(Array("JCode","%" & searchValue & "%","Name","%" & searchValue & "%","Mailing_Address","%" & searchValue & "%","CSZ","%" & searchValue & "%","IMB","%" & searchValue & "%","IMB_Digits","%" & searchValue & "%"),"JCode", 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/Jurisdiction/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.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  38. set Model.Contacts = ContactsRepository.Find(Array("JURISCODE = ?",id),empty)
  39. Model.Title = "Edit Jurisdiction"
  40. HTMLSecurity.SetAntiCSRFToken "JurisdictionEditForm"
  41. %> <!--#include file="../../Views/Jurisdiction/Edit.asp"--> <%
  42. Flash.Success = "Jurisdiction Updated."
  43. End Sub
  44. Public Sub EditPost
  45. MVC.RequirePost
  46. HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "JurisdictionEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id"))
  47. dim JCode : JCode = Request.Form("Id")
  48. dim model : set model = JurisdictionRepository.FindByJCode(JCode)
  49. set model = Automapper.AutoMap(Request.Form, model)
  50. 'model.Validate
  51. 'If model.Validator.HasErrors then
  52. FormCache.SerializeForm "EditJurisdiction", Request.Form
  53. ' Flash.Errors = model.Validator.Errors
  54. ' MVC.RedirectToActionExt "Edit", Array("Id",JCode)
  55. 'Else
  56. JurisdictionRepository.Update model
  57. FormCache.ClearForm "EditJurisdiction"
  58. Flash.Success = "Jurisdiction updated."
  59. MVC.RedirectToAction "Index"
  60. 'End If
  61. End Sub
  62. Public Sub Create
  63. dim form_params : set form_params = FormCache.DeserializeForm("NewJurisdiction")
  64. If Not form_params Is Nothing then
  65. set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)
  66. Else
  67. set Model = new Create_ViewModel_Class
  68. End If
  69. HTMLSecurity.SetAntiCSRFToken "JurisdictionCreateForm"
  70. %> <!--#include file="../../Views/Jurisdiction/Create.asp"--> <%
  71. End Sub
  72. Public Sub CreatePost
  73. MVC.RequirePost
  74. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "JurisdictionCreateForm", Request.Form("nonce"), "Create"
  75. dim new_Jurisdiction_model : set new_Jurisdiction_model = Automapper.AutoMap(Request.Form, new JurisdictionModel_Class)
  76. 'new_Jurisdiction_model.Validator.Validate
  77. 'If new_Jurisdiction_model.Validator.HasErrors then
  78. ' FormCache.SerializeForm "NewJurisdiction", Request.Form
  79. ' Flash.Errors = new_Jurisdiction_model.Validator.Errors
  80. ' MVC.RedirectToAction "Create"
  81. 'Else
  82. JurisdictionRepository.AddNew new_Jurisdiction_model
  83. ' FormCache.ClearForm "NewJurisdiction"
  84. Flash.Success = "Jurisdiction added."
  85. MVC.RedirectToAction "Index"
  86. 'End If
  87. End Sub
  88. Public Sub Delete
  89. dim id : id = Request.QueryString("Id")
  90. set Model = new Delete_ViewModel_Class
  91. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  92. Model.Title = "Delete Jurisdiction"
  93. HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm"
  94. %> <!--#include file="../../Views/Jurisdiction/Delete.asp"--> <%
  95. End Sub
  96. Public Sub DeletePost
  97. MVC.RequirePost
  98. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "JurisdictionDeleteForm", Request.Form("nonce"), "Create"
  99. dim id : id = Request.Form("Id")
  100. JurisdictionRepository.Delete id
  101. Flash.Success = "Jurisdiction deleted."
  102. MVC.RedirectToAction "Index"
  103. End Sub
  104. Public Sub Createkit
  105. dim id : id = Request.QueryString("Id")
  106. set Model = new Delete_ViewModel_Class
  107. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  108. Model.Title = "Create Kit"
  109. HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm"
  110. %> <!--#include file="../../Views/Jurisdiction/createkit.asp"--> <%
  111. End sub
  112. Public Sub CreateKitPost
  113. MVC.RequirePost
  114. HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "CreateKitForm", Request.Form("nonce"), "Index"
  115. dim id : id = Request.QueryString("Id")
  116. set Model = new Delete_ViewModel_Class
  117. set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id)
  118. Model.Title = "Create Kit"
  119. HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm"
  120. %> <!--#include file="../../Views/Jurisdiction/createkit.asp"--> <%
  121. End sub
  122. Public Sub Import
  123. dim page_size : page_size = 10
  124. dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1)
  125. dim page_count, record_count
  126. set Model = new PagedIndex_ViewModel_Class
  127. Model.Title = "Jurisdiction"
  128. set Model.Jurisdiction = JurisdictionRepository.FindPaged(empty, "JCode", page_size, page_num, page_count, record_count)
  129. Model.CurrentPageNumber = page_num
  130. Model.PageSize = page_size
  131. Model.PageCount = page_count
  132. 'Model.RecordCount = record_count
  133. %> <!--#include file="../../Views/Jurisdiction/import.asp"--> <%
  134. End Sub
  135. Public Sub ImportPost
  136. Dim Upload:Set Upload = New FreeASPUpload
  137. Upload.Save(server.mappath("/uploads"))
  138. Chilkat_CSV.LoadFile(Upload.UploadedFiles("filename").path)
  139. set Model = new PagedIndex_ViewModel_Class
  140. Model.RecordCount = Chilkat_CSV.NumRows
  141. Dim RowNumber
  142. On Error Resume Next
  143. for RowNumber = 1 to Model.RecordCount
  144. Dim Record: Set Record = JurisdictionRepository.FindByJCode(Chilkat_CSV.GetCell(CLng(RowNumber),0))
  145. Next
  146. On Error Goto 0
  147. %> <!--#include file="../../Views/Jurisdiction/import.asp"--> <%
  148. End Sub
  149. End Class
  150. MVC.Dispatch
  151. %>

Powered by TurnKey Linux.