You are on page 1of 14

Private Sub Command1_Click()

On Error Resume Next


If rs.State = adStateOpen Then
rs.Close
End If
rs.Open "select * from login where UserName='" & txtusername & "' And
Log_Password='" & txtPassword & "'", conn, 1, 2
rec_count = rs.RecordCount
If rec_count = 0 Then
MsgBox "Invalid User Name Or Password"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
Else
If Check1.Value = 1 Then
strq = "update login set flag='1' where UserName='" & txtusername & "' And
Log_Password='" & txtPassword & "'"
conn.Execute strq
End If
Unload Me
MDIForm1.Show
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
frmChangePassword.Show
End Sub
Private Sub Form_Activate()
check_db
End Sub
Private Sub check_db()

If rs.State = adStateOpen Then rs.Close


strq = "select * from login where flag='1'"
rs.Open strq, conn, 1, 2
If rs.RecordCount = 0 Then
Exit Sub
Else
txtusername = rs(0)
txtPassword = rs(1)
Check1.Value = 1
strq = "update login set flag='0' where flag='1'"
conn.Execute strq
End If
End Sub
Private Sub txtPassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Command1_Click
End If
End Sub
Private Sub txtusername_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Command1_Click
End If
End Sub

Book Issue Form


Private Sub Command1_Click()
If Trim(Text1) = "" Then
MsgBox "Please Enter Member No."
Text1.SetFocus
Exit Sub
End If
If Trim(Text2) = "" Then
MsgBox "Please Enter Member No."
Text2.SetFocus

Exit Sub
End If
strq = "insert into issue values('" & Create_ID & "','" & Text1 & "','" &
Text2 & "','" & _
IssueDate & "','" & ReturnDate & "','" & "I" & "')"
conn.Execute strq
strq = "Update BookMaster set status='I' where bookno=" & Text1 & ""
conn.Execute strq
strq = "Update MemberMaster set status='B' where memno=" & Text2 & ""
conn.Execute strq
End Sub
Private Function Create_ID() As String
strq = "select max(id) from issue"
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open strq, conn, 1, 2
If IsNull(rs(0)) = True Then
Create_ID = "1"
Else
Create_ID = Trim(Str(rs(0) + 1))
End If
End Function
Private Sub clear_TextBox()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
For Each ctl In Controls
If TypeOf ctl Is MaskEdBox Then
ctl.Mask = ""
ctl.Text = ""
ctl.Mask = "##/##/####"
End If
Next
End Sub

Private Sub Command2_Click()


Unload Me
End Sub
Private Sub Form_Activate()
clear_TextBox
End Sub
Private Sub Form_Load()
Me.Top = 1545
Me.Left = 2640
End Sub
Private Sub IssueDate_GotFocus()
IssueDate = Format(Date, "MM/DD/YYYY")
End Sub
Private Sub IssueDate_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub MaskEdBox1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub ReturnDate_GotFocus()
If IsDate(IssueDate) = False Then
Exit Sub
End If
dd = DateAdd("d", 7, IssueDate)
ReturnDate = Format(dd, "MM/DD/YYYY")
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub Text1_LostFocus()
If Trim(Text1) <> "" Then
strq = "select * from membermaster where memno=" & Text1 & ""
If rs.State = adStateOpen Then rs.Close
rs.Open strq, conn, 1, 2
If rs.RecordCount = 0 Then
MsgBox "Member not Found"
Text1 = ""
Text1.SetFocus
Exit Sub
End If
If rs(8) <> "P" Then
MsgBox "This Member have already a book or meber is expired"
Text1 = ""
Text1.SetFocus
Exit Sub
End If
lblName = rs(1)
lblAddress = rs(2)
lblMemNo = rs(0)
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub Text2_LostFocus()
If Trim(Text2) <> "" Then
strq = "select * from bookmaster where bookno=" & Text2 & ""
If rs.State = adStateOpen Then rs.Close

rs.Open strq, conn, 1, 2


If rs.RecordCount = 0 Then
MsgBox "Member not Found"
Text1 = ""
Text1.SetFocus
Exit Sub
End If
If rs(8) <> "P" Then
MsgBox "This Book is not present this time"
Text2.SetFocus
Exit Sub
End If
lblCat = rs(1)
lblBName = rs(2)
lblAuthor = rs(4)
End If
End Sub

Issue Book View form


Private Sub populateGrid()
Grid.ColWidth(0) = 0
Grid.ColWidth(1) = 2505
Grid.ColWidth(2) = 2625
Grid.ColWidth(3) = 2025
Grid.ColWidth(4) = 1845
Grid.TextMatrix(0, 1) = "Member No."
Grid.TextMatrix(0, 2) = "Book No."
Grid.TextMatrix(0, 3) = "Date of Issue"
Grid.TextMatrix(0, 4) = "Date Of Return"
If rs.State = adStateOpen Then rs.Close
strq = "select * from Issue where status='I'"
rs.Open strq, conn, 1, 2
For i = 1 To rs.RecordCount
If Grid.TextMatrix(1, 0) <> "" Then
Grid.TextMatrix(i, 8) = rs(8)
Grid.Rows = Grid.Rows + 1
End If
Grid.TextMatrix(i, 0) = rs(0)

Grid.TextMatrix(i, 1) = rs(1)
Grid.TextMatrix(i, 2) = rs(2)
Grid.TextMatrix(i, 3) = rs(3)
Grid.TextMatrix(i, 4) = rs(4)
rs.MoveNext
Next
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub CmdClo_Click()
Unload Me
End Sub
Private Sub Form_Activate()
populateGrid
End Sub
Private Sub Form_Load()
Me.Top = 1545
Me.Left = 2640
End Sub

New Member Form


Private Sub Command1_Click()
strq = "insert into memberMaster values('" & lblMemNo & "','" & _
txtName & "','" & txtAddress & "','" & txtTele1 & "','" & txtTele2 & "','" &
txtemail & "','" & DOJ & "','" & DOE & "','" & "P" & "')"
conn.Execute strq
Form_Activate
End Sub
Public Function MEMno() As String
strq = "select max(memno) from membermaster"

If rs.State = adStateOpen Then


rs.Close
End If
rs.Open strq, conn, 1, 2
If IsNull(rs(0)) = True Then
lblMemNo = "100"
Else
lblMemNo = Trim(Str(rs(0) + 1))
End If
End Function
Private Sub clear_TextBox()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
For Each ctl In Controls
If TypeOf ctl Is MaskEdBox Then
ctl.Mask = ""
ctl.Text = ""
ctl.Mask = "##/##/####"
End If
Next
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Activate()
clear_TextBox
MEMno
End Sub
Private Sub Form_Load()
Me.Top = 1545
Me.Left = 2640
End Sub

Member View Form


Private Sub populateGrid()
Grid.ColWidth(0) = 945
Grid.ColWidth(1) = 1875
Grid.ColWidth(2) = 2535
Grid.ColWidth(3) = 1100
Grid.ColWidth(4) = 1100
Grid.ColWidth(5) = 1300
Grid.ColWidth(6) = 945
Grid.ColWidth(7) = 945
Grid.ColWidth(8) = 600
Grid.TextMatrix(0, 0) = "Mem. No."
Grid.TextMatrix(0, 1) = "Name"
Grid.TextMatrix(0, 2) = "Address"
Grid.TextMatrix(0, 3) = "Telephone1"
Grid.TextMatrix(0, 4) = "Telephone2"
Grid.TextMatrix(0, 5) = "Email"
Grid.TextMatrix(0, 6) = "DOJ"
Grid.TextMatrix(0, 7) = "DOE"
Grid.TextMatrix(0, 8) = "Status"
If rs.State = adStateOpen Then rs.Close
strq = "select * from memberMaster"
rs.Open strq, conn, 1, 2
For i = 1 To rs.RecordCount
If Grid.TextMatrix(1, 0) <> "" Then
Grid.TextMatrix(i, 8) = rs(8)
Grid.Rows = Grid.Rows + 1
End If
Grid.TextMatrix(i, 0) = rs(0)
Grid.TextMatrix(i, 1) = rs(1)
Grid.TextMatrix(i, 2) = rs(2)
Grid.TextMatrix(i, 3) = rs(3)
Grid.TextMatrix(i, 4) = rs(4)
Grid.TextMatrix(i, 5) = rs(5)
Grid.TextMatrix(i, 6) = rs(6)

Grid.TextMatrix(i, 7) = rs(7)
Grid.TextMatrix(i, 8) = rs(8)
rs.MoveNext
Next
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Me.Top = 0
Me.Left = 0
populateGrid
End Sub

New Book Form


Public Function Create_ID() As String
strq = "select max(id) from bookmaster"
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open strq, conn, 1, 2
If IsNull(rs(0)) = True Then
Create_ID = "1"
Else
Create_ID = Trim(Str(rs(0) + 1))
End If
End Function
Public Function Bookno() As String
strq = "select max(bookno) from bookmaster"
If rs.State = adStateOpen Then
rs.Close
End If
rs.Open strq, conn, 1, 2
If IsNull(rs(0)) = True Then
lblBookNo = "100"

Else
lblBookNo = Trim(Str(rs(0) + 1))
End If
End Function
Private Sub AuCombo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub CatCombo_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub Command1_Click()
strq = "insert into bookmaster values('" & Create_ID & "','" & _
CatCombo & "','" & txtBookName & "','" & lblBookNo & "','" & AuCombo
& "','" & txtPrice & "','" & txtPage & "','" & Date & "','" & "P" & "')"
conn.Execute strq
Form_Activate
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Activate()
clear_TextBox
Bookno
popCombo
populateGrid
End Sub
Private Sub clear_TextBox()
Dim ctl As Control
For Each ctl In Controls

If TypeOf ctl Is TextBox Then


ctl.Text = ""
End If
Next
End Sub
Private Sub popCombo()
If rs.State = adStateOpen Then rs.Close
strq = "select * from authormaster"
rs.Open strq, conn, 1, 2
For i = 1 To rs.RecordCount
AuCombo.AddItem rs(1)
rs.MoveNext
Next
If rs.State = adStateOpen Then rs.Close
strq = "select * from catMaster"
rs.Open strq, conn, 1, 2
For i = 1 To rs.RecordCount
CatCombo.AddItem rs(1)
rs.MoveNext
Next
End Sub
Private Sub populateGrid()
Grid.ColWidth(0) = 0
Grid.ColWidth(1) = 2260
Grid.ColWidth(2) = 2370
Grid.ColWidth(3) = 2355
Grid.ColWidth(4) = 1500
Grid.ColWidth(5) = 1500
Grid.ColWidth(6) = 1500
Grid.TextMatrix(0, 1) = "Category"
Grid.TextMatrix(0, 2) = "Name Of Book"
Grid.TextMatrix(0, 3) = "Author"
Grid.TextMatrix(0, 4) = "Book No."
Grid.TextMatrix(0, 5) = "Price"
Grid.TextMatrix(0, 6) = "Date"
End Sub
Private Sub Grid_Click()
MsgBox Grid.CellWidth

End Sub
Private Sub txtBookName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub txtPage_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub txtPrice_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub

Book return Form


Private Sub Command1_Click()
If rs.State = adStateOpen Then rs.Close
strq = "select * from issue where status='I' and bookno=" & Text1 & " and
memno=" & Text2 & ""
rs.Open strq, conn, 1, 2
If rs.RecordCount = 0 Then
MsgBox "Invalid Entry"
Text1.SetFocus
Exit Sub
End If
strq = "Update issue set status='P' where bookno=" & Text1 & " and
memno=" & Text2 & ""
conn.Execute strq
strq = "Update BookMaster set status='P' where bookno=" & Text1 & ""
conn.Execute strq

strq = "Update MemberMaster set status='P' where memno=" & Text2 & ""
conn.Execute strq
Form_Activate
End Sub
Private Sub clear_TextBox()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
End If
Next
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Activate()
clear_TextBox
End Sub
Private Sub Form_Load()
Me.Top = 1545
Me.Left = 2640
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{Tab}"
End If
End Sub

You might also like