The Visual Basic .Net Form - book_note.vb, Text Codes
 
 
 

       
      Return



  The Form -  book_note.vb ...

 
 

 The codes  corresponding ...
   
    
   The text Code is red color, the codes added manuel ...

 
 
Public Class book_note

Inherits System.Windows.Forms.Form

Dim fbook_search As New book_searchForm

Dim vselect1 As System.Data.OleDb.OleDbCommand ' Select command

Dim vda1 As System.Data.OleDb.OleDbDataAdapter ' Dataadapter

Dim vdset1 As System.Data.DataSet

Dim mbeditflag As Boolean, mbaddflag As Boolean


 
      Windows Form Designer generated code

'list of operations available: navigation, add/new, modify, update, cancel, find/search, print, close

Private Sub book_note_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'move

Me.editphoto_photo.Top = -Me.editphoto_photo.Height

'resize

Me.Panel21.Top = (Me.Panel2.Height - Me.Panel21.Height) / 2

Me.Panel22.Left = (Me.Panel21.Width - Me.Panel22.Width) / 2

Me.lblNavLocation.Width = Me.Panel22.Left - 16

Me.lblNavLocation.Left = (Me.Panel22.Left - Me.lblNavLocation.Width) / 2

Me.lblNavLocation.Top = 0

Me.lboperation.Width = Me.lblNavLocation.Width

Me.lboperation.Left = Me.Panel22.Left + (Me.Panel22.Left - Me.lblNavLocation.Width) / 2

Me.lboperation.Top = Me.lblNavLocation.Top

Me.Panel91.Top = Me.Panel4.Top

Me.Panel41.Left = Me.Panel91.Left

Me.Panel42.Left = Me.Panel91.Left

' Me.Panel41.Width = 2 * Me.Panel91.Width + Me.Panel4.Width

Me.Panel91.Height = Me.Panel4.Height + Me.Panel41.Height + Me.Panel5.Height + Me.Panel42.Height + Me.Panel6.Height

Me.Panel41.Top = Me.Panel4.Top + Me.Panel4.Height

Me.Panel5.Top = Me.Panel41.Top + Me.Panel41.Height

Me.Panel42.Top = Me.Panel5.Top + Me.Panel5.Height

Me.Panel6.Top = Me.Panel42.Top + Me.Panel42.Height

Me.Panel43.Top = Me.Panel6.Top + Me.Panel6.Height

Me.Panel5.Left = Me.Panel4.Left

Me.Panel6.Left = Me.Panel4.Left

Me.Pic_line01.Width = Me.Panel4.Width

Me.Pic_line01.Left = Me.Panel91.Width

Me.Pic_line02.Width = Me.Pic_line01.Width

Me.Pic_line02.Left = Me.Pic_line01.Left

Me.Panel3.Height = Me.Panel43.Top - 8

Me.Panel3.Top = 4

Me.Pic_book.Left = (Me.Panel3.Width - Me.Pic_book.Width) / 2

Me.Pic_book.Top = Me.Panel33.Top + Me.Panel33.Height + (Me.Panel3.Height - (Me.Panel33.Top + Me.Panel33.Height + Me.Pic_book.Height)) / 2

'load book table, objbook_dset dataset

LoadDataSet()

sub_load("name")

sub_load("first")

sub_load("father")

sub_load("city")

sub_load("civil_status")

Me.ltoday.Text = FormatDateTime(Date.Now, DateFormat.LongDate)

NavFirst()

End Sub

'load book table, objbook_dset dataset

Public Sub LoadDataSet()

Try

'Attempt to load the dataset.

Me.LoadDataSet1()

Catch eLoad As System.Exception

'Add your error handling code here.

'Display error message, if any.

System.Windows.Forms.MessageBox.Show(eLoad.Message)

End Try

End Sub

Public Sub LoadDataSet1()

'Create a new dataset

Dim objDataSetTemp As work_VBNet.book_dset

objDataSetTemp = New work_VBNet.book_dset

Try

'Attempt to fill the temporary dataset.

Me.FillDataSet(objDataSetTemp)

Catch eFillDataSet As System.Exception

'Add your error handling code here.

Throw eFillDataSet

End Try

Try

'Empty the old records from the dataset.

objbook_dset.Clear()

'Merge the records into the main dataset.

objbook_dset.Merge(objDataSetTemp)

Catch eLoadMerge As System.Exception

'Add your error handling code here.

Throw eLoadMerge

End Try

End Sub

 

Public Sub FillDataSet(ByVal dataSet As work_VBNet.book_dset)

'Turn off constraint checking before the dataset is filled.

'This allows the adapters to fill the dataset without concern

'for dependencies between the tables.

dataSet.EnforceConstraints = False

Try

'Open the connection.

Me.OleDbConnection1.Open()

'Attempt to fill the dataset through the OleDbDataAdapter1.

Me.OleDbDataAdapter1.Fill(dataSet)

Catch fillException As System.Exception

'Add your error handling code here.

Throw fillException

Finally

'Turn constraint checking back on.

dataSet.EnforceConstraints = True

'Close the connection whether or not the exception was thrown.

Me.OleDbConnection1.Close()

End Try

End Sub

 

'add data to comboboxes

Private Sub sub_load(ByVal v_field As String)

Dim WhereSearch As String = ""

Dim i As Integer

Me.cmbname.Items.Clear()

Me.cmbfirst_name.Items.Clear()

Me.cmbfather_name.Items.Clear()

Me.cmbcity.Items.Clear()

Me.cmbcivil_status.Items.Clear()

Select Case v_field

Case "name"

WhereSearch = " WHERE (Trim(name) <> '')"

vselect1 = New OleDb.OleDbCommand("SELECT DISTINCT Trim(name) AS vname FROM book" & WhereSearch & " ORDER BY Trim(name)")

Case "first"

WhereSearch = " WHERE (Trim(first_name) <>'')"

vselect1 = New OleDb.OleDbCommand("SELECT DISTINCT Trim(first_name) AS vfirst FROM book" & WhereSearch & " ORDER BY Trim(first_name)")

Case "father"

WhereSearch = " WHERE (Trim(father_name) <>'')"

vselect1 = New OleDb.OleDbCommand("SELECT DISTINCT Trim(father_name) AS vfather FROM book" & WhereSearch & " ORDER BY Trim(father_name)")

Case "city"

WhereSearch = " WHERE (Trim(city)<>'')"

vselect1 = New OleDb.OleDbCommand("SELECT DISTINCT Trim(city) AS vcity FROM book" & WhereSearch & " ORDER BY Trim(city)")

Case "civil_status"

WhereSearch = " WHERE (Trim(civil_status) <>'')"

vselect1 = New OleDb.OleDbCommand("SELECT DISTINCT Trim(civil_status) AS vcivil FROM book" & WhereSearch & " ORDER BY Trim(civil_status)")

End Select

vda1 = New OleDb.OleDbDataAdapter(vselect1)

vdset1 = New DataSet

vselect1.Connection() = fagenda.OleDbConnection1 ' Select command

vselect1.CommandTimeout = 30

vdset1.EnforceConstraints = False

Try

fagenda.OleDbConnection1.Open()

vda1.Fill(vdset1, "book")

Catch fillException As System.Exception

System.Windows.Forms.MessageBox.Show(fillException.Message)

End Try

vdset1.EnforceConstraints = True

fagenda.OleDbConnection1.Close()

For i = 0 To vdset1.Tables("book").Rows.Count - 1

Select Case v_field

Case "name"

Me.cmbname.Items.Add(Trim(vdset1.Tables("book").Rows(i).Item("vname")))

Case "first"

Me.cmbfirst_name.Items.Add(Trim(vdset1.Tables("book").Rows(i).Item("vfirst")))

Case "father"

Me.cmbfather_name.Items.Add(Trim(vdset1.Tables("book").Rows(i).Item("vfather")))

Case "city"

Me.cmbcity.Items.Add(Trim(vdset1.Tables("book").Rows(i).Item("vcity")))

Case "civil_status"

Me.cmbcivil_status.Items.Add(Trim(vdset1.Tables("book").Rows(i).Item("vcivil")))

End Select

Next

End Sub

Private Sub book_note_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed

' close form

close_response()

End Sub

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

Select Case Me.ToolBar1.Buttons.IndexOf(e.Button)

Case 0

' First

NavFirst()

Case 1

' preview

NavPrev()

End Select

End Sub

Private Sub ToolBar2_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar2.ButtonClick

Select Case Me.ToolBar2.Buttons.IndexOf(e.Button)

Case 0

' next

NavNext()

Case 1

' last

NavLast()

End Select

End Sub

Private Sub ToolBar3_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar3.ButtonClick

Select Case Me.ToolBar3.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "add operation"

' add

sub_add()

End Select

End Sub

Private Sub ToolBar4_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar4.ButtonClick

Select Case Me.ToolBar4.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "modify operation"

' modify

sub_modify()

End Select

End Sub

Private Sub ToolBar5_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar5.ButtonClick

Select Case Me.ToolBar5.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "save operation"

' save

sub_Update()

End Select

End Sub

Private Sub ToolBar6_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar6.ButtonClick

Select Case Me.ToolBar6.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "cancel operation"

' cancel

sub_Cancel()

End Select

End Sub

Private Sub ToolBar7_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar7.ButtonClick

Select Case Me.ToolBar7.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "search operation"

' search

sub_find()

End Select

End Sub

Private Sub ToolBar8_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar8.ButtonClick

Select Case Me.ToolBar8.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "print operation"

' print

sub_print()

End Select

End Sub

Private Sub ToolBar9_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar9.ButtonClick

Select Case Me.ToolBar9.Buttons.IndexOf(e.Button)

Case 0

Me.lboperation.Text = "close operation"

' close form

close_response()

End Select

End Sub

Private Sub close_response()

Dim response As MsgBoxResult

Dim msg_inf As String

If (mbaddflag Or mbeditflag) Then

msg_inf = "are you sure want to lose all changes, book note ..."

response = MsgBox(msg_inf, MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Information Or MsgBoxStyle.YesNo, Title)

'Gets the result of the MessageBox display.

If (response = MsgBoxResult.Yes) Then

mbaddflag = False

mbeditflag = False

Me.Close()

End If

 

Else

Me.Close()

End If

End Sub

'navigation operation ... *****************************

Private Sub NavFirst()

Me.BindingContext(objbook_dset, "book").Position = 0

Me.objbook_dset_PositionChanged()

End Sub

Private Sub objbook_dset_PositionChanged()

mbaddflag = False

mbeditflag = False

Me.editbirth.Text = Str(Me.DateTime_birth.Value.Month) & "/" & Str(Me.DateTime_birth.Value.Day) & "/" & Str(Me.DateTime_birth.Value.Year)

Me.lblNavLocation.Text = "record : " + (((Me.BindingContext(objbook_dset, "book").Position + 1).ToString + " of ") _

+ Me.BindingContext(objbook_dset, "book").Count.ToString)

Select Case mbaddflag Or mbeditflag

Case False

Me.lboperation.Text = "navigation operation"

visible_control(False)

' Navigation controls enebled(True or False

If Me.BindingContext(objbook_dset, "book").Position + 1 = 1 Then

NavigationFP(False)

NavigationNL(True)

GoTo PP1

ElseIf Me.BindingContext(objbook_dset, "book").Position + 1 = Me.BindingContext(objbook_dset, "book").Count Then

NavigationFP(True)

NavigationNL(False)

GoTo PP1

Else

NavigationFP(True)

NavigationNL(True)

End If

PP1:

Enabled_AMS(True)

Enabled_CFP(True)

Case True

If mbaddflag = True Then lboperation.Text = "add operation"

If mbeditflag = True Then Me.lboperation.Text = "mudify operation"

visible_control(True)

NavigationFP(False)

NavigationNL(False)

Enabled_AMS(False)

Enabled_CFP(False)

End Select

'show photo

sub_showphoto()

Me.lblNavLocation.Focus()

End Sub

Private Sub visible_control(ByVal bval As Boolean)

Me.cmbname.Visible = bval

Me.cmbfirst_name.Visible = bval

Me.cmbfather_name.Visible = bval

Me.DateTime_birth.Visible = bval

Me.cmbsex.Visible = bval

Me.cmbcivil_status.Visible = bval

Me.cmbcountry.Visible = bval

Me.cmbcity.Visible = bval

Me.editname.Visible = Not bval

Me.editfirst_name.Visible = Not bval

Me.editfather_name.Visible = Not bval

Me.editbirth.Visible = Not bval

Me.editcivil_status.Visible = Not bval

Me.editsex.Visible = Not bval

Me.editcountry.Visible = Not bval

Me.editcity.Visible = Not bval

Me.editname.Left = Me.cmbname.Left

Me.editname.Width = Me.cmbname.Width

Me.editname.Top = Me.cmbname.Top

Me.editfirst_name.Left = Me.cmbfirst_name.Left

Me.editfirst_name.Width = Me.cmbfirst_name.Width

Me.editfirst_name.Top = Me.cmbfirst_name.Top

Me.editfather_name.Left = Me.cmbfather_name.Left

Me.editfather_name.Width = Me.cmbfather_name.Width

Me.editfather_name.Top = Me.cmbfather_name.Top

Me.editbirth.Left = Me.DateTime_birth.Left

Me.editbirth.Width = Me.DateTime_birth.Width

Me.editbirth.Top = Me.DateTime_birth.Top

Me.editsex.Left = Me.cmbsex.Left

Me.editsex.Width = Me.cmbsex.Width

Me.editsex.Top = Me.cmbsex.Top

Me.editcivil_status.Left = Me.cmbcivil_status.Left

Me.editcivil_status.Width = Me.cmbcivil_status.Width

Me.editcivil_status.Top = Me.cmbcivil_status.Top

Me.editcountry.Left = Me.cmbcountry.Left

Me.editcountry.Width = Me.cmbcountry.Width

Me.editcountry.Top = Me.cmbcountry.Top

Me.editcity.Left = Me.cmbcity.Left

Me.editcity.Width = Me.cmbcity.Width

Me.editcity.Top = Me.cmbcity.Top

End Sub

' Enabled the controls

Private Sub NavigationFP(ByVal bval As Boolean)

Me.ToolBarfirst.Enabled = bval

Me.ToolBarpreview.Enabled = bval

End Sub

' Enabled the controls

Private Sub NavigationNL(ByVal bval As Boolean)

Me.ToolBarnext.Enabled = bval

Me.ToolBarlast.Enabled = bval

End Sub

'Toolbar items enabled .

Private Sub Enabled_AMS(ByVal bval As Boolean)

Me.ToolBaradd.Enabled = bval

Me.ToolBarmodify.Enabled = bval

Me.ToolBarsave.Enabled = Not bval

Me.ToolBarcancel.Enabled = Not bval

Me.lblNavLocation.Enabled = bval

End Sub

'Toolbar items enabled .

Private Sub Enabled_CFP(ByVal bval As Boolean)

Me.ToolBarsearch.Enabled = bval

Me.ToolBarprint.Enabled = bval

End Sub

'show photo

Private Sub sub_showphoto()

If (mbaddflag = False) Then

If Me.editphoto_photo.Text.Trim <> "" Then

If System.IO.File.Exists(Me.editphoto_photo.Text.Trim) = True Then

Me.Panel_photo.BorderStyle = BorderStyle.None

Me.Pic_photo.Image = Image.FromFile(Me.editphoto_photo.Text.Trim)

Me.Pic_photo.Left = (Me.Panel_photo.Width - Me.Pic_photo.Width) / 2

Me.Pic_photo.Top = (Me.Panel_photo.Height - Me.Pic_photo.Height) / 2

Me.Btnphoto_del.Enabled = False

Me.Btnphoto_new.Enabled = False

If mbeditflag = True Then

Me.Btnphoto_del.Enabled = True

Me.Btnphoto_new.Enabled = True

End If

Else

GoTo pt

End If

Else

pt:

Me.Pic_photo.Image = Nothing

Me.Panel_photo.BorderStyle = BorderStyle.FixedSingle

If mbeditflag = True Then

Me.Btnphoto_new.Enabled = True

Else

Me.Btnphoto_new.Enabled = False

End If

Me.Btnphoto_del.Enabled = False

End If

End If

End Sub

Private Sub NavPrev()

Me.BindingContext(objbook_dset, "book").Position = (Me.BindingContext(objbook_dset, "book").Position - 1)

Me.objbook_dset_PositionChanged()

End Sub

Private Sub NavNext()

Me.BindingContext(objbook_dset, "book").Position = (Me.BindingContext(objbook_dset, "book").Position + 1)

Me.objbook_dset_PositionChanged()

End Sub

Private Sub NavLast()

Me.BindingContext(objbook_dset, "book").Position = (Me.objbook_dset.Tables("book").Rows.Count - 1)

Me.objbook_dset_PositionChanged()

End Sub

Private Sub sub_add()

Me.cmbname.SelectedIndex = -1

Me.cmbfirst_name.SelectedIndex = -1

Me.cmbfather_name.SelectedIndex = -1

Me.cmbsex.SelectedIndex = -1

Me.cmbcivil_status.SelectedIndex = -1

Me.cmbcountry.SelectedIndex = -1

Me.cmbcity.SelectedIndex = -1

Try

'Clear out the current edits

Me.BindingContext(objbook_dset, "book").EndCurrentEdit()

Me.BindingContext(objbook_dset, "book").AddNew()

mbaddflag = True

 

Catch eEndEdit As System.Exception

System.Windows.Forms.MessageBox.Show(eEndEdit.Message)

End Try

'show photo ...

Me.Btnphoto_del.Enabled = False

Me.Btnphoto_new.Enabled = True

 

Me.objbook_dset_PositionChanged()

End Sub

'--->

'show photo, add or remove/delete photo '''''''''''''''''''''

Private Sub Btnphoto_new_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btnphoto_new.Click

If mbaddflag = True Or mbeditflag = True Then

'OpenFileDialog control, displays the Photo corresponding and save it ...

sub_addphoto()

End If

End Sub

'OpenFileDialog control, displays the Photo corresponding and save it ...

Private Sub sub_addphoto()

Dim vfilename As String

Me.OpenFileDialog1.Title = "Book note, Select Picture"

Me.OpenFileDialog1.Filter = "All Files|*.*|JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif"

Me.OpenFileDialog1.FilterIndex = 3

' Show the Dialog, if the user clicked in the dialog and a picture file was selected, open it.

If OpenFileDialog1.ShowDialog() = DialogResult.OK Then

'add record to table per_appphoto

vfilename = OpenFileDialog1.FileName

Me.Panel_photo.BorderStyle = BorderStyle.None

Me.Pic_photo.Image = Image.FromFile(OpenFileDialog1.FileName)

Me.Pic_photo.Left = (Me.Panel_photo.Width - Me.Pic_photo.Width) / 2

Me.Pic_photo.Top = (Me.Panel_photo.Height - Me.Pic_photo.Height) / 2

Me.editphoto_photo.Text = vfilename

Me.Btnphoto_del.Enabled = True

End If

End Sub

Private Sub Btnphoto_del_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btnphoto_del.Click

If mbaddflag = True Or mbeditflag = True Then

' remove/delete photo and clear the file photo name corresponding

sub_removephoto()

End If

End Sub

' remove/delete photo and clear the file photo name corresponding

Private Sub sub_removephoto()

Dim response As MsgBoxResult

Dim msg_inf As String

Dim vvrec As Integer

msg_inf = "are you sure want to remove the photo of - " + Me.editfirst_name.Text + " " + Me.editname.Text

response = MsgBox(msg_inf, MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Information Or MsgBoxStyle.YesNo, Title)

'Gets the result of the MessageBox display.

If (response = MsgBoxResult.Yes) Then

'clear photo ...

Me.Panel_photo.BorderStyle = BorderStyle.FixedSingle

Pic_photo.Image.Dispose()

Pic_photo.Image = Nothing

Me.editphoto_photo.Text = ""

Me.Btnphoto_del.Enabled = False

Exit Sub

End If

If (response = MsgBoxResult.No) Then

Exit Sub

End If

End Sub

'<---

Private Sub sub_modify()

booknote_type = "edit"

mbeditflag = True

sub_Searchedit()

fbook_search.ShowDialog()

End Sub

Private Sub sub_Searchedit()

NavigationFP(False)

NavigationNL(False)

Enabled_AMS(False)

Enabled_CFP(False)

Me.ToolBarsave.Enabled = False

Me.ToolBarcancel.Enabled = False

End Sub

Public Sub sub_modifyok()

Me.BindingContext(objbook_dset, "book").Position = book_recno

Me.objbook_dset_PositionChanged()

Me.cmbname.Text = Me.editname.Text

Me.cmbfirst_name.Text = Me.editfirst_name.Text

Me.cmbfather_name.Text = Me.editfather_name.Text

Me.DateTime_birth.Text = Me.editbirth.Text

Me.cmbsex.Text = Me.editsex.Text

Me.cmbcivil_status.Text = Me.editcivil_status.Text

Me.cmbcountry.Text = Me.editcountry.Text

Me.cmbcity.Text = Me.editcity.Text

End Sub

Public Sub Searchedit_cancel()

mbeditflag = False

objbook_dset_PositionChanged()

End Sub

 

Private Sub sub_Update()

Dim response As MsgBoxResult

'convert, comboboxes to textboxes

Me.editname.Text = Me.cmbname.Text

Me.editfirst_name.Text = Me.cmbfirst_name.Text

Me.editfather_name.Text = Me.cmbfather_name.Text

Me.editbirth.Text = Me.DateTime_birth.Text

Me.editsex.Text = Me.cmbsex.Text

Me.editcivil_status.Text = Me.cmbcivil_status.Text

Me.editcountry.Text = Me.cmbcountry.Text

Me.editcity.Text = Me.cmbcity.Text

Me.editoriginalfirst_name.Text = Me.cmbfirst_name.Text

Me.editbirth_d.Text = Str(Me.DateTime_birth.Value.Day)

Me.editbirth_m.Text = Str(Me.DateTime_birth.Value.Month)

Me.editbirth_y.Text = Str(Me.DateTime_birth.Value.Year)

If (mbeditflag Or mbaddflag) Then

If ((Me.editname.Text = "") Or (Me.editfirst_name.Text = "") Or (Me.editfather_name.Text = "")) Then

response = MsgBox("save operation aborted - name box, first name box or father name box empty(ies) ...", MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Information Or MsgBoxStyle.YesNo, Title)

If (response = MsgBoxResult.Yes) Then Exit Sub

If (response = MsgBoxResult.No) Then sub_Cancel()

Exit Sub

Else

sub_updateok(Trim(Me.editname.Text), Trim(Me.editfirst_name.Text), Trim(Me.editfather_name.Text))

Try

'Attempt to update the datasource.

Me.UpdateDataSet()

Catch eUpdate As System.Exception

'Add your error handling code here.

'Display error message, if any.

System.Windows.Forms.MessageBox.Show(eUpdate.Message)

End Try

'load book table, objbook_dset dataset

LoadDataSet()

Me.objbook_dset_PositionChanged()

End If

End If

End Sub

'add data to comboboxes

Private Sub sub_updateok(ByVal v_name As String, ByVal v_first As String, ByVal v_father As String)

Dim WhereSearch As String = ""

Dim v_ord As Integer

WhereSearch = " WHERE ((name = '" & v_name & "') And (originalfirst_name = '" & v_first & "') And (father_name = '" & v_father & "'))"

vselect1 = New OleDb.OleDbCommand("SELECT bookid, name, first_name, originalfirst_name, father_name FROM book" & WhereSearch & " ORDER BY bookid")

vda1 = New OleDb.OleDbDataAdapter(vselect1)

vdset1 = New DataSet

vselect1.Connection() = fagenda.OleDbConnection1 ' Select command

vselect1.CommandTimeout = 30

vdset1.EnforceConstraints = False

Try

fagenda.OleDbConnection1.Open()

vda1.Fill(vdset1, "book")

Catch fillException As System.Exception

System.Windows.Forms.MessageBox.Show(fillException.Message)

End Try

vdset1.EnforceConstraints = True

fagenda.OleDbConnection1.Close()

If vdset1.Tables("book").Rows.Count() > 0 Then

v_ord = vdset1.Tables("book").Rows.Count() - 1

Me.editfirst_name.Text = Trim(Me.editoriginalfirst_name.Text) & Trim(Str(v_ord))

End If

End Sub

Public Sub UpdateDataSet()

'Create a new dataset to hold the changes that have been made to the main dataset.

Dim objDataSetChanges As work_VBNet.book_dset = New work_VBNet.book_dset

'Stop any current edits.

Me.BindingContext(objbook_dset, "book").EndCurrentEdit()

'Get the changes that have been made to the main dataset.

objDataSetChanges = CType(objbook_dset.GetChanges, work_VBNet.book_dset)

'Check to see if any changes have been made.

If (Not (objDataSetChanges) Is Nothing) Then

Try

'There are changes that need to be made, so attempt to update the datasource by

'calling the update method and passing the dataset and any parameters.

Me.UpdateDataSource(objDataSetChanges)

objbook_dset.Merge(objDataSetChanges)

objbook_dset.AcceptChanges()

Catch eUpdate As System.Exception

'Add your error handling code here.

Throw eUpdate

End Try

'Add your code to check the returned dataset for any errors that may have been

'pushed into the row object's error.

End If

End Sub

Public Sub UpdateDataSource(ByVal ChangedRows As work_VBNet.book_dset)

Try

'The data source only needs to be updated if there are changes pending.

If (Not (ChangedRows) Is Nothing) Then

'Open the connection.

Me.OleDbConnection1.Open()

'Attempt to update the data source.

OleDbDataAdapter1.Update(ChangedRows)

End If

Catch updateException As System.Exception

'Add your error handling code here.

Throw updateException

Finally

'Close the connection whether or not the exception was thrown.

Me.OleDbConnection1.Close()

End Try

End Sub

Private Sub sub_Cancel()

Me.objbook_dset.RejectChanges()

Me.BindingContext(objbook_dset, "book").CancelCurrentEdit()

Me.objbook_dset_PositionChanged()

End Sub

Private Sub sub_find()

booknote_type = "find"

sub_Searchedit()

fbook_search.ShowDialog()

End Sub

Public Sub sub_findok()

Me.BindingContext(objbook_dset, "book").Position = book_recno

Me.objbook_dset_PositionChanged()

Me.lboperation.Text = "search operation"

End Sub

Private Sub sub_print()

' Me.objbook_dset_PositionChanged()

End Sub

 

End Class

 

 

   
  
 



 

      Return