0% found this document useful (0 votes)
6 views3 pages

My Code

DONT CODE

Uploaded by

pviera365
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

My Code

DONT CODE

Uploaded by

pviera365
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

user code

Private sub Populate()


Con.open()
Dim query = "slect * from UserTbl
Dim adapter As SqlDataAdapter
adapter = new SqlDataAdapter(query,Con)
Dim builder As SqlCommandBuilder
builder = new SqlCommandBuilder(adapter)
Dim ds As Dataset
ds = new Dataset
adapter.Fill(ds)
UserDGV.DataSource = ds.Tables(0)

Con.Close()
End Sub
Private Sub Reset()
UnameTb.Text = ""
PhoneTb.Text = ""
AddressTb.Text = ""
PasswordTb.Text = ""
key = 0

End Sub
savebtn
if UnameTb.Text = "" or PhoneTb.Text = "" or AddressTb.Text = "" or
PasswordTb.Text = "" Then
msgBox(Missing Information)

else
Con.Open()
Dim query As String
query = "insert into UserTbl
values('"&UnameTb.Text&"','"&PhoneTb.Text&"','"&AddressTb.Text
&"','"&PasswordTb.Text&"')"
Dim cmd As Sqlcommand
cmd= new Sqlcommand(query,Con)
cmd.ExecuteNonQuery()
MsgBox("User Saved Successfully")
Con.Close()
Populate()
Reset()

Deletebtn code
Dim key = 0
if key = 0 Then
msgBox("Select The User To Be Deleted")

else
Con.Open()
Dim query As String
query = "Delete from UserTbl where Id "
Dim cmd As Sqlcommand
cmd= new Sqlcommand(query,Con)
cmd.ExecuteNonQuery()
MsgBox("User Deleted Successfully")
Con.Close()
Populate()
Reset()
cellmouseclick code
Dim row As DataGridViewRow = UserDGv.Rows(e.RowIndex)
UnameTb.Text = row.Cells(1).Value.ToString
PhoneTb.Text = row.Cells(2).Value.ToString
AddressTb.Text = row.Cells(3).Value.ToString
PasswordTb.Text = row.Cells(4).Value.ToString
If UnameTb.Text = "" Then
key = 0
else
key = Convert.ToInt32(row.Cells(0).Value.ToString)

End If

EditTb code
if UnameTb.Text = "" or PhoneTb.Text = "" or AddressTb.Text = "" or PasswordTb.Text
= "" Then
msgBox(Missing Information)

else
Con.Open()
Dim query As String
query = "Update UserTbl set name=
'"&UnameTb.Text&"',Phone='"&PhoneTb.Text&"',Address='"&AddressTb.Text&"',Password='
"&PasswordTb.Text&"'where Id="&key&""
Dim cmd As Sqlcommand
cmd= new Sqlcommand(query,Con)
cmd.ExecuteNonQuery()
MsgBox("User Updated Successfully")
Con.Close()
Populate()
Reset()

Book module code


Private sub Populate()
Con.open()
Dim query = "slect * from BookTbl
Dim adapter As SqlDataAdapter
adapter = new SqlDataAdapter(query,Con)
Dim builder As SqlCommandBuilder
builder = new SqlCommandBuilder(adapter)
Dim ds As Dataset
ds = new Dataset
adapter.Fill(ds)
BooksDGV.DataSource = ds.Tables(0)

Con.Close()
End Sub
Private Sub Reset()
BookNameTb.Text = ""
QtyTb.Text = ""
PriceTb.Text = ""
AuthorTb.Text = ""
Catcb.SelectedIndex = -1
key = 0

End Sub
if BookNameTb.Text = "" or AuthorTb.Text = "" or QtyTb.Text = "" or PriceTb.Text =
"" or Catcb.selectedindex= -1 Then
msgBox(Missing Information)

else
Con.Open()
Dim query As String
query = "insert into BookTbl
values('"&BookNameTb.Text&"','"&AuthorTb.Text&"','"&Catcb.SelectedItem.ToString
&"',"&QtyTb.Text&","&PriceTb.Text&")"
Dim cmd As Sqlcommand
cmd= new Sqlcommand(query,Con)
cmd.ExecuteNonQuery()
MsgBox("Book Saved Successfully")
Con.Close()
Populate()
Reset()

Cellmouseclick code
Dim Key = 0

You might also like