Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
26 views

Source Code

This document contains source code for a login form and multiple other forms for a point of sale system for a supermarket. The login form authenticates users by querying a database and allows accessing other forms. Other forms allow adding, updating, and deleting employee, product, and sale records from databases using SQL queries.

Uploaded by

Vicky Vignesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Source Code

This document contains source code for a login form and multiple other forms for a point of sale system for a supermarket. The login form authenticates users by querying a database and allows accessing other forms. Other forms allow adding, updating, and deleting employee, product, and sale records from databases using SQL queries.

Uploaded by

Vicky Vignesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Source code

Login.vb

Imports System.Data

Imports System.Data.OleDb

Public Class Form1

Dim con As New OleDbConnection

Dim sql As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Supermarket\


Supermarket\supermarket.mdb"

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button2.Click

TextBox1.Text = ""

TextBox2.Text = ""

End Sub

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

con.Open()

sql = "SELECT * FROM logs WHERE uname='" & TextBox1.Text & "' and pwd='" & TextBox2.Text & "'"

Dim cmd As New OleDbCommand(sql, con)

Dim rd As OleDbDataReader
rd = cmd.ExecuteReader

If rd.Read = True Then

MsgBox("Login Success")

MDIParent1.Show()

Me.Hide()

Else

MsgBox("Login Failed")

End If

con.Close()

End Sub

End Class

Public Class Form2

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


PictureBox1.Click

End Sub

Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Label5.Click

End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
Button1.Visible = False

Dim PrgCounter As Integer

ProgressBar1.Minimum = 0

ProgressBar1.Maximum = 1000000

Do While ProgressBar1.Value < 1000000

ProgressBar1.Value = PrgCounter

PrgCounter = PrgCounter + 1

Loop

If ProgressBar1.Value = 1000000 Then

Button1.Visible = True

End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button1.Click

Form1.Show()

Me.Hide()

End Sub

End Class

Imports System.Data
Imports System.Data.OleDb

Public Class Form3

Dim con As New OleDbConnection

Dim sql As String

Private Sub Form3_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Supermarket\


Supermarket\supermarket.mdb"

Button2.Enabled = False

End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

con.Open()

sql = "INSERT INTO Employee_reg (emp_name, j_date, emp_mob, emp_addr, emp_desig) values ('"
& TextBox1.Text & "', '" & DateTimePicker1.Value & "' , '" & TextBox2.Text & "' , '" & TextBox3.Text & "' ,
'" & ComboBox1.SelectedText & "' )"

Dim cmd As New OleDbCommand(sql, con)

If cmd.ExecuteNonQuery Then

MsgBox("Data Saved")

Else

MsgBox("Failed to Save")

End If

con.Close()

End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Button1.Enabled = False

Button2.Enabled = True

End Sub

Private Sub TextBox4_TextChanged(sender As System.Object, e As System.EventArgs) Handles


TextBox4.TextChanged

End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click

con.Open()

sql = "UPDATE Employee_reg SET emp_name='" & TextBox1.Text & "' , j_date='" &
DateTimePicker1.Value & "' , emp_mob='" & TextBox2.Text & "' , emp_addr ='" & TextBox3.Text & "' ,
emp_desig='" & ComboBox1.Text & "' WHERE ID=" & TextBox4.Text & ""

Dim cmd As New OleDbCommand(sql, con)

If cmd.ExecuteNonQuery Then

MsgBox("Data Update")

Else

MsgBox("Failed to Update")

End If

con.Close()

End Sub
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click

con.Open()

Dim sql As String

sql = "SELECT * FROM Employee_reg WHERE ID=" & TextBox4.Text & ""

Dim cmd As New OleDbCommand(sql, con)

Dim rd As OleDbDataReader

rd = cmd.ExecuteReader

If rd.Read Then

TextBox1.Text = rd.GetString(1)

TextBox2.Text = rd.GetString(3)

TextBox3.Text = rd.GetString(4)

ComboBox1.Text = rd.GetString(5)

DateTimePicker1.Value = rd.GetDateTime(2)

End If

con.Close()

End Sub

Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click

con.Open()

Dim sql As String

sql = "DELETE FROM Employee_reg WHERE ID=" & TextBox4.Text & ""

Dim cmd As New OleDbCommand(sql, con)


If cmd.ExecuteNonQuery Then

MsgBox("Employee Record REmoved Successfully")

Else

MsgBox("Failed to Remove Record")

End If

con.Close()

End Sub

End Class

Imports System.Data

Imports System.Data.OleDb

Public Class Form4

Dim con As New OleDbConnection

Dim sql As String

Private Sub Label3_Click(sender As System.Object, e As System.EventArgs) Handles Label3.Click

End Sub

Private Sub Form4_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

Button2.Enabled = False

Button6.Visible = False

Label8.Visible = False

TextBox6.Visible = False
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Supermarket\
Supermarket\supermarket.mdb"

End Sub

Private Sub Label5_Click(sender As System.Object, e As System.EventArgs) Handles Label5.Click

End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Button1.Enabled = False

Button2.Enabled = True

Dim qr As String

Dim id As Integer

con.Open()

qr = "SELECT pid FROM products"

Dim cd As New OleDbCommand(qr, con)

Dim rs As OleDbDataReader

rs = cd.ExecuteReader

If rs.Read Then

id = Val(rs.Item("pid"))

If id = Nothing Then

id = 1

MsgBox("less")

Else

id = id + 1

End If
End If

TextBox1.Text = id

con.Close()

End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

Dim sql As String

con.Open()

sql = "INSERT INTO products Values ('" & TextBox1.Text & "' , '" & TextBox2.Text & "','" &
TextBox3.Text & "' , '" & TextBox4.Text & "','" & DateTimePicker1.Value & "' ,'" & TextBox5.Text & "')"

Dim cmd As New OleDbCommand(sql, con)

If cmd.ExecuteNonQuery Then

MsgBox("Prodcut added successfully")

End If

con.Close()

End Sub

Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click

con.Open()

Dim sql As String

sql = "SELECT * FROM products WHERE pid=" & TextBox7.Text & ""

Dim cmd As New OleDbCommand(sql, con)

Dim rd As OleDbDataReader

rd = cmd.ExecuteReader
If rd.Read Then

TextBox1.Text = rd.GetInt32(0)

TextBox2.Text = rd.GetString(1)

TextBox3.Text = rd.GetInt32(2)

TextBox4.Text = rd.GetInt32(3)

DateTimePicker1.Value = rd.GetDateTime(4)

TextBox5.Text = rd.GetInt32(5)

TextBox6.Text = rd.GetInt32(5)

TextBox7.Text = rd.GetInt32(5)

End If

con.Close()

End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click

con.Open()

Dim sql1 As String

sql1 = "UPDATE products SET pname='" & TextBox2.Text & "' , pprice=" & TextBox3.Text &
" ,sprice=" & TextBox4.Text & " ,expdate ='" & DateTimePicker1.Value & "' , stock=" & TextBox5.Text & "
WHERE pid=" & TextBox7.Text & ""

Dim cmd As New OleDbCommand(sql1, con)

If cmd.ExecuteNonQuery Then

MsgBox("Data Updated")

Else

MsgBox("Failed to Update")

End If

con.Close()
End Sub

Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click

Button6.Visible = True

Label8.Visible = True

TextBox6.Visible = True

End Sub

Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click

con.Open()

Dim sql1 As String

Dim stock As Integer

stock = Val(TextBox5.Text) + Val(TextBox6.Text)

sql1 = "UPDATE products SET stock=" & stock & " WHERE pid=" & TextBox7.Text & ""

Dim cmd As New OleDbCommand(sql1, con)

If cmd.ExecuteNonQuery Then

MsgBox("Stock Updated")

Else

MsgBox("Failed to Update")

End If

con.Close()

Button6.Visible = False

Label8.Visible = False

TextBox6.Visible = False

End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click

con.Open()

Dim sql As String

sql = "DELETE FROM products WHERE pid=" & TextBox7.Text & ""

Dim cmd As New OleDbCommand(sql, con)

If cmd.ExecuteNonQuery Then

MsgBox("Product Removed Successfully")

Else

MsgBox("Failed to Remove product")

End If

con.Close()

End Sub

End Class

Imports System.Data

Imports System.Data.OleDb

Public Class Form5

Dim con As New OleDbConnection

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

con.Open()

Dim sql As String


' Dim upq As String

sql = "INSERT into sale_temp values ( '" & ComboBox1.Text & "' , '" & TextBox1.Text & "' , '" &
TextBox2.Text & "' , '" & TextBox3.Text & "', '" & TextBox4.Text & "' , '" & TextBox5.Text & "' ,'" &
TextBox6.Text & "' )"

Dim cmd As New OleDbCommand(sql, con)

' Dim cmd2 As New OleDbCommand(upq, con)

If cmd.ExecuteNonQuery Then ' Then

MsgBox("Product added")

End If

Dim qry As String

qry = "SELECT * FROM sale_temp"

Dim Adpt As New OleDbDataAdapter(qry, con)

Dim ds As New DataSet()

Adpt.Fill(ds, "sale")

DataGridView1.DataSource = ds.Tables(0)

con.Close()

DataGridView1.Visible = True

End Sub
Private Sub ComboBox1_TextChanged(sender As Object, e As System.EventArgs) Handles
ComboBox1.TextChanged

con.Open()

Dim qry As String

qry = "SELECT pname, sprice from products where pid=" & ComboBox1.Text & ""

Dim cmd As New OleDbCommand(qry, con)

Dim rd As OleDbDataReader

rd = cmd.ExecuteReader

If rd.Read Then

TextBox2.Text = rd.GetString(0)

TextBox3.Text = rd.GetInt32(1)

End If

con.Close()

End Sub

Private Sub Form5_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

DataGridView1.Visible = False

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Supermarket\


Supermarket\supermarket.mdb"

con.Open()

Dim qry As String


qry = "SELECT pid from products"

Dim cmd As New OleDbCommand(qry, con)

Dim rd As OleDbDataReader

rd = cmd.ExecuteReader

While rd.Read

ComboBox1.Items.Add(rd.GetInt32(0))

End While

con.Close()

End Sub

Private Sub TextBox6_GotFocus(sender As Object, e As System.EventArgs) Handles TextBox6.GotFocus

TextBox6.Text = Val(TextBox3.Text) * Val(TextBox4.Text)

End Sub

Private Sub TextBox6_TextChanged(sender As System.Object, e As System.EventArgs) Handles


TextBox6.TextChanged

End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

con.Open()

Dim qr As String
Dim sql As String

'Dim sql1 As String

qr = "select * FROM sale_temp"

Dim cmd As New OleDbCommand(qr, con)

Dim rdd As OleDbDataReader

rdd = cmd.ExecuteReader

Dim upq As String

While rdd.Read

sql = "insert into sales values (" & rdd.GetInt32(0) & " , '" & rdd.GetString(1) & "' , '" &
rdd.GetString(2) & "' , " & rdd.GetInt32(3) & " , " & rdd.GetInt32(4) & " , " & rdd.GetInt32(5) & " , " &
rdd.GetInt32(6) & ")"

Dim cd As New OleDbCommand(sql, con)

cd.ExecuteNonQuery()

Dim qq As String

Dim red As OleDbDataReader

Dim st As Integer

Dim stk As Integer

qq = "SELECT stock from products where pid=" & ComboBox1.Text

Dim cmdd As New OleDbCommand(qq, con)

red = cmdd.ExecuteReader

If red.Read Then

st = red.GetInt32(0)
stk = st - Val(TextBox4.Text)

End If

upq = "update products set stock=" & stk & " where pid=" & ComboBox1.Text

Dim ccd As New OleDbCommand(upq, con)

ccd.ExecuteNonQuery()

End While

con.Close()

Form6.Show()

Me.Hide()

End Sub

Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles


TextBox2.TextChanged

End Sub

Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)


Handles ComboBox1.SelectedIndexChanged

End Sub

End Class

Imports System.Data
Imports System.Data.OleDb

Public Class Form6

Dim con As New OleDbConnection

Private Sub Form6_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

'con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source" &


Application.ExecutablePath & "\supermarket.mdb"

' con.Open()

Dim sql As String

Dim grand As Integer = 0

sql = "select pname,cust_name,qty,price,total from sale_temp"

' Dim cd1 As New OleDbCommand(sql, con)

' Dim rd As OleDbDataReader

' rd = cd1.ExecuteReader

' If rd.Read Then

' TextBox1.Text = rd.GetString(1)

' End If

' While rd.Read

' ListBox1.Items.Add(rd.GetString(0))

'ListBox2.Items.Add(rd.GetInt32(2))

' ListBox3.Items.Add(rd.GetInt32(3))

' ListBox4.Items.Add(rd.GetInt32(4))

' grand = grand + rd.GetInt32(4)

' End While


' TextBox2.Text = grand

' con.Close()

End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

PrintDialog1.ShowDialog()

con.Open()

Dim sql1 As String

sql1 = "delete from sale_temp"

Dim cmd1 As New OleDbCommand(sql1, con)

If cmd1.ExecuteNonQuery Then

'MsgBox("View Bill")

End If

con.Close()

End Sub

End Class

Imports System.Data

Imports System.Data.OleDb

Public Class Form7

Dim con As New OleDbConnection

Private Sub Form7_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Supermarket\


Supermarket\supermarket.mdb"

con.Open()
Dim qry As String

qry = "SELECT pid from products"

Dim cmd As New OleDbCommand(qry, con)

Dim rd As OleDbDataReader

rd = cmd.ExecuteReader

While rd.Read

ComboBox1.Items.Add(rd.GetInt32(0))

End While

con.Close()

End Sub

Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)


Handles ComboBox1.SelectedIndexChanged

End Sub

Private Sub ComboBox1_TextChanged(sender As Object, e As System.EventArgs) Handles


ComboBox1.TextChanged

con.Open()

Dim qry As String

qry = "SELECT pname, sprice from products where pid=" & ComboBox1.Text & ""

Dim cmd As New OleDbCommand(qry, con)

Dim rd As OleDbDataReader

rd = cmd.ExecuteReader
If rd.Read Then

TextBox2.Text = rd.GetString(0)

TextBox3.Text = rd.GetInt32(1)

End If

con.Close()

End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

Dim qq As String

Dim red As OleDbDataReader

Dim st As Integer

Dim stk As Integer

Dim upq As String

con.Open()

qq = "SELECT stock from products where pid=" & ComboBox1.Text

Dim cmdd As New OleDbCommand(qq, con)

red = cmdd.ExecuteReader

If red.Read Then

st = red.GetInt32(0)

stk = st + Val(TextBox4.Text)

End If

upq = "update products set stock=" & stk & " where pid=" & ComboBox1.Text

Dim ccd As New OleDbCommand(upq, con)


If ccd.ExecuteNonQuery() Then

MsgBox("Updated")

End If

Dim sql As String

sql = "insert into salesreturn values( '" & TextBox1.Text & "', '" & ComboBox1.Text & "' , '" &
TextBox2.Text & "', '" & TextBox3.Text & "' , '" & TextBox4.Text & "' )"

Dim cmd As New OleDbCommand(sql, con)

cmd.ExecuteReader()

con.Close()

End Sub

End Class

You might also like