Ejemplo n.º 1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            ConstantWindow constantWindow = new ConstantWindow();

            if ((bool)constantWindow.ShowDialog(this))
            {
                long insertedValueId;
                switch (Constant.SelectedIndex)
                {
                case 0:
                    insertedValueId = BusinessEntity.Insert(constantWindow.Value);
                    break;

                case 1:
                    insertedValueId = Activity.Insert(constantWindow.Value);
                    break;

                default:
                    insertedValueId = ActivityDirection.Insert(constantWindow.Value);
                    break;
                }
                UpdateValues();
                Values.SelectItem(Values.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == insertedValueId));
            }
        }
Ejemplo n.º 2
0
        private void Edit_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (ValueExists())
            {
                long           selectedValueId = (long)(Values.SelectedItem as TextBlock).Tag;
                ConstantWindow constantWindow  = new ConstantWindow((Values.SelectedItem as TextBlock).Text, selectedValueId);
                if ((bool)constantWindow.ShowDialog(this))
                {
                    if (ValueExists())
                    {
                        switch (Constant.SelectedIndex)
                        {
                        case 0:
                            BusinessEntity.Update(selectedValueId, constantWindow.Value);
                            break;

                        case 1:
                            Activity.Update(selectedValueId, constantWindow.Value);
                            break;

                        case 2:
                            ActivityDirection.Update(selectedValueId, constantWindow.Value);
                            break;
                        }
                        UpdateValues();
                        Values.SelectItem(Values.Items.FirstOrDefault <TextBlock>(x => (long)x.Tag == selectedValueId));
                    }
                    else
                    {
                        ShowErrorWindow(2);
                    }
                }
            }
            else
            {
                ShowErrorWindow(2);
            }
        }