public void LoadDGVOQC(DataGridView datagv, string barcode, bool order) { TfSQL tf = new TfSQL(); DataTable dt = new DataTable(); string sqlDGV = "select a90_barcode, a90_status, a90_noise_status,a90_oqc_status, a90_oqc_data, a90_datetime from t_checkpusha90main where a90_barcode = '" + barcode + "' "; if (order) { sqlDGV += "order by a90_datetime desc limit 1"; } else { sqlDGV += "order by a90_datetime desc"; } tf.sqlDataAdapterFillDatatable(sqlDGV, ref dt); datagv.DataSource = dt; if (datagv.RowCount > 0) { datagv.Columns["a90_barcode"].HeaderText = "Barcode"; datagv.Columns["a90_status"].HeaderText = "Thurst Status "; datagv.Columns["a90_datetime"].HeaderText = "DateTime"; datagv.Columns["a90_noise_status"].HeaderText = "Noise Status"; datagv.Columns["a90_oqc_status"].HeaderText = "OQC Status"; datagv.Columns["a90_oqc_data"].HeaderText = "OQC Data"; } datagv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; }
public void LoadData() { TfSQL tf = new TfSQL(); string sqlExport = "select row_number() over(order by a90_datetime asc) stt, a90_model Model, a90_line line, a90_barcode Barcode, a90_status ThurstStatus,a90_noise_status as NoiseStatus, a90_datetime DateTime from t_checkpusha90main where a90_datetime > '" + dtpFrom.Value.ToString() + "' order by a90_datetime desc"; DataTable dt = new DataTable(); tf.sqlDataAdapterFillDatatable(sqlExport, ref dt); dgvData.DataSource = dt; dgvData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvData.Columns["stt"].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; if (dgvData.RowCount > 0) { for (int i = 0; i < dgvData.RowCount; i++) { if (dgvData.Rows[i].Cells["ThurstStatus"].Value.ToString() == "NG") { dgvData.Rows[i].Cells["ThurstStatus"].Style.BackColor = Color.Red; } if (dgvData.Rows[i].Cells["NoiseStatus"].Value.ToString() == "NG") { dgvData.Rows[i].Cells["NoiseStatus"].Style.BackColor = Color.Red; } } } }