예제 #1
0
        private void register(object userName)
        {
            us_users u = new us_users();
            u.us_username = (string)userName;
            

            if ((alreadyRegistered(u.us_username) == false) && (u.us_username != "") && (u.us_username.First() != ' ')) {

                try {
                    u.us_id = dbModel.us_users.Count() + 1;
                    dbModel.us_users.Add(u);
                    dbModel.SaveChanges();
                    MessageBox.Show("Registered! You have been registered. ", "Done", MessageBoxButton.OK);
                }
                catch (NullReferenceException n) {
                    u.us_id = 1;

                    dbModel.us_users.Add(u);
                    dbModel.SaveChanges();
                    MessageBox.Show("Registered! Your ID is 1", "Done", MessageBoxButton.OK);
                }
            }
            else { MessageBox.Show("Invalid input. No spaces are allowed!", "Error", MessageBoxButton.OK); }
            
        }
예제 #2
0
 private void chooseUser(string userName)
 {
     user = (from u in dbModel.us_users
            where u.us_username == userName
            select u).ToList().Last();
 }