You are on page 1of 40

LOGIN:

Option Explicit

Dim CtrTry As Integer

Public uname As String

Private Sub cmdCancel_Click()

Unload Me

End Sub

Private Sub cmdLogin_Click()

'initialization

Dim passwd As String

Dim counter As Integer

uname = UCase(txtuserName.Text)

passwd = UCase(txtPwd.Text)

'calling records of employee

Call setEmployee

'checking of users

If rs.RecordCount > 0 Then

CtrTry = CtrTry + 1

Do Until rs.EOF

If uname = rs!UserName And passwd = rs!Password Then

Set rs = Nothing
With MDIInventory

.Enabled = True

.Show

.mnu_inven.Enabled = True

.mnu_trans.Enabled = True

.mnuLogout.Enabled = True

.mnuLogin.Enabled = False

.MNUAD.Enabled = True

End With

Load Frm_welcome

Frm_welcome.Show

'checking if the uname is admin or ordinary user only

If uname = uuuname Then

Flag = True

Else

Flag = False

End If

counter = 0

Unload Me

Exit Do

Else

rs.MoveNext

counter = counter + 1
End If

Loop

'checking the number which user access

If counter > 0 Then

Set rs = Nothing

Label3.Caption = "Access Denied!!" & " " & "You only have " & " " & 3 - CtrTry & " " & "time(s)left to
Log In"

txtuserName.Text = ""

txtPwd.Text = ""

txtuserName.SetFocus

' ctr = 0

If CtrTry = 3 Then

Unload Me

CtrTry = 0

End If

End If

'This is only for the instance, that there is no registered user in the database

Else

MsgBox "There is No current permission has been set", vbInformation, "Inventory system"

With MDIInventory

.Show

.mnu_inven.Enabled = True

.mnu_trans.Enabled = True

.mnuLogout.Enabled = True
.mnuLogin.Enabled = False

End With

Flag = True

Unload Me

End If

End Sub

WELCOME PAGE:

Option Explicit

Private Sub MDIForm_UnLoad(cancel As Integer)

On Error Resume Next

If MsgBox("Are You Sure you want to Quit ?", vbExclamation + vbOKCancel, "Library Management
System") = vbOK Then

Unload frmLogin

Else

cancel = True

End If

End Sub

Private Sub mnu_customer_Click()

'show form

frmCustomer.Show vbModeless
End Sub

Private Sub mnu_Exit_Click()

'Terminate the program

On Error Resume Next

If MsgBox("Are You Sure you want to Quit ?", vbExclamation + vbOKCancel, "Library Management
System") = vbOK Then

Unload frmLogin

Unload Me

Else

Exit Sub

End If

End Sub

Private Sub mnu_PO_Click()

'show form

frmPO.Show vbModeless

End Sub

Private Sub mnu_products_Click()

'show form

frmProducts.Show vbModeless

End Sub

Private Sub mnu_sales_Click()

'show form
frmInvoice.Show vbModeless

End Sub

Private Sub mnu_supplies_Click()

'show form

frmSupplier.Show vbModeless

End Sub

Private Sub mnu_User_Click()

Flager

End Sub

Private Sub mnuAbout_Click()

frmAbout.Show

End Sub

Private Sub mnuLogin_Click()

frmLogin.Show

End Sub

Private Sub mnuLogout_Click()


frmLogin.Show

MDIInventory.Enabled = False

End Sub

Public Sub Flager()

Dim str As String

Dim dateNow As Date

If Flag = True Then

frmUser.Show vbModeless

Else

dateNow = Format(Now(), "dddd, yyyy mmmm dd")

str = dateNow & " " & "You are currently Log In as Guest,Permission is not allowed"

MsgBox str, vbQuestion, "Inventory System"

Exit Sub

End If

End Sub

Private Sub StatusBar1_PanelClick(ByVal Panel As MSComctlLib.Panel)

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)

Select Case Button.Index

Case 2: mnu_products_Click

Case 4: mnu_customer_Click
Case 6: mnu_supplies_Click

Case 8: mnu_sales_Click

Case 10: mnu_PO_Click

End Select

End Sub

PRODUCTS:

Option Explicit

Dim id As String

Private Sub cmdAppend_Click()

'connecting to the table1

Call setProduct

rs.AddNew

With Me

rs!ProdID = .txtProduct_ID

rs!ProductDesc = .txtDesc

rs!ProductName = .txtProductName

rs!QtySold = .txtSold

rs!SRP = .txtSRP

rs!SupplierPrice = .txtUnit_Price

rs!QtyLeft = .txtINStock

rs!Suppliers = .cboSupplier

End With

rs.Update
Call Clear

Set rs = Nothing

cmdNew.Enabled = True

cmdAppend.Enabled = False

' autonum_product

End Sub

Private Sub cmdCancel_Click()

cmdAppend.Enabled = False

cmdNew.Enabled = True

End Sub

Private Sub cmdDelete_Click()

Call ItemRecord

With rs

.Delete

Call Clear

If .BOF And .EOF = True Then

Call Clear

MsgBox "No data Available", vbInformation

End If

End With

End Sub

Private Sub cmdNew_Click()

'autonumber

autonum_product

setProduct
cmdAppend.Enabled = True

' Call ItemRecord

Call Clear

Set rs = Nothing

'checking of the Product ID

chekID (id)

cmdNew.Enabled = False

Frame1.Enabled = True

End Sub

Private Sub cmdQuit_Click()

Unload Me

End Sub

Private Sub Command1_Click()

Unload Me

End Sub

Private Sub Command2_Click()

On Error Resume Next

setProduct

ItemRecord

rs.MoveFirst
If rs.BOF = True Then

MsgBox "Currently in the First Record"

End If

End Sub

Private Sub Command3_Click()

On Error Resume Next

ItemRecord

rs.MovePrevious

If rs.BOF = True Then

MsgBox "Currently in the First Record"

End If

End Sub

Private Sub Command4_Click()

On Error Resume Next

ItemRecord

rs.MoveNext

If rs.EOF = True Then

MsgBox "Currently in the Last Record"

End If

End Sub

Private Sub Command5_Click()


On Error Resume Next

ItemRecord

rs.MoveLast

If rs.EOF = True Then

MsgBox "Currently in the Last Record"

End If

End Sub

Private Sub Form_Load()

id = txtProduct_ID.Text

Call setSupplier

If rs.RecordCount > 0 Then

Do While Not rs.EOF

cboSupplier.AddItem rs!SupplierName

rs.MoveNext

Loop

End If

Set rs = Nothing

Call setProduct

If rs.RecordCount > 0 Then

ItemRecord

Call usergrid_Load

With usergrid
.ColWidth(0) = 200

.ColWidth(1) = 1100

.ColWidth(2) = 2000

End With

Else

Exit Sub

End If

End Sub

Private Function chekID(id)

'connect

Set rs = New ADODB.Recordset

rs.Open "Select*from Product where ProdID='" & id & "'", cn, 3, 3

If rs.RecordCount > 0 Then

If Not (rs.BOF And rs.EOF) Then

Exit Function

Else

MsgBox "The ID is already exist! Please Put a New ID", vbCritical, "Inventory System"

End If

End If

Set rs = Nothing

End Function

Public Sub Clear()

With Me

.txtDesc = ""
.txtProductName = ""

.txtSold = ""

.txtSRP = ""

.txtUnit_Price = ""

.txtINStock = ""

End With

End Sub

Public Sub ItemRecord()

setProduct

With Me

.txtProduct_ID = rs!ProdID

.txtDesc = rs!ProductDesc = rs!ProdID

.txtProductName = rs!ProductName

.txtSold = rs!QtySold

.txtSRP = rs!SRP

.txtUnit_Price = rs!SupplierPrice

.txtINStock = rs!QtyLeft

.cboSupplier = rs!Suppliers

End With

setProduct

End Sub

Private Function autonum_product()

'making a function for displaying of the Auto PO ID

Set rs = New ADODB.Recordset


rs.Open "select * from Product Order By ProductName", cn, 3, 2

If rs.RecordCount = 0 Then

txtProduct_ID.Text = "P-0001"

Else

txtProduct_ID.Text = "P-" & Format(Right(rs!ProdID, 4) + 1, "0000")

End If

rs.Close

Set rs = Nothing

txtProduct_ID.Locked = True

End Function

Private Function usergrid_Load()

Set usergrid.DataSource = rs

Set rs = Nothing

End Function

CUSTOMER:

Private Sub cmdClose_Click()

Unload Me

End Sub

Private Sub cmdDelete_Click()

Cust
rs.Delete

rs.MoveNext

Clear

End Sub

Private Sub cmdEdit_Click()

rs.Clone

Cust2

rs.Update

End Sub

Private Sub cmdNew_Click()

Cust

Clear

rs.AddNew

With Me

.cmdEdit.Enabled = False

.cmdDelete.Enabled = False

.cmdNew.Enabled = False

.cmdCancel.Enabled = True

End With

End Sub

Private Sub cmdSave_Click()


Cust2

rs.Update

Clear

cmdSave.Enabled = False

End Sub

Private Sub Command3_Click()

Unload Me

End Sub

Private Sub Command4_Click()

Cust

With rs

.MoveNext

If rs.EOF = True Then

MsgBox "Last record", vbInformation

rs.MovePrevious

End If

End With

End Sub

Private Sub Command5_Click()

Cust

With rs

.MovePrevious
If rs.BOF = True Then

MsgBox "first record", vbInformation

rs.MoveNext

End If

End With

End Sub

Private Sub Command6_Click()

Cust

With rs

.MoveFirst

End With

End Sub

Private Sub Command7_Click()

Cust

With rs

.MoveLast

End With

End Sub

Private Sub Form_Load()

'setting the supplier


Call setCustomer 'functions

If rs.RecordCount > 0 Then

Call Cust

End If

usergrid_Load

End Sub

Public Sub Cust()

On Error Resume Next

With Me

.txtCust = rs!CustomerName

.txtAd = rs!Address

.txtCon2 = rs!ContactNumber

.txtE2 = rs!Email

End With

End Sub

Public Sub Cust2()

With Me

rs!CustomerName = .txtCust

rs!Address = .txtAd

rs!ContactNumber = .txtCon2

rs!Email = .txtE2

End With

End Sub

Public Sub Clear()


With Me

.txtCust = ""

.txtAd = ""

.txtCon2 = ""

.txtE2 = ""

End With

End Sub

Private Sub usergrid_Click()

Dim X As Integer

X = usergrid.Row

With usergrid

txtCust.Text = .TextMatrix(X, 1)

txtAd.Text = .TextMatrix(X, 2)

txtCon2.Text = .TextMatrix(X, 3)

txtE2.Text = .TextMatrix(X, 4)

End With

End Sub

Private Function usergrid_Load()

Set usergrid.DataSource = rs

End Function

SUPPLIER:
Private Sub Command1_Click()

setSupplier

Clear

rs.AddNew

Set DataGrid1.DataSource = rs

DataGrid1.Refresh

Command2.Enabled = True

End Sub

Private Sub Command2_Click()

supp1

rs.Update

Clear

End Sub

Private Sub Command3_Click()

Unload Me

End Sub

Private Sub Command4_Click()

Call supp

With rs
.MoveNext

If rs.EOF = True Then

MsgBox "Last record", vbInformation

rs.MovePrevious

End If

End With

End Sub

Private Sub Command5_Click()

Call supp

With rs

.MovePrevious

If rs.BOF = True Then

MsgBox "first record", vbInformation

rs.MoveNext

End If

End With

End Sub

Private Sub Command8_Click()

Call supp

With rs

.MoveFirst
If rs.BOF = True Then

MsgBox "First record", vbInformation

rs.MoveNext

End If

End With

End Sub

Private Sub Command9_Click()

Call supp

With rs

.MoveLast

If rs.EOF = True Then

MsgBox "Last record", vbInformation

rs.MovePrevious

End If

End With

End Sub

Private Sub Form_Load()

'setting the supplier

Call setSupplier 'functions

Set DataGrid1.DataSource = rs

DataGrid1.Refresh

If rs.RecordCount > 0 Then

Call supp
supp1

End If

Command2.Enabled = False

End Sub

Public Sub supp()

With Me

.txtSupp = rs!SupplierName

.txtC = rs!ContactName

.txtAd = rs!Address

.txtNum = rs!ContactNumber

.txtE = rs!Email

End With

End Sub

Public Sub supp1()

With Me

rs!SupplierName = .txtSupp

rs!ContactName = .txtC

rs!Address = .txtAd

rs!ContactNumber = .txtNum

rs!Email = .txtE

End With

End Sub
Public Sub Clear()

With Me

.txtSupp = ""

.txtC = ""

.txtAd = ""

.txtNum = ""

.txtE = ""

End With

End Sub

USER:

Dim userID As String

Dim uID, pswd As String

Private Sub cmdAppend_Click()

On Error Resume Next

uID = UCase(txtUsrID.Text)

pswd = UCase(txtPwd.Text)

setEmployee

rs.AddNew

'Assigns the variable values

rs!UserName = uID
rs!Password = pswd

rs.Update

MsgBox txtUsrID.Text & " " & "has been save!", vbInformation

Set DataGrid1.DataSource = rs

DataGrid1.Refresh

Call locate

txtUsrID.Text = ""

txtPwd.Text = ""

With Me

.cmdEdit.Enabled = True

.cmdDelete.Enabled = True

.cmdQuit.Enabled = True

.cmdCancel.Enabled = False

.cmdNew.Enabled = True

End With

End Sub

Private Sub cmdCancel_Click()

With Me

.cmdAppend.Enabled = False

.cmdEdit.Enabled = True

.cmdDelete.Enabled = True

.cmdQuit.Enabled = True
.cmdNew.Enabled = True

End With

cmdNew.Enabled = True

txtUsrID.Text = ""

txtPwd.Text = ""

txtUsrID.Locked = False

txtPwd.Locked = False

End Sub

Private Sub cmdDelete_Click()

With Me

.txtPwd = rs!Password

.txtUsrID = rs!UserName

End With

'

If MsgBox("Are You Sure you want to Delete this?", vbExclamation + vbOKCancel, "Library
Management System") = vbOK Then

rs.Delete

Set DataGrid1.DataSource = rs

DataGrid1.Refresh

txtUsrID.Text = ""

txtPwd.Text = ""

Else
Exit Sub

End If

If rs.RecordCount = 0 Then

MsgBox "there is No Record availabale", vbInformation, "Inventory System"

End If

End Sub

Private Sub cmdEdit_Click()

On Error Resume Next

uID = UCase(txtUsrID.Text)

pswd = UCase(txtPwd.Text)

If cmdEdit.Caption = "&Edit" Then

txtPwd.Enabled = True

txtUsrID.Enabled = True

With Me

.cmdDelete.Enabled = False

.cmdNew.Enabled = False

.cmdAppend.Enabled = False

End With

cmdEdit.Caption = "SAVE"

ElseIf cmdEdit.Caption = "SAVE" Then

rs.Clone

rs!UserName = uID

rs!Password = pswd
Set usergrid.DataSource = rs

usergrid.Refresh

rs.Update

cmdEdit.Caption = "&Edit"

With Me

.cmdDelete.Enabled = True

.cmdNew.Enabled = True

End With

End If

End Sub

Private Sub cmdNew_Click()

txtUsrID.Enabled = True

txtPwd.Enabled = True

txtUsrID.Text = ""

txtPwd.Text = ""

cmdAppend.Enabled = True

ctrl_Flag = False

With Me

.cmdEdit.Enabled = False

.cmdDelete.Enabled = False
.cmdQuit.Enabled = False

.cmdNew.Enabled = False

.cmdCancel.Enabled = True

End With

End Sub

Private Sub cmdQuit_Click()

Unload Me

End Sub

Private Sub Form_Load()

setEmployee

Call usergrid_Load

With usergrid

.ColWidth(0) = 200

.ColWidth(1) = 1100

.ColWidth(2) = 2000

End With

Call showdata

Call locate

End Sub
Public Sub locate()

Label9.Caption = rs.RecordCount

Label6.Caption = rs.AbsolutePosition

End Sub

Public Sub showdata()

setEmployee

If rs.RecordCount > 0 Then

With Me

.txtPwd.Text = rs!Password

.txtUsrID.Text = rs!UserName

Call locate

End With

End If

End Sub

Private Sub usergrid_Click()

Dim X As Integer
X = usergrid.Row

With usergrid

txtUsrID.Text = .TextMatrix(X, 1)

txtPwd.Text = .TextMatrix(X, 2)

End With

End Sub

Private Function usergrid_Load()

Set usergrid.DataSource = rs

Set rs = Nothing

End Function

PURCHASE ORDER:

Option Explicit

Dim PO_ID As String

Private Sub cboSupplier_Click()

Dim Sql As String

Dim rs As New ADODB.Recordset

Sql = "Select * from Product where Suppliers='" & cboSupplier.Text & "'"

rs.Open Sql, cn, 3, 3

If Not (rs.BOF And rs.EOF) Then

grdProduct.Enabled = True

Set grdProduct.DataSource = rs

grdProduct.Refresh

Set rs = Nothing
End If

End Sub

Private Sub Command1_Click()

'to show the ADDING Form

frmAdd.Show

With frmAdd

.Label2.Caption = SuppID

.Label4.Caption = itemAdd

End With

Command1.Enabled = False

'displaying the Description of Product to a text Box caption

lblStat.Caption = listP.ListItems.Count

End Sub

Private Sub Command2_Click()

Dim SupID, DateOr, DateRe, Supplier, Quantity As String

PO_ID = UCase(txtPO.Text)

SupID = cboSupplier.Text

DateOr = DPDate_Order.Value

DateRe = DPDate_Required.Value

'checking for the duplication of ID

CheckDuplication (PO_ID)

For i = 1 To listP.ListItems.Count
Supplier = listP.ListItems(i).Text

Quantity = listP.ListItems(i).ListSubItems(2).Text

cn.Execute "Insert Into PO(POID,PROD_ID,Qty,Supplier,DateOrder,DateRequired)" & _

"Values('" & PO_ID & "','" & Supplier & "','" & Quantity & "','" & SupID & "','" & DateOr & "','" &
DateRe & "')"

Next

listP.ListItems.Clear

MsgBox " Transaction No " & PO_ID & " has been purchased.", vbInformation, "Inventory system"

Call AutoID

End Sub

Private Function CheckDuplication(PO_ID)

'checking for the duplication of the PO ID

Set rs = New ADODB.Recordset

rs.Open "Select*from PO where POID='" & PO_ID & "'", cn, 3, 3

If rs.RecordCount > 0 Then

If Not (rs.BOF And rs.EOF) Then

Exit Function

Else

MsgBox "Duplication of ID", vbCritical, "Inventory System"

End If

End If

Set rs = Nothing

End Function

Private Function AutoID()


'making a function for displaying of the Auto PO ID

Set rs = New ADODB.Recordset

rs.Open "select * from PO Order By POID DESC", cn, 3, 2

If rs.RecordCount = 0 Then

txtPO.Text = "PO-0000"

Else

txtPO.Text = "PO-" & Format(Right(rs!POID, 4) + 1, "0000")

End If

rs.Close

Set rs = Nothing

txtPO.Locked = True

End Function

Private Sub Command4_Click()

Unload Me

End Sub

Private Sub Form_Load()

'setting the supplier

Call setPO 'functions

With grdProduct

.ColWidth(0) = 300

.ColWidth(1) = 1500

.ColWidth(2) = 2500

.ColWidth(3) = 2500

.ColWidth(6) = 1400
.Enabled = False

End With

Set rs = Nothing

'calling a Auto ID function

Call AutoID

'displaying the record of Supplier

setSupplier

If rs.RecordCount > 0 Then

Do Until rs.EOF

cboSupplier.AddItem rs!SupplierName

rs.MoveNext

Loop

End If

lblStat.Caption = listP.ListItems.Count

Set rs = Nothing

End Sub

Public Sub Clear()

'clearing the text

With Me

.cboSupplier.Text = ""

.txtPO.Text = ""

End With

End Sub

Private Sub grdProduct_Click()


'a Procedure for displaying the record in data grid

i = grdProduct.Row

With grdProduct

lblItemName.Caption = .TextMatrix(i, 2)

SuppID = .TextMatrix(i, 1)

itemAdd = .TextMatrix(i, 2)

End With

If Not SuppID = "" Then

Command1.Enabled = True

End If

End Sub

INVOICE:

Private Sub cboProducts_Click()

Dim rs As New ADODB.Recordset

rs.Open "select * from Product where ProductName='" & cboProducts.Text & "'", cn, 3, 3

If Not (rs.EOF Or rs.BOF) Then

grdproduct.Enabled = True

txts.Text = rs!SRP

Set grdproduct.DataSource = rs

grdproduct.Refresh

End If

Set rs = Nothing

End Sub
Private Sub Command1_Click()

With frmSell

.Label2.Caption = poAd

.Label4.Caption = itemAd

End With

frmSell.Show

End Sub

Private Sub Command2_Click()

Unload Me

End Sub

Private Sub Form_Load()

'setting the supplier

Call setSales 'functions

With grdproduct

.ColWidth(0) = 300

.ColWidth(1) = 1500

.ColWidth(2) = 2500

.ColWidth(3) = 2500

.ColWidth(6) = 1400

.Enabled = False
End With

If rs.RecordCount > 0 Then

End If

Set rs = Nothing

setCustomer

If rs.RecordCount > 0 Then

Do Until rs.EOF

cboCustomer.AddItem rs!CustomerName

rs.MoveNext

Loop

End If

Set rs = Nothing

setProduct

If rs.RecordCount > 0 Then

Do Until rs.EOF

cboProducts.AddItem rs!ProductName

rs.MoveNext

Loop

End If

Set rs = Nothing

End Sub

Private Sub grdProduct_Click()


i = grdproduct.Row

With grdproduct

poAd = .TextMatrix(i, 1)

itemAd = .TextMatrix(i, 2)

End With

End Sub

You might also like