For i = 0 To DataGridView1.Rows.Count.ToString - 1 If DataGridView1.Rows(i).Cells(0).Value = TextBox1.Text Then DataGridView1.Rows(i).Cells(2).Value = DataGridView1.Rows(i).Cells(2).Value + 1 Else Try con = New SqlConnection(cs) con.Open() cmd = New SqlCommand("SELECT ItemID, RTRIM(DishName),'1',Rate from Dish where ItemID like '" & TextBox1.Text & "' order by DishName", con) rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection) While (rdr.Read() = True) DataGridView1.Rows.Add(rdr(0), rdr(1), rdr(2), rdr(3)) Dim num1 As Double For j As Integer = 0 To DataGridView1.RowCount - 1 num1 = Val(DataGridView1.Rows(j).Cells("Qty").Value) * Val(DataGridView1.Rows(j).Cells("Rate").Value) num1 = Math.Round(num1, 2) DataGridView1.Rows(j).Cells("Amount").Value = num1 Next TotalCalc() End While con.Close() Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If Next
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)