01.
private
void
dgvShowReceive_CellClick(
object
sender, DataGridViewCellEventArgs e)
02.
{
03.
if
(e.ColumnIndex == 0)
04.
{
05.
if
(Convert.ToBoolean(dgvShowReceive.Rows[e.RowIndex].Cells[
"Select"
].Value) ==
false
)
06.
{
07.
dgvShowReceive.Rows[e.RowIndex].Cells[
"Select"
].Value =
true
;
08.
DialogResult result = MessageBox.Show(
"คุณต้องบันทึกใช่ไหม ?"
,
"ยืนยันการรับ"
, MessageBoxButtons.YesNo);
09.
if
(result == DialogResult.No)
10.
{
11.
dgvShowReceive.Rows[e.RowIndex].Cells[
"Select"
].Value =
false
;
12.
}
13.
if
(result == DialogResult.Yes)
14.
{
15.
16.
for
(
int
i = 0; i <= dgvShowReceive.Rows.Count - 1; i++)
17.
{
18.
string
id = dgvShowReceive.Rows[e.RowIndex].Cells[1].Value.ToString();
19.
string
keepItemID = dgvShowReceive.Rows[e.RowIndex].Cells[9].Value.ToString();
20.
21.
tr = Conn.BeginTransaction();
22.
sb =
new
StringBuilder();
23.
sb.Append(
"UPDATE tblOrderNormalTrn SET OrnStatus=@OrnStatus WHERE OrdID='"
+ id +
"' AND ItemID='"
+ keepItemID +
"'"
);
24.
string
sqlup = sb.ToString();
25.
26.
com.CommandText = sqlup;
27.
com.CommandType = CommandType.Text;
28.
com.Connection = Conn;
29.
com.Transaction = tr;
30.
com.Parameters.Clear();
31.
com.Parameters.Add(
"@OrnStatus"
, SqlDbType.Bit).Value = 1;
32.
com.ExecuteNonQuery();
33.
tr.Commit();
34.
35.
MessageBox.Show(
"บันทึกช้อมูลเสร็จสมบูรณ์ "
,
"ข้อความ"
, MessageBoxButtons.OK, MessageBoxIcon.Information);
36.
37.
ShowDataMember();
38.
ShowdgvShowReceive();
39.
return
;
40.
}
41.
}
42.
43.
}
44.
}
45.
}