0% found this document useful (0 votes)
99 views

Code

The document contains code for an inventory management system with forms for stock and sales. The stock form code handles adding, updating, deleting, and searching stock records. The sales form code handles adding sales records, updating the stock records, and searching, navigating, and displaying sales records. Functions are used to move data between the sales and stock records and clear form fields.

Uploaded by

api-3697508
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

Code

The document contains code for an inventory management system with forms for stock and sales. The stock form code handles adding, updating, deleting, and searching stock records. The sales form code handles adding sales records, updating the stock records, and searching, navigating, and displaying sales records. Functions are used to move data between the sales and stock records and clear form fields.

Uploaded by

api-3697508
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

**************************

CODE FOR STOCK FORM


**************************

Private Sub Command1_Click()


Dim avail_stock As Integer

rs.Find "pcode=" & Val(Text1.Text), , adSearchForward, 1


If (rs.EOF = True) Then
rs.AddNew
rs("pcode") = Val(Text1.Text)
rs("pname") = Text2.Text
rs("totalstock") = Val(Text3.Text)
rs.Update
MsgBox "Record Inserted", vbExclamation, "Inventory System"
Else
avail_stock = rs("totalstock")
rs("totalstock") = avail_stock + Val(Text3.Text)
rs.Update
MsgBox "Record updated", vbExclamation, "Inventory System"
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Command2_Click()
rs("pcode") = Val(Text1.Text)
rs("pname") = Text2.Text
rs("totalstock") = Val(Text3.Text)
rs.Update
MsgBox "Record updated", vbExclamation, "Inventory System"
End Sub

Private Sub Command3_Click()


rs.Delete
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
MsgBox "Record deleted", vbExclamation, "Inventory System"
End Sub

Private Sub Command4_Click()


Dim product_code
product_code = InputBox("Enter the product code", "Inventory system")
rs.Find "pcode=" & product_code, , adSearchForward, 1
If (rs.EOF = True) Then
MsgBox "Record Not Found", vbCritical, "Inventory System"
Else
Text1.Text = rs("pcode")
Text2.Text = rs("pname")
Text3.Text = rs("totalstock")
End If
End Sub

Private Sub Command5_Click()


rs.MoveNext
If (rs.EOF = True) Then
MsgBox "End of File Reached"
rs.MoveLast
Else
Text1.Text = rs("pcode")
Text2.Text = rs("pname")
Text3.Text = rs("totalstock")
End If

End Sub

Private Sub Command6_Click()


rs.MovePrevious
If (rs.BOF = True) Then
MsgBox "Begining of File Reached"
rs.MoveFirst
Else
Text1.Text = rs("pcode")
Text2.Text = rs("pname")
Text3.Text = rs("totalstock")
End If
End Sub

Private Sub Command7_Click()


rs.MoveFirst
Text1.Text = rs("pcode")
Text2.Text = rs("pname")
Text3.Text = rs("totalstock")
End Sub

Private Sub Command8_Click()


rs.MoveLast
Text1.Text = rs("pcode")
Text2.Text = rs("pname")
Text3.Text = rs("totalstock")
End Sub

Private Sub Command9_Click()


Unload Me
Form1.Show
End Sub

**************************
CODE FOR SALES FORM
**************************
Private Sub Command1_Click()
Dim avail_stock As Integer, total_stock As Integer

stockrs.Find "pcode=" & Text2.Text


If (stockrs.EOF = True) Then
MsgBox "Productcode Not Found", vbCritical, "Inventory System"
Else
total_stock = stockrs("totalstock")
avail_stock = total_stock - Val(Text4.Text)
If (avail_stock <= 0) Then
MsgBox "Insufficient stock", vbCritical, "Inventory System"
Text4.SetFocus
Else
salesrs.AddNew
Call move_data2salestable
salesrs.Update
MsgBox "Record Inserted into sales table", vbExclamation, "Inventory System"

'the following code update the stock table


stockrs("totalstock") = avail_stock
stockrs.Update
MsgBox "Stock table updated", vbExclamation, "Inventory System"
Call clearformfields
End If
End If
End Sub
Public Sub clearformfields()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub

Private Sub Command2_Click()


Call move_data2salestable
salesrs.Update
MsgBox "Record Updated", vbExclamation, "Inventory System"
End Sub

Public Sub move_data2salestable()


salesrs("customer_id") = Val(Text1.Text)
salesrs("date1") = DTPicker1.Value
salesrs("pcode") = Val(Text2.Text)
salesrs("pname") = Text3.Text
salesrs("nitem") = Val(Text4.Text)
salesrs("uprice") = Val(Text5.Text)
salesrs("tprice") = Val(Text6.Text)

End Sub

Private Sub Command3_Click()


salesrs.Delete
Call clearformfields
MsgBox "Record deleted", vbExclamation, "Inventory System"

End Sub

Private Sub Command4_Click()


Dim customerid
customerid = InputBox("Enter the Customer_id", "Inventory system")
salesrs.Find "Customer_id=" & customerid, , adSearchForward, 1
If (salesrs.EOF = True) Then
MsgBox "Record Not Found", vbCritical, "Inventory System"
Else
Call display_sales_record
End If
End Sub

Private Sub Command5_Click()


salesrs.MoveNext
If (salesrs.EOF = True) Then
MsgBox "End of File Reached"
salesrs.MoveLast
Else
Call display_sales_record
End If
End Sub

Private Sub Command6_Click()


salesrs.MovePrevious
If (salesrs.BOF = True) Then
MsgBox "Begining of File Reached"
salesrs.MoveFirst
Else
Call display_sales_record
End If
End Sub

Public Sub display_sales_record()


Text1.Text = salesrs("customer_id")
DTPicker1.Value = salesrs("date1")
Text2.Text = salesrs("pcode")
Text3.Text = salesrs("pname")
Text4.Text = salesrs("nitem")
Text5.Text = salesrs("uprice")
Text6.Text = salesrs("tprice")
End Sub

Private Sub Command7_Click()


salesrs.MoveFirst
Call display_sales_record
End Sub

Private Sub Command8_Click()


salesrs.MoveLast
Call display_sales_record
End Sub

Private Sub Command9_Click()


Unload Me
Form1.Show
End Sub

Private Sub Text5_Change()


Text6.Text = Val(Text5) * Val(Text4)
End Sub

You might also like