Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                _fleetSeriesDateRace = (List <FleetSeriesDateRace>)ViewState["_FleetSeriesDateRace"]; // Load state
            }
            else
            {
                _fleetSeriesDateRace = new List <FleetSeriesDateRace>(); // allocate memory

                // Set the values via the IsCrossPagePostBack because the PreviousPage values won't be available after a PostBack here.
                hiddenSeasonID.Value = PreviousPage.SelectedSeason;
                labelSeason.Text     = CentralLibrary.GetSeason(SelectedSeason);

                if (PreviousPage.SelectedDate.Trim().Length > 0)
                {
                    UpdateDate(PreviousPage.SelectedDate);
                }
                else
                {
                    UpdateDate(CentralLibrary.GetCurrentDateTime());
                }

                CentralLibrary.GetFleets(listFleet);                                           // Get the fleets
                CentralLibrary.GetFleetSeries(listFleetSeries, SelectedFleet, SelectedSeason); // After getting the fleets, get the series for the selected fleet

                CentralLibrary.GetTimes(listRace);

                panelSchedule.Visible    = false;
                labelErrorSeries.Visible = false;
                labelErrorSave.Visible   = false;
                buttonRemove.Enabled     = false;
            }
        }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         return;
     }
     CentralLibrary.GetFleets(listFleet);
     ShowSummary(false);
 }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                _fleetSeriesRace = (List <FleetSeriesRace>)ViewState["_FleetSeriesRace"]; // Load state
            }
            else
            {
                _fleetSeriesRace = new List <FleetSeriesRace>(); // allocate memory

                // Set the values via the IsCrossPagePostBack because the PreviousPage values won't be available after a PostBack here.
                hiddenSeasonID.Value = PreviousPage.SelectedSeason;

                hiddenRaceID.Value = Request[Constant.GetVar.RaceId];

                CentralLibrary.GetTimes(listRace);
                CentralLibrary.GetFleets(listFleet);
                CentralLibrary.GetFleetSeries(listFleetSeries, Convert.ToInt32(listFleet.SelectedValue), SelectedSeason);
                FindNextRaceNumber();

                labelScored.Visible = false;

                if (IsNewRace) // Creating a new race entry
                {
                    linkDeleteRace.Visible = false;

                    if (PreviousPage.SelectedDate.Trim().Length > 0)
                    {
                        UpdateDate(PreviousPage.SelectedDate);
                    }
                    else
                    {
                        UpdateDate(CentralLibrary.GetCurrentDateTime());
                    }
                }
                else // Editing an existing race entry
                {
                    var ctx = new SailTallyDataContext();

                    // Get the data
                    var race = (from r in ctx.SS_Races
                                where r.RaceID == SelectedRace
                                select r).Single();
                    var raceSerys = from rs in ctx.SS_RaceSeries
                                    join fs in ctx.SS_FleetSeries on rs.FleetSeriesID equals fs.FleetSeriesID
                                    join f in ctx.SS_Fleets on fs.FleetID equals f.FleetID
                                    join s in ctx.SS_Series on fs.SeriesID equals s.SeriesID
                                    where rs.RaceID == SelectedRace
                                    select new { rs.RaceSeriesID, rs.RaceNumber, fs.FleetSeriesID, f.FleetID, f.FleetName, s.SeriesID, s.SeriesName };

                    // Put the data to the controls
                    UpdateDate(race.FirstWarningDate, CentralLibrary.FormatTime(race.FirstWarningDate));

                    foreach (var raceSeries in raceSerys)
                    {
                        var fsr = new FleetSeriesRace()
                        {
                            FleetId       = raceSeries.FleetID,
                            FleetSeriesId = raceSeries.FleetSeriesID,
                            RaceNo        = raceSeries.RaceNumber,
                            RaceSeriesId  = raceSeries.RaceSeriesID,
                            FleetName     = raceSeries.FleetName,
                            SeriesName    = raceSeries.SeriesName
                        };
                        _fleetSeriesRace.Add(fsr);

                        var item        = new ListItem();
                        var fleetSeries = fsr.Display(); //raceSeries.FleetName.Trim() + " / " + raceSeries.SeriesName.Trim() + " / " + raceSeries.RaceNumber.ToString();
                        item.Text  = fleetSeries;
                        item.Value = fleetSeries;
                        listSelectedFleetSeries.Items.Add(item);
                    }

                    // Determine if there are any races scored (if so, disable editing since don't want to create a new RaceID)
                    var scores = from s in ctx.SS_Scores
                                 where s.RaceID == SelectedRace
                                 select s;

                    var raceFleets = from rf in ctx.SS_RaceFleets
                                     where rf.RaceID == SelectedRace
                                     select rf;

                    if (!scores.Any() && !raceFleets.Any())
                    {
                        return;
                    }

                    labelScored.Visible = true;
                    hiddenScored.Value  = "1";

                    calendarRace.Enabled            = false;
                    listRace.Enabled                = false;
                    listSelectedFleetSeries.Enabled = false;
                    buttonRemoveFleetSeries.Enabled = false;
                    linkDeleteRace.Enabled          = false;

                    // Note: Now allow race series insertion (Fleet/Series/RaceNo can be added even if previous scored)
                    //this.listFleet.Enabled = false;
                    //this.listFleetSeries.Enabled = false;
                    //this.textRaceNo.Enabled = false;
                    //this.buttonAddFleetSeries.Enabled = false;
                    //this.linkSave.Enabled = false;
                }
            }
        }