-
Dec 15th, 2017, 07:50 PM
#1
Thread Starter
Member
How to make changes on one form that will change information on another form
I am trying to get column 6 in the data grid view to be subtracted by 1 when the save button is pressed. The problem is the data grid view of column 6 is on my book_table form and the save button that i will press to subtract 1 from the data grid view is on my transaction form.
I have written this bit of code but it does not seem to work. i created a variable called butclcik and set its return type as a boolean. (Public butclcik As Boolean) Then i made an instance of the Book table called boktble. (Dim boktble As Book_Table = New Book_Table) I then tried to subtract 1 from the datagridview column 6 like this
Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1)
vb.net Code:
Dim boktble As Book_Table = New Book_Table Public butclcik As Boolean Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click butclcik = True Try If butclcik = True Then Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1) End If Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) DayOverduetextbox.Text = datatiercal.Daysoverdueprocal Transaction_TableDataGridView.Columns(7).DefaultCellStyle.Format = "c" Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) MsgBox("Transaction was saved") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
This is all the code in my transaction form.
vb.net Code:
Public Class Transactions_Table Private Shared Instance As Transactions_Table Public Shared ReadOnly Property TransactionsTableInstance() As Transactions_Table Get If Instance Is Nothing Then Instance = New Transactions_Table End If Return Instance End Get End Property Private Sub Transaction_TableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub Transactions_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Book_TableTableAdapter1.Fill(Me.LibrarymanagementDataSet2.Book_Table) 'TODO: This line of code loads data into the 'LibrarymanagementDataSet2.Transaction_Table' table. You can move, or remove it, as needed. Me.Transaction_TableTableAdapter.Fill(Me.LibrarymanagementDataSet2.Transaction_Table) End Sub Dim boktble As Book_Table = New Book_Table Public butclcik As Boolean Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click butclcik = True Try If butclcik = True Then Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1) End If Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) DayOverduetextbox.Text = datatiercal.Daysoverdueprocal Transaction_TableDataGridView.Columns(7).DefaultCellStyle.Format = "c" Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) MsgBox("Transaction was saved") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub Transactions_Table_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing Instance = Nothing End Sub Private Sub Transaction_TableBindingNavigatorSaveItem_Click_1(sender As Object, e As EventArgs) Handles Transaction_TableBindingNavigatorSaveItem.Click Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click Try Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) Transaction_TableBindingSource.AddNew() DayOverduetextbox.Text = datatiercal.Daysoverdueprocal CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click Try Dim result As Integer = MessageBox.Show("Are you sure you want to delete this Transaction", "Delete Transaction", MessageBoxButtons.YesNo) If result = DialogResult.No Then MessageBox.Show("Transaction was not deleted") ElseIf result = DialogResult.Yes Then Transaction_TableBindingSource.RemoveCurrent() MessageBox.Show("The Transaction was deleted") End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click Try Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) DayOverduetextbox.Text = datatiercal.Daysoverdueprocal Transaction_TableDataGridView.Columns(7).DefaultCellStyle.Format = "c" Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) MsgBox("Transaction was Updated") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub RenewButton_Click(sender As Object, e As EventArgs) Handles RenewButton.Click Try Due_DateDateTimePicker.Value = Due_DateDateTimePicker.Value.Date.AddDays(7) Return_DateDateTimePicker.Value = Due_DateDateTimePicker.Value.Date Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) DayOverduetextbox.Text = datatiercal.Daysoverdueprocal Transaction_TableDataGridView.Columns(7).DefaultCellStyle.Format = "c" Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) MsgBox("The Book has Been Renews for a week") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub FillByToolStripButton_Click(sender As Object, e As EventArgs) Try Me.Transaction_TableTableAdapter.FillBy(Me.LibrarymanagementDataSet2.Transaction_Table) Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub IDToolStripButton_Click(sender As Object, e As EventArgs) Handles IDToolStripButton.Click Try Me.Transaction_TableTableAdapter.ID(Me.LibrarymanagementDataSet2.Transaction_Table, CType(Param1ToolStripTextBox.Text, Integer)) Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Transaction_TableBindingSource.MovePrevious() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Try Transaction_TableBindingSource.MoveNext() Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class
Last edited by Srut; Dec 15th, 2017 at 07:53 PM.
-
Dec 15th, 2017, 11:49 PM
#2
Re: How to make changes on one form that will change information on another form
Which forum creates and displays the other and how does it do it? I'm on a phone and there appears to be a lot of irrelevant code to look through to see whether you've included that.
-
Dec 16th, 2017, 12:56 AM
#3
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
I have a form called book management system which is a mdi container. from the book management form i can open the transaction _form and book_form. what i want to do is have the transaction form subtract a value from the data grid form on the Book_form. but the code i wrote to do this isn't working and i am unsure why.
-
Dec 16th, 2017, 02:13 PM
#4
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
Anyone else who reads this have any idea could use all the help i get
-
Dec 16th, 2017, 02:59 PM
#5
Re: How to make changes on one form that will change information on another form
This line has problems,
Code:
Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1)
Your trying to subtract 1 from a dgv column ValueType, do you really want to change the columns value type?
It sounds like you want to change a value in the Books table after you have changed a value in the transaction table. If so, then work directly with the books table. then when you open the Books_Table form the value will already be correct.
-
Dec 16th, 2017, 07:52 PM
#6
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
i tired working with the book table directly but the butclick variable stay false when i check if the button was pressed. can you give me more detail about how to get it to work directly from the book_table
-
Dec 16th, 2017, 09:43 PM
#7
Re: How to make changes on one form that will change information on another form
Originally Posted by Srut
i tired working with the book table directly but the butclick variable stay false when i check if the button was pressed. can you give me more detail about how to get it to work directly from the book_table
It's hard for me to even respond to this because it really doesn't make sense. At least not to me.
this code,
Code:
Public butclcik As Boolean
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
butclcik = True
Try
If butclcik = True Then
Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1)
End If
Doesn't make sense. butclcik is ALWAYS true when you click the Savebutton, it really doesn't serve any purpose.
I can't really help with working directly with the Book table without more information.
I am trying to get column 6 in the data grid view to be subtracted by 1 when the save button is pressed
I'm guessing that the dgv column 6 is bound to a field in the Book table. Are you saying you want to subtract 1 from the value in that field for EVERY row in that table? If so you can do that by manually cycling through the Me.LibrarymanagementDataSet2.Book_Table datatable using a For/Next loop or add an Update Query to the Book_TableTableAdapter in the LibrarymanagementDataSet2 dataset.
-
Dec 16th, 2017, 09:55 PM
#8
Re: How to make changes on one form that will change information on another form
If you have an object on a Form, and you want to access that object from another Form, you must declare that object variable as a public variable, or use a public property to access the object if it's variable is private. It's no different to manipulating objects on any other class.
-
Dec 16th, 2017, 09:56 PM
#9
Re: How to make changes on one form that will change information on another form
If you want one MDI child form to affect a change on another then the "proper" way is to do it without either knowing that the other exists. If child A is to make a change on child B then child A should raise an event, the parent form should handle that event and call a method of child B and then child B should make the change.
I'm guessing that you don't want to go that far though, so the options for child A getting direct access to child B are:
1. If child B is the default instance of it's type then child A can access it via the default instance.
2. Child A can use a loop or LINQ query to get a reference to child B from the MdiChildren collection of its MdiParent.
3. The parent form can pass a child B reference into child A.
You need to decide which way you want to go.
Once child A has a reference to child B, I would still very much suggest that child A simply calls a method and the actual change is made by child B to itself within that method.
-
Dec 17th, 2017, 12:00 PM
#10
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
Originally Posted by wes4dbt
It's hard for me to even respond to this because it really doesn't make sense. At least not to me.
this code,
Code:
Public butclcik As Boolean
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
butclcik = True
Try
If butclcik = True Then
Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1)
End If
Doesn't make sense. butclcik is ALWAYS true when you click the Savebutton, it really doesn't serve any purpose.
I can't really help with working directly with the Book table without more information.
I'm guessing that the dgv column 6 is bound to a field in the Book table. Are you saying you want to subtract 1 from the value in that field for EVERY row in that table? If so you can do that by manually cycling through the Me.LibrarymanagementDataSet2.Book_Table datatable using a For/Next loop or add an Update Query to the Book_TableTableAdapter in the LibrarymanagementDataSet2 dataset.
ok so i made a method in the book table called Copiescount()
vb.net Code:
Public Sub Copiescount() If Transactions_Table.butclcik = True Then CopiesTextBox.Text = Double.Parse((CopiesTextBox.Text = CopiesTextBox.Text) - 1) Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) Me.Book_TableTableAdapter.Update(Me.LibrarymanagementDataSet2) End If End Sub
here i check to see if the butclcik is true in the transaction form before doing the calculations in the book form. when i check if the butclcik value is true it comes back correct so that part is fine. the problem is the calculation is not being made. p.s in changed it to the copiestextbox instead of the datagridview.
Last edited by Srut; Dec 17th, 2017 at 12:15 PM.
-
Dec 17th, 2017, 12:04 PM
#11
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
Originally Posted by Niya
If you have an object on a Form, and you want to access that object from another Form, you must declare that object variable as a public variable, or use a public property to access the object if it's variable is private. It's no different to manipulating objects on any other class.
i did do this in the transaction table to get the value of butclcik in the Book_table and it works now thank you but the problem is getting the expression to make the subtraction from the values in the book_table after it checks if butclcik is true in the Transaction table.
vb.net Code:
Public Shared butclcik As Boolean Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click Try butclcik = True Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) DayOverduetextbox.Text = datatiercal.Daysoverdueprocal Transaction_TableDataGridView.Columns(7).DefaultCellStyle.Format = "c" Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.Book_TableTableAdapter1.Update(Me.LibrarymanagementDataSet2) Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) MsgBox("Transaction was saved") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
Last edited by Srut; Dec 17th, 2017 at 12:19 PM.
-
Dec 17th, 2017, 12:17 PM
#12
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
here is the book table where i am now working directly with as you guys suggested but the calculation are not being done
vb.net Code:
Public Class Book_Table Private Shared Instance As Book_Table Public Shared ReadOnly Property BoolTableInstance() As Book_Table Get If Instance Is Nothing Then Instance = New Book_Table() End If Return Instance End Get End Property Public Sub Copiescount() If Transactions_Table.butclcik = True Then CopiesTextBox.Text = Double.Parse((CopiesTextBox.Text = CopiesTextBox.Text) - 1) Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) Me.Book_TableTableAdapter.Update(Me.LibrarymanagementDataSet2) End If End Sub Private Sub Book_TableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles Book_TableBindingNavigatorSaveItem.Click Me.Validate() Me.Book_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click Try Book_TableBindingSource.AddNew() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click Try Me.Validate() Me.Book_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) Book_NameTextBox.Select() MsgBox("Book Was Saved") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click Try Dim result As Integer = MessageBox.Show("Are you sure you want to delete this Book", "Delete Book", MessageBoxButtons.YesNo) If result = DialogResult.No Then MessageBox.Show("Book was not deleted") ElseIf result = DialogResult.Yes Then Book_TableBindingSource.RemoveCurrent() MessageBox.Show("The Book was deleted") End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub Update_Book_Click(sender As Object, e As EventArgs) Handles Update_Book.Click Try Me.Validate() Me.Book_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) MsgBox("Book was updated") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub Book_Table_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing Instance = Nothing End Sub Private Sub View_Books_Click(sender As Object, e As EventArgs) Handles View_Books.Click Dim ViewBooksub As ViewBook = ViewBook.ViewBookInstance ViewBooksub.Show() ViewBooksub.Focus() End Sub Private Sub Book_TableBindingNavigatorSaveItem_Click_1(sender As Object, e As EventArgs) Handles Book_TableBindingNavigatorSaveItem.Click Me.Validate() Me.Book_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub Book_TableBindingNavigatorSaveItem_Click_2(sender As Object, e As EventArgs) Handles Book_TableBindingNavigatorSaveItem.Click Me.Validate() Me.Book_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub Book_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'LibrarymanagementDataSet2.Book_Table' table. You can move, or remove it, as needed. Me.Book_TableTableAdapter.Fill(Me.LibrarymanagementDataSet2.Book_Table) Validate() Book_TableBindingSource.EndEdit() TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub Book_ID2ToolStripButton_Click(sender As Object, e As EventArgs) Handles Book_ID2ToolStripButton.Click Try Me.Book_TableTableAdapter.Book_ID2(Me.LibrarymanagementDataSet2.Book_Table, CType(Param1ToolStripTextBox.Text, Integer)) Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Book_TableBindingNavigator.MovePreviousItem.PerformClick() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Try Book_TableBindingNavigator.MoveNextItem.PerformClick() Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub CopiesTextBox_TextChanged(sender As Object, e As EventArgs) Handles CopiesTextBox.TextChanged End Sub End Class
here is the transaction table.
vb.net Code:
Public Class Transactions_Table Private Shared Instance As Transactions_Table Public Shared ReadOnly Property TransactionsTableInstance() As Transactions_Table Get If Instance Is Nothing Then Instance = New Transactions_Table End If Return Instance End Get End Property Private Sub Transaction_TableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) End Sub Private Sub Transactions_Table_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Book_TableTableAdapter1.Fill(Me.LibrarymanagementDataSet2.Book_Table) 'TODO: This line of code loads data into the 'LibrarymanagementDataSet2.Transaction_Table' table. You can move, or remove it, as needed. Me.Transaction_TableTableAdapter.Fill(Me.LibrarymanagementDataSet2.Transaction_Table) End Sub Public Shared butclcik As Boolean Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click Try butclcik = True Dim datatiercal As DataTier = New DataTier(Due_DateDateTimePicker.Value.Date, Return_DateDateTimePicker.Value.Date) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) DayOverduetextbox.Text = datatiercal.Daysoverdueprocal Transaction_TableDataGridView.Columns(7).DefaultCellStyle.Format = "c" Me.Validate() Me.Transaction_TableBindingSource.EndEdit() Me.Book_TableTableAdapter1.Update(Me.LibrarymanagementDataSet2) Me.TableAdapterManager.UpdateAll(Me.LibrarymanagementDataSet2) CostTextBox.Text = String.Format("{0:c2}", datatiercal.finepreiceprocal) MsgBox("Transaction was saved") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
Last edited by Srut; Dec 17th, 2017 at 12:34 PM.
-
Dec 17th, 2017, 12:23 PM
#13
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
Originally Posted by wes4dbt
It's hard for me to even respond to this because it really doesn't make sense. At least not to me.
this code,
Code:
Public butclcik As Boolean
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
butclcik = True
Try
If butclcik = True Then
Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1)
End If
Doesn't make sense. butclcik is ALWAYS true when you click the Savebutton, it really doesn't serve any purpose.
I can't really help with working directly with the Book table without more information.
I'm guessing that the dgv column 6 is bound to a field in the Book table. Are you saying you want to subtract 1 from the value in that field for EVERY row in that table? If so you can do that by manually cycling through the Me.LibrarymanagementDataSet2.Book_Table datatable using a For/Next loop or add an Update Query to the Book_TableTableAdapter in the LibrarymanagementDataSet2 dataset.
?
ok i just read what you wrote completely if i make an update query and display this as a datagridview it will place the updated information for the number of copies after i have made a transaction in my transaction table?
-
Dec 17th, 2017, 12:32 PM
#14
Thread Starter
Member
Re: How to make changes on one form that will change information on another form
Originally Posted by wes4dbt
It's hard for me to even respond to this because it really doesn't make sense. At least not to me.
this code,
Code:
Public butclcik As Boolean
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
butclcik = True
Try
If butclcik = True Then
Double.Parse((boktble.Book_TableDataGridView.Columns(6).ValueType = boktble.Book_TableDataGridView.Columns(6).ValueType) - 1)
End If
Doesn't make sense. butclcik is ALWAYS true when you click the Savebutton, it really doesn't serve any purpose.
I can't really help with working directly with the Book table without more information.
I'm guessing that the dgv column 6 is bound to a field in the Book table. Are you saying you want to subtract 1 from the value in that field for EVERY row in that table? If so you can do that by manually cycling through the Me.LibrarymanagementDataSet2.Book_Table datatable using a For/Next loop or add an Update Query to the Book_TableTableAdapter in the LibrarymanagementDataSet2 dataset.
how would i go about subtracting 1 from the copies in the book table after i make a transaction in the transaction table and click save. i thought after i click save in the transaction table and make butclick true then it would preform the expression to subtract 1 from copies in the book table after it checks if butclcik is true. but you are telling me after i click it and butclick will alsway be true so i cant use it this way. how would i go about make it so every time i click save in the transaction table the expression to subtract 1 from copies is done in the book table.
-
Dec 17th, 2017, 03:33 PM
#15
Re: How to make changes on one form that will change information on another form
Here's an example, you will have to change the names to work with your system.
Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim row As DataRow = Me.BooksDBDataSet.Books.FindByBookId(3)
If Not row Is Nothing Then
row("copies") = CInt(row("copies")) - 1
Me.BooksTableAdapter.Update(Me.BooksDBDataSet.Books)
End If
End Sub
You will have to replace Me.BooksDBDataSet.Books.FindByBookId(3) the "3" with the current BookId value in the transaction table.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|