Esempio n. 1
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));
        }
Esempio n. 2
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);
            }
        }