|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <%
- '=======================================================================================================================
- ' CustomOfficeCopyJob Model
- '=======================================================================================================================
-
- Class CustomOfficeCopyJobModel_Class
- Public Validator
- Public Class_Get_Properties
-
- Public ID '90
- Public Jcode '106
- Public Precinct '106
- Public StartingBallotNumber '122
- Public Amount '122
- Public Status '106
- Public Donedate '122
-
- Private Sub Class_Initialize
- 'ValidateExitsts Me, "",""
- Class_Get_Properties = Array("ID, Jcode, Precinct, StartingBallotNumber, Amount, Status, Donedate")
- End Sub
-
- End CLass
-
- '=======================================================================================================================
- ' CustomOfficeCopyJob Repository
- '=======================================================================================================================
-
- Class CustomOfficeCopyJobRepository_Class
-
- Public Function FindByID(ID)
- dim sql : sql = "Select [ID], [Jcode], [Precinct], [StartingBallotNumber], [Amount], [Status], [Donedate] FROM [CustomOfficeCopyJob] WHERE ID = ?"
- dim rs : set rs = DAL.Query(sql,ID)
- If rs.EOF then
- Err.Raise 1, "CustomOfficeCopyJobRepository_Class", CustomOfficeCopyJobNotFoundException("ID", ID)
- Else
- set FindByID = Automapper.AutoMap(rs,"CustomOfficeCopyJobModel_Class")
- End If
- End Function
-
- Public Function GetAll(orderBy)
- set GetAll = Find(empty,orderBy)
- End Function
-
- Public Function Find(where_kvarray, order_string_or_array)
- dim sql : sql = "Select [ID], [Jcode], [Precinct], [StartingBallotNumber], [Amount], [Status], [Donedate] FROM [CustomOfficeCopyJob]"
-
- If Not IsEmpty(where_kvarray) then
- sql = sql & " WHERE "
- dim where_keys, where_values
- KVUnzip where_kvarray, where_keys, where_values
-
- dim i
- For i = 0 to UBound(where_keys)
- If i > 0 then sql = sql & " AND "
- sql = sql & " " & where_keys(i) & " "
- Next
- End If
-
- If Not IsEmpty(order_string_or_array) then
- sql = sql & "ORDER BY "
- If IsArray(order_string_or_array) then
- dim order_array : order_array = order_string_or_array
- For i = 0 to UBound(order_array)
- If i > 0 then sql = sql & ", "
- sql = sql & " " & order_array(i)
- Next
- Else
- sql = sql & order_string_or_array & " "
- End If
- End If
-
- dim rs : set rs = DAL.Query(sql, where_values)
- set Find = CustomOfficeCopyJobList(rs)
- Destroy rs
- 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], [Jcode], [Precinct], [StartingBallotNumber], [Amount], [Status], [Donedate] FROM [CustomOfficeCopyJob]"
-
- If Not IsEmpty(where_kvarray) then
- sql = sql & " WHERE "
- dim where_keys, where_values
- KVUnzip where_kvarray, where_keys, where_values
-
- dim i
- For i = 0 to UBound(where_keys)
- If i > 0 then sql = sql & " AND "
- sql = sql & " " & where_keys(i) & " "
- Next
- End If
-
- If Not IsEmpty(order_string_or_array) then
- sql = sql & "ORDER BY "
- If IsArray(order_string_or_array) then
- dim order_array : order_array = order_string_or_array
- For i = 0 to UBound(order_array)
- If i > 0 then sql = sql & ", "
- sql = sql & " " & order_array(i)
- Next
- Else
- sql = sql & order_string_or_array & " "
- End If
- End If
-
- dim list : set list = new LinkedList_Class
- dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
-
- If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
- rs.PageSize = per_page
- rs.AbsolutePage = page_num
- page_count = rs.PageCount
- record_count = rs.RecordCount
- End If
-
- set FindPaged = PagedCustomOfficeCopyJobList(rs, per_page)
- Destroy rs
- 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], [Jcode], [Precinct], [StartingBallotNumber], [Amount], [Status], [Donedate] FROM [CustomOfficeCopyJob]"
-
- If Not IsEmpty(where_kvarray) then
- sql = sql & " WHERE "
- dim where_keys, where_values
- KVUnzip where_kvarray, where_keys, where_values
-
- dim i
- For i = 0 to UBound(where_keys)
- If i > 0 then sql = sql & " OR"
- sql = sql & " " & where_keys(i) & " LIKE ?"
- Next
- End If
-
- If Not IsEmpty(order_string_or_array) then
- sql = sql & " ORDER BY "
- If IsArray(order_string_or_array) then
- dim order_array : order_array = order_string_or_array
- For i = 0 to UBound(order_array)
- If i > 0 then sql = sql & ", "
- sql = sql & " " & order_array(i)
- Next
- Else
- sql = sql & order_string_or_array & " "
- End If
- End If
-
- dim list : set list = new LinkedList_Class
- dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)
-
- If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then
- rs.PageSize = per_page
- rs.AbsolutePage = page_num
- page_count = rs.PageCount
- record_count = rs.RecordCount
- End If
-
- set SearchTablePaged = PagedCustomOfficeCopyJobList(rs, per_page)
- Destroy rs
- End Function
-
- Private Function PagedCustomOfficeCopyJobList(rs, per_page)
- dim list : set list = new LinkedList_Class
-
- dim x : x =0
- Do While x < per_page and Not rs.EOF
- list.Push Automapper.AutoMap(rs, new CustomOfficeCopyJobModel_Class)
- x = x +1
- rs.MoveNext
- Loop
- set PagedCustomOfficeCopyJobList = list
- End Function
-
- Private Function CustomOfficeCopyJobNotFoundException(ByVal field_name, ByVal field_val)
- CustomOfficeCopyJobNotFoundException = "CustomOfficeCopyJob was not found with " & field_name & " of '" & field_val & "'."
- End Function
-
- Private Function CustomOfficeCopyJobList(rs)
- dim list : set list = new LinkedList_Class
- dim model
-
- Do until rs.EOF
- set model = new CustomOfficeCopyJobModel_Class
- list.Push Automapper.AutoMap(rs, model)
- rs.MoveNext
- Loop
- set CustomOfficeCopyJobList = list
- End Function
-
- Public Sub AddNew(ByRef model)
- dim sql : sql = "INSERT INTO [CustomOfficeCopyJob] (" &_
- "[Jcode]," &_
- "[Precinct]," &_
- "[StartingBallotNumber]," &_
- "[Amount]," &_
- "[Status])" &_
- "VALUES (?,?,?,?,?)"
- DAL.Execute sql, Array(model.Jcode, _
- model.Precinct, _
- model.StartingBallotNumber, _
- model.Amount, _
- "Ready")
- sql = "SELECT TOP 1 ID FROM [CustomOfficeCopyJob] ORDER BY ID DESC"
- dim rs : set rs = DAL.Query(sql, empty)
- model.ID = rs("ID")
- Destroy rs
- End Sub
-
- Public Sub Update(model)
- dim sql : sql = "UPDATE [CustomOfficeCopyJob] SET [Jcode] = ?," &_
- "[Precinct] = ?," &_
- "[StartingBallotNumber] = ?," &_
- "[Amount] = ?," &_
- "[Status] = ?," &_
- "[Donedate] = ?" &_
- " WHERE [ID] = ?"
-
- DAL.Execute sql, Array(model.Jcode, _
- model.Precinct, _
- model.StartingBallotNumber, _
- model.Amount, _
- model.Status, _
- model.Donedate, _
- model.ID)
- End Sub
-
- Public Sub Delete(id)
- dim sql : sql = "DELETE FROM [CustomOfficeCopyJob] WHERE [ID] = ?"
- DAL.Execute sql, id
- End Sub
- End Class
-
- dim CustomOfficeCopyJobRepository__Singleton
- Function CustomOfficeCopyJobRepository()
- If IsEmpty(CustomOfficeCopyJobRepository__Singleton) then
- set CustomOfficeCopyJobRepository__Singleton = new CustomOfficeCopyJobRepository_Class
- End If
- set CustomOfficeCopyJobRepository = CustomOfficeCopyJobRepository__Singleton
- End Function
- %>
|