Beispiel #1
0
        private void btSignUp_Click(object sender, RoutedEventArgs e)
        {
            tbUser user = new tbUser
            {
                UserName = txtUser.Text,
                Password = txtPassword.Password,
                Email    = txtEmail.Text,
                Phone    = txtPhone.Text,
            };

            db.tbUsers.Add(user);
            db.SaveChanges();
            if (ImagePath != "")
            {
                string newPath = Environment.CurrentDirectory + $"\\Images\\Users\\{user.ID}.png";
                File.Copy(ImagePath, newPath);
                user.Image = newPath;
                db.SaveChanges();
            }

            MessageBox.Show("Done!");

            Main_Screen main = new Main_Screen();

            main.Show();
            Close();
        }
Beispiel #2
0
        private void btLogin_Click(object sender, RoutedEventArgs e)
        {
            var result = db.tbUsers.Where(x => x.UserName == txtUser.Text && x.Password == txtPassword.Password).ToList();

            if (result.Count() == 1)
            {
                user.userName = txtUser.Text;
                Main_Screen main = new Main_Screen();
                main.Show();
                Close();
            }
            else
            {
                MessageBox.Show("User Name or Password are invalid!");
            }
        }