コード例 #1
0
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            LoginScreenWndw loginScreenWndw = new LoginScreenWndw();

            loginScreenWndw.Show();
            this.Close();
        }
コード例 #2
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (!(ValidateRegistration()))
            {
                return;
            }

            string login    = txtBoxLogin.Text;
            string password = txtBoxPswrd.Text;
            string address  = txtBoxAddress.Text;
            string tel      = txtBoxTel.Text;
            int    num      = Convert.ToInt32(txtBoxIsAdmin.Text);
            bool   _isAdmin = Convert.ToBoolean(num);

            using (var db = new Model1())
            {
                var users = (from user in db.tblUsers
                             where user.NikName == login
                             select user).ToList();

                if (users.Count == 1)
                {
                    MessageBox.Show("User with current Login is exist");
                    return;
                }

                tblUser newUser = new tblUser()
                {
                    NikName = login, Password = password, Address = address, Tel = tel, IsAdmin = _isAdmin
                };
                db.tblUsers.Add(newUser);
                db.SaveChanges();
            }

            LoginScreenWndw loginScreenWndw = new LoginScreenWndw();

            loginScreenWndw.Show();
            this.Close();
        }