Example #1
0
        private string SetPosition(int raceID)
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                var     RaceResults = Data.RaceResults.Where(Results => Results.RaceID == raceID);
                Boolean match       = true;

                for (int i = 1; i <= 22; i++)
                {
                    match = false;

                    foreach (RaceResult result in RaceResults)
                    {
                        if (result.FinalPosition.Trim() == string.Format("{0}", i))
                        {
                            match = true;
                            break;
                        }
                    }

                    if (!match)
                    {
                        return(string.Format("{0}", i));
                    }
                }
            }

            return(null);
        }
Example #2
0
        private void addResult()
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                var allResults = Data.RaceResults.Where(RaceResult => RaceResult.RaceID == Int32.Parse(RaceTitleDpd.SelectedValue));

                foreach (RaceResult result in allResults)
                {
                    if (result.FinalPosition.Trim() == PositionTxt.Text || result.DriverID == Int32.Parse(DriverCbx.SelectedValue))
                    {
                        return;
                    }
                }

                RaceResult raceResult = new RaceResult();

                raceResult.RaceID        = Int32.Parse(RaceTitleDpd.SelectedValue);
                raceResult.DriverID      = Int32.Parse(DriverCbx.SelectedValue);
                raceResult.TeamID        = Int32.Parse(TeamCbx.SelectedValue);
                raceResult.FinalPosition = PositionTxt.Text;
                raceResult.RaceTime      = TimeSpan.FromHours(Int32.Parse(HourTxt.Text))
                                           + TimeSpan.FromMinutes(Int32.Parse(MinuteTxt.Text))
                                           + TimeSpan.FromSeconds(Int32.Parse(SecondTxt.Text));

                Data.RaceResults.InsertOnSubmit(raceResult);
                Data.SubmitChanges();
                GridViewRaceResult.DataBind();
            }

            getRaceResults(Int32.Parse(RaceTitleDpd.SelectedValue));
        }
        private void addNewCircuit()
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                Circuit circuit = new Circuit();

                circuit.CircuitName = TextBox1.Text;

                Data.Circuits.InsertOnSubmit(circuit);
                Data.SubmitChanges();

                Response.Redirect("~/AddCircuit");
            }
        }
Example #4
0
        private void getRaceResults(int raceID)
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                var race = Data.Races.Single(Race => Race.RaceID == raceID);

                RaceTitleDpd.SelectedValue = string.Format("{0}", race.RaceID);

                RaceTitleLbl.Text = race.RaceName;

                GridViewRaceResult.DataBind();

                PositionTxt.Text = SetPosition(race.RaceID);
            }
        }
Example #5
0
        private void addNewRace()
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                Race race = new Race();

                race.RaceName  = RaceNameTxt.Text;
                race.CircuitID = Int32.Parse(CircuitDpd.SelectedValue);

                Data.Races.InsertOnSubmit(race);
                Data.SubmitChanges();

                Response.Redirect("~/AddRace");
            }
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int raceID = Int32.Parse(SqlDataSource1.SelectParameters["param1"].DefaultValue);

            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                if (!IsPostBack)
                {
                    var race = Data.Races.Single(Race => Race.RaceID == raceID);

                    RaceTitleLbl.Text          = race.RaceName;
                    RaceTitleDpd.SelectedValue = String.Format("{0}", raceID);
                    PositionTxt.Text           = SetPosition(raceID);
                }
            }
        }
Example #7
0
        private void addNewDriver()
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                Driver driver = new Driver();

                driver.FirstName  = FirstNameTxt.Text;
                driver.SecondName = SecondNameTxt.Text;
                driver.TeamID     = Int32.Parse(DropDownTeams.SelectedValue);

                Data.Drivers.InsertOnSubmit(driver);
                Data.SubmitChanges();

                Response.Redirect("~/AddDriver");
            }
        }
Example #8
0
        protected void addTeamBtn_Click(object sender, EventArgs e)
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                Team team = new Team();

                team.TeamName    = TeamNameTxt.Text;
                team.Constructor = ConstructorTxt.Text;
                team.Chassis     = ChassisTxt.Text;
                team.Engine      = EngineTxt.Text;

                Data.Teams.InsertOnSubmit(team);
                Data.SubmitChanges();

                Response.Redirect("~/AddTeam");
            }
        }
Example #9
0
        private void getTeamDetails()
        {
            using (FormulaOneDataContext Data = new FormulaOneDataContext())
            {
                Team team = Data.Teams.Single(Team => Team.TeamID == 3);

                teamNameLbl.Text = team.TeamName;

                // select the 2 drivers of that team
                var Drivers = Data.Drivers.Where(Driver => Driver.TeamID == team.TeamID);

                List <string> teamMembers = new List <string>();

                foreach (Driver driver in Drivers)
                {
                    teamMembers.Add(driver.FirstName + " " + driver.SecondName);
                }

                driver1Lbl.Text = teamMembers[0];
                driver2Lbl.Text = teamMembers[1];
            }
        }