private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            if (txtbName.Text == "" || txtbSurname.Text == "" || txtbPatr.Text == "" || txtbNominal.Text == "")
            {
                MessageBox.Show("Заполните все поля");
            }
            else
            {
                SkidCards sc = new SkidCards();

                Employee emp   = cbxEmp.SelectedItem as Employee;
                int      idEmp = emp.idEmployee;

                sc.Surname    = txtbName.Text;
                sc.Name       = txtbName.Text;
                sc.Patronymic = txtbPatr.Text;
                sc.idEmployee = idEmp;
                sc.Nominal    = txtbNominal.Text;
                sc.NumberCard = txtbNCard.Text;

                db.SkidCards.Add(sc);
                db.SaveChanges();

                Close();
            }
        }
Example #2
0
 private void btnDel_Click(object sender, RoutedEventArgs e)
 {
     if (dgSaleCard.SelectedItem != null)
     {
         SkidCards sc = dgSaleCard.SelectedItem as SkidCards;
         db.SkidCards.Remove(sc);
         db.SaveChanges();
         dgSaleCard.ItemsSource = db.SkidCards.ToArray().ToList();
     }
     else
     {
         MessageBox.Show("Выберите поле для удаления!");
     }
 }
Example #3
0
        private void txtbSkidCard_TextChanged(object sender, TextChangedEventArgs e)
        {
            string        nCard        = txtbSkidCard.Text;
            user3Entities db1          = new user3Entities();
            SkidCards     ItemSkidCart = db.SkidCards.Where(i => i.NumberCard == nCard).FirstOrDefault();

            if (ItemSkidCart != null)
            {
                txtSCardCheck.Text = "Проверен";
                SkidCard           = double.Parse(ItemSkidCart.Nominal);
                txtItogS.Text      = Convert.ToString(Summa - (Summa * SkidCard));
                SummaS             = Summa - (Summa * SkidCard);
            }
            else
            {
                txtSCardCheck.Text = "Ошибка";
                txtItogS.Text      = txtItog.Text;
            }
        }
Example #4
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            new AddBludoWindow(idZak).ShowDialog();
            Summa = 0;
            dgOrdBludo.ItemsSource = db.ZakazBluda.Where(t => t.idZakaza == idZak).ToArray().ToList();
            foreach (var item in db.ZakazBluda)
            {
                if (item.idZakaza == idZak)
                {
                    Summa += item.Summa;
                }
            }
            txtItog.Text = $"Итог: {Summa}";
            foreach (var item in db.Zakazi)
            {
                if (item.idZakaza == idZak)
                {
                    item.SummaZakaza = Summa;
                }
            }
            db.SaveChanges();
            if (txtbSkidCard.Text != null)
            {
                string        nCard = txtbSkidCard.Text;
                user3Entities db1   = new user3Entities();

                SkidCards ItemSkidCart = db.SkidCards.Where(i => i.NumberCard == nCard).FirstOrDefault();
                if (ItemSkidCart != null)
                {
                    txtSCardCheck.Text = "Проверен";
                    SkidCard           = double.Parse(ItemSkidCart.Nominal);
                    txtItogS.Text      = Convert.ToString(Summa - (Summa * SkidCard));
                    SummaS             = Summa - (Summa * SkidCard);
                }
                else
                {
                    txtSCardCheck.Text = "Ошибка";
                    txtItogS.Text      = txtItog.Text;
                }
            }
            btnDel.IsEnabled  = true;
            btnSave.IsEnabled = true;
        }