コード例 #1
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     lsvTeams.ItemsSource   = TeamsDB.getTeams();
     lsvTeams.SelectedIndex = 0;
     if (CircuitDB.getClosedRaces() > 0)
     {
         EstatForm = Estat.CURSA_TANCADA;
     }
     else
     {
         EstatForm = Estat.SENSE_CANVIS;
     }
 }
コード例 #2
0
        //----------------------------------------------------------------------
        #endregion
        //----------------------------------------------------------------------

        //----------------------------------------------------------------------
        #region public functions
        //----------------------------------------------------------------------
        public override void execCmd(Connection db)
        {
            Match = new Match();

            home    = TeamsDB.getTeam(db, _idTeamHome);
            visitor = TeamsDB.getTeam(db, _idTeamVisitor);

            Match.Home    = home;
            Match.Visitor = visitor;

            makeMatchScore();
            checkTheWinner();
        }
コード例 #3
0
 private void crearTeamViewModel(TeamsDB equip)
 {
     if (equip != null)
     {
         Team = new TeamViewModel(equip);
         gdvPilotsTeam.ItemsSource = TeamsDB.getPilots(Team.Id);
         activeButtonAssignedPilot();
     }
     else
     {
         Team = new TeamViewModel();
         gdvPilotsTeam.ItemsSource = null;
     }
     Team.PropertyChanged += Team_PropertyChanged;
 }
コード例 #4
0
 public TeamViewModel(TeamsDB team)
 {
     this.Pos                = team.Pos;
     this.Id                 = team.Id;
     this.TeamName           = team.TeamName;
     this.FullName           = team.FullName;
     this.TeamChief          = team.TeamChief;
     this.Chassis            = team.Chassis;
     this.PowerUnit          = team.PowerUnit;
     this.FirstTeamEntry     = team.FirstTeamEntry;
     this.WorldChampionships = team.WorldChampionships;
     this.FastestLaps        = team.FastestLaps;
     this.Description        = team.Description;
     this.UriLogo            = team.UriLogo;
     this.UriCar             = team.UriCar;
     this.Punctuation        = team.Punctuation;
     this.Pilots             = team.Pilots;
 }
コード例 #5
0
        private Boolean activeButtonAssignedPilot()
        {
            int  numPilots = TeamsDB.getNumPilots(Team.Id);
            bool actiu     = false;

            if (numPilots < 2)
            {
                if (EstatForm != Estat.NO_SELECCIONAT)
                {
                    actiu = true;
                }
            }
            else
            {
                actiu = false;
            }
            btnAssignedPilot.IsEnabled = actiu;
            return(btnAssignedPilot.IsEnabled);
        }
コード例 #6
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (validarDadesFormulari())
            {
                if (EstatForm == Estat.MODIFICAT)
                {
                    //Estat.MODIFICAT
                    TeamsDB teamDB = (TeamsDB)lsvTeams.SelectedItem;
                    if (teamDB != null)
                    {
                        teamDB.TeamName           = Team.TeamName;
                        teamDB.FullName           = Team.FullName;
                        teamDB.TeamChief          = Team.TeamChief;
                        teamDB.Chassis            = Team.Chassis;
                        teamDB.PowerUnit          = Team.PowerUnit;
                        teamDB.FirstTeamEntry     = Team.FirstTeamEntry;
                        teamDB.WorldChampionships = Team.WorldChampionships;
                        teamDB.FastestLaps        = Team.FastestLaps;
                        teamDB.Description        = Team.Description;
                        teamDB.UriLogo            = Team.UriLogo;
                        teamDB.UriCar             = Team.UriCar;

                        teamDB.Update();
                        updateListTeamAndPilotsUnasignedTeam();
                        lsvTeams.SelectedIndex = Team.Pos - 1;
                    }
                }
                else if (EstatForm == Estat.NOU)
                {
                    //Estat.NOU
                    TeamsDB teamDB = new TeamsDB(-1, Team.TeamName, Team.TeamName, Team.TeamChief, Team.Chassis,
                                                 Team.PowerUnit, Team.FirstTeamEntry, Team.WorldChampionships, Team.FastestLaps,
                                                 Team.Description, Team.UriLogo, Team.UriCar);
                    teamDB.Insert();
                    updateListTeamAndPilotsUnasignedTeam();
                    lsvTeams.SelectedIndex = lsvTeams.Items.Count - 1;
                }
                EstatForm = Estat.SENSE_CANVIS;
            }
        }
コード例 #7
0
        private async void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (lsvTeams.SelectedItem != null)
            {
                TeamsDB t       = (TeamsDB)lsvTeams.SelectedItem;
                Boolean esborra = false;
                if (PilotDB.getPilotsTeam(t.Id).Count > 0)
                {
                    ContentDialog deleteTeamDialog = new ContentDialog
                    {
                        Title             = "Equip amb pilots",
                        Content           = "Vols esborrar l'equip i deixar als pilots sense equip?",
                        PrimaryButtonText = "Esborrar",
                        CloseButtonText   = "Cancel·lar"
                    };

                    ContentDialogResult result = await deleteTeamDialog.ShowAsync();

                    if (result == ContentDialogResult.Primary)
                    {
                        esborra = true;
                    }
                }
                else
                {
                    esborra = true;
                }
                if (esborra)
                {
                    t.Delete();
                    crearTeamViewModel(null);
                    updateListTeamAndPilotsUnasignedTeam();
                    EstatForm = Estat.NO_SELECCIONAT;
                }
            }
        }
コード例 #8
0
        //----------------------------------------------------------------------
        #endregion
        //----------------------------------------------------------------------

        //----------------------------------------------------------------------
        #region public functions
        //----------------------------------------------------------------------
        public override void execCmd(Connection db)
        {
            ArrTeams = new List <Team>();

            ArrTeams = TeamsDB.getAllTeams(db);
        }
コード例 #9
0
 private void UpdateListPilotsTeams()
 {
     gdvPilotsTeam.ItemsSource = TeamsDB.getPilots(Team.Id);
     updateListTeamAndPilotsUnasignedTeam();
     activeButtonAssignedPilot();
 }
コード例 #10
0
 private void updateListTeamAndPilotsUnasignedTeam()
 {
     lsvTeams.ItemsSource = TeamsDB.getTeams();
     gdvPilotsUnasignedTeam.ItemsSource = PilotDB.getPilotsUnasignedTeam();
 }