Esempio n. 1
0
        public override void LoadData()
        {
            CheckManager();
            using (databaseContext = CreateDatabaseContext())
            {
                GiocatoriManager playerManager = new GiocatoriManager(databaseContext);
                grdGiocatori.DataSource = playerManager.GetPagedPlayers(startPage, pageSize);

            }
        }
Esempio n. 2
0
 public InsertGiocatore(long NumeroSW)
     : this()
 {
     originalPlayer = NumeroSW;
     using (databaseContext = CreateDatabaseContext())
     {
         GiocatoriManager manager = new GiocatoriManager(databaseContext);
         Giocatore giocatore = manager.GetPlayerFromNumberSW(originalPlayer.Value);
         txtCAP.Text = giocatore.CAP;
         txtCitta.Text = giocatore.Citta;
         txtCognome.Text = giocatore.Cognome;
         txtEmail.Text = giocatore.Email;
         txtIndirizzo.Text = giocatore.Indirizzo;
         txtNome.Text = giocatore.Nome;
         txtPassword.Text = giocatore.Password;
         txtProvincia.Text = giocatore.Provincia;
         txtTelefono.Text = giocatore.Telefono;
         dtIscrizione.Value = giocatore.DataIscrizione;
         dtNascita.Value = giocatore.DataNascita;
         cmbSesso.SelectedValue = giocatore.Sesso;
         cmbTipoGiocatore.SelectedValue = giocatore.TipoGiocatore;
     }
 }
Esempio n. 3
0
        private void btnSalva_Click(object sender, EventArgs e)
        {
            if (validateForm())
            {
                using (databaseContext = CreateDatabaseContext())
                {
                    GiocatoriManager manager = new GiocatoriManager(databaseContext);
                    DateTime dataIscrizione = dtIscrizione.Value.Date;
                    DateTime dataNascita = dtNascita.Value.Date;

                    bool res = manager.SavePlayer(originalPlayer, txtCognome.Text.Trim(), txtNome.Text.Trim(), dataNascita, txtIndirizzo.Text.Trim(), txtCitta.Text.Trim(), txtProvincia.Text.Trim(), txtCAP.Text.Trim(), txtTelefono.Text.Trim(), dataIscrizione, cmbSesso.SelectedItem.ToString(), cmbTipoGiocatore.SelectedItem.ToString(), txtEmail.Text.Trim(), txtPassword.Text.Trim());

                    if (res)
                    {
                        databaseContext.SaveChanges();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Errore durante il salvataggio, ricontrollare i dati inseriti");
                    }
                }
            }
        }
Esempio n. 4
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtSearch.Text))
            {
                long? numberToSearch = null;
                try
                {
                    numberToSearch = long.Parse(txtSearch.Text.Trim());
                }
                catch
                {
                    numberToSearch = null;
                }

                using (databaseContext = CreateDatabaseContext())
                {
                    GiocatoriManager playerManager = new GiocatoriManager(databaseContext);
                    PersonaggiManagerNew characterManager = new PersonaggiManagerNew(databaseContext);

                    if (numberToSearch.HasValue)
                    {
                        List<Giocatore> firstSource = new List<Giocatore>();
                        List<Personaggio> secondSource = new List<Personaggio>();
                        firstSource.Add(playerManager.GetPlayerFromNumberSW(numberToSearch.Value));
                        secondSource.Add(characterManager.GetCharacterByNumber(numberToSearch.Value));
                        grdGiocatori.DataSource = firstSource;
                        grdPersonaggi.DataSource = secondSource;
                    }
                    else
                    {
                        grdGiocatori.DataSource = playerManager.GetPlayerByName(txtSearch.Text.Trim());
                        grdPersonaggi.DataSource = characterManager.GetCharactersByName(txtSearch.Text.Trim());
                    }
                }
            }
            else
            {
                LoadData();
            }
        }
Esempio n. 5
0
 private void lnkNext_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (databaseContext = CreateDatabaseContext())
     {
         GiocatoriManager manager = new GiocatoriManager(databaseContext);
         int max = manager.Count();
         startPage += 50;
         if (startPage >= max)
         {
             startPage = max - 50;
             if (startPage < 0)
             {
                 startPage = 0;
             }
         }
     }
     LoadData();
 }
Esempio n. 6
0
        private void LoadData()
        {
            using (databaseContext = CreateDatabaseContext())
            {
                EventiManagerNew eventManager = new EventiManagerNew(databaseContext);
                Evento myEvent = eventManager.GetEventFromNumber(cdEvento);
                txtNomeEvento.Text = myEvent.TitoloEvento;

                grdGiorni.DataSource = myEvent.EventoGiornis;

                GiocatoriManager manager = new GiocatoriManager(databaseContext);
                IList<Giocatore> source = manager.GetAllPlayers();
                cmbGiocatore.DataSource = source;
            }
        }