Conn.Open()
cmd.Connection = Conn
SqlString = "insert into Checkbill_1(c_orderid,c_namefood,c_foodprice,c_cusname,c_datetime) values(@c_orderid,@c_namefood,@c_foodprice,@c_cusname,@c_datetime)"
cmd = New System.Data.SqlClient.SqlCommand(SqlString, Conn)
For i As Integer = 0 To DataGridView4.RowCount - 1
If Not DataGridView4.Rows(i).IsNewRow Then
With cmd
.Parameters.Add(New SqlParameter("@c_orderid", DataGridView4.Rows(i).Cells(0).Value))
.Parameters.Add(New SqlParameter("@c_namefood", DataGridView4.Rows(i).Cells(1).Value))
.Parameters.Add(New SqlParameter("@c_foodprice", DataGridView4.Rows(i).Cells(2).Value))
.Parameters.Add(New SqlParameter("@c_cusname", DataGridView4.Rows(i).Cells(3).Value))
.Parameters.Add(New SqlParameter("@c_datetime", lbldatetime.Text))
End With
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
End If
Next
MessageBox.Show("เรียบร้อยเดี๋ยวพนักงานจะมาเก็บเงิน")
Conn.Close()
With cmd
.Parameters.AddWithValue("@c_orderid", DataGridView4.Rows(i).Cells(0).Value))
.Parameters.AddWithValue("@c_namefood", DataGridView4.Rows(i).Cells(1).Value))
.Parameters.AddWithValue("@c_foodprice", DataGridView4.Rows(i).Cells(2).Value))
.Parameters.AddWithValue("@c_cusname", DataGridView4.Rows(i).Cells(3).Value))
.Parameters.AddWithValue("@c_datetime", Now.ToString(New CultureInfo("en-GB"))
End With
Conn.Open()
cmd.Connection = Conn
SqlString = "insert into Checkbill_1(c_orderid,c_namefood,c_foodprice,c_cusname,c_datetime) values(@c_orderid,@c_namefood,@c_foodprice,@c_cusname, CONVERT(datetime,@c_datetime, 103))"
cmd = New System.Data.SqlClient.SqlCommand(SqlString, Conn)
For i As Integer = 0 To DataGridView4.RowCount - 1
If Not DataGridView4.Rows(i).IsNewRow Then
With cmd
.Parameters.Add(New SqlParameter("@c_orderid", DataGridView4.Rows(i).Cells(0).Value))
.Parameters.Add(New SqlParameter("@c_namefood", DataGridView4.Rows(i).Cells(1).Value))
.Parameters.Add(New SqlParameter("@c_foodprice", DataGridView4.Rows(i).Cells(2).Value))
.Parameters.Add(New SqlParameter("@c_cusname", DataGridView4.Rows(i).Cells(3).Value))
.Parameters.Add(New SqlParameter("@c_datetime", lbldatetime.Text))
End With
cmd.ExecuteNonQuery()
cmd.Parameters.Clear()
End If
Next
MessageBox.Show("เรียบร้อยเดี๋ยวพนักงานจะมาเก็บเงิน")
Conn.Close()