public async void Block(Login item, user3Entities db)
        {
            TimeSpan timeSpan = new TimeSpan(0, 0, 5);

            if (item.CountWrong >= 5 && item.UserName == "Admin")
            {
                timer.Interval = timeSpan;
                timer.Start();
                await Task.Run(() => this.timer.Tick += ((o, e) =>
                {
                    item.CountWrong = 0;
                    db.SaveChanges();
                    MessageBox.Show(item.UserName + " разблокирован");
                    timer.Stop();
                }));
            }
            if (item.CountWrong >= 5 && item.UserName == "Manager")
            {
                timer.Interval = timeSpan;
                timer.Start();
                await Task.Run(() => this.timer.Tick += ((o, e) =>
                {
                    item.CountWrong = 0;
                    db.SaveChanges();
                    MessageBox.Show(item.UserName + " разблокирован");
                    timer.Stop();
                }));
            }
        }
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            bool          enter = false;
            user3Entities db    = new user3Entities();

            Login itemLogin = db.Login.Where(i => i.UserName == txtbLogin.Text).FirstOrDefault();

            if (itemLogin == null)
            {
                MessageBox.Show("Ошибка ввода данных!");
            }
            else
            {
                foreach (var item in db.Login)
                {
                    if (itemLogin.UserName == item.UserName && pswbPassword.Password == item.Password)
                    {
                        this.Login = item.UserName;
                        this.Dates = DateTime.Now.ToString();
                        new MainWindow(this.Login, this.Dates).Show();
                        this.Close();
                        enter = true;
                    }
                }
                if (!enter)
                {
                    itemLogin.CountWrong++;
                    if (itemLogin.CountWrong < 5)
                    {
                        MessageBox.Show($"Неправильно введены логин или пароль Попытка {itemLogin.CountWrong}/5", "Ошибка", MessageBoxButton.OK);
                    }
                    if (itemLogin.CountWrong == 5)
                    {
                        MessageBox.Show("Этот логин Заблокирован (" + itemLogin.UserName + ")");
                        Block(itemLogin, db);
                    }
                    if (itemLogin.CountWrong > 5)
                    {
                        MessageBox.Show("Дождитесь, пока пройдет блокировка");
                    }
                    db.SaveChanges();
                }
            }
        }
Beispiel #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;
            }
        }
Beispiel #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;
        }