private void ButtonSaveUser_OnClick(object sender, RoutedEventArgs e)
        {
            CheckPassAndLogin check = new CheckPassAndLogin();
            CaffeDataContext  db    = new CaffeDataContext();
            HashClass         hash  = new HashClass();

            if (check.ChceckPassEqals(Pass1TB.Text, Pass2TB.Text) && check.ChceckPassNumeric(Pass1TB.Text) &&
                check.CheckPassLength(Pass1TB.Text))
            {
                int  IdMax = db.Users.Max(s => s.Id_user);
                User u     = new User()
                {
                    Name     = UserNameTB.Text,
                    Id_user  = IdMax + 1,
                    Password = hash.GetHashString(Pass1TB.Text)
                };
                db.Users.InsertOnSubmit(u);
                db.SubmitChanges();

                MessageBox.Show("Zapisoano zmiany !!!");
                Pass1TB.Text    = "";
                Pass2TB.Text    = "";
                UserNameTB.Text = "";
            }

            else
            {
                MessageBox.Show("Nieprawidłowe dane !");
            }
        }
        private void ButtonSavePassChange_OnClick(object sender, RoutedEventArgs e)
        {
            CheckPassAndLogin check = new CheckPassAndLogin();

            if (check.ChceckPassEqals(Pass11TB.Text, Pass22TB.Text) && check.ChceckPassNumeric(Pass11TB.Text) &&
                check.CheckPassLength(Pass11TB.Text))
            {
                CaffeDataContext db   = new CaffeDataContext();
                HashClass        hash = new HashClass();
                User             u    = db.Users.FirstOrDefault(s => s.Id_user == userID);
                u.Password = hash.GetHashString(Pass11TB.Text);
                db.SubmitChanges();

                MessageBox.Show("Zapisano zmieny  !!!");
                Pass11TB.Text = "";
                Pass22TB.Text = "";
            }

            else
            {
                MessageBox.Show("Nieprawidłowe dane !");
            }
        }
Exemple #3
0
        private void ButtonLoginClick(object sender, RoutedEventArgs e)
        {
            HashClass        hs   = new HashClass();
            CaffeDataContext db   = new CaffeDataContext();
            User             user = db.Users.FirstOrDefault(s => s.Password.Equals(hs.GetHashString(_loginString)));

            if (user == null)
            {
                MessageBox.Show("Nieprawidłowe dane logowania !");
                _loginString = "";
            }
            else if (user.Name.Equals("Admin"))
            {
                AdminWindow aw = new AdminWindow();
                this.Close();
                aw.Show();
            }
            else
            {
                AllOrdersWindow allOrdersWindow = new AllOrdersWindow(user);
                this.Close();
                allOrdersWindow.Show();
            }
        }