DataGridView update problem

Vladimir Nikitovic

New member
Joined
Aug 28, 2008
Messages
1
Programming Experience
5-10
Hi,
Short intro: Program is for managing supplies of the restaurant
There are simple items to sell or complex items with ingredients. This part of program manage complex items with ingredients.

From the list of items you chose item and then you can make a list of ingredients that item is consist of :

ekran1_resize.jpg


VB.NET:
CODE:

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


'Manage Items to chose in combo box

Me.MagacinTableAdapter.Fill(Me.KonobarDataSet.Magacin)

'To display without errasing table

Me.MagacinSlozeniTableAdapter.ClearBeforeFill = True

'to show ingredients of choosen item by BrojID

Me.MagacinSlozeniTableAdapter.Fillby(Me.KonobarDataSet.MagacinSlozeni, BrojID)

End Sub



Ingredients of item Palačinke (Pancakes):
Combo box is linked to table Magacin (Items)
List of item as ingredients is in table MagacinSlozeni (ItemsComplex)

sastojci.jpg


For better review further I will display a whole table:

sastojcividi_resize.jpg


If you chose item form combo box and then put Kolicina (quantity), it appears in table like this:

sastojcividiananas_resize.jpg


VB.NET:
CODE:

Private Sub MagacinSlozeniDataGridView_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles MagacinSlozeniDataGridView.CellEndEdit

Dim Red As KonobarDataSet.MagacinSlozeniRow
Red = CType(CType(Me.MagacinSlozeniBindingSource.Current, DataRowView).Row, KonobarDataSet.MagacinSlozeniRow)

Dim NoviRed As KonobarDataSet.MagacinRow
NoviRed = CType(CType(Me.MagacinBindingSource.Current, DataRowView).Row, KonobarDataSet.MagacinRow)

Select Case e.ColumnIndex.ToString
Case 2
Red.MagacinID = BrojID
Red.cena = NoviRed.Cena
Red.Naziv = NoviRed.Naziv
Red.JedinicaMere = NoviRed.JedinicaMere
Red.Kolicina = 0
Case 4
Case 5

'If item is complex:

If NoviRed.Slozeni = True Then
Dim KolicinaID As Decimal
MagacinID = NoviRed.ID
KolicinaID = Red.Kolicina

Me.MagacinSlozeniTableAdapter.FillByMagacinID(Me.KonobarDataSet.MagacinSlozeni, BrojID, KolicinaID, MagacinID)
Me.MagacinSlozeniBindingSource.MoveLast()

End If
End Select



If you chose item that already have ingredients, like another Palacinka, all of them appears in table:

faza1_resize.jpg



Red item is Palacinka chosen from combo box and yellow are ingredients programmatically filled:

faza2_resize.jpg



And when the floppy is pressed:

faza3_resize.jpg


VB.NET:
CODE:

Private Sub MagacinSlozeniBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MagacinSlozeniBindingNavigatorSaveItem.Click

Me.Validate()

Me.MagacinSlozeniBindingSource.EndEdit()

Me.MagacinSlozeniTableAdapter.Update(Me.KonobarDataSet.MagacinSlozeni)

End Sub


FINALY THE PROBLEM:

Only items that are choose from the combo box is Saved, NONE of ingredients

faza4_resize.jpg


Where is the problem...

How to solve it...

http://www.ti.rs/problem/problem.html

Done (not successfully) with:
Visual Studio 2008
SQL Express 2005
 
Back
Top