private void ConditionControlDeleted(object sender, EventArgs e) { SmsConditionControl control = (SmsConditionControl)sender; EventCondition cond = control.EventCondition; if (cond.ItemId > 0 && MessageBox.Show("Do you really want to delete event condition?", "Deleting confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { //если информация о состоянии сохранена в БД //и получен положительный ответ на ее удаление try { GlobalObjects.CasEnvironment.NewKeeper.Delete(cond); _smsEvent.EventConditions.Remove(cond); } catch (Exception ex) { Program.Provider.Logger.Log("Error while removing data", ex); } flowLayoutPanelConditions.Controls.Remove(control); control.Deleted -= ConditionControlDeleted; control.Dispose(); } else if (cond.ItemId <= 0) { flowLayoutPanelConditions.Controls.Remove(control); control.Deleted -= ConditionControlDeleted; control.Dispose(); } }
/// <summary> /// Обновляет значения полей /// </summary> public void FillControls() { textBoxDescription.Text = _smsEventType.Description; textBoxName.Text = _smsEventType.FullName; foreach (Control c in flowLayoutPanelConditions.Controls) { if (c != panelAddCondition) { c.Dispose(); } } flowLayoutPanelConditions.Controls.Clear(); listViewCompliance.Items.Clear(); if (_smsEventType != null) { textBoxDescription.Text = _smsEventType.Description; textBoxName.Text = _smsEventType.FullName; foreach (EventCondition condition in _smsEventType.EventConditions) { SmsConditionControl newControl = new SmsConditionControl(condition); newControl.Deleted += ConditionControlDeleted; if (flowLayoutPanelConditions.Controls.Count >= 1) { newControl.ShowHeaders = false; } flowLayoutPanelConditions.Controls.Add(newControl); } foreach (EventTypeRiskLevelChangeRecord record in _smsEventType.ChangeRecords) { listViewCompliance.Items.Add(new ListViewItem(GetListViewSubItems(record), null) { Tag = record }); } } flowLayoutPanelConditions.Controls.Add(panelAddCondition); }
private void LinkLabelAddNewConditionLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (_smsEvent == null) { return; } SmsConditionControl performance = new SmsConditionControl(new EventCondition { ParentId = _smsEvent.ItemId }); performance.Deleted += ConditionControlDeleted; if (flowLayoutPanelConditions.Controls.Count > 1) { performance.ShowHeaders = false; } flowLayoutPanelConditions.Controls.Remove(panelAddCondition); flowLayoutPanelConditions.Controls.Add(performance); flowLayoutPanelConditions.Controls.Add(panelAddCondition); performance.Focus(); }
/// <summary> /// Обновляет значения полей /// </summary> private void FillControls() { Program.MainDispatcher.ProcessControl(dictionaryComboEventType); Program.MainDispatcher.ProcessControl(dictionaryComboEventClass); Program.MainDispatcher.ProcessControl(dictionaryComboBoxCategory); foreach (Control c in flowLayoutPanelConditions.Controls) { if (c != panelAddCondition) { c.Dispose(); } } flowLayoutPanelConditions.Controls.Clear(); dictionaryComboEventType.SelectedIndexChanged -= LookupComboboxEventTypeSelectedIndexChanged; dictionaryComboEventClass.SelectedIndexChanged -= DictionaryComboEventClassSelectedIndexChanged; dictionaryComboBoxCategory.SelectedIndexChanged -= DictionaryComboBoxCategorySelectedIndexChanged; comboBoxIncident.Items.Clear(); foreach (IncidentType o in IncidentType.Items) { comboBoxIncident.Items.Add(o); } dictionaryComboEventClass.Type = typeof(EventClass); dictionaryComboBoxCategory.Type = typeof(EventCategory); dictionaryComboEventType.Type = typeof(SmsEventType); dictionaryComboEventType.ScreenControl = new EventTypesListScreen(_smsEvent); if (_smsEvent != null) { dictionaryComboEventType.SelectedItem = _smsEvent.EventType; dictionaryComboBoxCategory.SelectedItem = _smsEvent.EventCategory; dictionaryComboEventClass.SelectedItem = _smsEvent.EventClass; comboBoxIncident.SelectedItem = _smsEvent.IncidentType; dateTimePickerEventDate.Value = _smsEvent.RecordDate; textBoxDescription.Text = _smsEvent.Description; textBoxRemarks.Text = _smsEvent.Remarks; foreach (EventCondition condition in _smsEvent.EventConditions) { SmsConditionControl newControl = new SmsConditionControl(condition); newControl.Deleted += ConditionControlDeleted; if (flowLayoutPanelConditions.Controls.Count >= 1) { newControl.ShowHeaders = false; } flowLayoutPanelConditions.Controls.Add(newControl); } } flowLayoutPanelConditions.Controls.Add(panelAddCondition); SetRiskIndex(); dictionaryComboEventType.SelectedIndexChanged += LookupComboboxEventTypeSelectedIndexChanged; dictionaryComboEventClass.SelectedIndexChanged += DictionaryComboEventClassSelectedIndexChanged; dictionaryComboBoxCategory.SelectedIndexChanged += DictionaryComboBoxCategorySelectedIndexChanged; flowLayoutPanelConditions.Controls.Add(panelAddCondition); }