private void btn_AlarmGroupListOK_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { MessageBox.Show("请选择报警组"); return; } try { var alarmGroup = _iAlarmDesignRepository.FindAlarmGroupByName( dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); _iAlarmDesignRepository.EditAlarm(_alarmName, "Group", alarmGroup); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 修改变量报警属性 /// </summary> /// <param name="e">需要修改的单元</param> /// <returns>不需要刷新界面dataGridView返回true,需要刷新界面dataGridView返回false</returns> private bool ChangeAlarmProperty(DataGridViewCellEventArgs e) { DataGridViewCell currentCell = dataGridView_Avaiable.SelectedCells[0]; DataGridViewRow currentRow = dataGridView_Avaiable.Rows[currentCell.RowIndex]; try { switch (e.ColumnIndex) { case 0: //name _iAalarmDesignRepository.EditAlarm(_nameTemp, "name", currentRow.Cells[e.ColumnIndex].Value.ToString()); break; case 1: //variable object variable = currentRow.Cells[e.ColumnIndex].Value; if (variable == null) { _iAalarmDesignRepository.EditAlarm(currentRow.Cells[0].Value.ToString(), "Variable", null); return(false); } VariableBase alarm = _iVariableDesignRepository.FindVariableByPath(variable.ToString()); if (alarm == null) { MessageBox.Show("当前变量不存在"); return(false); } _iAalarmDesignRepository.EditAlarm(currentRow.Cells[0].Value.ToString(), "Variable", alarm); break; case 2: //config break; case 3: //level _iAalarmDesignRepository.EditAlarm(currentRow.Cells[0].Value.ToString(), "Level", alarm_Level.Items.IndexOf( currentRow.Cells[e.ColumnIndex].Value.ToString())); break; case 4: //group break; case 5: //descript _iAalarmDesignRepository.EditAlarm(currentRow.Cells[0].Value.ToString(), "Description", currentRow.Cells[e.ColumnIndex].Value.ToString()); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(false); }