You are on page 1of 18

8.

SOURCE CODE

Imports System.Data.SQL

Public Class frmLogin

Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

Timer2.Start()

Connection()

End Sub

Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnClose.Click

If MsgBox("Do you want to exit this application?", vbYesNo + vbQuestion) = vbYes Then

Me.Close()

End If

End Sub

Imports System.Data.Sql

Imports System.Data.SqlClient

Public Class Form1

Dim x As String = ""

Dim rand As Random = New Random()

Dim cs As String = "Data Source=ARUN-PC\SQLEXPRESS;Initial


Catalog=inventory;Persist Security Info=True;User ID=sa;Password=sql;"

Dim con As SqlConnection = New SqlConnection("Data Source=ARUN-


PC\SQLEXPRESS;Initial Catalog=inventory;Persist Security Info=True;User
ID=sa;Password=sql")

Dim com As SqlCommand

Dim ds As DataSet

Dim cmd As SqlCommand = Nothing

Dim cmd1 As SqlCommand = Nothing

1
Dim dt As New DataTable

Dim col As New AutoCompleteStringCollection

Dim col2 As New AutoCompleteStringCollection

' Dim con As SqlConnection = New SqlConnection("Data Source=UTHAYA-


PC\SQLEXPRESS;Initial Catalog=inventory;Persist Security Info=True;User
ID=sa;Password=sql")

' Dim com As SqlCommand

Dim qry As String

Dim adp As SqlDataAdapter

' Dim ds As DataSet

Dim i As Integer

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


Handles MyBase.Load

Connection()

loadItem()

loadItem1()

loadItem2()

GetData()

getdata1()

getLastID()

getLastID1()

getLastID2()

getLastID3()

getLastID4()

getLastID5()

End Sub

Private Sub getLastID()

2
Dim SQLDR As SqlDataReader

Dim SQLCommand As New SqlCommand

With SQLCommand

.Connection = con

.CommandText = "select MAX(productid) from product"

End With

Try

If con.State = ConnectionState.Open Then

con.Close()

End If

con.Open()

SQLDR = SQLCommand.ExecuteReader

If SQLDR.Read Then

TextBox1.Text = Val(SQLDR.Item(0)) + 1

End If

con.Close()

Catch ex As Exception

TextBox1.Text = 1000

End Try

'getLastID()

End Sub

Private Sub getLastID1()

Dim SQLDR As SqlDataReader

Dim SQLCommand As New SqlCommand

With SQLCommand

3
.Connection = con

.CommandText = "select MAX(InvoiceNo) from sale"

End With

Try

If con.State = ConnectionState.Open Then

con.Close()

End If

con.Open()

SQLDR = SQLCommand.ExecuteReader

If SQLDR.Read Then

TextBox7.Text = Val(SQLDR.Item(0)) + 1

End If

con.Close()

Catch ex As Exception

TextBox7.Text = 1000

End Try

'getLastID()

End Sub

Private Sub getLastID2()

Dim SQLDR As SqlDataReader

Dim SQLCommand As New SqlCommand

With SQLCommand

.Connection = con

.CommandText = "select MAX(InvoiceNo) from purchase"

End With

4
Try

If con.State = ConnectionState.Open Then

con.Close()

End If

con.Open()

SQLDR = SQLCommand.ExecuteReader

If SQLDR.Read Then

TextBox26.Text = Val(SQLDR.Item(0)) + 1

End If

con.Close()

Catch ex As Exception

TextBox26.Text = 1000

End Try

'getLastID()

End Sub

Private Sub getLastID3()

Dim SQLDR As SqlDataReader

Dim SQLCommand As New SqlCommand

With SQLCommand

.Connection = con

.CommandText = "select MAX(employeeid) from Employee"

End With

Try

If con.State = ConnectionState.Open Then

con.Close()

5
End If

con.Open()

SQLDR = SQLCommand.ExecuteReader

If SQLDR.Read Then

TextBox31.Text = Val(SQLDR.Item(0)) + 1

End If

Catch ex As Exception

TextBox31.Text = 1000

End Try

con.Close()

'getLastID()

End Sub

6
9. BIBLIOGRAPHY

REFERENCESES

 EilasM.Awad, “System Analysis And Design,” Galgogia Publications


(P) Limited, Second Edition.
 “Distributed .Net Programming In Vb .Net” By Tom Barnaby
 “Professional Vb.Net, 2nd Edition” By Fred Barwell, Et Al
 Roger S Pressman (1997), “Software Engineering”, Tata McGraw-Hill
Publishing Company’s
 James R Groff And Paul N Weinberg, “The Complete Reference: Sql”,
Tata McGraw-Hill.

ONLINE REFERENCES

 www.msdn.microsoft.com
 www.microsoftdotnet.net

7
APPENDIX
SCREEN SHOTS

Fig.1 Login

8
9
10
11
12
13
14
15
16
17
18

You might also like