Please Help Guys

Submitted by ayenvelasco on
Can somebody explain this code? ===============================================
  1. Option Explicit
  2.  
  3.  
  4. Public Const keySchoolYear = "scho"
  5.  
  6. Public Type tSchoolYear
  7.     SchoolYearTitle As String
  8.     Locked As Boolean
  9. End Type
  10.  
  11. Public Type tSemester
  12.     SemesterID As String
  13.     Semester As String
  14. End Type
  15.  
  16. Public Function SchoolYearRecordExisted() As TranDBResult
  17.  
  18.     Dim vRS As New ADODB.Recordset
  19.    
  20.  
  21.     If CreateDefaultrsYear(vRS) <> Success Then
  22.         SchoolYearRecordExisted = Failed
  23.         GoTo ReleaseAndExit
  24.     End If
  25.    
  26.  
  27.     If AnyRecordExisted(vRS) = True Then
  28.         SchoolYearRecordExisted = Success
  29.     Else
  30.         SchoolYearRecordExisted = Failed
  31.     End If
  32.    
  33. ReleaseAndExit:
  34.     Set vRS = Nothing
  35. End Function
  36.  
  37. Public Function AddSchoolYear(newSchoolYear As tSchoolYear) As TranDBResult
  38.  
  39.    
  40.     Dim vRS As New ADODB.Recordset
  41.    
  42.     'default
  43.     AddSchoolYear = Failed
  44.        
  45.     If CreateDefaultrsYear(vRS) <> Success Then
  46.         AddSchoolYear = NotConnected
  47.         GoTo ReleaseAndExit
  48.     End If
  49.    
  50.     If SchoolYearExistByTitle(newSchoolYear.SchoolYearTitle) = Success Then
  51.         AddSchoolYear = DuplicateTitle
  52.         GoTo ReleaseAndExit
  53.     End If
  54.    
  55.     vRS.AddNew
  56.    
  57.     vRS.Fields("schoolyear").Value = newSchoolYear.SchoolYearTitle
  58.     vRS.Fields("Locked").Value = newSchoolYear.Locked
  59.  
  60.  
  61.     vRS.Update
  62.  
  63.     AddSchoolYear = Success
  64.  
  65.    
  66.    
  67. ReleaseAndExit:
  68.     Set vRS = Nothing
  69. End Function
  70.  
  71. Public Function EditSchoolYear(OldSchoolYearTitle As String, newSchoolYear As tSchoolYear) As TranDBResult
  72.    
  73.     Dim vRS As New ADODB.Recordset
  74.    
  75.     If OldSchoolYearTitle = newSchoolYear.SchoolYearTitle Then
  76.         'nothing to process, hust return success
  77.         EditSchoolYear = Success
  78.     Else
  79.         'find duplicate
  80.         If SchoolYearExistByTitle(newSchoolYear.SchoolYearTitle) = Success Then
  81.             EditSchoolYear = DuplicateTitle
  82.         Else
  83.  
  84.             If ConnectRS(con, vRS, "SELECT  * From tblSchoolYear WHERE (((tblSchoolYear.SchoolYear)='" & OldSchoolYearTitle & "'));") Then
  85.            
  86.                 'edit
  87.                 vRS.MoveFirst
  88.                 vRS.Fields("schoolyear").Value = newSchoolYear.SchoolYearTitle
  89.                 vRS.Fields("Locked").Value = newSchoolYear.Locked
  90.  
  91.                 vRS.Update
  92.        
  93.                 EditSchoolYear = Success
  94.                 'edited
  95.             Else
  96.                 EditSchoolYear = Failed
  97.             End If
  98.         End If
  99.     End If
  100.        
  101.  
  102.     Set vRS = Nothing
  103. End Function
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110. Public Function ExecuteDeleteSchoolYear(sSchoolYearTitle As String) As TranDBResult
  111.    
  112.     Dim vSchoolYear As tSchoolYear
  113.     Dim DeleteResult As Integer
  114.     'default
  115.     ExecuteDeleteSchoolYear = Failed
  116.    
  117.     'check if record exist and if it is edited by other user
  118.     If MsgBox("WARNING:" & vbNewLine & _
  119.     "Deleting School Year Record will affect all other record" & vbNewLine & vbNewLine & _
  120.     "Delete this record anyway?", vbQuestion + vbYesNo) = vbYes Then
  121.    
  122.         If Len(sSchoolYearTitle) < 1 Then Exit Function
  123.        
  124.        
  125.         'delete file
  126.         DeleteResult = DeleteSchoolYear(sSchoolYearTitle)
  127.        
  128.         Select Case DeleteResult
  129.            
  130.             Case 1 'deleted
  131.                 MsgBox "School Year deleted.", vbInformation
  132.            
  133.             Case Else 'failed
  134.                 MsgBox "Deleting School Year went failed.", vbExclamation
  135.                
  136.         End Select
  137.        
  138.        
  139.     End If
  140.    
  141.     ExecuteDeleteSchoolYear = DeleteResult
  142. End Function
  143.  
  144.  
  145.  
  146.  
  147.  
  148. Public Function DeleteSchoolYear(sSchoolYearTitle As String) As TranDBResult
  149.    
  150.     Dim vRS As New ADODB.Recordset
  151.    
  152.         If ConnectRS(con, vRS, "DELETE tblSchoolYear.SchoolYear From tblSchoolYear WHERE (((tblSchoolYear.SchoolYear)='" & sSchoolYearTitle & "'));") Then
  153.             DeleteSchoolYear = Success
  154.         Else
  155.             DeleteSchoolYear = Failed
  156.         End If
  157.        
  158.     Set vRS = Nothing
  159. End Function
  160.  
  161.  
  162.  
  163. Public Function GetSchoolYearMoveNext(ByRef vRS As ADODB.Recordset, ByRef vSchoolYear As tSchoolYear) As TranDBResult
  164.     If Not vRS.EOF Then
  165.         vSchoolYear.SchoolYearTitle = vRS.Fields("schoolyear").Value
  166.         vSchoolYear.Locked = vRS.Fields("Lock").Value
  167.  
  168.         vRS.MoveNext
  169.         GetSchoolYearMoveNext = Success
  170.     Else
  171.         GetSchoolYearMoveNext = Failed
  172.     End If
  173.    
  174. End Function
  175.  
  176. Public Function SchoolYearExistByTitle(sSchoolYearTitle As String) As TranDBResult
  177.    
  178.     Dim vRS As New ADODB.Recordset
  179.    
  180.     'default
  181.     SchoolYearExistByTitle = Failed
  182.        
  183.     If CreateDefaultrsYear(vRS) <> 1 Then
  184.         SchoolYearExistByTitle = Failed
  185.         GoTo ReleaseAndExit
  186.     End If
  187.    
  188.     If AnyRecordExisted(vRS) Then
  189.         vRS.MoveFirst
  190.         vRS.Find "schoolyear= '" & sSchoolYearTitle & "'"
  191.        
  192.         If RecordNoMatch(vRS) Then
  193.             SchoolYearExistByTitle = Failed
  194.         Else
  195.             SchoolYearExistByTitle = Success
  196.         End If
  197.     Else
  198.         SchoolYearExistByTitle = Failed
  199.     End If
  200.    
  201.    
  202. ReleaseAndExit:
  203.     Set vRS = Nothing
  204. End Function
  205.  
  206.  
  207.  
  208. Public Function CreateDefaultrsYear(ByRef vRS As ADODB.Recordset) As TranDBResult
  209.     'default
  210.     CreateDefaultrsYear = Failed
  211.    
  212.     If ConnectRS(con, vRS, "SELECT * FROM tblSchoolYear") Then
  213.         CreateDefaultrsYear = Success
  214.     End If
  215. End Function
  216.  
  217. Public Function GetNextSchoolYear(sOldSchoolYear As String, ByRef newSchoolYear As String) As TranDBResult
  218.     Dim vRS As New ADODB.Recordset
  219.     Dim sSQL As String
  220.    
  221.     sSQL = "SELECT tblSchoolYear.SchoolYear" & _
  222.         " From tblSchoolYear" & _
  223.         " Where (((Val(Left([tblSchoolYear]![SchoolYear], 4))) > " & Left(sOldSchoolYear, 4) & "))" & _
  224.         " ORDER BY tblSchoolYear.SchoolYear;"
  225.    
  226.     If ConnectRS(con, vRS, sSQL) = True Then
  227.         newSchoolYear = (vRS.Fields("SchoolYear"))
  228.         GetNextSchoolYear = Success
  229.     Else
  230.         GetNextSchoolYear = Failed
  231.     End If
  232.    
  233.    
  234.     Set vRS = Nothing
  235. End Function
  236.  
  237.  
  238.  
  239. Public Function GetSchoolYearByTitle(sSchoolYearTitle As String, ByRef vSchoolYear As tSchoolYear) As TranDBResult
  240.    
  241.     Dim vRS As New ADODB.Recordset
  242.     Dim sSQL As String
  243.    
  244.     'default
  245.     GetSchoolYearByTitle = Failed
  246.        
  247.     sSQL = "SELECT * FROM tblSchoolYear WHERE tblSchoolYear.SchoolYear='" & sSchoolYearTitle & "'"
  248.      
  249.     If ConnectRS(con, vRS, sSQL) = False Then
  250.         GetSchoolYearByTitle = Failed
  251.         GoTo ReleaseAndExit
  252.     End If
  253.    
  254.     If AnyRecordExisted(vRS) Then
  255.    
  256.         vSchoolYear.SchoolYearTitle = sSchoolYearTitle
  257.         vSchoolYear.Locked = (vRS.Fields("Locked"))
  258.    
  259.         GetSchoolYearByTitle = Success
  260.  
  261.     Else
  262.         GetSchoolYearByTitle = Failed
  263.     End If
  264.    
  265.    
  266. ReleaseAndExit:
  267.     Set vRS = Nothing
  268. End Function
  269. Public Function GetSemesterByTitle(sSemesterTitle As String, ByRef vSem As tSemester) As TranDBResult
  270.  
  271.     Dim vRS As New ADODB.Recordset
  272.        
  273.     If ConnectRS(con, vRS, "SELECT *  FROM tbSemester WHERE (((tblDepartment.Semester)='" & sSemesterTitle & "'));") Then
  274.         If vRS.RecordCount > 0 Then
  275.             vSem.SemesterID = vRS.Fields("SemesterID").Value
  276.             vSem.Semester = vRS.Fields("Semester").Value
  277.             GetSemesterByTitle = Success
  278.         Else
  279.             GetSemesterByTitle = Failed
  280.         End If
  281.     Else
  282.         GetSemesterByTitle = Failed
  283.     End If
  284.    
  285.     Set vRS = Nothing
  286. End Function
  287.  
  288. Public Function SaveActiveSchoolYear(sSYTitle As String)
  289.     SaveSetting App.Title, "DataSetting", "activeschoolyear", sSYTitle
  290. End Function
  291.  
  292. Public Function GetActiveSchoolYear() As String
  293.     GetActiveSchoolYear = GetSetting(App.Title, "DataSetting", "activeschoolyear", "0000")
  294. End Function
  295.  
  296. Public Function SaveActiveSemester(sSemester As String)
  297.     SaveSetting App.Title, "DataSetting", "activesemester", sSemester
  298. End Function
  299. Public Function GetActiveSemester() As String
  300.      GetActiveSemester = GetSetting(App.Title, "DataSetting", "activesemester", "0000")
  301. End Function