コード例 #1
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void RenameGridRow(int number)
        {
            var comboBox = WindowCosts.FindName("ComboBoxRCs_" + number) as ComboBox;

            NameScope.GetNameScope(WindowCosts).UnregisterName(comboBox.Name);
            comboBox.Name = ("ComboBoxRCs_" + (number - 1));
            NameScope.GetNameScope(WindowCosts).RegisterName(comboBox.Name, comboBox);
            comboBox.SetValue(Grid.RowProperty, (number - 2));

            comboBox = WindowCosts.FindName("ComboBoxNotes_" + number) as ComboBox;
            NameScope.GetNameScope(WindowCosts).UnregisterName(comboBox.Name);
            comboBox.Name = ("ComboBoxNotes_" + (number - 1));
            NameScope.GetNameScope(WindowCosts).RegisterName(comboBox.Name, comboBox);
            comboBox.SetValue(Grid.RowProperty, (number - 2));

            var textBox = WindowCosts.FindName("TextBoxWeight_" + number) as TextBox;

            NameScope.GetNameScope(WindowCosts).UnregisterName(textBox.Name);
            textBox.Name = ("TextBoxWeight_" + (number - 1));
            NameScope.GetNameScope(WindowCosts).RegisterName(textBox.Name, textBox);
            textBox.SetValue(Grid.RowProperty, (number - 2));

            var button = WindowCosts.FindName("ButtonRemoveCargo_" + number) as Button;

            NameScope.GetNameScope(WindowCosts).UnregisterName(button.Name);
            button.Name = ("ButtonRemoveCargo_" + (number - 1));
            NameScope.GetNameScope(WindowCosts).RegisterName(button.Name, button);
            button.SetValue(Grid.RowProperty, (number - 2));
        }
コード例 #2
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void RemoveGridRow(int number)
        {
            var comboBox = WindowCosts.FindName("ComboBoxRCs_" + number) as ComboBox;

            NameScope.GetNameScope(WindowCosts).UnregisterName(comboBox.Name);
            GridTransports.Children.Remove(comboBox);

            var border = WindowCosts.FindName("BorderRCs_" + number) as Border;

            NameScope.GetNameScope(WindowCosts).UnregisterName(border.Name);
            GridTransports.Children.Remove(border);

            comboBox = WindowCosts.FindName("ComboBoxNotes_" + number) as ComboBox;
            NameScope.GetNameScope(WindowCosts).UnregisterName(comboBox.Name);
            GridTransports.Children.Remove(comboBox);

            border = WindowCosts.FindName("BorderNotes_" + number) as Border;
            NameScope.GetNameScope(WindowCosts).UnregisterName(border.Name);
            GridTransports.Children.Remove(border);

            var textBox = WindowCosts.FindName("TextBoxWeight_" + number) as TextBox;

            NameScope.GetNameScope(WindowCosts).UnregisterName(textBox.Name);
            GridTransports.Children.Remove(textBox);

            var button = WindowCosts.FindName("ButtonRemoveCargo_" + number) as Button;

            NameScope.GetNameScope(WindowCosts).UnregisterName(button.Name);
            GridTransports.Children.Remove(button);

            GridTransports.RowDefinitions.RemoveAt(number - 1);
        }
コード例 #3
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
        {
            var transports = new List <Transport>();

            for (int i = 1; i <= GridTransports.RowDefinitions.Count; i++)
            {
                string note = (WindowCosts.FindName("ComboBoxNotes_" + i) as ComboBox).Text;

                DirectoryNote directoryNote = null;

                if (!_bc.IsDirectoryNote(note))
                {
                    directoryNote = _bc.AddDirectoryNote(note);
                }
                else
                {
                    directoryNote = _bc.GetDirectoryNote(note);
                }

                string weightText = (WindowCosts.FindName("TextBoxWeight_" + i) as TextBox).Text;

                var transport = new Transport();

                transport.DirectoryRC   = (WindowCosts.FindName("ComboBoxRCs_" + i) as ComboBox).SelectedItem as DirectoryRC;
                transport.DirectoryNote = directoryNote;
                transport.Weight        = string.IsNullOrWhiteSpace(weightText) ? 0 : double.Parse(weightText);

                transports.Add(transport);
            }
            var currency = (Currency)Enum.Parse(typeof(Currency), ComboBoxCurrencies.SelectedItem.ToString());

            Date = DatePickerDate.SelectedDate.Value;

            if (!_isEdit)
            {
                _bc.AddInfoCosts(DatePickerDate.SelectedDate.Value, ComboBoxCostItems.SelectedItem as DirectoryCostItem,
                                 RadioButtonIncoming.IsChecked.Value,
                                 ComboBoxTransportCompanies.SelectedItem as DirectoryTransportCompany, double.Parse(TextBoxSumm.Text), currency,
                                 transports);

                ComboBoxNotes_1.ItemsSource = null;
                ComboBoxNotes_1.ItemsSource = _bc.GetDirectoryNotes().ToList();

                ClearForm();
                InitializeValidation(GridCosts.Children);
            }
            else
            {
                _bc.RemoveInfoCost(_infoCost);
                _bc.AddInfoCosts(DatePickerDate.SelectedDate.Value, ComboBoxCostItems.SelectedItem as DirectoryCostItem,
                                 RadioButtonIncoming.IsChecked.Value,
                                 ComboBoxTransportCompanies.SelectedItem as DirectoryTransportCompany, double.Parse(TextBoxSumm.Text), currency,
                                 transports);
            }

            this.Close();
        }
コード例 #4
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void ComboBoxRCs_SelectionChanged(object sender, RoutedEventArgs e)
        {
            var comboBox = sender as ComboBox;

            var costItem = ComboBoxCostItems.SelectedItem as DirectoryCostItem;

            if (costItem != null)
            {
                if (costItem.Name == "Транспорт (5031)")
                {
                    var rc = comboBox.SelectedItem as DirectoryRC;
                    if (rc != null)
                    {
                        if (rc.Name == "ПАМ-16")
                        {
                            RadioButtonIncoming.IsEnabled = true;
                        }
                        else
                        {
                            RadioButtonIncoming.IsEnabled = false;
                        }
                    }
                }
                else
                {
                    RadioButtonIncoming.IsEnabled = false;
                }
            }

            string borderName = "Border" + comboBox.Name.Substring(8);
            var    border     = WindowCosts.FindName(borderName) as Border;

            if (!string.IsNullOrWhiteSpace(comboBox.Text) && comboBox.ItemsSource.Cast <DirectoryRC>().Select(r => r.FullName).Contains(comboBox.Text))
            {
                border.BorderThickness = new Thickness(0);

                comboBox.Tag = "1";
            }
            else
            {
                border.BorderBrush     = Brushes.Red;
                border.BorderThickness = new Thickness(2);

                comboBox.Tag = null;
            }

            VisibilityWeight();
            ChangeButtonAddVisibility(comboBox.Tag);
        }
コード例 #5
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void ComboBoxValidation(ComboBox comboBox)
        {
            string borderName = "Border" + comboBox.Name.Substring(8);
            var    border     = WindowCosts.FindName(borderName) as Border;

            if (!string.IsNullOrWhiteSpace(comboBox.Text))
            {
                border.BorderThickness = new Thickness(0);

                comboBox.Tag = "1";
            }
            else
            {
                border.BorderBrush     = Brushes.Red;
                border.BorderThickness = new Thickness(2);

                comboBox.Tag = null;
            }

            ChangeButtonAddVisibility(comboBox.Tag);
        }
コード例 #6
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void ComboBoxTransportCompanies_SelectedChanged(object sender, RoutedEventArgs e)
        {
            var comboBox = sender as ComboBox;

            string borderName = "Border" + comboBox.Name.Substring(8);
            var    border     = WindowCosts.FindName(borderName) as Border;

            if (comboBox.SelectedIndex != -1)
            {
                border.BorderThickness = new Thickness(0);

                comboBox.Tag = "1";
            }
            else
            {
                border.BorderBrush     = Brushes.Red;
                border.BorderThickness = new Thickness(2);

                comboBox.Tag = null;
            }

            ChangeButtonAddVisibility(comboBox.Tag);
        }
コード例 #7
0
ファイル: AddEditDayCost.xaml.cs プロジェクト: breshch/AIS
        private void ComboBoxCostItems_SelectionChanged(object sender, RoutedEventArgs e)
        {
            var comboBox = sender as ComboBox;

            string borderName = "Border" + comboBox.Name.Substring(8);
            var    border     = WindowCosts.FindName(borderName) as Border;

            if (!string.IsNullOrWhiteSpace(comboBox.Text) && comboBox.ItemsSource.Cast <DirectoryCostItem>().Select(c => c.Name).Contains(comboBox.Text))
            {
                border.BorderThickness = new Thickness(0);

                comboBox.Tag = "1";
            }
            else
            {
                border.BorderBrush     = Brushes.Red;
                border.BorderThickness = new Thickness(2);

                comboBox.Tag = null;
            }

            VisibilityWeight();
            ChangeButtonAddVisibility(comboBox.Tag);
        }