dineshkumaar
Member
- Joined
- Jun 5, 2009
- Messages
- 21
- Programming Experience
- 10+
Hi Everybody
I am developing a software for keeping record of Delivery of a particular product.
I have a Table named 'DelMan' which is the mastar table of Deliverymen
I have another Table called 'Deliveries' to store Daily Delivery details for all the deliverymen
I wanted to design the User interface in such a way that the user can enter the data either using textboxes of using datagridview.
for the purpose, I provided Bound Textboxes and also bound datagridview (for the same table 'Deliveries') on the form.
The Textboxes are contained in a panel control on the form while datagridview is on the form.
The user interface goes like this:
when the form loads, user needs to enter the date of delivery. After the date is entered, Delivery table is populated with the enterd 'date', 'Product', 'Rate' values for each deliveryman from 'Delman' table. The 'Qty' Column has to be entered by the user and the amount is calculated.
The main problem is that when I Enter the qunatity for the first record (or deliveryman) and save it, it is succesfully done. But when I enter the 'qty' value for the next record and save it, it give the following error:
" Concurrency Voilation: The update command affected 0 of the expected 1 records. "
Please help.
I am attatching the Pic of the UI form.
the Code is as under:
Thanks a lot
Dinesh Kumaar
I am developing a software for keeping record of Delivery of a particular product.
I have a Table named 'DelMan' which is the mastar table of Deliverymen
I have another Table called 'Deliveries' to store Daily Delivery details for all the deliverymen
I wanted to design the User interface in such a way that the user can enter the data either using textboxes of using datagridview.
for the purpose, I provided Bound Textboxes and also bound datagridview (for the same table 'Deliveries') on the form.
The Textboxes are contained in a panel control on the form while datagridview is on the form.
The user interface goes like this:
when the form loads, user needs to enter the date of delivery. After the date is entered, Delivery table is populated with the enterd 'date', 'Product', 'Rate' values for each deliveryman from 'Delman' table. The 'Qty' Column has to be entered by the user and the amount is calculated.
The main problem is that when I Enter the qunatity for the first record (or deliveryman) and save it, it is succesfully done. But when I enter the 'qty' value for the next record and save it, it give the following error:
" Concurrency Voilation: The update command affected 0 of the expected 1 records. "
Please help.
I am attatching the Pic of the UI form.
the Code is as under:
VB.NET:
Public Class frmDelivery
Dim stkDateTimePicker As Date
Dim DisableRowEnter As Boolean = False
Dim DisableCombo As Boolean = False
Private Sub DeliveriesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeliveriesBindingNavigatorSaveItem.Click, btnSave.Click
'DeliveriesBindingSource.CurrencyManager.Refresh()
Try
Me.Validate()
Me.DeliveriesBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.BpclDRnDataSet)
MsgBox("Records Saved Successfully")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub frmDelivery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'BpclDRnDataSet.ProdMaster' table. You can move, or remove it, as needed.
Me.ProdMasterTableAdapter.Fill(Me.BpclDRnDataSet.ProdMaster)
'TODO: This line of code loads data into the 'BpclDRnDataSet.ProdMaster' table. You can move, or remove it, as needed.
Me.DelManTableAdapter.Fill(Me.BpclDRnDataSet.DelMan)
'TODO: This line of code loads data into the 'BpclDRnDataSet.DelMan' table. You can move, or remove it, as needed.
Me.DelManTableAdapter.Fill(Me.BpclDRnDataSet.DelMan)
'TODO: This line of code loads data into the 'BpclDRnDataSet.Deliveries' table. You can move, or remove it, as needed.
Me.DeliveriesTableAdapter.Fill(Me.BpclDRnDataSet.Deliveries)
tspDate.Text = Date.Today.ToShortDateString
tspDate.Focus()
End Sub
Private Sub tspDate_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tspDate.Leave
stkDateTimePicker = CDate(tspDate.Text)
GetData(tspDate.Text)
End Sub
Private Sub GetData(ByVal mStkDate As Date)
Dim delvmf As DataRowView
Dim DeliveryReg As bpclDRnDataSet.DeliveriesRow
Dim prodmf As DataRowView = ProdMasterBindingSource.Current
For Each delvmf In DelManBindingSource
Dim fpos As Int16 = DeliveriesBindingSource.Find("DelManCode", delvmf("DelManCode"))
If fpos = -1 Then
DeliveryReg = BpclDRnDataSet.Tables("Deliveries").NewRow
DeliveryReg("DelManCode") = delvmf("DelManCode")
DeliveryReg("DelMan") = delvmf("DelvManName")
DeliveryReg("StkDate") = stkDateTimePicker
DeliveryReg("ProdCode") = prodmf("ProdCode")
DeliveryReg("ProdDescr") = prodmf("ProdDescr")
DeliveryReg("Net_Retail") = prodmf("Net_retail")
DeliveryReg("Qty") = 0
DeliveryReg("Amount") = 0
DeliveryReg("AmtRecd") = 0
DeliveryReg("isCylinder") = prodmf("isCylinder")
DeliveryReg("isRegulator") = prodmf("isRegulator")
DeliveryReg("isHotPlate") = prodmf("isHotPlate")
DeliveryReg("isRubberTube") = prodmf("isRubberTube")
DeliveryReg("isCommercial") = prodmf("isCommercial")
DeliveryReg("isDomestic") = prodmf("isDomestic")
DeliveryReg("is14kgDom") = prodmf("is14kgDom")
DeliveryReg("is19kgCom") = prodmf("is19kgCom")
BpclDRnDataSet.Tables("Deliveries").Rows.Add(DeliveryReg)
End If
Next
End Sub
Private Sub tspFind_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tspFind.TextChanged
FindinGrid(tspFind.Text)
End Sub
Private Sub FindinGrid(ByVal mDelMan As String)
For Each dgv As DataGridViewRow In DeliveriesDataGridView.Rows
If Mid(dgv.Cells("DelMan").Value, 1, Len(mDelMan)).ToUpper = mDelMan.ToUpper Then
DeliveriesDataGridView.CurrentCell = dgv.Cells("DelMan")
Exit For
End If
Next
End Sub
Private Sub QtyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QtyTextBox.TextChanged
If Len(QtyTextBox.Text) > 0 Then
If Not IsDBNull(DeliveriesBindingSource.Current("Net_Retail")) And Not IsDBNull(QtyTextBox.Text) Then
AmountTextBox.Text = QtyTextBox.Text * DeliveriesBindingSource.Current("Net_Retail")
AmtRecdTextBox.Text = AmountTextBox.Text
End If
End If
End Sub
Private Sub DeliveriesDataGridView_RowEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DeliveriesDataGridView.RowEnter
DisableCombo = True
If Not DisableRowEnter Then
DelManCodeComboBox.Text = DeliveriesDataGridView.Rows(e.RowIndex).Cells("DelMan").Value
End If
DisableRowEnter = False
End Sub
Private Sub DelManCodeComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DelManCodeComboBox.SelectedIndexChanged
DisableRowEnter = True
If Not DisableCombo Then
FindinGrid(DelManCodeComboBox.Text)
End If
DisableCombo = False
End Sub
Private Sub DeliveriesBindingNavigator_Refre****ems(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeliveriesBindingNavigator.Refre****ems
Panel1.Enabled = DeliveriesBindingSource.Current IsNot Nothing
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'MsgBox(Me.BindingContext().Contains())
MsgBox(DeliveriesDataGridView.BindingContext.Item(BpclDRnDataSet).ToString)
MsgBox(QtyTextBox.BindingContext(DeliveriesBindingSource, "Qty").ToString)
End Sub
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
End Sub
End Class
Thanks a lot
Dinesh Kumaar