N
NicoMigs
Guest
'Import System
Imports System.Data.OleDb
Public Class Form1
Public DNS As OleDbConnection
Public yify As New OleDbCommand
Public rd As OleDbDataReader
Public QRS As New OleDbDataAdapter
Public Sy As New DataSet
Public RTX As String
Public Sub Opendatabase()
Try
DNS = New OleDbConnection("Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & Application.StartupPath & "\\BOOKING.mdb")
If DNS.State = ConnectionState.Open Then DNS.Close()
DNS.Open()
' MsgBox("ALRIGHT")
Catch ex As Exception
MessageBox.Show("Cannot Reserve!")
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
opendatabase()
RTX = "Insert into tbl_name (NumberOfCustomers,Lastname,Firstname,Middlename,Age,DateOfBirth,Contactnumber,Address,OtherContacts,Relationship,Telephone,Mobilenumber,NumberOfGuests,Pincode) Values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "')"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
MsgBox("Reserve!")
loadlist()
Txtbehave()
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = True
Button5.Enabled = False
Button6.Enabled = True
End Sub
Public Sub loadlist()
opendatabase()
RTX = "Select * from tbl_name"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
ListView1.Items.Clear()
While rd.Read
Dim lv As ListViewItem = ListView1.Items.Add(rd.Item("NumberOfCustomers").ToString)
lv.SubItems.Add(rd.Item("Lastname").ToString)
lv.SubItems.Add(rd.Item("Firstname").ToString)
lv.SubItems.Add(rd.Item("Middlename").ToString)
lv.SubItems.Add(rd.Item("Age").ToString)
lv.SubItems.Add(rd.Item("DateOfBirth").ToString)
lv.SubItems.Add(rd.Item("Contactnumber").ToString)
lv.SubItems.Add(rd.Item("Address").ToString)
lv.SubItems.Add(rd.Item("OtherContact").ToString)
lv.SubItems.Add(rd.Item("Relationship").ToString)
lv.SubItems.Add(rd.Item("Telephone").ToString)
lv.SubItems.Add(rd.Item("Mobilenumber").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
lv.SubItems.Add(rd.Item("Pincode").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
End While
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BOOKINGTableAdapter3.Fill(Me.BOOKINGDataSetlast.BOOKING)
loadlist()
txtbehave()
Button2.Enabled = False
Button3.Enabled = False
Button5.Enabled = False
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs)
TextBox1.Text = ListView1.FocusedItem.SubItems(0).Text
TextBox2.Text = ListView1.FocusedItem.SubItems(1).Text
TextBox3.Text = ListView1.FocusedItem.SubItems(2).Text
TextBox4.Text = ListView1.FocusedItem.SubItems(3).Text
TextBox5.Text = ListView1.FocusedItem.SubItems(4).Text
TextBox6.Text = ListView1.FocusedItem.SubItems(5).Text
TextBox7.Text = ListView1.FocusedItem.SubItems(6).Text
TextBox8.Text = ListView1.FocusedItem.SubItems(7).Text
TextBox9.Text = ListView1.FocusedItem.SubItems(8).Text
TextBox10.Text = ListView1.FocusedItem.SubItems(9).Text
TextBox11.Text = ListView1.FocusedItem.SubItems(10).Text
TextBox12.Text = ListView1.FocusedItem.SubItems(11).Text
TextBox13.Text = ListView1.FocusedItem.SubItems(12).Text
TextBox14.Text = ListView1.FocusedItem.SubItems(13).Text
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
opendatabase()
RTX = "Update tbl_name set NumberOfCustomers='" & TextBox2.Text & "',Lastname='" & TextBox3.Text & "',Firstname='" & TextBox4.Text & "',Middlename='" & TextBox5.Text & "',Age='" & TextBox6.Text & "',DateOfBirth='" & TextBox7.Text & "',Contactnumber='" & TextBox8.Text & "',Address='" & TextBox9.Text & "',OtherContacts='" & TextBox10.Text & "',Relationship='" & TextBox11.Text & "',Telephone='" & TextBox12.Text & ",Mobilenumber='" & TextBox13.Text & "',NumberOfGuests='" & TextBox14.Text & "',Pincode='" & "' where NumberOfCustomers='" & TextBox1.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
MsgBox("Record Update!")
loadlist()
txtbehave()
Button3.Enabled = False
Button4.Enabled = True
Button5.Enabled = True
End Sub
Public Sub txtbehave()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False
TextBox9.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
TextBox12.Enabled = False
TextBox13.Enabled = False
TextBox14.Enabled = False
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
txtbehave()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox7.Enabled = True
TextBox8.Enabled = True
TextBox9.Enabled = True
TextBox10.Enabled = True
TextBox11.Enabled = True
TextBox12.Enabled = True
TextBox13.Enabled = True
TextBox14.Enabled = True
TextBox1.Focus()
Button1.Enabled = True
Button2.Enabled = False
Button5.Enabled = False
Button6.Enabled = False
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If TextBox1.Text = "" Then
MsgBox("Select Data First!")
Else
Dim result = MessageBox.Show("Are you sure you want to Delete?", "System", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If DialogResult.Yes = result Then
Opendatabase()
RTX = "delete * from tbl_name where NumberOfCustomers='" & TextBox1.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
MsgBox("Record Deleted!")
loadlist()
txtbehave()
Else
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MsgBox("Select Data First!")
Else
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox2.Focus()
Button1.Enabled = False
Button2.Enabled = True
Button5.Enabled = True
Button6.Enabled = False
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Button7.Enabled = True
Button6.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button1.Enabled = False
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs)
If ComboBox1.Text = "NumberOfCustomers" Then
opendatabase()
RTX = "delete * from tbl_name where NumberOfCustomers='" & TextBox1.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
ListView1.Items.Clear()
While rd.Read
Dim lv As ListViewItem = ListView1.Items.Add(rd.Item("NumberOfCustomers").ToString)
lv.SubItems.Add(rd.Item("Lastname").ToString)
lv.SubItems.Add(rd.Item("Firstname").ToString)
lv.SubItems.Add(rd.Item("Middlename").ToString)
lv.SubItems.Add(rd.Item("Age").ToString)
lv.SubItems.Add(rd.Item("DateOfBirth").ToString)
lv.SubItems.Add(rd.Item("Contactnumber").ToString)
lv.SubItems.Add(rd.Item("Address").ToString)
lv.SubItems.Add(rd.Item("OtherContact").ToString)
lv.SubItems.Add(rd.Item("Relationship").ToString)
lv.SubItems.Add(rd.Item("Telephone").ToString)
lv.SubItems.Add(rd.Item("Mobilenumber").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
lv.SubItems.Add(rd.Item("Pincode").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
End While
ElseIf ComboBox1.Text = "Lastname" Then
opendatabase()
RTX = "select * from tbl_name where studname='" & TextBox7.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
ListView1.Items.Clear()
While rd.Read
Dim lv As ListViewItem = ListView1.Items.Add(rd.Item("NumberOfCustomers").ToString)
lv.SubItems.Add(rd.Item("Lastname").ToString)
lv.SubItems.Add(rd.Item("Firstname").ToString)
lv.SubItems.Add(rd.Item("Middlename").ToString)
lv.SubItems.Add(rd.Item("Age").ToString)
lv.SubItems.Add(rd.Item("DateOfBirth").ToString)
lv.SubItems.Add(rd.Item("Contactnumber").ToString)
lv.SubItems.Add(rd.Item("Address").ToString)
lv.SubItems.Add(rd.Item("OtherContact").ToString)
lv.SubItems.Add(rd.Item("Relationship").ToString)
lv.SubItems.Add(rd.Item("Telephone").ToString)
lv.SubItems.Add(rd.Item("Mobilenumber").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
lv.SubItems.Add(rd.Item("Pincode").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
End While
Else
MsgBox("Select Search Criteria First!!")
End If
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs)
loadlist()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
' Reset or clear any controls (recommended)
TextBox1.Clear()
' NOT recommended:
' Application.Restart()
End Sub
End Class
Continue reading...
Imports System.Data.OleDb
Public Class Form1
Public DNS As OleDbConnection
Public yify As New OleDbCommand
Public rd As OleDbDataReader
Public QRS As New OleDbDataAdapter
Public Sy As New DataSet
Public RTX As String
Public Sub Opendatabase()
Try
DNS = New OleDbConnection("Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & Application.StartupPath & "\\BOOKING.mdb")
If DNS.State = ConnectionState.Open Then DNS.Close()
DNS.Open()
' MsgBox("ALRIGHT")
Catch ex As Exception
MessageBox.Show("Cannot Reserve!")
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
opendatabase()
RTX = "Insert into tbl_name (NumberOfCustomers,Lastname,Firstname,Middlename,Age,DateOfBirth,Contactnumber,Address,OtherContacts,Relationship,Telephone,Mobilenumber,NumberOfGuests,Pincode) Values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "')"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
MsgBox("Reserve!")
loadlist()
Txtbehave()
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = True
Button5.Enabled = False
Button6.Enabled = True
End Sub
Public Sub loadlist()
opendatabase()
RTX = "Select * from tbl_name"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
ListView1.Items.Clear()
While rd.Read
Dim lv As ListViewItem = ListView1.Items.Add(rd.Item("NumberOfCustomers").ToString)
lv.SubItems.Add(rd.Item("Lastname").ToString)
lv.SubItems.Add(rd.Item("Firstname").ToString)
lv.SubItems.Add(rd.Item("Middlename").ToString)
lv.SubItems.Add(rd.Item("Age").ToString)
lv.SubItems.Add(rd.Item("DateOfBirth").ToString)
lv.SubItems.Add(rd.Item("Contactnumber").ToString)
lv.SubItems.Add(rd.Item("Address").ToString)
lv.SubItems.Add(rd.Item("OtherContact").ToString)
lv.SubItems.Add(rd.Item("Relationship").ToString)
lv.SubItems.Add(rd.Item("Telephone").ToString)
lv.SubItems.Add(rd.Item("Mobilenumber").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
lv.SubItems.Add(rd.Item("Pincode").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
End While
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BOOKINGTableAdapter3.Fill(Me.BOOKINGDataSetlast.BOOKING)
loadlist()
txtbehave()
Button2.Enabled = False
Button3.Enabled = False
Button5.Enabled = False
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs)
TextBox1.Text = ListView1.FocusedItem.SubItems(0).Text
TextBox2.Text = ListView1.FocusedItem.SubItems(1).Text
TextBox3.Text = ListView1.FocusedItem.SubItems(2).Text
TextBox4.Text = ListView1.FocusedItem.SubItems(3).Text
TextBox5.Text = ListView1.FocusedItem.SubItems(4).Text
TextBox6.Text = ListView1.FocusedItem.SubItems(5).Text
TextBox7.Text = ListView1.FocusedItem.SubItems(6).Text
TextBox8.Text = ListView1.FocusedItem.SubItems(7).Text
TextBox9.Text = ListView1.FocusedItem.SubItems(8).Text
TextBox10.Text = ListView1.FocusedItem.SubItems(9).Text
TextBox11.Text = ListView1.FocusedItem.SubItems(10).Text
TextBox12.Text = ListView1.FocusedItem.SubItems(11).Text
TextBox13.Text = ListView1.FocusedItem.SubItems(12).Text
TextBox14.Text = ListView1.FocusedItem.SubItems(13).Text
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
opendatabase()
RTX = "Update tbl_name set NumberOfCustomers='" & TextBox2.Text & "',Lastname='" & TextBox3.Text & "',Firstname='" & TextBox4.Text & "',Middlename='" & TextBox5.Text & "',Age='" & TextBox6.Text & "',DateOfBirth='" & TextBox7.Text & "',Contactnumber='" & TextBox8.Text & "',Address='" & TextBox9.Text & "',OtherContacts='" & TextBox10.Text & "',Relationship='" & TextBox11.Text & "',Telephone='" & TextBox12.Text & ",Mobilenumber='" & TextBox13.Text & "',NumberOfGuests='" & TextBox14.Text & "',Pincode='" & "' where NumberOfCustomers='" & TextBox1.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
MsgBox("Record Update!")
loadlist()
txtbehave()
Button3.Enabled = False
Button4.Enabled = True
Button5.Enabled = True
End Sub
Public Sub txtbehave()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False
TextBox9.Enabled = False
TextBox10.Enabled = False
TextBox11.Enabled = False
TextBox12.Enabled = False
TextBox13.Enabled = False
TextBox14.Enabled = False
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
txtbehave()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox7.Enabled = True
TextBox8.Enabled = True
TextBox9.Enabled = True
TextBox10.Enabled = True
TextBox11.Enabled = True
TextBox12.Enabled = True
TextBox13.Enabled = True
TextBox14.Enabled = True
TextBox1.Focus()
Button1.Enabled = True
Button2.Enabled = False
Button5.Enabled = False
Button6.Enabled = False
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
If TextBox1.Text = "" Then
MsgBox("Select Data First!")
Else
Dim result = MessageBox.Show("Are you sure you want to Delete?", "System", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If DialogResult.Yes = result Then
Opendatabase()
RTX = "delete * from tbl_name where NumberOfCustomers='" & TextBox1.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
MsgBox("Record Deleted!")
loadlist()
txtbehave()
Else
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MsgBox("Select Data First!")
Else
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox2.Focus()
Button1.Enabled = False
Button2.Enabled = True
Button5.Enabled = True
Button6.Enabled = False
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Button7.Enabled = True
Button6.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button1.Enabled = False
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs)
If ComboBox1.Text = "NumberOfCustomers" Then
opendatabase()
RTX = "delete * from tbl_name where NumberOfCustomers='" & TextBox1.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
ListView1.Items.Clear()
While rd.Read
Dim lv As ListViewItem = ListView1.Items.Add(rd.Item("NumberOfCustomers").ToString)
lv.SubItems.Add(rd.Item("Lastname").ToString)
lv.SubItems.Add(rd.Item("Firstname").ToString)
lv.SubItems.Add(rd.Item("Middlename").ToString)
lv.SubItems.Add(rd.Item("Age").ToString)
lv.SubItems.Add(rd.Item("DateOfBirth").ToString)
lv.SubItems.Add(rd.Item("Contactnumber").ToString)
lv.SubItems.Add(rd.Item("Address").ToString)
lv.SubItems.Add(rd.Item("OtherContact").ToString)
lv.SubItems.Add(rd.Item("Relationship").ToString)
lv.SubItems.Add(rd.Item("Telephone").ToString)
lv.SubItems.Add(rd.Item("Mobilenumber").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
lv.SubItems.Add(rd.Item("Pincode").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
End While
ElseIf ComboBox1.Text = "Lastname" Then
opendatabase()
RTX = "select * from tbl_name where studname='" & TextBox7.Text & "'"
yify = New OleDbCommand(RTX, DNS)
rd = yify.ExecuteReader
ListView1.Items.Clear()
While rd.Read
Dim lv As ListViewItem = ListView1.Items.Add(rd.Item("NumberOfCustomers").ToString)
lv.SubItems.Add(rd.Item("Lastname").ToString)
lv.SubItems.Add(rd.Item("Firstname").ToString)
lv.SubItems.Add(rd.Item("Middlename").ToString)
lv.SubItems.Add(rd.Item("Age").ToString)
lv.SubItems.Add(rd.Item("DateOfBirth").ToString)
lv.SubItems.Add(rd.Item("Contactnumber").ToString)
lv.SubItems.Add(rd.Item("Address").ToString)
lv.SubItems.Add(rd.Item("OtherContact").ToString)
lv.SubItems.Add(rd.Item("Relationship").ToString)
lv.SubItems.Add(rd.Item("Telephone").ToString)
lv.SubItems.Add(rd.Item("Mobilenumber").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
lv.SubItems.Add(rd.Item("Pincode").ToString)
lv.SubItems.Add(rd.Item("NumberOfGuests").ToString)
End While
Else
MsgBox("Select Search Criteria First!!")
End If
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs)
loadlist()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
' Reset or clear any controls (recommended)
TextBox1.Clear()
' NOT recommended:
' Application.Restart()
End Sub
End Class
Continue reading...