Esempio n. 1
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. 2
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();
            }
        }