bc-vnt Posted September 7, 2012 Report Posted September 7, 2012 (edited) Download : PPhone-Book.rar download - 2sharedImports MyLibraryFunctions.MydataImports MyLibraryFunctions.LoadDataImports MyLibraryFunctions.CommClassesImports MyLibraryFunctions.MyFunctions''' <summary>''' Note: This Program is more Advance for more info Regarding this Application''' Just Send me an email: bc_vnt@yahoo.it''' </summary>''' <remarks>Copy Right:2010</remarks>''' Programmer: Bc-VntPublic Class PhoneBook Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click 'Dim InsertInfo As List(Of IPersonals) = New List(Of IPersonals) 'InsertInfo.Add(New InsertData(Me.txtFname.Text, Me.txtMname.Text, Me.txtLname.Text, _ ' Me.txtAddress.Text, Me.txtEadd.Text, Me.txtMobNo.Text, Me.txtTelNo.Text)) Dim Disable As Functions = New Functions Dim Insert As InsertData = (New InsertData(Me.txtFname.Text, Me.txtMname.Text, Me.txtLname.Text, _ Me.txtAddress.Text, Me.txtEadd.Text, Me.txtMobNo.Text, Me.txtTelNo.Text)) If Me.txtFname.Text = String.Empty And txtMobNo.Text = String.Empty And txtTelNo.Text = String.Empty Then MsgBox("Please Fill the ff Important details", MsgBoxStyle.Information, "Phone Book") Else Insert.MyData() End If Disable.DisableString(Me) Disable.DisableButton(Me) Me.btnAdd.Focus() Me.txtSearch.Enabled = True Me.btnAdd.Enabled = True Me.btnEdit.Enabled = True Me.btnLoad.Enabled = True Me.btnExit.Enabled = True Disable.ClearTextBox(Me) End Sub Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim Disable As Functions = New Functions Dim Update As UpdateData = New UpdateData(Me.txtFname.Text, Me.txtMname.Text, Me.txtLname.Text, _ Me.txtAddress.Text, Me.txtEadd.Text, Me.txtMobNo.Text, Me.txtTelNo.Text) If Me.txtFname.Text = String.Empty And txtMobNo.Text = String.Empty And txtTelNo.Text = String.Empty Then MsgBox("No Data!", MsgBoxStyle.Information, "Phone Book") Else Update.MyData() End If Disable.DisableString(Me) Disable.DisableButton(Me) Me.txtSearch.Enabled = True Me.btnAdd.Enabled = True Me.btnEdit.Enabled = True Me.btnLoad.Enabled = True Me.btnExit.Enabled = True Disable.ClearTextBox(Me) End Sub Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim Disable As Functions = New Functions Dim Delete As DeleteData = New DeleteData(Me.txtFname.Text, Me.txtMname.Text, Me.txtLname.Text, _ Me.txtAddress.Text, Me.txtEadd.Text, Me.txtMobNo.Text, Me.txtTelNo.Text) Delete.MyData() Disable.DisableString(Me) Disable.DisableButton(Me) Me.btnAdd.Enabled = True Me.btnEdit.Enabled = True Me.btnLoad.Enabled = True Me.txtSearch.Enabled = True Me.btnExit.Enabled = True Disable.ClearTextBox(Me) End Sub Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim Load As SearchFromTable = New SearchFromTable With Me.DataGridView1 .DataSource = Load.GetMyData _ ("Select *" _ + " From tblInfo Where Fname='" & Trim(Me.txtSearch.Text) & "'" _ + " or Lname='" & Trim(Me.txtSearch.Text) & "'") End With End Sub Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click Dim Load As SearchFromTable = New SearchFromTable With Me.DataGridView1 .DataSource = Load.GetMyData _ ("Select * From tblInfo") End With End Sub Private Sub PhoneBook_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim response As MsgBoxResult response = MsgBox("Are you sure you want to close this application?", _ vbYesNo + vbExclamation + vbApplicationModal + _ vbDefaultButton2, "Close confirmation") If response = MsgBoxResult.Yes Then Me.Visible = False Me.Dispose() Me.Close() End ElseIf response = MsgBoxResult.No Then e.Cancel = True Exit Sub End If End Sub Private Sub PhoneBook_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Disable As Functions = New Functions Disable.DisableString(Me) Disable.DisableButton(Me) Me.btnExit.Enabled = True Me.btnAdd.Enabled = True Me.btnEdit.Enabled = True Me.btnLoad.Enabled = True Me.txtSearch.Enabled = True End Sub Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim Enable As Functions = New Functions Enable.EnabledString(Me) Me.btnEdit.Enabled = False Me.btnSave.Enabled = True Me.btnCancel.Enabled = True End Sub Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click Dim Enable As Functions = New Functions Enable.EnabledString(Me) Me.btnAdd.Enabled = False Me.btnUpdate.Enabled = True Me.btnDelete.Enabled = True Me.btnCancel.Enabled = True End Sub ''' <summary> ''' You can use DoubleClick or Enter in Datagridview to Load the data ''' in textboxes. ''' </summary> Private Sub DataGridView1_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEnter Dim GridRow As DataGridViewRow = DataGridView1.CurrentRow txtFname.Text = CStr(GridRow.Cells.Item("Fname").Value) txtMname.Text = CStr(GridRow.Cells.Item("Mname").Value) txtLname.Text = CStr(GridRow.Cells.Item("Lname").Value) txtAddress.Text = CStr(GridRow.Cells.Item("Address").Value) txtMobNo.Text = CStr(GridRow.Cells.Item("MobNo").Value) txtTelNo.Text = CStr(GridRow.Cells.Item("TelNo").Value) txtEadd.Text = CStr(GridRow.Cells.Item("EAdd").Value) End Sub Private Sub DataGridView1_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseDoubleClick Dim GridRow As DataGridViewRow = DataGridView1.CurrentRow txtFname.Text = CStr(GridRow.Cells.Item("Fname").Value) txtMname.Text = CStr(GridRow.Cells.Item("Mname").Value) txtLname.Text = CStr(GridRow.Cells.Item("Lname").Value) txtAddress.Text = CStr(GridRow.Cells.Item("Address").Value) txtMobNo.Text = CStr(GridRow.Cells.Item("MobNo").Value) txtTelNo.Text = CStr(GridRow.Cells.Item("TelNo").Value) txtEadd.Text = CStr(GridRow.Cells.Item("EAdd").Value) End Sub ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks>Note: To Load datas in Datagridview Click Load Button</remarks> Private Sub txtSearch_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSearch.KeyPress If Asc(e.KeyChar) = Keys.Enter Then btnSearch_Click(Nothing, Nothing) e.Handled = True End If End Sub Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Dim Disable As Functions = New Functions Disable.ClearTextBox(Me) Disable.DisableString(Me) Disable.DisableButton(Me) Me.btnAdd.Enabled = True Me.btnEdit.Enabled = True Me.btnLoad.Enabled = True Me.txtSearch.Enabled = True Me.btnExit.Enabled = True End Sub Private Sub txtMobNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMobNo.KeyPress Dim NumOlny As Functions = New Functions e.Handled = NumOlny.TrapKey(Asc(e.KeyChar)) End Sub Private Sub txtTelNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTelNo.KeyPress Dim NumOlny As Functions = New Functions e.Handled = NumOlny.TrapKey(Asc(e.KeyChar)) End SubEnd ClassSursa : VB.NET Books for Beginners Edited September 14, 2012 by bc-vnt Quote