Example #1
0
        // Attempt to add a recruit into tblRecruit
        protected void btnAddRecruit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    // Retrieve data entered by the user into the form inputs
                    var firstName      = txtBoxFirstName.Text.Trim();
                    var lastName       = txtBoxLastName.Text.Trim();
                    var contactNumber  = txtBoxPhoneNumber.Text.Trim();
                    var emailAddress   = txtBoxEmailAddress.Text.Trim();
                    var birthYear      = Convert.ToInt32(txtBoxBirthYear.Text.Trim());
                    var graduationYear = Convert.ToInt32(txtBoxGradYear.Text.Trim());
                    var currentTeam    = txtBoxCurrentTeam.Text.Trim();
                    var jerseyNumber   = Convert.ToInt32(txtBoxJerseyNumber.Text.Trim());
                    var position       = dropdownPosition.SelectedItem.Text.Trim();
                    var mothersName    = txtBoxMothersName.Text.Trim();
                    var fathersName    = txtBoxFathersName.Text.Trim();
                    var recruitStatus  = dropdownStatus.SelectedItem.Text.Trim();
                    var dateAdded      = Convert.ToString(DateTime.Today);

                    // Attempt to add a recruit to the database from the data entered by the user into the form
                    var addRecruit = ConnectionClass.AddRecruit(firstName, lastName, contactNumber, emailAddress, birthYear, graduationYear, currentTeam, jerseyNumber, position, mothersName, fathersName, recruitStatus, dateAdded);

                    // Display different messages to the user to let them know whether the recruit was added to the database successfully
                    if (addRecruit)
                    {
                        lblAddRecruitError.Text    = "Recruit Added Successfuly!";
                        lblAddRecruitError.Visible = true;
                    }

                    else
                    {
                        lblAddRecruitError.Visible = true;
                    }
                }

                lblAddRecruitError.Visible = true;
            }

            catch (Exception ex)
            {
                lblAddRecruitError.Text    = ex.Message;
                lblAddRecruitError.Visible = true;
            }
        }
Example #2
0
        // 11/23/18 Minseok Choi
        // retrieve user inputs for adding a scouting report and add a new report in the database
        protected void btnAddScoutingReport_Click(object sender, EventArgs e)
        {
            try
            {
                // Check to make sure form passes all validation checks
                if (Page.IsValid)
                {
                    // get values from session
                    string recruitId = Request.QueryString["id"];
                    string accountId = Session["userId"].ToString();

                    // Retrieve user inputs
                    string skating = dropdownSkating.SelectedValue;
                    string individualOffesiveSkills  = dropdownIndividualOffesiveSkills.SelectedValue;
                    string individualDefensiveSkills = dropdownIndividualDefensiveSkills.SelectedValue;
                    string offensiveTeamPlay         = dropdownOffensiveTeamPlay.SelectedValue;
                    string defensiveTeamPlay         = dropdownDefensiveTeamPlay.SelectedValue;
                    string hockeySense    = dropdownHockeySense.SelectedValue;
                    string strengthPower  = dropdownStrengthPower.SelectedValue;
                    string workEthic      = dropdownWorkEthic.Text.Trim();
                    string overallRanking = dropdownOverallRanking.Text.Trim();
                    string notes          = txtNotes.Text.Trim();

                    // Connect to the database and attempt to add new scouting report
                    bool addPlayerScoutingReport = ConnectionClass.AddPlayerScoutingReport(
                        recruitId, accountId, skating, individualOffesiveSkills, individualDefensiveSkills, offensiveTeamPlay,
                        defensiveTeamPlay, hockeySense, strengthPower, workEthic, overallRanking, notes);

                    // If adding a scouting report is successful redirect user to the account list page
                    if (addPlayerScoutingReport)
                    {
                        Response.Redirect("Recruits.aspx");     // todo change temporal url
                    }
                    // If adding an scouting report is not successful display failed message to the suer
                    else
                    {
                        lblAddScoutingReportError.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                lblAddScoutingReportError.Visible = true;
                lblAddScoutingReportError.Text    = ex.Message;
            }
        }
Example #3
0
        protected void ListViewAccounts_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            isAdmin();

            string accountID = e.CommandArgument.ToString();

            if (e.CommandName == "updateAccount")
            {
                Session["accountID"] = accountID;
                Response.Redirect("UpdateAccount.aspx");
            }
            else if (e.CommandName == "deleteAccount")
            {
                ConnectionClass.DeleteAccount(accountID);
                Page.Response.Redirect(Page.Request.Url.ToString(), true);
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Only work when the page is initialized
            if (!IsPostBack)
            {
                if (Session["username"] == null)
                {
                    Response.Redirect("Default.aspx");
                }

                lblLoggedInUser.Text        = "Welcome, " + Session["username"];
                lblEditRecruitError.Visible = false;

                lblEditRecruitError.CssClass = "alert alert-danger small font-weight-bold text-center";
                int id = Convert.ToInt32(Request.QueryString["id"]);

                //load selected recruit information as the hint of the textboxes through a RecruitClass object.
                RecruitClass recruit = ConnectionClass.DisplayRecruit(id);

                //txtBoxFirstName.Attributes.Add("placeholder",recruit.FirstName);
                //txtBoxLastName.Attributes.Add("placeholder", recruit.LastName);
                //txtBoxPhoneNumber.Attributes.Add("placeholder", recruit.ContactNumber);
                //txtBoxEmailAddress.Attributes.Add("placeholder", recruit.EmailAddress);
                //txtBoxBirthYear.Attributes.Add("placeholder", recruit.Birthyear.ToString());
                //txtBoxGradYear.Attributes.Add("placeholder", recruit.GraduationYear.ToString());
                //txtBoxCurrentTeam.Attributes.Add("placeholder", recruit.CurrentTeam);
                //txtBoxJerseyNumber.Attributes.Add("placeholder", recruit.JerseyNumber.ToString());
                //txtBoxMothersName.Attributes.Add("placeholder", recruit.MothersName);
                //txtBoxFathersName.Attributes.Add("placeholder", recruit.FathersName);

                //Added by Ryan Watson 11-22-18
                txtBoxFirstName.Text    = recruit.FirstName;
                txtBoxLastName.Text     = recruit.LastName;
                txtBoxPhoneNumber.Text  = recruit.ContactNumber;
                txtBoxEmailAddress.Text = recruit.EmailAddress;
                txtBoxBirthYear.Text    = recruit.Birthyear.ToString();
                txtBoxGradYear.Text     = recruit.GraduationYear.ToString();
                txtBoxCurrentTeam.Text  = recruit.CurrentTeam;
                txtBoxJerseyNumber.Text = recruit.JerseyNumber.ToString();
                //txtBoxPosition.Text = recruit.Position.ToString();
                txtBoxMothersName.Text = recruit.MothersName;
                txtBoxFathersName.Text = recruit.FathersName;
                //txtBoxStatus.Text = recruit.Status.ToString();
            }
        }
        // 11/23/18 Minseok Choi
        // retrieve user inputs for adding a scouting report and add a new report in the database
        protected void btnAddScoutingReport_Click(object sender, EventArgs e)
        {
            try
            {
                // Check to make sure form passes all validation checks
                if (Page.IsValid)
                {
                    // get values from session
                    string recruitId = Request.QueryString["id"];
                    string accountId = Session["userId"].ToString();

                    // Retrieve user inputs
                    string skating               = dropdownSkating.SelectedValue;
                    string agilitySpeed          = dropdownAgilitySpeed.SelectedValue;
                    string trafficReboundControl = dropdownTrafficReboundControl.SelectedValue;
                    string hockeySense           = dropdownHockeySense.SelectedValue;
                    string strengthFitness       = dropdownStrengthFitness.SelectedValue;
                    string mentalToughness       = dropdownMentalToughness.SelectedValue;
                    string battleMentality       = dropdownBattleMentality.SelectedValue;
                    string overallRanking        = dropdownOverallRanking.Text.Trim();
                    string notes = txtNotes.Text.Trim();

                    // Connect to the database and attempt to add new scouting report
                    bool addGoalieScoutingReport = ConnectionClass.AddGoalieScoutingReport(
                        recruitId, accountId, skating, agilitySpeed, trafficReboundControl, hockeySense, strengthFitness,
                        mentalToughness, battleMentality, overallRanking, notes);

                    // If adding a scouting report is successful redirect user to the account list page
                    if (addGoalieScoutingReport)
                    {
                        Response.Redirect("Recruits.aspx");     // todo change temporal url
                    }
                    // If adding an scouting report is not successful display failed message to the suer
                    else
                    {
                        lblAddScoutingReportError.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                lblAddScoutingReportError.Visible = true;
                lblAddScoutingReportError.Text    = ex.Message;
            }
        }
Example #6
0
        // 11/08/18_Heeyeong Kim
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var listViewRecruit = ListViewRecruits;

                // Retrieve data entered by the user into the form inputs
                var name      = txtBoxName.Text.Trim();
                var birthYear = dropdownBirthYear.SelectedItem.Text.Trim();
                var position  = dropdownPosition.SelectedItem.Text.Trim();

                if (birthYear.Equals("--Select--"))
                {
                    birthYear = null;
                }
                int birth = Convert.ToInt32(birthYear);

                if (!name.Equals("") && !Regex.IsMatch(name, @"^[a-zA-Z]+$"))
                {
                    lblSearchRecruitError.Text    = "Uppercase and lowercase letters only";
                    lblSearchRecruitError.Visible = true;
                    listViewRecruit.DataSource    = null;
                    listViewRecruit.DataBind();
                    return;
                }

                // Call SearchRecruits and retrieve data from database
                DataTable dt = ConnectionClass.SearchRecruits(name, birth, position);

                // If there is no result, error message shows up
                if (dt != null)
                {
                    if (dt.Rows.Count == 0)
                    {
                        lblSearchRecruitError.Text    = "Recruit Not Found";
                        lblSearchRecruitError.Visible = true;
                    }

                    listViewRecruit.DataSource = dt;
                    listViewRecruit.DataBind();
                }
            }
        }
Example #7
0
        protected void BtnEditReport_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    string reportId = Request.QueryString["id"];


                    // Retrieve user inputs
                    string skating = dropdownSkating.SelectedValue;
                    string individualOffesiveSkills  = dropdownIndividualOffesiveSkills.SelectedValue;
                    string individualDefensiveSkills = dropdownIndividualDefensiveSkills.SelectedValue;
                    string offensiveTeamPlay         = dropdownOffensiveTeamPlay.SelectedValue;
                    string defensiveTeamPlay         = dropdownDefensiveTeamPlay.SelectedValue;
                    string hockeySense    = dropdownHockeySense.SelectedValue;
                    string strengthPower  = dropdownStrengthPower.SelectedValue;
                    string workEthic      = dropdownWorkEthic.Text.Trim();
                    string overallRanking = dropdownOverallRanking.Text.Trim();
                    string notes          = txtNotes.Text.Trim();

                    bool editPlayerScoutingReport = ConnectionClass.EditPlayerScoutingReport(
                        reportId, skating, individualOffesiveSkills, individualDefensiveSkills, offensiveTeamPlay,
                        defensiveTeamPlay, hockeySense, strengthPower, workEthic, overallRanking, notes);

                    if (editPlayerScoutingReport)
                    {
                        lblEditReportError.CssClass = "alert alert-success";
                        lblEditReportError.Text     = "Player Report Edited Successfully!";
                        lblEditReportError.Visible  = true;
                    }
                    else
                    {
                        lblEditReportError.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                lblEditReportError.Text   += "\n" + ex.Message;
                lblEditReportError.Visible = true;
            }
        }
Example #8
0
        //Gabriele 25/11/18
        //UPDATE: Gabriele 4/12/18 - to also delete scouting reports for all recruits when applicable
        protected void BtnDelete_Click(object sender, EventArgs e)
        {
            string       recruitID = Request.QueryString["id"];
            RecruitClass recruit   = ConnectionClass.GetRecruit(Convert.ToInt32(recruitID));
            string       position  = recruit.Position;

            try
            {
                ConnectionClass.DeleteReport(recruitID, position);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                ConnectionClass.DeleteRecruit(recruitID);
                Response.Redirect("Recruits.aspx");
            }
        }
Example #9
0
        protected void BtnEditReport_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    string reportId = Request.QueryString["id"];
                    // Retrieve user inputs
                    var skating               = dropdownSkating.SelectedValue;
                    var agilitySpeed          = dropdownAgilitySpeed.SelectedValue;
                    var trafficReboundControl = dropdownTrafficReboundControl.SelectedValue;
                    var hockeySense           = dropdownHockeySense.SelectedValue;
                    var strengthFitness       = dropdownStrengthFitness.SelectedValue;
                    var mentalToughness       = dropdownMentalToughness.SelectedValue;
                    var battleMentality       = dropdownBattleMentality.SelectedValue;
                    var overallRanking        = dropdownOverallRanking.Text.Trim();
                    var notes = txtNotes.Text.Trim();

                    // Connect to the database and attempt to add new scouting report
                    bool editGoalieScoutingReport = ConnectionClass.EditGoalieReport(reportId,
                                                                                     skating, agilitySpeed, trafficReboundControl, hockeySense, strengthFitness,
                                                                                     mentalToughness, battleMentality, overallRanking, notes);

                    if (editGoalieScoutingReport)
                    {
                        lblEditReportError.CssClass = "alert alert-success";
                        lblEditReportError.Text     = "Goalie Report Edited Successfully!";
                        lblEditReportError.Visible  = true;
                    }
                    else
                    {
                        lblEditReportError.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                lblEditReportError.Text   += ex.Message;
                lblEditReportError.Visible = true;
            }
        }
Example #10
0
        // 11/23/18 Minseok Choi
        protected void Page_Load(object sender, EventArgs e)
        {
            // get recruitId from url param
            string recruitId = Request.QueryString["id"];

            // check username, recruitId and accountType valid
            if (Session["username"] == null || String.IsNullOrEmpty(recruitId) ||
                Session["accountType"] == null ||
                !(Session["accountType"].ToString() == AccountType.Coach.ToString() ||
                  Session["accountType"].ToString() == AccountType.Scout.ToString()))
            {
                Response.Redirect("Recruits.aspx");
            }

            lblLoggedInUser.Text = "Welcome, " + Session["username"];
            lblAddScoutingReportError.Visible = false;

            // set values in the name labels
            ConnectionClass.GetRecruitName(recruitId, out string firstName, out string lastName);
            lblRecruitIDData.Text = recruitId;
            lblFirstNameData.Text = firstName;
            lblLastNameData.Text  = lastName;
        }
Example #11
0
        protected void btnUpdateAccount_Click(object sender, EventArgs e)
        {
            try
            {
                // Check to make sure form passes all validation checks
                if (Page.IsValid)
                {
                    isAdmin();
                    // Retrieve user inputs from username, password, and email address textboxes
                    var         accountID    = lblAccountID.Text.Trim();
                    var         username     = txtUsername.Text.Trim();
                    var         password     = txtPassword.Text.Trim();
                    var         emailAddress = txtEmailAddress.Text.Trim();
                    var         sAccountType = ddlAccountType.SelectedValue;
                    AccountType accountType  = Utility.ConvertStringToAccountType(sAccountType);

                    // Connect to the database and attempt to add new user to the tblStaffAccount
                    var updateAccount = ConnectionClass.UpdateAccount(accountID, username, password, emailAddress, accountType);

                    // If adding an account is successful redirect user to the account list page
                    if (updateAccount)
                    {
                        Response.Redirect("Accounts.aspx");
                    }
                    // If adding an account is not successful display failed message to the suer
                    else
                    {
                        lblUpdateAccountError.Visible = true;
                    }
                }
            }
            catch (Exception ex)
            {
                lblUpdateAccountError.Visible = true;
                lblUpdateAccountError.Text    = ex.Message;
            }
        }
Example #12
0
        // 25/11/18 Gabriele //Updated to master
        //UPDATE: Gabriele 4/12/18 - to also delete scouting reports for all recruits when applicable
        protected void ListViewRecruits_deleteRecruit(object sender, ListViewCommandEventArgs e)
        {
            string       recruitID = e.CommandArgument.ToString();
            RecruitClass recruit   = ConnectionClass.GetRecruit(Convert.ToInt32(recruitID));
            string       position  = recruit.Position;


            try
            {
                ConnectionClass.DeleteReport(recruitID, position);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (e.CommandName == "deleteRecruit")
                {
                    ConnectionClass.DeleteRecruit(recruitID);
                    Page.Response.Redirect(Page.Request.Url.ToString(), true);
                }
            }
        }