Exemplo n.º 1
0
        private void LogInClick(object sender, RoutedEventArgs e)
        {
            WindowControl windowControl = new WindowControl();
            WindowUser    windowUser    = new WindowUser();
            WindowWorkers windowWorkers = new WindowWorkers();

            EMTYEntities db     = new EMTYEntities();
            var          worker = db.Workers.AsNoTracking().FirstOrDefault(u => u.Email == TextBoxLigin.Text && u.Password == TextBoxPassword.Password);
            var          user   = db.User.AsNoTracking().FirstOrDefault(u => u.Login == TextBoxLigin.Text && u.Password == TextBoxPassword.Password);

            if (user == null && worker == null)
            {
                LabelAnswer.Content = "Пользователь не найден";
            }

            else if (string.IsNullOrEmpty(TextBoxLigin.Text) || string.IsNullOrEmpty(TextBoxPassword.Password))
            {
                LabelAnswer.Content = "Введите логин и пароль";
            }
            try
            {
                if (TextBoxLigin.Text == user.Login)
                {
                    var myWindow = MainWindow.GetWindow(this);
                    myWindow.Close();
                    windowUser.Show();
                }
            }
            catch
            {
                try
                {
                    if (TextBoxLigin.Text == worker.Email && worker.TitleID == 2)
                    {
                        var myWindow = MainWindow.GetWindow(this);
                        myWindow.Close();
                        windowWorkers.Show();
                    }

                    else if (TextBoxLigin.Text == worker.Email && worker.TitleID == 1)
                    {
                        var myWindow = MainWindow.GetWindow(this);
                        myWindow.Close();
                        windowControl.Show();
                    }
                }
                catch
                {
                    LabelAnswer.Content = "Неправильно введёт логин или пароль";
                }
            }
        }
Exemplo n.º 2
0
        private void ButtonSignUpClick(object sender, RoutedEventArgs e)
        {
            Regex regexPass  = new Regex("(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{6,}");
            Regex regexEmail = new Regex("/@/");

            //if (regexPass.IsMatch(TextBoxPasswordReg.Password))
            //{
            //    LabelAnswer.Content = "Лёгкий пароль, Пример:Fg78Td62";
            //}

            if (regexEmail.IsMatch(TextBoxEmailReg.Text))
            {
                LabelAnswer.Content = "Не паравильно введена почта";
            }

            else if (TextBoxPasswordReg.Password != TextBoxConfirmPassword.Password)
            {
                LabelAnswer.Content = "Повторный пароль не совпадает";
            }

            else if (TextBoxPasswordReg.Password == TextBoxConfirmPassword.Password)
            {
                User user = new User();
                user.Surname    = TextBoxSurnameReg.Text;
                user.Name       = TextBoxNameReg.Text;
                user.Patronumic = TextBoxPatronumicReg.Text;
                user.Telephone  = TextBoxPhoneReg.Text;
                user.Login      = TextBoxLiginReg.Text;
                user.Password   = TextBoxPasswordReg.Password;
                user.Email      = TextBoxEmailReg.Text;
                user.TotalID    = 3;
                dataEntities.User.Add(user);
                dataEntities.SaveChanges();


                WindowUser windowUser = new WindowUser();
                windowUser.Show();
                var ThisWindow = SignUpWindow.GetWindow(this);
                ThisWindow.Close();
            }
        }