private void SaveKqPosition(int?status)
        {
            List <Model_Service.MenJin.Kq_Position> resutls = new List <Model_Service.MenJin.Kq_Position>();

            for (int i = 0; i < this.dgvUserR.Rows.Count; i++)
            {
                DataRowView drv = this.dgvUserR.Rows[i].DataBoundItem as DataRowView;
                for (int j = 0; j < this.dgvUserR.Columns.Count; j++)
                {
                    string strColumnName = this.dgvUserR.Columns[j].Name;
                    if (strcolumns.Contains(strColumnName))
                    {
                        continue;
                    }
                    if (this.dgvUserR.Rows[i].Cells[j].Selected)
                    {
                        var model = new Model_Service.MenJin.Kq_Position();
                        model.Id = new Model_Service.MenJin.Kq_PositionId();
                        var machineModel = this.machinesBLL.GetModelByName(strColumnName);
                        model.Id.MachineId = machineModel.Id;
                        model.Id.UserId    = drv["UserId"].TryInt().Value;
                        model.status       = status ?? -1;
                        resutls.Add(model);
                    }
                }
            }
            if (resutls.Count <= 0)
            {
                MessageBox.Show("您尚未选择任何单元格");
                return;
            }
            if (this.machinesBLL.SaveKq_PositionList(resutls))
            {
                MessageBox.Show("保存成功");
                for (int i = 0; i < this.dgvUserR.Rows.Count; i++)
                {
                    DataRow dr = (this.dgvUserR.Rows[i].DataBoundItem as DataRowView).Row;
                    for (int j = 0; j < this.dgvUserR.Columns.Count; j++)
                    {
                        string strColumnName = this.dgvUserR.Columns[j].Name;
                        if (strcolumns.Contains(strColumnName))
                        {
                            continue;
                        }
                        if (this.dgvUserR.Rows[i].Cells[j].Selected)
                        {
                            if (status == null)
                            {
                                dr[strColumnName] = DBNull.Value;
                            }
                            else
                            {
                                dr[strColumnName] = status;
                            }
                        }
                    }
                    dr.AcceptChanges();
                }
            }
        }
 private void dgvUserR_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex < 0 || e.RowIndex < 0)
         {
             return;
         }
         string strColumnName = this.dgvUserR.Columns[e.ColumnIndex].Name;
         if (strcolumns.Contains(strColumnName))
         {
             return;
         }
         DataRowView drv          = this.dgvUserR.Rows[e.RowIndex].DataBoundItem as DataRowView;
         int         _userId      = drv["UserId"].TryInt().Value;
         var         result       = this.dgvUserR.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.TryInt();
         var         machineModel = this.machinesBLL.GetModelByName(strColumnName);
         if (result == null)
         {
             var model = new Model_Service.MenJin.Kq_Position();
             model.Id           = new Model_Service.MenJin.Kq_PositionId();
             model.Id.MachineId = machineModel.Id;
             model.Id.UserId    = _userId;
             model.status       = 0;
             if (this.machinesBLL.SaveKq_Position(model))
             {
                 this.dgvUserR.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 0;
             }
         }
         else
         {
             if (result.Value == 0)
             {
                 var model = new Model_Service.MenJin.Kq_Position();
                 model.Id           = new Model_Service.MenJin.Kq_PositionId();
                 model.Id.MachineId = machineModel.Id;
                 model.Id.UserId    = _userId;
                 model.status       = 0;
                 if (this.machinesBLL.SaveKq_Position(model))
                 {
                     this.dgvUserR.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 1;
                 }
             }
             else
             {
                 if (this.machinesBLL.DelKq_Position(_userId, machineModel.Id))
                 {
                     this.dgvUserR.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = DBNull.Value;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message, "系统错误", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }