STOCK----
Imports System.Data
Imports System.Data.OleDb
Public Class Stockfrm
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim purchaseid, pqty, sqty As Integer
Dim qty, total, totalamt, famt As Double
Dim salesid As Integer
Dim i, k As Integer
Dim tax As Double
Private Sub Stockfrm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\Earthen Product System\WindowsApplication1\earthen_db.mdb")
con.Open()
cmd = New OleDbCommand("select * from gproduct", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
For i = 0 To ds.Tables(0).Rows.Count - 1
cmbname.Items.Add(ds.Tables(0).Rows(i).Item(1))
Next
con.Close()
End Sub
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnupdate.Click
con.Open()
qty = Val(txtoldquantity.Text) + Val(txtnewquantity.Text)
cmd = New OleDbCommand("select * from purchaseorder", con)
cmd.CommandText = "update gproduct set pqty='" & qty & "' where
pname='" & cmbname.Text & "'"
cmd.ExecuteNonQuery()
MsgBox("values are updated")
con.Close()
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnclear.Click
txtpno.Text = ""
cmbname.Text = ""
txtoldquantity.Text = ""
txtnewquantity.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
MDIform.Show()
Hide()
End Sub
Private Sub cmbname_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbname.SelectedIndexChanged
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\Earthen Product System\WindowsApplication1\earthen_db.mdb")
con.Open()
cmd = New OleDbCommand("select * from gproduct where pname='" &
cmbname.Text & "'", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
txtpno.Text = ds.Tables(0).Rows(0).Item(0)
txtoldquantity.Text = ds.Tables(0).Rows(0).Item(3)
con.Close()
End Sub
End Class
SALE ORDER----
Imports System.Data
Imports System.Data.OleDb
Public Class Salesorderfrm
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
Dim sid As Integer
Dim total, gst, famt As Double
Dim qty As Integer
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnsave.Click
con.Open()
cmd = New OleDbCommand("select * from salesorder", con)
cmd.CommandText = " insert into salesorder values (" & txtsid.Text &
", " & txtcid.Text & ",'" & cmbcnm.Text & "'," & txtpno.Text & ",'" &
cmbpnm.Text & "','" & txtsrate.Text & "','" & cmbqty.Text & "','" &
txttotal.Text & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("values are saved")
con.Close()
End Sub
Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnclear.Click
txtsid.Text = ""
txtcid.Text = ""
txtpno.Text = ""
txtsrate.Text = ""
txttotal.Text = ""
End Sub
Private Sub Salesorderfrm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\Earthen Product System\WindowsApplication1\earthen_db.mdb")
con.Open()
cmd = New OleDbCommand("Select * from temp", con)
cmd.CommandText = " delete from temp"
cmd.ExecuteNonQuery()
con.Close()
con.Open()
cmd = New OleDbCommand("Select max(salesorderid) from salesorder",
con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
sid = Val(ds.Tables(0).Rows(0).Item(0))
sid = sid + 1
txtsid.Text = sid
con.Close()
'con = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="e:\sports accsories\WindowsApplication1\glass_databse.mdb"
con.Open()
cmd = New OleDbCommand("select * from customer", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
For i = 0 To ds.Tables(0).Rows.Count - 1
cmbcnm.Items.Add(ds.Tables(0).Rows(i).Item(1))
Next
con.Close()
'con = New OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data
Source="e:\sports accsories\WindowsApplication1\glass_databse.mdb"
con.Open()
cmd = New OleDbCommand("select * from gproduct", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
For i = 0 To ds.Tables(0).Rows.Count - 1
' MsgBox(ds.Tables(0).Rows(i).Item(1))
cmbpnm.Items.Add(ds.Tables(0).Rows(i).Item(1))
Next
con.Close()
con.Open()
cmd = New OleDbCommand("delete from temp", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
con.Close()
con.Open()
cmd = New OleDbCommand("select * from temp", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
DataGridView1.Refresh()
End Sub
Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnupdate.Click
con.Open()
cmd = New OleDbCommand("select * from temp", con)
cmd.CommandText = " insert into temp values (" & txtpno.Text & ", '" &
cmbpnm.Text & "'," & txtsrate.Text & "," & cmbqty.Text & "," & txttotal.Text &
")"
cmd.ExecuteNonQuery()
MessageBox.Show("values are saved")
con.Close()
qty = Val(txtqty.Text) - Val(cmbqty.Text)
con.Open()
cmd = New OleDbCommand("select * from gproduct", con)
cmd.CommandText = "update gproduct set pqty=" & qty & " where pno=" &
txtpno.Text & ""
cmd.ExecuteNonQuery()
MessageBox.Show("qunatity updated")
con.Close()
famt = famt + total
con.Open()
cmd = New OleDbCommand("select * from temp", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
con.Close()
End Sub
Private Sub btnhome_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnhome.Click
MDIform.Show()
Hide()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
billfrm.txttotal.Text = famt
gst = famt * 0.18
billfrm.txttax.Text = gst
famt = famt + gst
billfrm.txtbillamount.Text = famt
billfrm.txtcid.Text = txtcid.Text
billfrm.txtname.Text = cmbcnm.Text
billfrm.Show()
Hide()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
End Sub
Private Sub cmbcnm_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbcnm.SelectedIndexChanged
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\Earthen Product System\WindowsApplication1\earthen_db.mdb")
con.Open()
cmd = New OleDbCommand("select * from customer where custname='" &
cmbcnm.Text & "'", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
txtcid.Text = ds.Tables(0).Rows(0).Item(0)
con.Close()
End Sub
Private Sub cmbpnm_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbpnm.SelectedIndexChanged
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:\Earthen Product System\WindowsApplication1\earthen_db.mdb")
con.Open()
cmd = New OleDbCommand("select * from gproduct where pname='" &
cmbpnm.Text & "'", con)
da = New OleDbDataAdapter(cmd)
ds = New DataSet("mytable")
da.Fill(ds)
txtpno.Text = ds.Tables(0).Rows(0).Item(0)
txtsrate.Text = ds.Tables(0).Rows(0).Item(3)
txtqty.Text = ds.Tables(0).Rows(0).Item(4)
con.Close()
End Sub
Private Sub cmbqty_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmbqty.Click
total = Val(cmbqty.Text) * Val(txtsrate.Text)
txttotal.Text = total
End Sub
Private Sub cmbqty_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles cmbqty.KeyPress
Dim chr As String = "!,@,#,$,%,^,&,*,(,),_,-,=,+,[,],
{,},\,|,;,',:,',<,>,/,?"
If Char.IsLetter(e.KeyChar) = True Then
e.Handled = True
MsgBox("Quantity must be in numbers")
ElseIf chr.Contains(e.KeyChar.ToString.ToLower) Then
e.KeyChar = ChrW(0)
e.Handled = True
MsgBox("Quantity must be in numbers")
Else
cmbqty.BackColor = Color.White
End If
End Sub
Private Sub cmbqty_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmbqty.TextChanged
total = Val(cmbqty.Text) * Val(txtsrate.Text)
txttotal.Text = total
End Sub
End Class