コード例 #1
0
ファイル: NewUser.cs プロジェクト: riemanntensor/scoretrend
        public void addNewUserInformation()
        {
            using (ScoreTrendDataClassesDataContext dbNewUser = new ScoreTrendDataClassesDataContext())
            {
                try
                {
                    user newUser = new user();  //create new user table row with this object

                    newUser.username = u;   //set new username as u;
                    newUser.password = p;   //set new password as p;
                    newUser.teamid = intTeamIdSelected;     //send the rest of the information to the user table
                    newUser.leagueid = intLeagueIdSelected;
                    newUser.firstname = firstname;
                    newUser.lastname = lastname;

                    if (radYesAuth.Checked) //if authorized scorekeeper
                    {
                        newUser.authorized = 1;
                    }
                    else
                    {
                        newUser.authorized = 0;
                    }

                    dbNewUser.users.InsertOnSubmit(newUser);
                    dbNewUser.SubmitChanges();  //submit changes

                    if (radYesIAmAPlayer.Checked)   //if user is a player
                    {
                        player newPlayer = new player();    //create new player table row with this object

                        newPlayer.teamid = intTeamIdSelected;   //insert new player information
                        newPlayer.firstname = firstname;
                        newPlayer.lastname = lastname;

                        dbNewUser.players.InsertOnSubmit(newPlayer);
                        dbNewUser.SubmitChanges();  //submit changes

                        var newPlayerIdGiven1 = from players in context.players where players.firstname == firstname && players.lastname == lastname select players;

                        //update player id for new player from the users table player id
                        var newPlayerIdGiven2 = (from players in context.players where players.firstname == firstname && players.lastname == lastname select players).Single();
                        newPlayerIdGiven2.playerid = 3012;

                        context.SubmitChanges();

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Cannot communicate with database. Application will now close.","ScoreTrend" + ex);
                    Application.Exit();
                }
            }
        }
コード例 #2
0
		private void detach_users(user entity)
		{
			this.SendPropertyChanging();
			entity.player = null;
		}
コード例 #3
0
		private void attach_users(user entity)
		{
			this.SendPropertyChanging();
			entity.player = this;
		}
コード例 #4
0
 partial void Deleteuser(user instance);
コード例 #5
0
 partial void Updateuser(user instance);
コード例 #6
0
 partial void Insertuser(user instance);