private void button_CarAllocation_Click(object sender, EventArgs e) { int rowIndex = dataGridView_Grouping.SelectedCells[0].RowIndex; string kcxh = dataGridView_Grouping.Rows[rowIndex].Cells["考场序号"].Value.ToString(); string kscc = dataGridView_Grouping.Rows[rowIndex].Cells["考试场次"].Value.ToString(); string qdxm = null; TMRIWriteResponse response; for (int i = 0; i < dataGridView_Car.RowCount; i++) { string kchp = dataGridView_Car.Rows[i].Cells["考车号牌"].Value.ToString(); if (TMRIWrite.WriteCarAllocation(out response, kchp, kcxh, kscc, qdxm)) { dataGridView_Car.Rows[i].Cells["身份证明号码"].Value = response.message; string sql = $"update BAS_GROUPING_DETAIL set CAR_ID=(select ID from BAS_CAR where LICENSE_PLATE={kchp}) where STUDENT_ID=(select ID from BAS_STUDENT where IDNUMBER={response.message})"; mDBM.Select(sql); } else if (null != response) { MessageBox.Show($"Error: {response.code}\nMessage: {response.message}", "错误"); } } dataGridView_GroupingDetail.DataSource = mDBM.Select(groupingDetailQuerySql).Tables[0]; MessageBox.Show("全部考试车辆分配成功"); }
private void dataGridView_Car_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && dataGridView_Grouping.RowCount > 0) { string kchp = (sender as DataGridView).Rows[e.RowIndex].Cells["考车号牌"].Value.ToString(); int rowIndex = dataGridView_Grouping.SelectedCells[0].RowIndex; string kcxh = dataGridView_Grouping.Rows[rowIndex].Cells["考场序号"].Value.ToString(); string kscc = dataGridView_Grouping.Rows[rowIndex].Cells["考试场次"].Value.ToString(); string qdxm = null; TMRIWriteResponse response; if (TMRIWrite.WriteCarAllocation(out response, kchp, kcxh, kscc, qdxm)) { MessageBox.Show("考试车辆分配成功"); (sender as DataGridView).Rows[e.RowIndex].Cells["身份证明号码"].Value = response.message; // string sql = $"update BAS_GROUPING_DETAIL set CAR_ID=(select ID from BAS_CAR where LICENSE_PLATE={kchp}) where STUDENT_ID=(select ID from BAS_STUDENT where IDNUMBER={response.message})"; string sql = $"update BAS_BOOKING " + $"set EXAMINER1_ID=(select EXAMINER_ID from BAS_GROUPING where PLACE_ID=(select ID from BAS_PLACE where SEQUENCENUMBER='{kcxh}') and ROWNUM=1), " + $"CAR_ID=(select ID from BAS_CAR where LICENSE_PLATE='{kchp}')" + $" where STUDENT_ID=(select ID from BAS_STUDENT where IDNUMBER='{response.message}')"; mDBM.Select(sql); dataGridView_GroupingDetail.DataSource = mDBM.Select(groupingDetailQuerySql).Tables[0]; } else if (null != response) { MessageBox.Show($"Error: {response.code}\nMessage: {response.message}", "错误"); } } }