Beispiel #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Button btnDelete       = (Button)sender;
            string stationnrString = btnDelete.Name.Replace("DeleteStation", "");

            Structs.Station station = CommonCode.GetStation(int.Parse(stationnrString),
                                                            chkDistiguish.Checked);
            DialogResult res =
                MessageBox.Show("Är du säker på att du vill radera station " +
                                station.StationNr.ToString() + "?",
                                "Bekräfta radering",
                                MessageBoxButtons.YesNo);

            try
            {
                if (res == DialogResult.Yes)
                {
                    Trace.WriteLine("FStationsField: Deleting station " +
                                    station.StationNr.ToString());
                    CommonCode.DelStation(station);
                    checkStationsNumbers();
                }
            }
            catch (ApplicationException exc)
            {
                if (exc.Message.IndexOf("CompetitorResults") > -1)
                {
                    Trace.WriteLine(
                        "FStationsField: Failed to delete station since there is results for this station." +
                        "Asking user what to do.");

                    res =
                        MessageBox.Show("Det finns inmatade resultat för denna station. " +
                                        "Är du verkligen säker på att du vill radera station " +
                                        station.StationNr.ToString() + "?",
                                        "Bekräfta radering",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button2);
                    if (res == DialogResult.Yes)
                    {
                        Trace.WriteLine("FStationsField: Deleting results and station " +
                                        station.StationNr.ToString());
                        CommonCode.DelStation(station, true);
                        checkStationsNumbers();
                    }
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        private void numDdStationsTot_ValueChanged()
        {
            Trace.WriteLine("FStations: numDdStationsTot_ValueChanged on thread \"" +
                            Thread.CurrentThread.Name + "\" ( " +
                            AppDomain.GetCurrentThreadId().ToString() + " )");

            // Check if a stations is to be removed
            if ((int)this.numDdStationsTot.Value < this.totalNumberOfStations)
            {
                foreach (Structs.Station station in stationList)
                {
                    if (station.StationNr == this.totalNumberOfStations)
                    {
                        // Check if they're sure
                        DialogResult res =
                            MessageBox.Show("Är du säker? Detta kommer att " +
                                            "radera station nr " +
                                            this.totalNumberOfStations.ToString() +
                                            ".",
                                            "Konfirmera radering",
                                            MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question);
                        if (res == DialogResult.No)
                        {
                            this.numDdStationsTot.Value =
                                this.totalNumberOfStations;
                            return;
                        }
                        // Set current station to 1
                        this.vScrollBar1.Value = 1;
                        this.setCurrentStation(1);

                        // Delete station
                        CommonCode.DelStation(station);
                    }
                }
            }
            // Update all maximum
            totalNumberOfStations     = (int)numDdStationsTot.Value;
            progressBarKonfig.Maximum = totalNumberOfStations;
            this.vScrollBar1.Maximum  = totalNumberOfStations;

            Trace.WriteLine("FStations: numDdStationsTot_ValueChanged ended.");
        }
Beispiel #3
0
        private void saveCurrent()
        {
            int nrOfStations         = (int)numNrOfSeries.Value;
            int nrOfShootsPerStation = (int)numNrOfShootPerSeries.Value;

            int shoots  = 0;
            int figures = 0;

            switch (chkUseOnlyOneBoxForResult.Checked)
            {
            case true:
                figures = 1;
                shoots  = 10 * nrOfShootsPerStation;
                break;

            case false:
                figures = nrOfShootsPerStation;
                shoots  = 10 * nrOfShootsPerStation;
                break;
            }
            for (int i = 1; i <= CommonCode.GetStationsCount(); i++)
            {
                Structs.Station station = CommonCode.GetStation(i, false);
                station.Figures = figures;
                station.Shoots  = shoots;
                CommonCode.UpdateStation(station);
            }

            while (CommonCode.GetStationsCount() < nrOfStations)
            {
                Structs.Station station = new Structs.Station();
                station.CompetitionId = CommonCode.GetCompetitions()[0].CompetitionId;
                station.Figures       = figures;
                station.Points        = false;
                station.Shoots        = shoots;
                station.StationNr     = CommonCode.GetStationsCount() + 1;
                CommonCode.NewStation(station, false);
            }
            while (CommonCode.GetStationsCount() > nrOfStations)
            {
                Structs.Station station = CommonCode.GetStation(CommonCode.GetStationsCount(), false);
                CommonCode.DelStation(station);
            }

            Structs.Competition competition = CommonCode.GetCompetitions()[0];
            int timeAvailable = competition.PatrolTimeBetween;
            int timeNeeded    = calculateTimeRequirements();

            if (timeNeeded > timeAvailable)
            {
                DialogResult res = MessageBox.Show("Du har avsatt " + timeAvailable.ToString() +
                                                   " minuter för varje skjutlag.\r\n\r\n" +
                                                   "Beräknad tid för varje skjutlag med hänsyn taget till " +
                                                   "skjuttid (6 minuter per serie) och markeringstid " +
                                                   "(6 minuter per serie) är " +
                                                   timeNeeded.ToString() + " minuter.\r\n\r\n" +
                                                   "Vill du öka upp avsatt tid?",
                                                   "Kontrollberäkning",
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Warning);
                if (res == DialogResult.Yes)
                {
                    competition.PatrolTimeBetween = timeNeeded;
                    CommonCode.UpdateCompetition(competition);
                    DateTime         patrolStart = competition.StartTime;
                    Structs.Patrol[] patrols     = CommonCode.GetPatrols();
                    for (int i = 0; i < patrols.Length; i++)
                    {
                        Structs.Patrol patrol = patrols[i];

                        //Trace.WriteLine(patrol.StartDateTimeDisplay.ToShortTimeString());
                        patrol.StartDateTime        = patrolStart;
                        patrol.StartDateTimeDisplay = patrolStart;
                        CommonCode.UpdatePatrol(patrol);

                        patrolStart = patrolStart.AddMinutes(timeNeeded);
                    }
                }
            }
        }