Beruflich Dokumente
Kultur Dokumente
Imports system.data.oledb
Imports System.Text.RegularExpressions
Imports VB = Microsoft.VisualBasic
Me.PhoneBookTableAdapter.Fill(Me.Telephonedir1DataSet.Phon
eBook)
cn = New
OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data
source=d:\PhoneBook\telephonedir1.mdb")
adp = New OleDbDataAdapter("select * from PhoneBook",
cn)
filldatasetanddataview()
bindingfields()
showpos()
Button13_Click(Me, e)
Beep()
End Sub
Private Sub filldatasetanddataview()
ds = New DataSet()
adp.Fill(ds, "PhoneBook")
dv = New DataView(ds.Tables("PhoneBook"))
cm = CType(Me.BindingContext(dv), CurrencyManager)
DataGridView1.DataSource = dv
DataGridView1.Refresh()
End Sub
Private Sub showpos()
End Sub
Private Sub bindingfields()
TextBox1.DataBindings.Clear()
TextBox2.DataBindings.Clear()
TextBox3.DataBindings.Clear()
TextBox4.DataBindings.Clear()
TextBox5.DataBindings.Clear()
TextBox6.DataBindings.Clear()
TextBox7.DataBindings.Clear()
TextBox8.DataBindings.Clear()
TextBox9.DataBindings.Clear()
TextBox10.DataBindings.Clear()
TextBox11.DataBindings.Clear()
TextBox12.DataBindings.Clear()
TextBox13.DataBindings.Clear()
TextBox14.DataBindings.Clear()
TextBox15.DataBindings.Clear()
TextBox16.DataBindings.Clear()
TextBox19.DataBindings.Clear()
PictureBox1.DataBindings.Clear()
TextBox1.DataBindings.Add("text", dv, "DOB")
TextBox2.DataBindings.Add("text", dv, "Designation")
TextBox3.DataBindings.Add("text", dv, "Address")
TextBox4.DataBindings.Add("text", dv, "City")
TextBox5.DataBindings.Add("text", dv, "Country")
TextBox6.DataBindings.Add("text", dv, "Pin_Code")
TextBox7.DataBindings.Add("text", dv, "Tel_office")
TextBox8.DataBindings.Add("text", dv, "Tel_Residence")
TextBox9.DataBindings.Add("text", dv, "Mobile1")
TextBox10.DataBindings.Add("text", dv, "Mobile2")
TextBox11.DataBindings.Add("text", dv, "E_mail")
TextBox12.DataBindings.Add("text", dv, "BloodGroup")
TextBox13.DataBindings.Add("text", dv, "State")
TextBox14.DataBindings.Add("text", dv, "Name")
TextBox15.DataBindings.Add("text", dv, "MName")
TextBox16.DataBindings.Add("text", dv, "LName")
TextBox19.DataBindings.Add("text", dv, "Photograph")
PictureBox1.DataBindings.Add("ImageLocation", dv,
"Photograph")
End Sub
End Sub
Private Sub Button3_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button3.Click
'DELETION
Dim i As Integer
Dim cmd1 As OleDbCommand = New
OleDbCommand("delete from PhoneBook where Name=@Name1
and MName = @MName1 and LName=@LName1", cn)
i = cm.Position - 1
If (i < 0) Then
i=0
End If
cmd1.Parameters.AddWithValue("@Name1",
BindingContext(dv).Current("Name"))
cmd1.Parameters.AddWithValue("@MName1",
BindingContext(dv).Current("MName"))
cmd1.Parameters.AddWithValue("@LName1",
BindingContext(dv).Current("LName"))
cn.Open()
cmd1.ExecuteNonQuery()
cn.Close()
filldatasetanddataview()
bindingfields()
cm.Position = i
MessageBox.Show("Record Deleted from Phonebook")
End Sub
Else
cm.Position = intpos
End If
Case "TELEPHONE"
dv.Sort = "Tel_office"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
dv.Sort = "Tel_Residence"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record not found")
End If
Else
cm.Position = intpos
End If
Case "CITY"
dv.Sort = "City"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record Not Found")
Else
cm.Position = intpos
End If
Case "DOB"
dv.Sort = "DOB"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record Not Found")
Else
cm.Position = intpos
End If
Case "MOBILE"
dv.Sort = "Mobile1"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
dv.Sort = "Mobile2"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record not found")
End If
Else
cm.Position = intpos
End If
Case "BLOOD GROUP"
dv.Sort = "BloodGroup"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record Not Found")
Else
cm.Position = intpos
End If
Case "DESIGNATION"
dv.Sort = "Designation"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record Not Found")
Else
cm.Position = intpos
End If
Case "E-MAIL"
dv.Sort = "E_mail"
intpos = dv.Find(Trim(TextBox17.Text))
If intpos = -1 Then
MessageBox.Show("Record Not Found")
Else
cm.Position = intpos
End If
DataGridView1.Refresh()
End Select
End Sub
End Sub
End Sub
End Sub
Private Sub TextBox8_Validating(ByVal sender As Object,
ByVal e As System.ComponentModel.CancelEventArgs) Handles
TextBox8.Validating
'validating tel_residence
Dim exp As New
System.Text.RegularExpressions.Regex("\d{7}")
End Sub
End While
dr.Close()
cn.Close()
End Sub
End Sub
End Class