Hey guys im trying to display diffirent tables on 1 datagridview (ofcourse its one at a time only)
so far it works everytime i change the datatable using listview for selecting now the problem is how do i insert data on it but only using a single form....each table have the same field name but different table name in this case different dept
heres my code for inserting items
If frmSGHI.ToolStripLabel9.Text = "Center Lane" Then
Dim SqlStatement As String = "INSERT INTO tblcenterlane(DESCRIPTION, UNIT, BEG, OT_KITCHEN, OT_F&B, OT_F.O., OT_S&M, OT_H.K., ADMIN, DEL, PULLOUT, SPOILAGE, ENDING, UNIT_COST, AMOUNT, VARIANCE, REMARKS, DEPARTMENT, DATE, DATE_DURATION_FROM, DATE_DURATION_TO, SUPPLIER_ID, CATEGORY) VALUES('" & txtItemDesc.Text & "','" & txtUnit.Text & "','" & txtBeg.Text & "','" & txtDel.Text & "','" & txtSpoilDmg.Text & "','" & txtPout.Text & "','" & txtEnding.Text & "','" & txtUnitCost.Text & "','" & txtAmount.Text & "','" & txtVariance.Text & "','" & txtDate.Text & "','" & txtDurationF.Text & "','" & txtDurationT.Text & "','" & txtSupplier.Text & "','" & txtCategory.Text & "','" & rtxtRemarks.Text & "')"
Save(SqlStatement)
MsgBox("1")
ElseIf frmSGHI.ToolStripLabel9.Text = "Foods" Then
Dim SqlStatement As String = "INSERT INTO tblfoods(DESCRIPTION, UNIT, BEG, OT_KITCHEN, OT_F&B, OT_F.O., OT_S&M, OT_H.K., ADMIN, DEL, PULLOUT, SPOILAGE, ENDING, UNIT_COST, AMOUNT, VARIANCE, REMARKS, DEPARTMENT, DATE, DATE_DURATION_FROM, DATE_DURATION_TO, SUPPLIER_ID, CATEGORY) VALUES('" & txtItemDesc.Text & "','" & txtUnit.Text & "','" & txtBeg.Text & "','" & txtDel.Text & "','" & txtSpoilDmg.Text & "','" & txtPout.Text & "','" & txtEnding.Text & "','" & txtUnitCost.Text & "','" & txtAmount.Text & "','" & txtVariance.Text & "','" & txtDate.Text & "','" & txtDurationF.Text & "','" & txtDurationT.Text & "','" & txtSupplier.Text & "','" & txtCategory.Text & "','" & rtxtRemarks.Text & "')"
Save(SqlStatement)
MsgBox("2")
ElseIf frmSGHI.ToolStripLabel9.Text = "Lane B" Then
Dim SqlStatement As String = "INSERT INTO tbllaneb(DESCRIPTION, UNIT, BEG, OT_KITCHEN, OT_F&B, OT_F.O., OT_S&M, OT_H.K., ADMIN, DEL, PULLOUT, SPOILAGE, ENDING, UNIT_COST, AMOUNT, VARIANCE, REMARKS, DEPARTMENT, DATE, DATE_DURATION_FROM, DATE_DURATION_TO, SUPPLIER_ID, CATEGORY) VALUES('" & txtItemDesc.Text & "','" & txtUnit.Text & "','" & txtBeg.Text & "','" & txtDel.Text & "','" & txtSpoilDmg.Text & "','" & txtPout.Text & "','" & txtEnding.Text & "','" & txtUnitCost.Text & "','" & txtAmount.Text & "','" & txtVariance.Text & "','" & txtDate.Text & "','" & txtDurationF.Text & "','" & txtDurationT.Text & "','" & txtSupplier.Text & "','" & txtCategory.Text & "','" & rtxtRemarks.Text & "')"
Save(SqlStatement)
MsgBox("3")
ElseIf frmSGHI.ToolStripLabel9.Text = "Lane C" Then
Dim SqlStatement As String = "INSERT INTO tbllanec(DESCRIPTION, UNIT, BEG, OT_KITCHEN, OT_F&B, OT_F.O., OT_S&M, OT_H.K., ADMIN, DEL, PULLOUT, SPOILAGE, ENDING, UNIT_COST, AMOUNT, VARIANCE, REMARKS, DEPARTMENT, DATE, DATE_DURATION_FROM, DATE_DURATION_TO, SUPPLIER_ID, CATEGORY) VALUES('" & txtItemDesc.Text & "','" & txtUnit.Text & "','" & txtBeg.Text & "','" & txtDel.Text & "','" & txtSpoilDmg.Text & "','" & txtPout.Text & "','" & txtEnding.Text & "','" & txtUnitCost.Text & "','" & txtAmount.Text & "','" & txtVariance.Text & "','" & txtDate.Text & "','" & txtDurationF.Text & "','" & txtDurationT.Text & "','" & txtSupplier.Text & "','" & txtCategory.Text & "','" & rtxtRemarks.Text & "')"
Save(SqlStatement)
MsgBox("4")
ElseIf frmSGHI.ToolStripLabel9.Text = "Lane D" Then
Dim SqlStatement As String = "INSERT INTO tbllaned(DESCRIPTION, UNIT, BEG, OT_KITCHEN, OT_F&B, OT_F.O., OT_S&M, OT_H.K., ADMIN, DEL, PULLOUT, SPOILAGE, ENDING, UNIT_COST, AMOUNT, VARIANCE, REMARKS, DEPARTMENT, DATE, DATE_DURATION_FROM, DATE_DURATION_TO, SUPPLIER_ID, CATEGORY) VALUES('" & txtItemDesc.Text & "','" & txtUnit.Text & "','" & txtBeg.Text & "','" & txtDel.Text & "','" & txtSpoilDmg.Text & "','" & txtPout.Text & "','" & txtEnding.Text & "','" & txtUnitCost.Text & "','" & txtAmount.Text & "','" & txtVariance.Text & "','" & txtDate.Text & "','" & txtDurationF.Text & "','" & txtDurationT.Text & "','" & txtSupplier.Text & "','" & txtCategory.Text & "','" & rtxtRemarks.Text & "')"
Save(SqlStatement)
MsgBox("5")
Else
MsgBox("6")
End If
Public Sub Save(ByRef SqlStatement As String)
On Error GoTo wat
Dim cmd As MySqlCommand = New MySqlCommand
With cmd
.CommandText = SqlStatement
.CommandType = CommandType.Text
.Connection = myconn
.ExecuteNonQuery()
End With
MsgBox("Success!")
If MsgBox("Do You Want to Add New Record?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
ClearTextboxes()
txtItemDesc.Focus()
Else
myconn.Close()
Me.Close()
End If
wat:
End Sub
im sorry if its really that long or messy