My Code
My Code
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()
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