/// <summary>
 /// 单击选种测试仪器
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CheckDatas_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (Global.userlog == "sakj")
         {
             if (e.ColumnIndex == 0)
             {
                 string err = string.Empty;
                 if (CheckDatas.Rows[e.RowIndex].Cells["已选择"].Value.ToString() == "False")
                 {
                     CheckDatas.Rows[e.RowIndex].Cells["已选择"].Value = true;
                     //labelEquipment.Text = "已选择仪器:" + CheckDatas.Rows[e.RowIndex].Cells[2].Value.ToString();
                     //Global.TestInstrument[0,0] = CheckDatas.Rows[e.RowIndex].Cells[1].Value.ToString();
                     try
                     {
                         sql.SetIntrument(CheckDatas.Rows[e.RowIndex].Cells["已选择"].Value.ToString(), CheckDatas.Rows[e.RowIndex].Cells["仪器编号"].Value.ToString(), out err);
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show(ex.Message, "Error");
                         return;
                     }
                     //只选择一款仪器
                     if (chkBoxMachine.Checked == true)
                     {
                         for (int j = 0; j < CheckDatas.Rows.Count; j++)
                         {
                             if (j != e.RowIndex)
                             {
                                 if (CheckDatas.Rows[j].Cells["已选择"].Value.ToString() == "True")
                                 {
                                     //string d = CheckDatas.Rows[j].Cells[0].Value.ToString();
                                     CheckDatas.Rows[j].Cells["已选择"].Value = false;
                                     try
                                     {
                                         sql.SetIntrument(CheckDatas.Rows[j].Cells["已选择"].Value.ToString(), CheckDatas.Rows[j].Cells["仪器编号"].Value.ToString(), out err);
                                     }
                                     catch (Exception ex)
                                     {
                                         MessageBox.Show(ex.Message, "Error");
                                     }
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     int sl = 0;
                     for (int j = 0; j < CheckDatas.Rows.Count; j++)
                     {
                         if (CheckDatas.Rows[j].Cells["已选择"].Value.ToString() == "True")
                         {
                             sl = sl + 1;
                         }
                     }
                     if (sl == 1)//只有一款仪器不给去掉勾选
                     {
                         MessageBox.Show("至少选择一款仪器", "提示");
                         return;
                     }
                     CheckDatas.Rows[e.RowIndex].Cells["已选择"].Value = false;
                     try
                     {
                         sql.SetIntrument(CheckDatas.Rows[e.RowIndex].Cells["已选择"].Value.ToString(), CheckDatas.Rows[e.RowIndex].Cells["仪器编号"].Value.ToString(), out err);
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show(ex.Message, "Error");
                     }
                 }
             }
             else if (e.ColumnIndex > 3)
             {
                 if (addMachine == false)
                 {
                     //frmMachine mh = new frmMachine();
                     //mh.ucem = this;
                     //string err = string.Empty;
                     //DialogResult dr = mh.ShowDialog();
                     //if (dr == DialogResult.OK)
                     //{
                     //    if (CheckDatas.CurrentCell.ColumnIndex == 4)
                     //    {
                     //        sql.RepairIntrument(CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[3].Value.ToString(), CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[4].Value.ToString(),
                     //            CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[2].Value.ToString(),CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[6].Value.ToString(), out err);
                     //    }
                     //    if (CheckDatas.CurrentCell.ColumnIndex == 3)
                     //    {
                     //sql.RepairIntrument(CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[3].Value.ToString(), CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[4].Value.ToString(),
                     //           CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[2].Value.ToString(),CheckDatas.Rows[CheckDatas.CurrentCell.RowIndex].Cells[6].Value.ToString(), out err);
                     //    }
                     //}
                 }
             }
         }
     }
     catch (Exception ex)
     {
         dy.savediary(DateTime.Now.ToString(), "选择测试仪器失败:" + ex.Message, "错误");
         MessageBox.Show(ex.Message, "选择测试仪器");
     }
 }