Ejemplo n.º 1
0
        private void ChangeCounteragentBtn_Click(object sender, RoutedEventArgs e)
        {
            Сounteragent      Btn = (sender as Button).DataContext as Сounteragent;
            ChangeCounteagent changeCounteagent = new ChangeCounteagent(Btn.IdСounteragent, Btn.Name, Btn.Surname, Btn.MiddleName, Btn.INN, Btn.Adress, Btn.Phone, Btn.Role, TableCounteragents);

            changeCounteagent.ShowDialog();
        }
Ejemplo n.º 2
0
        private void DeleteCountreagentBtn_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Вы уверены, что хотите удалить контрагента?", "Удаление",
                                                      MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                Сounteragent Btn          = (sender as Button).DataContext as Сounteragent;
                var          сounteragent = db.Сounteragent.Where(p => p.IdСounteragent == Btn.IdСounteragent).FirstOrDefault();
                сounteragent.Removed = true;
                db.SaveChanges();
                TableCounteragents.ItemsSource = db.Сounteragent.Where(p => p.Role == Btn.Role && p.Removed == false).ToList();
            }
        }
Ejemplo n.º 3
0
        private void BtnAddCounteragent_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Выберите роль:\n Yes - Поставщик \n No - ПОкупатель", "Удаление",
                                                      MessageBoxButton.YesNo, MessageBoxImage.Question);
            int role;

            if (result == MessageBoxResult.Yes)
            {
                role = 1;
            }

            else
            {
                role = 2;
            }


            if (TxtForName.Text != String.Empty && TxtForSurname.Text != String.Empty && TxtForMiddle.Text != String.Empty && TxtForInn.Text != String.Empty && TxtForPhone.Text != String.Empty)
            {
                var checkCounteragent = db.Сounteragent.Where(p => p.INN == TxtForInn.Text).FirstOrDefault();
                if (checkCounteragent == null)
                {
                    Сounteragent сounteragent = new Сounteragent();
                    сounteragent.Name       = TxtForName.Text;
                    сounteragent.Surname    = TxtForSurname.Text;
                    сounteragent.MiddleName = TxtForMiddle.Text;
                    сounteragent.INN        = TxtForInn.Text;
                    сounteragent.Adress     = TxtForAdress.Text;
                    сounteragent.Phone      = TxtForPhone.Text;
                    сounteragent.Role       = role;
                    сounteragent.Removed    = false;
                    db.Сounteragent.Add(сounteragent);
                    db.SaveChanges();
                    TableCounteragents.ItemsSource = db.Сounteragent.Where(p => p.Role == 1 && p.Removed == false).ToList();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Такой контерагент уже существует!");
                }
            }
            else
            {
                MessageBox.Show("Вы не заполнили поля!");
            }
        }