コード例 #1
0
 partial void DeleteTeam(Team instance);
コード例 #2
0
 partial void InsertTeam(Team instance);
コード例 #3
0
 partial void UpdateTeam(Team instance);
コード例 #4
0
        //Binds the registration data to the LINQ to SQL dbml based on user specified entries//
        //Sends an email to the user provided email address//
        //Clears all textboxes and reestablished the datacontext to allow the user to enter again//
        private void Applicant_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            RegisterValidation _applicant = Register_Window.DataContext as RegisterValidation;

            if (Confirm_Password_Input.Text != New_Password_Input.Text)
            {
                MessageBox.Show("Your passwords must match before you can finish registering. Please check your password and try again.");
            }
            else
            {
                    Player user = new Player();
                    user.FirstName = First_Name_Input.Text;
                    user.LastName = Last_Name_Input.Text;
                    user.Email = Email_Input.Text;
                    user.PhoneNumber = Phone_Number_Input.Text;
                    user.Address = Address_Input.Text;
                    user.Address2 = Address2_Input.Text;
                    user.City = City_Input.Text;
                    user.State = State_Input.Text;
                    user.Zipcode = Zipcode_Input.Text;
                    user.Position = Position_Selection.Text;
                    user.AltPosition1 = Alt_Position_Selection.Text;
                    user.AltPosition2 = Alt_Position_Selection2.Text;
                    user.Gender = Gender_Selection.Text;
                    user.Password = Confirm_Password_Input.Text;

                    if (AccountType.Text == "Team Captain")
                    {
                        user.UserType = 1;
                        user.Approved = 1;
                        user.Position = "Team Captain";
                        user.TeamName = CustomTeam.Text;
                        globals.user.TID = user.TID;

                        globals.user.UserType = user.UserType;

                        Team newTeam = new Team();
                        newTeam.TeamName = CustomTeam.Text;
                        newTeam.CoachFirstName = First_Name_Input.Text;
                        newTeam.CoachLastName = Last_Name_Input.Text;

                        user.TeamName = CustomTeam.Text;
                        db.Teams.InsertOnSubmit(newTeam);
                    }

                    if (AccountType.Text == "Team Player")
                    {

                        var teamquery = from teams in db.Teams
                                        where teams.TeamName == TeamList.Text
                                        select teams;

                        foreach (var team in teamquery)
                        {
                            user.TID = team.TID;
                            user.TeamName = team.TeamName;

                        }
                    }

                    db.Players.InsertOnSubmit(user);

                    try
                    {
                        db.SubmitChanges();
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    if (AccountType.Text == "Team Captain")
                    {
                        var teamquery = from teams in db.Teams
                                        where teams.TeamName == CustomTeam.Text
                                        select teams;

                        foreach (var team in teamquery)
                        {
                            globals.user.TID = team.TID;
                            user.TID = team.TID;
                        }
                        try
                        {
                            db.SubmitChanges();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    MessageBox.Show("You have successfully registered!");

                    Window BacktoMain = new MainWindow();
                    BacktoMain.Show();
                    this.Close();

            try
                {
                    SmtpClient client = new SmtpClient("smtp.live.com", 587);
                    client.EnableSsl = true;
                    client.Timeout = 10000;
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials = new NetworkCredential("*****@*****.**", "1qaz2wsx!QAZ@WSX");

                    MailMessage msg = new MailMessage();
                    msg.To.Add(Email_Input.Text);
                    msg.From = new MailAddress("*****@*****.**");
                    msg.Subject = "Registration Successful";
                    msg.Body = "Congratulations!\nYou have successfully registered.";
                    client.Send(msg);
                    MessageBox.Show("Please check your E-Mail for verification.");
                }
                catch (Exception ex)
                {

                    MessageBox.Show(ex.ToString());
                }

            _applicant = new RegisterValidation();
            Register_Window.DataContext = _applicant;
            e.Handled = true;

            }
        }