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; } }
//---------------------------------------------------------------------- #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(); }
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; }
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; }
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); }
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; } }
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; } } }
//---------------------------------------------------------------------- #endregion //---------------------------------------------------------------------- //---------------------------------------------------------------------- #region public functions //---------------------------------------------------------------------- public override void execCmd(Connection db) { ArrTeams = new List <Team>(); ArrTeams = TeamsDB.getAllTeams(db); }
private void UpdateListPilotsTeams() { gdvPilotsTeam.ItemsSource = TeamsDB.getPilots(Team.Id); updateListTeamAndPilotsUnasignedTeam(); activeButtonAssignedPilot(); }
private void updateListTeamAndPilotsUnasignedTeam() { lsvTeams.ItemsSource = TeamsDB.getTeams(); gdvPilotsUnasignedTeam.ItemsSource = PilotDB.getPilotsUnasignedTeam(); }