Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sorry Sir Nagkarambol-rambol na ang error ko :(
- Form1
- Private Sub login()
- Module3.getconnected
- Dim rs As New ADODB.Recordset
- rs.Open "Select * From tblUser where username= '" & Text1 & "'", con, adOpenStatic, adLockReadOnly
- If rs.RecordCount < 1 Then
- MsgBox "Username is invalid", vbInformation, "Login"
- Text1.SetFocus
- Exit Sub
- Else
- If Text2.Text = rs!Password Then
- Unload Me
- Load Form2
- Form2.Show
- Exit Sub
- Else
- MsgBox "Password is invalid", vbInformation, "Login"
- Text2.SetFocus
- Exit Sub
- End If
- End If
- Set rs = Nothing
- End Sub
- Private Sub Command1_Click()
- If Text1.Text = "" Then
- MsgBox "Username is Empty"
- Text1.SetFocus
- Exit Sub
- ElseIf Text2.Text = "" Then
- MsgBox "password is Empty"
- Text2.SetFocus
- Exit Sub
- Else
- Call login
- End If
- End Sub
- Private Sub Command2_Click()
- Form1.Hide
- Form3.Show
- End Sub
- Private Sub Form_Load()
- Text2.PasswordChar = "*"
- End Sub
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text2.SetFocus
- End If
- End Sub
- Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
- If KeyCode = vbKeyReturn Then
- KeyCode = 0
- Call Command1_Click
- End If
- End Sub
- Form2
- Dim myLS As New Class1
- Dim cat As String
- Dim Title As String
- Dim Author As String
- Dim Description As String
- Dim Category As String
- Private Sub Command1_Click()
- myLS.Add Text1, Text2, Text3, Text4
- myLS.showdb Grid1
- End Sub
- Private Sub Command2_Click()
- myLS.Update Text1, Text2, Text3, Text4
- myLS.showdb Grid1
- End Sub
- Private Sub Command3_Click()
- myLS.Delete Text1
- myLS.showdb Grid1
- End Sub
- Private Sub Command4_Click()
- Form2.Hide
- Form3.Show
- End Sub
- Private Sub Command5_Click()
- End
- End Sub
- Private Sub Form_Load()
- Set myLS = New Class1
- myLS.showdb Grid1
- cat = "Book Title"
- Option1.Value = True
- End Sub
- Private Sub Grid1_DblClick()
- With Grid1
- .Col = 1
- Text1.Text = .Text
- Text1 = .Text
- .Col = 2
- Text2.Text = .Text
- .Col = 3
- Text3.Text = .Text
- .Col = 4
- Text4.Text = .Text
- End With
- End Sub
- Private Sub Option1_Click()
- cat = "Title"
- End Sub
- Private Sub Option2_Click()
- cat = "Author"
- End Sub
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text2.SetFocus
- End If
- End Sub
- Private Sub Text2_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text3.SetFocus
- End If
- End Sub
- Private Sub Text3_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text4.SetFocus
- End If
- End Sub
- Private Sub Text4_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text1.SetFocus
- End If
- End Sub
- Private Sub Text5_Change()
- myLS.searchoption Grid1, cat, Text5
- With Grid1
- .Col = 1
- Text1.Text = .Text
- Text = .Text
- .Col = 2
- Text2.Text = .Text
- .Col = 3
- Text3.Text = .Text
- .Col = 4
- Text4.Text = .Text
- End With
- End Sub
- Form3
- Dim myLSS As New Class2
- Dim catt As String
- Dim UserID As String
- Dim Firstname As String
- Dim Lastname As String
- Dim Address As String
- Dim Age As String
- Dim Gender As String
- Dim IDNumber As String
- Dim Course As String
- Dim YearSection As String
- Dim Username As String
- Dim Password As String
- Private Sub Command1_Click()
- myLSS.AddNa Text1, Text2, Text3, Text4, Text5, Text6, Text7, Text8, Text9, Text10, Text11
- myLSS.showdbb Grid2
- End Sub
- Private Sub Command2_Click()
- myLSS.UpdateNa Text1, Text2, Text3, Text4, Text5, Text6, Text7, Text8, Text9, Text10, Text11
- myLSS.showdbb Grid2
- End Sub
- Private Sub Command3_Click()
- myLSS.DeleteNa Text1
- myLSS.showdbb Grid2
- End Sub
- Private Sub Form_Load()
- Set myLSS = New Class2
- myLSS.showdbb Grid2
- catt = "Firstname"
- Option1.Value = True
- End Sub
- Private Sub Grid2_DblClick()
- With Grid2
- .Col = 1
- Text1.Text = .Text
- Text1 = .Text
- .Col = 2
- Text2.Text = .Text
- .Col = 3
- Text3.Text = .Text
- .Col = 4
- Text4.Text = .Text
- .Col = 5
- Text5.Text = .Text
- .Col = 6
- Text6.Text = .Text
- .Col = 7
- Text7.Text = .Text
- .Col = 8
- Text8.Text = .Text
- .Col = 9
- Text9.Text = .Text
- .Col = 10
- Text10.Text = .Text
- .Col = 11
- Text11.Text = .Text
- End With
- End Sub
- Private Sub Option1_Click()
- catt = "Firstname"
- End Sub
- Private Sub Option2_Click()
- catt = "Lastname"
- End Sub
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text2.SetFocus
- End If
- End Sub
- Private Sub Text10_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text11.SetFocus
- End If
- End Sub
- Private Sub Text11_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text1.SetFocus
- End If
- End Sub
- Private Sub Text12_Change()
- myLSS.searchoptionNa Grid2, catt, Text12
- With Grid2
- .Col = 1
- Text1.Text = .Text
- Text1 = .Text
- .Col = 2
- Text2.Text = .Text
- .Col = 3
- Text3.Text = .Text
- .Col = 4
- Text4.Text = .Text
- .Col = 5
- Text5.Text = .Text
- .Col = 6
- Text6.Text = .Text
- .Col = 7
- Text7.Text = .Text
- .Col = 8
- Text8.Text = .Text
- .Col = 9
- Text9.Text = .Text
- .Col = 10
- Text10.Text = .Text
- .Col = 11
- Text11.Text = .Text
- End With
- End Sub
- Private Sub Text2_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text3.SetFocus
- End If
- End Sub
- Private Sub Text3_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text4.SetFocus
- End If
- End Sub
- Private Sub Text4_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text5.SetFocus
- End If
- End Sub
- Private Sub Text5_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text6.SetFocus
- End If
- End Sub
- Private Sub Text6_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text7.SetFocus
- End If
- End Sub
- Private Sub Text7_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text8.SetFocus
- End If
- End Sub
- Private Sub Text8_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text9.SetFocus
- End If
- End Sub
- Private Sub Text9_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then
- Text10.SetFocus
- End If
- End Sub
- Module1
- Public Function dbpath()
- dbpath = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Loriebelle\Documents\1AVisual Basic Output Files\Database\The Library System Database Made by Yanz.mdb;Persist Security Info=False"
- End Function
- Module2
- Public Function dbpathh()
- dbpathh = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Loriebelle\Documents\1AVisual Basic Output Files\Database\The Library System Database Made by Yanz.mdb;Persist Security Info=False"
- End Function
- Module3
- Option Explicit
- Public con As ADODB.Connection
- Public Sub getconnected()
- Set con = New ADODB.Connection
- con.CursorLocation = adUseClient
- con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Loriebelle\Desktop\Handouts\Final Library System\The Library System Database Made by Yanz.mdb;Persist Security Info=False"
- con.Open
- End Sub
- Class1
- Dim rs As New ADODB.Recordset
- Dim conn As New ADODB.Connection
- Dim sql As String
- Private Sub Class_Initialize()
- Set rs = New ADODB.Recordset
- Set conn = New ADODB.Connection
- conn.Open Module1.dbpath
- With rs
- .LockType = adLockOptimistic
- .CursorLocation = adUseClient
- .CursorType = adOpenDynamic
- End With
- End Sub
- Private Sub Class_Terminate()
- Set rs = Nothing
- Set conn = Nothing
- End Sub
- Public Function showdb(grd As MSHFlexGrid)
- If rs.State = 1 Then rs.Close
- sql = "select*from tblLibrary"
- rs.Open sql, conn
- Set grd.DataSource = rs
- End Function
- Public Function Add(Text1 As String, Text2 As String, Text3 As String, Text4 As String)
- If rs.State = 1 Then rs.Close
- rs.Open sql, conn
- With rs
- .AddNew
- !Title = Text1
- !Author = Text2
- !Description = Text3
- !Category = Text4
- .Update
- End With
- MsgBox "Yes Na Save !", vbOKOnly
- End Function
- Public Function Update(Text1 As String, Text2 As String, Text3 As String, Text4 As String)
- If rs.State = 1 Then rs.Close
- sql = "select*from tblLibrary where Title = '" & Text1 & "' "
- rs.Open sql, conn
- With rs
- .Update
- !Title = Text1
- !Author = Text2
- !Description = Text3
- !Category = Text4
- .Update
- End With
- MsgBox "Updated Na !", vbOKOnly
- End Function
- Public Function Delete(Text1 As String)
- If rs.State = 1 Then rs.Close
- sql = "Delete*from tblLibrary where Title= '" & Text1 & "' "
- rs.Open sql, conn
- MsgBox "Hala Nga a Gin DELETE mo !!", vbOKOnly
- End Function
- Public Function searchoption(grd As MSHFlexGrid, Category As String, Search As String)
- If rs.State = 1 Then rs.Close
- sql = "select*from tblLibrary where " & Category & " like '%" & Search & "%'"
- rs.Open sql, conn
- Set grd.DataSource = rs
- End Function
- Class2
- Dim rs As New ADODB.Recordset
- Dim conn As New ADODB.Connection
- Dim sql As String
- Private Sub Class_Initialize()
- Set rs = New ADODB.Recordset
- Set conn = New ADODB.Connection
- conn.Open Module2.dbpathh
- With rs
- .LockType = adLockOptimistic
- .CursorLocation = adUseClient
- .CursorType = adOpenDynamic
- End With
- End Sub
- Private Sub Class_Terminate()
- Set rs = Nothing
- Set conn = Nothing
- End Sub
- Public Function showdbb(grd As MSHFlexGrid)
- If rs.State = 1 Then rs.Close
- sql = "select*from tblUser"
- rs.Open sql, conn
- Set grd.DataSource = rs
- End Function
- Public Function AddNa(Text1 As String, Text2 As String, Text3 As String, Text4 As String, Text5 As String, Text6 As String, Text7 As String, Text8 As String, Text9 As String, Text10 As String, Text11 As String)
- If rs.State = 1 Then rs.Close
- rs.Open sql, conn
- With rs
- .AddNew
- !Firstname = Text1
- !Lastname = Text2
- !MI = Text3
- !Address = Text4
- !Age = Text5
- !Gender = Text6
- !IDNumber = Text7
- !Course = Text8
- !YearSection = Text9
- !Username = Text10
- !Password = Text11
- .Update
- End With
- MsgBox "Yes Na Save !", vbOKOnly
- End Function
- Public Function UpdateNa(Text1 As String, Text2 As String, Text3 As String, Text4 As String, Text5 As String, Text6 As String, Text7 As String, Text8 As String, Text9 As String, Text10 As String, Text11 As String)
- If rs.State = 1 Then rs.Close
- sql = "select*from tblUser where Firstname = '" & Text1 & "' "
- rs.Open sql, conn
- With rs
- .Update
- !Firstname = Text1
- !Lastname = Text2
- !MI = Text3
- !Address = Text4
- !Age = Text5
- !Gender = Text6
- !IDNumber = Text7
- !Course = Text8
- !YearSection = Text9
- !Username = Text10
- !Password = Text11
- .Update
- End With
- MsgBox "Updated Na !", vbOKOnly
- End Function
- Public Function DeleteNa(Text1 As String)
- If rs.State = 1 Then rs.Close
- sql = "Delete*from tblUser where Firstname= '" & Text1 & "' "
- rs.Open sql, conn
- MsgBox "Hala Nga a Gin DELETE mo !!", vbOKOnly
- End Function
- Public Function searchoptionNa(grd As MSHFlexGrid, Category As String, Search As String)
- If rs.State = 1 Then rs.Close
- sql = "select*from tblUser where " & Category & " like '%" & Search & "%'"
- rs.Open sql, conn
- Set grd.DataSource = rs
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement