From 7951df57155b5c0eaee88f14d5aae9f482a5591c Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Mon, 20 May 2024 16:20:20 -0400 Subject: [PATCH] More cleanup of views and controllers --- App/Controllers/Home/HomeController.asp | 2 +- App/Controllers/Kit/KitController.asp | 43 +++++++++++++ App/DomainModels/KitRepository.asp | 39 +++++++++--- App/Views/Home/createTrackingKit.asp | 73 ++++++++++++++++++++++ App/Views/Kit/createTrackingKit.asp | 32 ++++++++++ App/Views/Kit/delete.asp | 80 +++++++++++++++++++++++++ App/Views/Kit/edit.asp | 80 +++++++++++++++++++++++++ App/Views/Kit/index.asp | 23 ++++++- 8 files changed, 362 insertions(+), 10 deletions(-) create mode 100644 App/Views/Home/createTrackingKit.asp create mode 100644 App/Views/Kit/createTrackingKit.asp diff --git a/App/Controllers/Home/HomeController.asp b/App/Controllers/Home/HomeController.asp index 60e2c96..3030697 100644 --- a/App/Controllers/Home/HomeController.asp +++ b/App/Controllers/Home/HomeController.asp @@ -20,7 +20,7 @@ Class HomeController Model.PageSize = page_size Model.PageCount = page_count Model.RecordCount = record_count - %> <% + %> <% End Sub Public Sub Search diff --git a/App/Controllers/Kit/KitController.asp b/App/Controllers/Kit/KitController.asp index 59c95b3..d497ccd 100644 --- a/App/Controllers/Kit/KitController.asp +++ b/App/Controllers/Kit/KitController.asp @@ -143,7 +143,27 @@ Class KitController MVC.RedirectToAction "Index" 'End If End Sub + Public Sub CreateTrackingKit + dim form_params : set form_params = FormCache.DeserializeForm("NewKit") + + dim ID : ID = Request.QueryString("Id") + dim model : set model = new Create_ViewModel_Class + model.Title = "Create Kit " + model.JCode = ID + dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty) + set model.Jurisdiction = ugh.pop() + + 'If Not form_params Is Nothing then + ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) + 'Else + ' set Model = new Create_ViewModel_Class + 'End If + + HTMLSecurity.SetAntiCSRFToken "KitCreateForm" + + %> <% + End Sub Public Sub Create dim form_params : set form_params = FormCache.DeserializeForm("NewKit") @@ -189,6 +209,29 @@ Class KitController 'End If End Sub + Public Sub CreateTrackingKitPost + + MVC.RequirePost + HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create" + + dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class) + + 'new_Kit_model.Validator.Validate + + 'If new_Kit_model.Validator.HasErrors then + ' FormCache.SerializeForm "NewKit", Request.Form + ' Flash.Errors = new_Kit_model.Validator.Errors + ' MVC.RedirectToAction "Create" + 'Else + + KitRepository.AddNew new_Kit_model + KitLabelsRepository.BulkAdd new_Kit_model.ID,Request.Form("Amount") + ' FormCache.ClearForm "NewKit" + Flash.Success = "Kit added." + MVC.RedirectToAction "Index" + 'End If + End Sub + Public Sub Delete dim id : id = Request.QueryString("Id") set Model = new Delete_ViewModel_Class diff --git a/App/DomainModels/KitRepository.asp b/App/DomainModels/KitRepository.asp index c660f9e..96b64f9 100644 --- a/App/DomainModels/KitRepository.asp +++ b/App/DomainModels/KitRepository.asp @@ -10,10 +10,20 @@ Class KitModel_Class Public ID '90 Public JobNumber '106 Public Jcode '106 + Public CreatedOn '122 + Public LabelsPrinted '122 + Public ExportedToSnailWorks '122 + Public InkJetJob '90 + Public JobType '106 + Public Filename '106 + Public Cass '90 + Public Status '106 + Public OutboundSTID '106 + Public InboundSTID '106 Private Sub Class_Initialize 'ValidateExitsts Me, "","" - Class_Get_Properties = Array("ID, JobNumber, Jcode") + Class_Get_Properties = Array("ID, JobNumber, Jcode, CreatedOn, LabelsPrinted, ExportedToSnailWorks, InkJetJob, JobType, Filename, Cass, Status, OutboundSTID, InboundSTID") End Sub End CLass @@ -138,7 +148,7 @@ Class KitRepository_Class Public Function FindByID(ID) - dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit] WHERE ID = ?" + dim sql : sql = "Select [ID], [JobNumber], [Jcode], [CreatedOn], [LabelsPrinted], [ExportedToSnailWorks], [InkJetJob], [JobType], [Filename], [Cass], [Status], [OutboundSTID], [InboundSTID] FROM [Kit] WHERE ID = ?" dim rs : set rs = DAL.Query(sql,ID) If rs.EOF then Err.Raise 1, "KitRepository_Class", KitNotFoundException("ID", ID) @@ -152,7 +162,7 @@ Class KitRepository_Class End Function Public Function Find(where_kvarray, order_string_or_array) - dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]" + dim sql : sql = "Select [ID], [JobNumber], [Jcode], [CreatedOn], [LabelsPrinted], [ExportedToSnailWorks], [InkJetJob], [JobType], [Filename], [Cass], [Status], [OutboundSTID], [InboundSTID] FROM [Kit]" If Not IsEmpty(where_kvarray) then sql = sql & " WHERE " @@ -185,7 +195,7 @@ Class KitRepository_Class End Function Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) - dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]" + dim sql : sql = "Select [ID], [JobNumber], [Jcode], [CreatedOn], [LabelsPrinted], [ExportedToSnailWorks], [InkJetJob], [JobType], [Filename], [Cass], [Status], [OutboundSTID], [InboundSTID] FROM [Kit]" If Not IsEmpty(where_kvarray) then sql = sql & " WHERE " @@ -227,7 +237,7 @@ Class KitRepository_Class End Function Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) - dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]" + dim sql : sql = "Select [ID], [JobNumber], [Jcode], [CreatedOn], [LabelsPrinted], [ExportedToSnailWorks], [InkJetJob], [JobType], [Filename], [Cass], [Status], [OutboundSTID], [InboundSTID] FROM [Kit]" If Not IsEmpty(where_kvarray) then sql = sql & " WHERE " @@ -305,15 +315,21 @@ Class KitRepository_Class "VALUES (?,?,?,?)" DAL.Execute sql, Array(model.JobNumber, _ model.Jcode,Now(),"Labels") - sql = "SELECT TOP 1 ID FROM [Kit] ORDER BY ID DESC" + sql = "SELECT TOP 1 ID FROM [Kit] ORDER BY ID DESC" dim rs : set rs = DAL.Query(sql, empty) model.ID = rs("ID") Destroy rs End Sub - - Public Sub Update(model) +Public Sub Update(model) dim sql : sql = "UPDATE [Kit] SET [JobNumber] = ?," &_ "[Jcode] = ?," &_ + "[CreatedOn] = ?," &_ + "[LabelsPrinted] = ?," &_ + "[ExportedToSnailWorks] = ?," &_ + "[InkJetJob] = ?," &_ + "[JobType] = ?," &_ + "[Filename] = ?," &_ + "[Cass] = ?," &_ "[Status] = ?," &_ "[OutboundSTID] = ?," &_ "[InboundSTID] = ?" &_ @@ -321,6 +337,13 @@ Class KitRepository_Class DAL.Execute sql, Array(model.JobNumber, _ model.Jcode, _ + model.CreatedOn, _ + model.LabelsPrinted, _ + model.ExportedToSnailWorks, _ + model.InkJetJob, _ + model.JobType, _ + model.Filename, _ + model.Cass, _ model.Status, _ model.OutboundSTID, _ model.InboundSTID, _ diff --git a/App/Views/Home/createTrackingKit.asp b/App/Views/Home/createTrackingKit.asp new file mode 100644 index 0000000..96b1cef --- /dev/null +++ b/App/Views/Home/createTrackingKit.asp @@ -0,0 +1,73 @@ +

Create Kit

+
+
+ <%= H(Model.RecordCount) %> <%= Choice(Model.RecordCount >=2," Jurisdictions"," Jurisdiction") %> found. Showing <%= H(Model.PageSize) %> records per page. +
+
+ + <%= HTML.FormTag("Home", "Search", empty, empty) %> + +
+ +
+ + +
+
+ + +
+
+ + + + + + + + + + + + <% dim it : set it = Model.Jurisdiction.Iterator %> + <% dim Jurisdiction %> + <% While it.HasNext %> + <% set Jurisdiction = it.GetNext() %> + + + + + + + + <% Wend %> + +
JCodeNameMailing_AddressCSZ
<% = H(Jurisdiction.JCode) %><% = H(Jurisdiction.Name) %><% = H(Jurisdiction.Mailing_Address) %><% = H(Jurisdiction.CSZ) %> + <%= HTML.LinkToExt("", "Kit", "createTrackingKit", Array("Id", Jurisdiction.JCode), Array("class", "btn btn-primary")) %> +
+
+ <% If Model.CurrentPageNumber <> 1 then %> + <%= HTML.LinkToExt("", MVC.ControllerName, MVC.ActionName, Array("page_num", 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> +   + <%= HTML.LinkToExt("", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber - 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> +  + <% Else %> + +   + +   + <% End If %> + <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %> + <%= HTML.LinkToExt("", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber + 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> +   + <%= HTML.LinkToExt("", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.PageCount,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> +   + <% Else %> + +   + +   +<% End If %> +
+ \ No newline at end of file diff --git a/App/Views/Kit/createTrackingKit.asp b/App/Views/Kit/createTrackingKit.asp new file mode 100644 index 0000000..94553cb --- /dev/null +++ b/App/Views/Kit/createTrackingKit.asp @@ -0,0 +1,32 @@ +

<%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %> JCODE: <%= H(Model.JCODE) %>

+ +<%= HTML.FormTag("Kit", "CreatePost", empty, empty) %> +<%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitCreateForm")) %> +<%= HTML.Hidden("Jcode", Model.Jcode) %> +<%= HTML.Hidden("JobType", "Labels") %> +
+ +
+
+
+
+ + <%= HTML.TextboxExt("JobNumber", Model.JobNumber, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Amount", Model.Amount, Array("class", "form-control")) %> +
+
+
+

+ <%= HTML.Button("submit", " Create", "btn-primary") %> +    + <%= HTML.LinkToExt(" Cancel", "Kit", "Index", empty, Array("class", "btn btn-default")) %> +
+ + \ No newline at end of file diff --git a/App/Views/Kit/delete.asp b/App/Views/Kit/delete.asp index bcd49a0..f3db59c 100644 --- a/App/Views/Kit/delete.asp +++ b/App/Views/Kit/delete.asp @@ -26,6 +26,86 @@ +
+
+
+ + <%= HTML.TextboxExt("CreatedOn", Model.Kit.CreatedOn, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("LabelsPrinted", Model.Kit.LabelsPrinted, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("ExportedToSnailWorks", Model.Kit.ExportedToSnailWorks, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("InkJetJob", Model.Kit.InkJetJob, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("JobType", Model.Kit.JobType, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Filename", Model.Kit.Filename, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Cass", Model.Kit.Cass, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Status", Model.Kit.Status, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("OutboundSTID", Model.Kit.OutboundSTID, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("InboundSTID", Model.Kit.InboundSTID, Array("class", "form-control")) %> +
+
+
diff --git a/App/Views/Kit/edit.asp b/App/Views/Kit/edit.asp index 8a95dd3..7aa3470 100644 --- a/App/Views/Kit/edit.asp +++ b/App/Views/Kit/edit.asp @@ -18,6 +18,86 @@ +
+
+
+ + <%= HTML.TextboxExt("CreatedOn", Model.Kit.CreatedOn, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("LabelsPrinted", Model.Kit.LabelsPrinted, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("ExportedToSnailWorks", Model.Kit.ExportedToSnailWorks, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("InkJetJob", Model.Kit.InkJetJob, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("JobType", Model.Kit.JobType, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Filename", Model.Kit.Filename, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Cass", Model.Kit.Cass, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("Status", Model.Kit.Status, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("OutboundSTID", Model.Kit.OutboundSTID, Array("class", "form-control")) %> +
+
+
+
+
+
+ + <%= HTML.TextboxExt("InboundSTID", Model.Kit.InboundSTID, Array("class", "form-control")) %> +
+
+

<% = HTML.Button("submit", " Save", "btn-primary") %> diff --git a/App/Views/Kit/index.asp b/App/Views/Kit/index.asp index f88227e..2e1253e 100644 --- a/App/Views/Kit/index.asp +++ b/App/Views/Kit/index.asp @@ -2,7 +2,7 @@
<%= H(Model.RecordCount) %> Kit found. Showing <%= H(Model.PageSize) %> records per page. - <%'= HTML.LinkToExt(" New","Kit", "Create", empty, Array("class", "btn btn-xs btn-primary")) %> + <%= HTML.LinkToExt(" New","Kit", "Create", empty, Array("class", "btn btn-xs btn-primary")) %>
@@ -27,6 +27,17 @@ ID JobNumber Jcode + CreatedOn + LabelsPrinted + ExportedToSnailWorks + InkJetJob + JobType + Filename + Cass + Status + OutboundSTID + InboundSTID + @@ -41,6 +52,16 @@ <% = H(Kit.ID) %> <% = H(Kit.JobNumber) %> <% = H(Kit.Jcode) %> + <% = H(Kit.CreatedOn) %> + <% = H(Kit.LabelsPrinted) %> + <% = H(Kit.ExportedToSnailWorks) %> + <% = H(Kit.InkJetJob) %> + <% = H(Kit.JobType) %> + <% = H(Kit.Filename) %> + <% = H(Kit.Cass) %> + <% = H(Kit.Status) %> + <% = H(Kit.OutboundSTID) %> + <% = H(Kit.InboundSTID) %> <% Wend %>