Exemplo n.º 1
0
        private void ChangeActionButton_Click(object sender, RoutedEventArgs e)
        {
            if (ActionsViewListBox.SelectedItem == null || ModulesComboBox.SelectedItem == null ||
                string.IsNullOrEmpty(ActionNameTextBox.Text))
            {
                return;
            }

            var actionTypeId = Convert.ToInt32(ActionsViewListBox.SelectedValue);
            var moduleId     = Convert.ToInt32(ModulesComboBox.SelectedValue);
            var actionName   = ActionNameTextBox.Text;

            if (_ac.ActionTypesTable.AsEnumerable().Any(r => r.Field <Int64>("ModuleID") == moduleId &&
                                                        r.Field <string>("ActionName") == actionName))
            {
                MetroMessageBox.Show("Данное действие уже присудствует в этом модуле.", "Предупреждение",
                                     MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            _ac.ChangeAction(actionTypeId, moduleId, actionName);

            //Refill items source
            ActionsViewListBox.ItemsSource = GetDetailActionView();
            if (ActionsViewListBox.HasItems)
            {
                ActionsViewListBox.SelectedIndex = 0;
            }

            CancelEditActionButton_Click(null, null);
        }