示例#1
0
    protected void cmdCreate_Click(object sender, EventArgs e)
    {
        panAlert.Visible = true;
        if (txtLocation.Text == "")
        {
            lblAlert.Text = "Please enter a location";
        }
        else if (txtWeather.Text == "")
        {
            lblAlert.Text = "Please enter weather conditions";
        }
        else if (string.IsNullOrWhiteSpace(txtBoysTeam1.Text) || string.IsNullOrWhiteSpace(txtBoysAbbr1.Text))
        {
            lblAlert.Text = "Please enter team name information for boy's team #1";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam2.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr2.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam2.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr2.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #2";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam3.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr3.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam3.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr3.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #3";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam4.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr4.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam4.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr4.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #4";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam5.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr5.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam5.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr5.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #5";
        }
        else if ((string.IsNullOrWhiteSpace(txtBoysTeam6.Text) && !string.IsNullOrWhiteSpace(txtBoysAbbr6.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam6.Text) && string.IsNullOrWhiteSpace(txtBoysAbbr6.Text)))
        {
            lblAlert.Text = "Invalid name information for boy's team #6";
        }
        else if (string.IsNullOrWhiteSpace(txtGirlsTeam1.Text) || string.IsNullOrWhiteSpace(txtGirlsAbbr1.Text))
        {
            lblAlert.Text = "Please enter team name information for girl's team #1";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam2.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr2.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam2.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr2.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #2";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam3.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr3.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam3.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr3.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #3";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam4.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr4.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam4.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr4.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #4";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam5.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr5.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam5.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr5.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #5";
        }
        else if ((string.IsNullOrWhiteSpace(txtGirlsTeam6.Text) && !string.IsNullOrWhiteSpace(txtGirlsAbbr6.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam6.Text) && string.IsNullOrWhiteSpace(txtGirlsAbbr6.Text)))
        {
            lblAlert.Text = "Invalid name information for girl's team #6";
        }
        else
        {
            string meetLocation = txtLocation.Text;

            int month = 1;
            if (ddlMonth.Text == "February")
            {
                month = 2;
            }
            else if (ddlMonth.Text == "March")
            {
                month = 3;
            }
            else if (ddlMonth.Text == "April")
            {
                month = 4;
            }
            else if (ddlMonth.Text == "May")
            {
                month = 5;
            }
            else if (ddlMonth.Text == "June")
            {
                month = 6;
            }
            else if (ddlMonth.Text == "July")
            {
                month = 7;
            }
            else if (ddlMonth.Text == "August")
            {
                month = 8;
            }
            else if (ddlMonth.Text == "September")
            {
                month = 9;
            }
            else if (ddlMonth.Text == "October")
            {
                month = 10;
            }
            else if (ddlMonth.Text == "November")
            {
                month = 11;
            }
            else if (ddlMonth.Text == "December")
            {
                month = 12;
            }

            DateTime meetDateTime   = new DateTime(Convert.ToInt32(ddlYear.Text), month, Convert.ToInt32(ddlDay.Text));
            string   meetWeather    = txtWeather.Text;
            string   boysTeam1Abbr  = txtBoysAbbr1.Text.Trim();
            string   boysTeam1Name  = txtBoysTeam1.Text.Trim();
            string   boysTeam2Abbr  = txtBoysAbbr2.Text.Trim();
            string   boysTeam2Name  = txtBoysTeam2.Text.Trim();
            string   boysTeam3Abbr  = txtBoysAbbr3.Text.Trim();
            string   boysTeam3Name  = txtBoysTeam3.Text.Trim();
            string   boysTeam4Abbr  = txtBoysAbbr4.Text.Trim();
            string   boysTeam4Name  = txtBoysTeam4.Text.Trim();
            string   boysTeam5Abbr  = txtBoysAbbr5.Text.Trim();
            string   boysTeam5Name  = txtBoysTeam5.Text.Trim();
            string   boysTeam6Abbr  = txtBoysAbbr6.Text.Trim();
            string   boysTeam6Name  = txtBoysTeam6.Text.Trim();
            string   girlsTeam1Abbr = txtGirlsAbbr1.Text.Trim();
            string   girlsTeam1Name = txtGirlsTeam1.Text.Trim();
            string   girlsTeam2Abbr = txtGirlsAbbr2.Text.Trim();
            string   girlsTeam2Name = txtGirlsTeam2.Text.Trim();
            string   girlsTeam3Abbr = txtGirlsAbbr3.Text.Trim();
            string   girlsTeam3Name = txtGirlsTeam3.Text.Trim();
            string   girlsTeam4Abbr = txtGirlsAbbr4.Text.Trim();
            string   girlsTeam4Name = txtGirlsTeam4.Text.Trim();
            string   girlsTeam5Abbr = txtGirlsAbbr5.Text.Trim();
            string   girlsTeam5Name = txtGirlsTeam5.Text.Trim();
            string   girlsTeam6Abbr = txtGirlsAbbr6.Text.Trim();
            string   girlsTeam6Name = txtGirlsTeam6.Text.Trim();

            List <string> boysNames = new List <string>();
            if (!string.IsNullOrWhiteSpace(boysTeam1Name))
            {
                boysNames.Add(boysTeam1Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam2Name))
            {
                boysNames.Add(boysTeam2Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam3Name))
            {
                boysNames.Add(boysTeam3Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam4Name))
            {
                boysNames.Add(boysTeam4Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam5Name))
            {
                boysNames.Add(boysTeam5Name);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam6Name))
            {
                boysNames.Add(boysTeam6Name);
            }

            List <string> boysAbbrs = new List <string>();
            if (!string.IsNullOrWhiteSpace(boysTeam1Abbr))
            {
                boysAbbrs.Add(boysTeam1Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam2Abbr))
            {
                boysAbbrs.Add(boysTeam2Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam3Abbr))
            {
                boysAbbrs.Add(boysTeam3Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam4Abbr))
            {
                boysAbbrs.Add(boysTeam4Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam5Abbr))
            {
                boysAbbrs.Add(boysTeam5Abbr);
            }
            if (!string.IsNullOrWhiteSpace(boysTeam6Abbr))
            {
                boysAbbrs.Add(boysTeam6Abbr);
            }

            List <string> girlsNames = new List <string>();
            if (!string.IsNullOrWhiteSpace(girlsTeam1Name))
            {
                girlsNames.Add(girlsTeam1Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam2Name))
            {
                girlsNames.Add(girlsTeam2Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam3Name))
            {
                girlsNames.Add(girlsTeam3Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam4Name))
            {
                girlsNames.Add(girlsTeam4Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam5Name))
            {
                girlsNames.Add(girlsTeam5Name);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam6Name))
            {
                girlsNames.Add(girlsTeam6Name);
            }

            List <string> girlsAbbrs = new List <string>();
            if (!string.IsNullOrWhiteSpace(girlsTeam1Abbr))
            {
                girlsAbbrs.Add(girlsTeam1Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam2Abbr))
            {
                girlsAbbrs.Add(girlsTeam2Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam3Abbr))
            {
                girlsAbbrs.Add(girlsTeam3Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam4Abbr))
            {
                girlsAbbrs.Add(girlsTeam4Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam5Abbr))
            {
                girlsAbbrs.Add(girlsTeam5Abbr);
            }
            if (!string.IsNullOrWhiteSpace(girlsTeam6Abbr))
            {
                girlsAbbrs.Add(girlsTeam6Abbr);
            }

            if (boysNames.Distinct().Count() != boysNames.Count())
            {
                lblAlert.Text = "All Boy's names must be unique";
            }
            else if (boysAbbrs.Distinct().Count() != boysAbbrs.Count())
            {
                lblAlert.Text = "All Boy's abbrs must be unique";
            }
            else if (girlsNames.Distinct().Count() != girlsNames.Count())
            {
                lblAlert.Text = "All Girl's names must be unique";
            }
            else if (girlsAbbrs.Distinct().Count() != girlsAbbrs.Count())
            {
                lblAlert.Text = "All Girl's abbrs must be unique";
            }
            else
            {
                Dictionary <string, string> boysTeams = new Dictionary <string, string>();
                boysTeams.Add(boysTeam1Abbr, boysTeam1Name);
                if (!string.IsNullOrWhiteSpace(boysTeam2Abbr))
                {
                    boysTeams.Add(boysTeam2Abbr, boysTeam2Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam3Abbr))
                {
                    boysTeams.Add(boysTeam3Abbr, boysTeam3Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam4Abbr))
                {
                    boysTeams.Add(boysTeam4Abbr, boysTeam4Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam5Abbr))
                {
                    boysTeams.Add(boysTeam5Abbr, boysTeam5Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam6Abbr))
                {
                    boysTeams.Add(boysTeam6Abbr, boysTeam6Name);
                }

                Dictionary <string, string> girlsTeams = new Dictionary <string, string>();
                girlsTeams.Add(girlsTeam1Abbr, girlsTeam1Name);
                if (!string.IsNullOrWhiteSpace(girlsTeam2Abbr))
                {
                    girlsTeams.Add(girlsTeam2Abbr, girlsTeam2Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam3Abbr))
                {
                    girlsTeams.Add(girlsTeam3Abbr, girlsTeam3Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam4Abbr))
                {
                    girlsTeams.Add(girlsTeam4Abbr, girlsTeam4Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam5Abbr))
                {
                    girlsTeams.Add(girlsTeam5Abbr, girlsTeam5Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam6Abbr))
                {
                    girlsTeams.Add(girlsTeam6Abbr, girlsTeam6Name);
                }

                Teams newTeams = new Teams(boysTeams, girlsTeams);

                newMeet = new Meet(meetDateTime, meetLocation, meetWeather, newTeams);

                if (newMeet.validate())
                {
                    DatabaseMgr dm = new DatabaseMgr();
                    meetID = dm.FindMeetId(newMeet);

                    if (meetID < 0)
                    {
                        panAlert.GroupingText = "Problem loading meet database. Please try again later";
                    }
                    else
                    {
                        if (meetID == 0) //Meet does not exist in database
                        {
                            bool didAdd = dm.AddMeet(newMeet, Session["Username"].ToString());
                            if (didAdd)
                            {
                                Session["ActiveMeet"] = newMeet;

                                //Open MeetHub here
                                Response.Redirect("MeetHub.aspx");
                            }
                            else
                            {
                                lblAlert.Text = "Problem addign meet to database, please try again later";
                            }
                        }
                        else
                        {
                            panAlert.Visible         = false;
                            panDatabaseAlert.Visible = true;

                            lblDatabaseAlert.Text = "Meet already exists, do you wish to overwrite existing meet, or open existing meet?";
                            cmdCreate.Visible     = false;
                        }
                    }
                }
                else
                {
                    lblAlert.Text = "Unknown problem creating this meet. Data was invalid.";
                }
            }
        }
    }
示例#2
0
        private void cmdCreateMeet_Click(object sender, EventArgs e)
        {
            if (txtLocation.Text == "")
            {
                MessageBox.Show("Please enter a location", "Invalid Data");
            }
            else if (cboWeather.Text == "")
            {
                MessageBox.Show("Please enter weather conditions", "Invalid Data");
            }
            else if (string.IsNullOrWhiteSpace(txtBoysTeam1Name.Text) || string.IsNullOrWhiteSpace(txtBoysTeam1Abbr.Text))
            {
                MessageBox.Show("Please enter team name information for boy's team #1", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtBoysTeam2Name.Text) && !string.IsNullOrWhiteSpace(txtBoysTeam2Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam2Name.Text) && string.IsNullOrWhiteSpace(txtBoysTeam2Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for boy's team #2", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtBoysTeam3Name.Text) && !string.IsNullOrWhiteSpace(txtBoysTeam3Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam3Name.Text) && string.IsNullOrWhiteSpace(txtBoysTeam3Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for boy's team #3", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtBoysTeam4Name.Text) && !string.IsNullOrWhiteSpace(txtBoysTeam4Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam4Name.Text) && string.IsNullOrWhiteSpace(txtBoysTeam4Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for boy's team #4", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtBoysTeam5Name.Text) && !string.IsNullOrWhiteSpace(txtBoysTeam5Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam5Name.Text) && string.IsNullOrWhiteSpace(txtBoysTeam5Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for boy's team #5", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtBoysTeam6Name.Text) && !string.IsNullOrWhiteSpace(txtBoysTeam6Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtBoysTeam6Name.Text) && string.IsNullOrWhiteSpace(txtBoysTeam6Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for boy's team #6", "Invalid Data");
            }
            else if (string.IsNullOrWhiteSpace(txtGirlsTeam1Name.Text) || string.IsNullOrWhiteSpace(txtGirlsTeam1Abbr.Text))
            {
                MessageBox.Show("Please enter team name information for girl's team #1", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtGirlsTeam2Name.Text) && !string.IsNullOrWhiteSpace(txtGirlsTeam2Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam2Name.Text) && string.IsNullOrWhiteSpace(txtGirlsTeam2Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for girl's team #2", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtGirlsTeam3Name.Text) && !string.IsNullOrWhiteSpace(txtGirlsTeam3Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam3Name.Text) && string.IsNullOrWhiteSpace(txtGirlsTeam3Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for girl's team #3", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtGirlsTeam4Name.Text) && !string.IsNullOrWhiteSpace(txtGirlsTeam4Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam4Name.Text) && string.IsNullOrWhiteSpace(txtGirlsTeam4Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for girl's team #4", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtGirlsTeam5Name.Text) && !string.IsNullOrWhiteSpace(txtGirlsTeam5Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam5Name.Text) && string.IsNullOrWhiteSpace(txtGirlsTeam5Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for girl's team #5", "Invalid Data");
            }
            else if ((string.IsNullOrWhiteSpace(txtGirlsTeam6Name.Text) && !string.IsNullOrWhiteSpace(txtGirlsTeam6Abbr.Text)) || (!string.IsNullOrWhiteSpace(txtGirlsTeam6Name.Text) && string.IsNullOrWhiteSpace(txtGirlsTeam6Abbr.Text)))
            {
                MessageBox.Show("Invalid name information for girl's team #6", "Invalid Data");
            }
            else
            {
                string   meetLocation   = txtLocation.Text;
                DateTime meetDateTime   = dtpMeetDate.Value;
                string   meetWeather    = cboWeather.Text;
                string   boysTeam1Abbr  = txtBoysTeam1Abbr.Text.Trim();
                string   boysTeam1Name  = txtBoysTeam1Name.Text.Trim();
                string   boysTeam2Abbr  = txtBoysTeam2Abbr.Text.Trim();
                string   boysTeam2Name  = txtBoysTeam2Name.Text.Trim();
                string   boysTeam3Abbr  = txtBoysTeam3Abbr.Text.Trim();
                string   boysTeam3Name  = txtBoysTeam3Name.Text.Trim();
                string   boysTeam4Abbr  = txtBoysTeam4Abbr.Text.Trim();
                string   boysTeam4Name  = txtBoysTeam4Name.Text.Trim();
                string   boysTeam5Abbr  = txtBoysTeam5Abbr.Text.Trim();
                string   boysTeam5Name  = txtBoysTeam5Name.Text.Trim();
                string   boysTeam6Abbr  = txtBoysTeam6Abbr.Text.Trim();
                string   boysTeam6Name  = txtBoysTeam6Name.Text.Trim();
                string   girlsTeam1Abbr = txtGirlsTeam1Abbr.Text.Trim();
                string   girlsTeam1Name = txtGirlsTeam1Name.Text.Trim();
                string   girlsTeam2Abbr = txtGirlsTeam2Abbr.Text.Trim();
                string   girlsTeam2Name = txtGirlsTeam2Name.Text.Trim();
                string   girlsTeam3Abbr = txtGirlsTeam3Abbr.Text.Trim();
                string   girlsTeam3Name = txtGirlsTeam3Name.Text.Trim();
                string   girlsTeam4Abbr = txtGirlsTeam4Abbr.Text.Trim();
                string   girlsTeam4Name = txtGirlsTeam4Name.Text.Trim();
                string   girlsTeam5Abbr = txtGirlsTeam5Abbr.Text.Trim();
                string   girlsTeam5Name = txtGirlsTeam5Name.Text.Trim();
                string   girlsTeam6Abbr = txtGirlsTeam6Abbr.Text.Trim();
                string   girlsTeam6Name = txtGirlsTeam6Name.Text.Trim();

                List <string> boysNames = new List <string>();
                if (!string.IsNullOrWhiteSpace(boysTeam1Name))
                {
                    boysNames.Add(boysTeam1Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam2Name))
                {
                    boysNames.Add(boysTeam2Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam3Name))
                {
                    boysNames.Add(boysTeam3Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam4Name))
                {
                    boysNames.Add(boysTeam4Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam5Name))
                {
                    boysNames.Add(boysTeam5Name);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam6Name))
                {
                    boysNames.Add(boysTeam6Name);
                }

                List <string> boysAbbrs = new List <string>();
                if (!string.IsNullOrWhiteSpace(boysTeam1Abbr))
                {
                    boysAbbrs.Add(boysTeam1Abbr);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam2Abbr))
                {
                    boysAbbrs.Add(boysTeam2Abbr);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam3Abbr))
                {
                    boysAbbrs.Add(boysTeam3Abbr);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam4Abbr))
                {
                    boysAbbrs.Add(boysTeam4Abbr);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam5Abbr))
                {
                    boysAbbrs.Add(boysTeam5Abbr);
                }
                if (!string.IsNullOrWhiteSpace(boysTeam6Abbr))
                {
                    boysAbbrs.Add(boysTeam6Abbr);
                }

                List <string> girlsNames = new List <string>();
                if (!string.IsNullOrWhiteSpace(girlsTeam1Name))
                {
                    girlsNames.Add(girlsTeam1Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam2Name))
                {
                    girlsNames.Add(girlsTeam2Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam3Name))
                {
                    girlsNames.Add(girlsTeam3Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam4Name))
                {
                    girlsNames.Add(girlsTeam4Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam5Name))
                {
                    girlsNames.Add(girlsTeam5Name);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam6Name))
                {
                    girlsNames.Add(girlsTeam6Name);
                }

                List <string> girlsAbbrs = new List <string>();
                if (!string.IsNullOrWhiteSpace(girlsTeam1Abbr))
                {
                    girlsAbbrs.Add(girlsTeam1Abbr);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam2Abbr))
                {
                    girlsAbbrs.Add(girlsTeam2Abbr);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam3Abbr))
                {
                    girlsAbbrs.Add(girlsTeam3Abbr);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam4Abbr))
                {
                    girlsAbbrs.Add(girlsTeam4Abbr);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam5Abbr))
                {
                    girlsAbbrs.Add(girlsTeam5Abbr);
                }
                if (!string.IsNullOrWhiteSpace(girlsTeam6Abbr))
                {
                    girlsAbbrs.Add(girlsTeam6Abbr);
                }

                if (boysNames.Distinct().Count() != boysNames.Count())
                {
                    MessageBox.Show("All Boy's names must be unique", "Invalid Data");
                }
                else if (boysAbbrs.Distinct().Count() != boysAbbrs.Count())
                {
                    MessageBox.Show("All Boy's abbrs must be unique", "Invalid Data");
                }
                else if (girlsNames.Distinct().Count() != girlsNames.Count())
                {
                    MessageBox.Show("All Girl's names must be unique", "Invalid Data");
                }
                else if (girlsAbbrs.Distinct().Count() != girlsAbbrs.Count())
                {
                    MessageBox.Show("All Girl's abbrs must be unique", "Invalid Data");
                }
                else
                {
                    Dictionary <string, string> boysTeams = new Dictionary <string, string>();
                    boysTeams.Add(boysTeam1Abbr, boysTeam1Name);
                    if (!string.IsNullOrWhiteSpace(boysTeam2Abbr))
                    {
                        boysTeams.Add(boysTeam2Abbr, boysTeam2Name);
                    }
                    if (!string.IsNullOrWhiteSpace(boysTeam3Abbr))
                    {
                        boysTeams.Add(boysTeam3Abbr, boysTeam3Name);
                    }
                    if (!string.IsNullOrWhiteSpace(boysTeam4Abbr))
                    {
                        boysTeams.Add(boysTeam4Abbr, boysTeam4Name);
                    }
                    if (!string.IsNullOrWhiteSpace(boysTeam5Abbr))
                    {
                        boysTeams.Add(boysTeam5Abbr, boysTeam5Name);
                    }
                    if (!string.IsNullOrWhiteSpace(boysTeam6Abbr))
                    {
                        boysTeams.Add(boysTeam6Abbr, boysTeam6Name);
                    }

                    Dictionary <string, string> girlsTeams = new Dictionary <string, string>();
                    girlsTeams.Add(girlsTeam1Abbr, girlsTeam1Name);
                    if (!string.IsNullOrWhiteSpace(girlsTeam2Abbr))
                    {
                        girlsTeams.Add(girlsTeam2Abbr, girlsTeam2Name);
                    }
                    if (!string.IsNullOrWhiteSpace(girlsTeam3Abbr))
                    {
                        girlsTeams.Add(girlsTeam3Abbr, girlsTeam3Name);
                    }
                    if (!string.IsNullOrWhiteSpace(girlsTeam4Abbr))
                    {
                        girlsTeams.Add(girlsTeam4Abbr, girlsTeam4Name);
                    }
                    if (!string.IsNullOrWhiteSpace(girlsTeam5Abbr))
                    {
                        girlsTeams.Add(girlsTeam5Abbr, girlsTeam5Name);
                    }
                    if (!string.IsNullOrWhiteSpace(girlsTeam6Abbr))
                    {
                        girlsTeams.Add(girlsTeam6Abbr, girlsTeam6Name);
                    }

                    Teams newTeams = new Teams(boysTeams, girlsTeams);

                    Meet newMeet = new Meet(meetDateTime, meetLocation, meetWeather, newTeams);

                    if (newMeet.validate())
                    {
                        MessageBox.Show("Meet created successfully");
                        //Switch forms
                        //MeetHub(newMeet);
                        MeetHub newForm = new MeetHub(newMeet);
                        this.Hide();
                        newForm.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Unknown problem creating this meet. Data was invaalid.");
                    }
                }
            }
        }
示例#3
0
        public void TestValidateMethod()
        {
            Console.WriteLine("Inside " + GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            bool test = true;

            Performance myPerformance1 = new Performance("A", "AA", 1.1m);
            Performance myPerformance2 = new Performance("B", "BB", 2.2m);
            Performance myPerformance3 = new Performance("C", "CC", 3.3m);
            Performance myPerformance4 = new Performance("D", "DD", 4.1m);
            Performance myPerformance5 = new Performance("", "DD", 4.1m);

            List <Performance> myPerformancesA = new List <Performance>();

            myPerformancesA.Add(myPerformance1);
            myPerformancesA.Add(myPerformance2);

            List <Performance> myPerformancesB = new List <Performance>();

            myPerformancesB.Add(myPerformance3);
            myPerformancesB.Add(myPerformance4);

            List <Performance> myPerformancesC = new List <Performance>();

            myPerformancesC.Add(myPerformance5);

            //Events
            Dictionary <string, List <Performance> > myEventsA = new Dictionary <string, List <Performance> >();

            myEventsA.Add("Boy's 100", myPerformancesA);
            myEventsA.Add("Boy's 200", myPerformancesB);

            Dictionary <string, List <Performance> > myEventsB = new Dictionary <string, List <Performance> >();

            myEventsB.Add("Boy's 100", myPerformancesA);
            myEventsB.Add("Boy's 200", myPerformancesB);
            myEventsB.Add("Boy's 400", myPerformancesC);

            Dictionary <string, List <Performance> > myEventsC = new Dictionary <string, List <Performance> >();

            myEventsC.Add("Boy's 100", myPerformancesA);
            myEventsC.Add("200", myPerformancesB);

            //Team Names
            Dictionary <string, string> boysNamesA = new Dictionary <string, string>();

            boysNamesA.Add("BLN", "Baldwin");
            boysNamesA.Add("TJ", "Thomas Jefferson");
            boysNamesA.Add("WHS", "Washington HS");

            Dictionary <string, string> dupBoysNames = new Dictionary <string, string>();

            dupBoysNames.Add("BLN", "Baldwin");
            dupBoysNames.Add("TJ", "Thomas Jefferson");
            dupBoysNames.Add("BLD", "Baldwin");

            Dictionary <string, string> boysNamesC = new Dictionary <string, string>();

            boysNamesC.Add("BLN", "Baldwin");
            boysNamesC.Add("TJ", "Thomas Jefferson");
            boysNamesC.Add("", "Washinton HS");

            Dictionary <string, string> girlsNamesA = new Dictionary <string, string>();

            girlsNamesA.Add("PLM", "Plum");
            girlsNamesA.Add("GWY", "Gateway");
            girlsNamesA.Add("KCH", "Knoch");

            Dictionary <string, string> dupGirlsNames = new Dictionary <string, string>();

            dupGirlsNames.Add("PLM", "Plum");
            dupGirlsNames.Add("GWY", "Gateway");
            dupGirlsNames.Add("PM", "Plum");

            Dictionary <string, string> girlsNamesC = new Dictionary <string, string>();

            girlsNamesC.Add("PLM", "Plum");
            girlsNamesC.Add("GWY", "Gateway");
            girlsNamesC.Add("KCH", "");

            Dictionary <string, string> overAbbr = new Dictionary <string, string>();

            overAbbr.Add("PLM", "Plum");
            overAbbr.Add("GATE", "Gateway");
            overAbbr.Add("KCH", "Kiski");

            Teams teams1 = new Teams(boysNamesA, girlsNamesA);
            Teams teams2 = new Teams(dupBoysNames, girlsNamesA);
            Teams teams3 = new Teams(boysNamesC, girlsNamesA);
            Teams teams4 = new Teams(boysNamesA, girlsNamesC);
            Teams teams5 = new Teams(boysNamesA, dupGirlsNames);
            Teams teams6 = new Teams(overAbbr, girlsNamesA);
            Teams teams7 = new Teams(boysNamesA, overAbbr);

            Meet validMeet          = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams1, myEventsA);
            Meet validNoEventsMeet  = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams1);
            Meet invalidDateTime    = new Meet(DateTime.MinValue, "Baldwin HS", "Windy", teams1, myEventsA);
            Meet invalidLocation1   = new Meet(new DateTime(2017, 04, 13), null, "Windy", teams1, myEventsA);
            Meet invalidWeather1    = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", null, teams1, myEventsA);
            Meet invalidLocation2   = new Meet(new DateTime(2017, 04, 13), "", "Windy", teams1, myEventsA);
            Meet invalidWeather2    = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "", teams1, myEventsA);
            Meet dupBoysNameMeet    = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams2, myEventsA);
            Meet dupGirlsNameMeet   = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams5, myEventsA);
            Meet overBoysAbbrMeet   = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams6, myEventsA);
            Meet overGirlsAbbrMeet  = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams7, myEventsA);
            Meet invalidBoysName    = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams3, myEventsA);
            Meet invalidGirlsName   = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams4, myEventsA);
            Meet invalidPerformance = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams1, myEventsB);
            Meet invalidEventName   = new Meet(new DateTime(2017, 04, 13), "Baldwin HS", "Windy", teams1, myEventsC);

            if (!validMeet.validate())
            {
                test = false;
                Console.WriteLine("validMeet failed");
            }
            if (!validNoEventsMeet.validate())
            {
                test = false;
                Console.WriteLine("validNoEventsMeet failed");
            }
            if (invalidDateTime.validate())
            {
                test = false;
                Console.WriteLine("invalidDateTime was valid");
            }
            if (invalidLocation1.validate())
            {
                test = false;
                Console.WriteLine("invalidLocation1 was valid");
            }
            if (invalidLocation2.validate())
            {
                test = false;
                Console.WriteLine("invalidLocation2 was valid");
            }
            if (invalidWeather1.validate())
            {
                test = false;
                Console.WriteLine("invalidWeather1 was valid");
            }
            if (invalidWeather2.validate())
            {
                test = false;
                Console.WriteLine("invalidWeather2 was valid");
            }
            if (dupBoysNameMeet.validate())
            {
                test = false;
                Console.WriteLine("dupBoysNameMeet was valid");
            }
            if (dupGirlsNameMeet.validate())
            {
                test = false;
                Console.WriteLine("dupGirlsNameMeet was valid");
            }
            if (overBoysAbbrMeet.validate())
            {
                test = false;
                Console.WriteLine("overBoysAbbrMeet was valid");
            }
            if (overGirlsAbbrMeet.validate())
            {
                test = false;
                Console.WriteLine("overGirlsAbbrMeet was valid");
            }
            if (invalidBoysName.validate())
            {
                test = false;
                Console.WriteLine("invalidBoysName was valid");
            }
            if (invalidGirlsName.validate())
            {
                test = false;
                Console.WriteLine("invalidGirlsName was valid");
            }
            if (invalidPerformance.validate())
            {
                test = false;
                Console.WriteLine("invalidPerformance was valid");
            }
            if (invalidEventName.validate())
            {
                test = false;
                Console.WriteLine("invalidEventName was valid");
            }
            else
            {
                Console.WriteLine("TestValidateMethod Passed!");
            }

            Assert.True(test, GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Failed");
            Console.WriteLine(GetType().Name + " - " + System.Reflection.MethodBase.GetCurrentMethod().Name + " Passed");
        }