Esempio n. 1
0
        private void ovenSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (comboBox == null)
            {
                return;
            }
            if (comboBox.SelectedIndex == -1)
            {
                return;
            }
            if (comboBox.SelectedValue == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(comboBox);

            if (dgrow == null)
            {
                return;
            }

            SupplyDetailsHelper supplyDetailHelper = (SupplyDetailsHelper)dgrow.Item;

            if (supplyDetailHelper == null)
            {
                return;
            }

            supplyDetailHelper.IdOven    = (int)comboBox.SelectedValue;
            supplyDetailHelper.IdDetails = 0;
        }
Esempio n. 2
0
        private void countValueChange(object sender, PropertyChangedEventArgs e)
        {
            IntSpinnerControl updown = sender as IntSpinnerControl;

            if (updown == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(updown);

            if (dgrow == null)
            {
                return;
            }

            SupplyDetailsHelper supplyDetailHelper = (SupplyDetailsHelper)dgrow.Item;

            if (supplyDetailHelper == null)
            {
                return;
            }

            supplyDetailHelper.DetailsCount = (int)updown.Value;
        }
Esempio n. 3
0
        private void removeRecord(object sender, System.Windows.RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(button);

            if (dgrow == null)
            {
                return;
            }

            SupplyDetailsHelper supplyDetailHelper = (SupplyDetailsHelper)dgrow.Item;

            if (supplyDetailHelper == null)
            {
                return;
            }

            sdh_collection.remove(supplyDetailHelper);
        }
Esempio n. 4
0
        private void saveSupply()
        {
            if (sdh_collection.Collection.Count == 0)
            {
                System.Windows.MessageBox.Show("Невозможно сохранить пустое поступление!");
                return;
            }
            if (System.Windows.MessageBox.Show("Подтвердите поступление", "Подтвердите поступление", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
            {
                return;
            }

            if (!sdh_collection.isAllCorrect())
            {
                System.Windows.MessageBox.Show("Проверьте введенные данные!\nОдна или более строк заполнены некорректно!");
                return;
            }

            Supply supply = new Supply();

            supply.SupplyDate = DateTime.Now;

            if (supply.save())
            {
                for (int i = 0; i < sdh_collection.Collection.Count; i++)
                {
                    SupplyDetailsHelper sdh           = sdh_collection.Collection[i];
                    SupplyDetails       supplyDetails = new SupplyDetails();
                    supplyDetails.IdDetails    = sdh.IdDetails;
                    supplyDetails.IdSupply     = supply.Id;
                    supplyDetails.DetailsCount = sdh.DetailsCount;
                    if (!supplyDetails.save())
                    {
                        System.Windows.MessageBox.Show("При сохранении произошли ошибки.");
                        supply.remove();
                        return;
                    }
                }

                ///Update current count
                //sdh_collection.Collection.Count-1 - т.к. последняя строка пустая
                for (int i = 0; i < sdh_collection.Collection.Count - 1; i++)
                {
                    sdh_collection.Collection[i].Detail.CurrentCount = 0;
                }

                sdh_collection.clear();

                SupplyDetailsHelper newSupplyDetails = new SupplyDetailsHelper();
                sdh_collection.add(newSupplyDetails);
            }
            else
            {
                System.Windows.MessageBox.Show("При сохранении произошли ошибки.");
                return;
            }
        }
Esempio n. 5
0
        public SupplyPage()
        {
            InitializeComponent();

            DataContext = new
            {
                Collection = sdh_collection.Collection
            };

            SupplyDetailsHelper supplyDetails = new SupplyDetailsHelper();

            sdh_collection.add(supplyDetails);

            btnSaveSupply.Click += delegate
            {
                saveSupply();
            };
        }
Esempio n. 6
0
        private void detailsSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (comboBox == null)
            {
                return;
            }
            if (comboBox.SelectedIndex == -1)
            {
                return;
            }
            if (comboBox.SelectedValue == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(comboBox);

            if (dgrow == null)
            {
                return;
            }

            SupplyDetailsHelper supplyDetailHelper = (SupplyDetailsHelper)dgrow.Item;

            if (supplyDetailHelper == null)
            {
                return;
            }

            supplyDetailHelper.IdDetails = (int)comboBox.SelectedValue;

            int notFillRowCount = SupplyDetailsHelperCollection.instance()
                                  .Collection.Where(x => x.IdDetails == 0).Count();

            if (supplyDetailHelper.IdDetails != 0 && notFillRowCount == 0)
            {
                SupplyDetailsHelper supplyDetails = new SupplyDetailsHelper();
                sdh_collection.add(supplyDetails);
            }
        }