示例#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));
        }
 private void detach_RaceResults(RaceResult entity)
 {
     this.SendPropertyChanging();
     entity.Race = null;
 }
 private void attach_RaceResults(RaceResult entity)
 {
     this.SendPropertyChanging();
     entity.Race = this;
 }
 partial void DeleteRaceResult(RaceResult instance);
 partial void UpdateRaceResult(RaceResult instance);
 partial void InsertRaceResult(RaceResult instance);