public void UpdateStatusOQC(MouseEventArgs e) { if (login) { if (txt_barcodeOQC.Text.Trim() != "" || txt_dataOQC.Text.Trim() != "") { TfSQL tf = new TfSQL(); string sqlcheckbarcode = "select count(*) from t_checkpusha90main where a90_barcode = '" + txt_barcodeOQC.Text + "'"; int checkbarcode = int.Parse(tf.sqlExecuteScalarString(sqlcheckbarcode)); if (checkbarcode > 0) { string status = ""; if (e.Button == MouseButtons.Right) { status = "NG"; btn_statusOQC.Text = "NG"; btn_statusOQC.BackColor = Color.Red; } if (e.Button == MouseButtons.Left) { status = "OK"; btn_statusOQC.Text = "OK"; btn_statusOQC.BackColor = Color.Green; } string sqlUpdate = "update t_checkpusha90main set a90_oqc_status = '" + status + "', a90_oqc_data = '" + txt_dataOQC.Text + "' where a90_barcode = '" + txt_barcodeOQC.Text + "'"; if (tf.sqlExecuteNonQuery(sqlUpdate, false)) { LoadDGVOQC(dgv_OQC, txt_barcodeOQC.Text, true); txt_barcodeOQC.Text = null; txt_barcodeOQC.SelectNextControl(txt_barcodeOQC, true, false, true, true); //trả lại con chỏ vô textbox timerOQC.Interval = int.Parse(txt_timerOQC.Text) * 1000; timerOQC.Enabled = true; } else { dgv_OQC.DataSource = null; } } else { MessageBox.Show("Barocde No is Null <Không có Mã barcode này >", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { return; } } else { MessageBox.Show("Not Login <Chưa đăng nhập> ", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
public void AddStatus(MouseEventArgs e) { if (login) { if (txt_barcode.Text.Trim() != "") { string status = ""; if (e.Button == MouseButtons.Right) { status = "NG"; btn_status.Text = "NG"; btn_status.BackColor = Color.Red; } if (e.Button == MouseButtons.Left) { status = "OK"; btn_status.Text = "OK"; btn_status.BackColor = Color.Green; } TfSQL tf = new TfSQL(); string sqlInsert = "insert into t_checkpusha90main(a90_model, a90_line, a90_barcode, a90_status, a90_datetime ,a90_factory) "; sqlInsert += "values('" + lbl_model.Text + "','" + lbl_line.Text + "','" + txt_barcode.Text + "','" + status + "', now(),'NCVP')"; if (tf.sqlExecuteNonQuery(sqlInsert, false)) { LoadDGV(dgv, txt_barcode.Text, true); txt_barcode.Text = null; txt_barcode.SelectNextControl(txt_barcode, true, false, true, true); timer1.Interval = int.Parse(txtTimer.Text) * 1000; timer1.Enabled = true; } else { dgv.DataSource = null; } } else { return; } } else { MessageBox.Show("Not Login <Chưa đăng nhập> ", "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }