static void Main(string[] args) { CentroResidenziale centroResidenziale = new CentroResidenziale(); Mensa mensaIngegneria = new Mensa("Mensa Ingegneria"); Persona persona = new Studente("Domenico", "Cavallaro"); persona.CodiceFiscale = "MMCVLR"; persona.RedditoFamiliare = 20000; Persona persona2 = new Studente("Angelo", "Rossi"); persona2.RedditoFamiliare = 7850; Studente studente = centroResidenziale.ImmatricolaStudente(persona); Studente studente2 = centroResidenziale.ImmatricolaStudente(persona2); mensaIngegneria.ErogaPasto(studente.Tesserino); mensaIngegneria.ErogaPasto(studente2.Tesserino); mensaIngegneria.StampaTesseriniUtilizzati(); double prezzoMedio = mensaIngegneria.PrezzoMedioDeiPastiErogati(); Console.WriteLine($"Prezzo medio pasti erogati: {prezzoMedio}"); }
private void EliminaStudente(object sender, RoutedEventArgs e) { Studente studente = (Studente)lbxStudenti.SelectedItem; studente.Elimina(); lbxStudenti.Items.Refresh(); }
static void Main(string[] args) { Scuola scuola = new Scuola("RosselliRasetti"); Classe c = scuola.CreaClasse(4, "AI"); Studente s1 = new Studente("Alessio", "Manieri"); Studente s2 = new Studente("Filippo", "Pepe"); Materia m1 = scuola.CreaMateria("Informatica"); Materia m2 = scuola.CreaMateria("Italiano"); Materia m3 = scuola.CreaMateria("Matematica"); Materia m4 = scuola.CreaMateria("Religione"); Votazione v1 = new Votazione(m1, s1, 8); Votazione v2 = new Votazione(m3, s1, 9); Votazione v3 = new Votazione(m2, s1, 6); Votazione v4 = new Votazione(m4, s1, 3); s1.AddVoto(v1); s1.AddVoto(v3); s2.AddVoto(v2); s2.AddVoto(v4); c.AddStudente(s1); c.AddStudente(s1); Console.WriteLine(s1.TrovaVotoMassimo()); }
static void Main(string[] args) { StreamReader sr = new StreamReader(@"ElencoStudenti.txt"); Studente[] vettS = new Studente[25]; int i; string strC; for (i = 0; i < vettS.Length; i++) { strC = sr.ReadLine(); vettS[i] = new Studente(strC, 0); } sr.Close(); vettS[1].InserisciAssenza(); vettS[2].InserisciAssenza(); vettS[2].InserisciAssenza(); vettS[0].InserisciVoto(30, 0); vettS[0].InserisciVoto(25, 1); Random n = new Random(); for (i = 0; i < vettS.Length; i++) vettS[i].InserisciVoto(n.Next(1, 30), i); for (i = 0; i < vettS.Length; i++) vettS[i].CalcolaMedia(); foreach(Studente s in vettS) Console.WriteLine(s); }
private void GestioneStudente(object sender, RoutedEventArgs e) { Studente studente = (Studente)lbxStudenti.SelectedItem; GestioneStudente gestione = new GestioneStudente(studente); gestione.ShowDialog(); }
private void BtnCaricaStudente_Click(object sender, RoutedEventArgs e) { try { if (txtNome.Text == "" || txtCognome.Text == "") { MessageBox.Show("Inserire i valori", "", MessageBoxButton.OK, MessageBoxImage.Exclamation); txtNome.Text = ""; txtCognome.Text = ""; txtNome.Focus(); } else { string nome = txtNome.Text; string cognome = txtCognome.Text; Studente s = new Studente(nome, cognome, matricola); studenti.Add(s); cmbStudenti.Items.Add(s.GetProprieta()); matricola++; txtNome.Text = ""; txtCognome.Text = ""; txtNome.Focus(); cmbStudenti.SelectedIndex = -1; } } catch (Exception ex) { MessageBox.Show(ex.Message); txtNome.Text = ""; txtCognome.Text = ""; txtNome.Focus(); } }
public void Cancella(String cf) { Studente studente = contesto.Studenti.Where(x => x.CodiceFiscale == cf).First(); contesto.Studenti.Remove(studente); StudenteCorso[] iscrizioni = contesto.StudentiCorsi.Where(x => x.Studente == cf).ToArray(); contesto.StudentiCorsi.RemoveRange(iscrizioni); }
static void Main(string[] args) { Studente s = new Studente("Mario", "Rossi", "AAA"); Direttore d = new Direttore("Carlo", "Bianchi", "BBB"); Console.WriteLine(d.Descrizione); Console.WriteLine(s.Descrizione); }
public StudenteModels(Studente s) { CodiceFiscale = s.CodiceFiscale; Nome = s.Nome; Cognome = s.Cognome; DataNascita = s.DataNascita; Sesso = s.Sesso; Email = s.Email; }
public bool IscriviStudente(Studente studente, String nomecorso) { contesto.Studenti.Add(studente); contesto.StudentiCorsi.Add(new StudenteCorso { Studente = studente.CodiceFiscale, Corso = nomecorso }); return(true); }
public void ModificaStudente(Studente studenteModificato) { /*var studente = db.Studenti.Find(studenteModificato.Id); * studente.Nome = studenteModificato.Nome; * studente.Cognome = studenteModificato.Cognome; * studente.Indirizzo = studenteModificato.Indirizzo; equivale alla riga di codice d.entry*/ db.Entry(studenteModificato).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); }
private void TrasferisciStudente(object sender, RoutedEventArgs e) { Studente studente = (Studente)lbxStudenti.SelectedItem; SelezionaRisorsa trasferisci = new SelezionaRisorsa(studente.Sede.Classi); if (trasferisci.ShowDialog() == true) { studente.Classe = (Classe)trasferisci.ElementoSelezionato; lbxStudenti.Items.Refresh(); } }
public void ModificaStudente(Studente studenteModificato) { /*alternativa alle due righe successive * var studente = db.Studenti.Find(studenteModificato.Id); * studente.Cognome = studenteModificato.Cognome; * studente.Nome = studenteModificato.Nome; * studente.Indirizzo = studenteModificato.Indirizzo;*/ db.Entry(studenteModificato).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); }
public static void Initialize(MyDbContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Studenti.Any()) { return; // DB has been seeded } var studenti = new Studente[] { new Studente { Nome = "Carson", Cognome = "Alexander", Eta = 18, Classe = "4G", Scuola = "ISII G. Marconi" }, new Studente { Nome = "Meredith", Cognome = "Alonso", Eta = 17, Classe = "3G", Scuola = "Colombini" }, new Studente { Nome = "Arturo", Cognome = "Anand", Eta = 16, Classe = "2G", Scuola = "ISII G. Marconi" }, new Studente { Nome = "Gytis", Cognome = "Barzdukas", Eta = 19, Classe = "5G", Scuola = "Gioia" }, }; foreach (Studente s in studenti) { context.Studenti.Add(s); } context.SaveChanges(); var professori = new Professore[] { new Professore { Nome = "Marco", Cognome = "Zucchini", Eta = 55, Scuola = "ISII G. Marconi" }, new Professore { Nome = "Max", Cognome = "Pancini", Eta = 55, Scuola = "ISII G. Marconi" }, new Professore { Nome = "MariaLuisa", Cognome = "Silva", Eta = 55, Scuola = "ISII G. Marconi" }, new Professore { Nome = "Luciana", Cognome = "Badini", Eta = 55, Scuola = "ISII G. Marconi" }, }; foreach (Professore s in professori) { context.Professori.Add(s); } context.SaveChanges(); }
public GestioneStudente(Studente studente) { InitializeComponent(); Studente = studente; DataContext = studente; for (int i = 1; i <= 10; i++) { cmbValutazione.Items.Add(i); } cmbValutazione.SelectedIndex = 0; }
static void Main(string[] args) { Scuola scuola = new Scuola("Rosselli-Rasetti"); Materia materia = scuola.CreateMateria("Religione"); Classe classe = scuola.CreateClasse(4, "AI"); Studente s = new Studente("alex", "buratta"); Votazione max = scuola.TrovaVotoMassimo(); Votazione min = scuola.TrovaVotoMinimo(); classe.AddStudenti(s); Console.Write($"il voto massimo è{max.voto} Data:{max.data} materia:{max.Materia.nome}"); Console.Write($"il voto minimo è{min.voto} Data:{min.data} materia:{min.Materia.nome}"); }
public List <Studente> RestituisciListaStudenti() { var studente1 = new Studente { Id = 1, Cognome = "Mario", Nome = "Rossi" }; var studente2 = new Studente { Id = 2, Cognome = "MastroCesare", Nome = "Francesco" }; return(new List <Studente> { studente1, studente2 }); }
private void Crea(object sender, RoutedEventArgs e) { try { Studente studente = new Studente(txtNome.Text, txtCognome.Text, txtUsername.Text, txtPassword.Password, dtpNascita.DisplayDate, sede, classe); DialogResult = true; Close(); } catch (Exception err) { MessageBox.Show(err.Message); } }
static void Main(string[] args) { Direttore dir = new Direttore("aaa", "bbb"); Console.WriteLine($"Il direttore è {dir.Descrizione}"); Studente s = new Studente("Giorgio", "Bianchi", "123"); string desc = s.Descrizione; s.Stampa(desc, s.Matricola); Console.WriteLine("premere un tasto per terminare."); //Console.ReadLine(); Environment.Exit(0); }
public Studente ImmatricolaStudente(Persona persona) { Studente studente = (Studente)persona; int numeroMatricola = NumeroMatricolaCorrente++; studente.Matricola = numeroMatricola; this.StudentiImmatricolati.Add(studente); Tesserino tesserino = new Tesserino(numeroMatricola); tesserino.FasciaReddito = CalcolaFasciaReddito(studente); studente.Tesserino = tesserino; return(studente); }
public Studente AsStudente() { Studente s = new Studente { CodiceFiscale = this.CodiceFiscale, Nome = this.Nome, Cognome = this.Cognome, DataNascita = this.DataNascita, Sesso = this.Sesso, Email = this.Email }; return(s); }
private async void Timer_Tick(object sender, object e) { timer.Stop(); while (true) { if (mfrc.IsTagPresent()) { var uid = mfrc.ReadUid(); byte[] chiave = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; var tagsl = mfrc.SelectTag(uid); if (tagsl) { var content = mfrc.ReadBlock(2, uid, chiave, null); String decoded = ascii.GetString(content); decoded = decoded.Substring(0, decoded.IndexOf('\0')); try { Studente s = new Studente { ID = decoded }; string str = "Test"; // Genera una eccezione! str = JsonConvert.SerializeObject(s); pubnub.Publish<string>( "rfid_dev", str, false, DisplayReturnMessage, DisplayErrorMessage ); } catch (Exception) { } } else { } mfrc.HaltTag(); mfrc.Reset(); break; } } timer.Start(); }
static void Main(string[] args) { Scuola scuola = new Scuola("Rosselli_Rasetti"); Classe classe = scuola.CreaClasse("AI", 4); Studente studente1 = new Studente("Nicola", "Galeotti"); Studente studente2 = new Studente("Narcis", "Buzatu"); classe.AddStudente(studente1); classe.AddStudente(studente2); Materia materia1 = new Materia("Matematica"); Votazione voto1 = new Votazione(8, studente1, materia1); Votazione voto2 = new Votazione(7, studente2, materia1); Votazione votomax = scuola.TrovaVotoMassimo(); Console.WriteLine($"Il voto massimo della scuola {scuola.Nome} è {votomax.GetVotoDouble()}."); }
static void Main(string[] args) { Scuola scuola = new Scuola("Rosselli_Rasetti"); Classe classe = scuola.CreateClasse(4, "AI"); Studente studente1 = new Studente("miao", "bau"); Studente studente2 = new Studente("pino", "frontani"); classe.AddStudente(studente1); classe.AddStudente(studente2); Materia materia1 = new Materia("REligione"); Votazione voto1 = new Votazione(8, studente1, materia1); Votazione voto2 = new Votazione(7, studente2, materia1); Votazione votomax = scuola.TrovaVotoMassimo(); Console.WriteLine($"Il voto massimo della scuola {scuola.GetNome()} è {votomax.GetVotoDouble()}."); }
void Start() { Studente stud = new Studente("Marco", "", 0); stud.Matricola = 232440; //Corretto: Matricola è una property della classe Studente. stud.Cognome = "Minerva"; //Coretto: Cognome è una property ereditata dalla classe base Persona. Debug.Log("Il nome dello studente è: " + stud.Nome + ", la sua matricola è: " + stud.Matricola); Persona pers = new Persona("Marco", ""); pers.Cognome = "Minerva"; //Coretto: Cognome è una property della classe Persona. //pers.Matricola = 232440; //Errato: la property Matricola non è visibile dalla classe Persona. Debug.Log("Il cognome della persona è: " + pers.Cognome); stud = new Studente("Marco", "Minerva", 232440); stud.StampaMessaggio(); pers = new Persona("Donald", "Duck"); pers.StampaMessaggio(); }
public static Studente InsertStudente(Studente studente, int classeid) { try { studente.IDClasse = classeid; using (var connection = new MySqlConnection(connectionString)) { var sql = "INSERT INTO STUDENTE (ID,Nome,Cognome,IDClasse)" + " VALUES (null,@Nome,@Cognome,@IDClasse); " + " SELECT CAST(LAST_INSERT_ID() as int ) "; studente.ID = connection.Query <int>(sql, studente).FirstOrDefault(); } } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } return(studente); }
private int CalcolaFasciaReddito(Studente studente) { double reddito = studente.RedditoFamiliare; if (reddito <= 0) { return(0); } else if (reddito <= 10000) { return(1); } else if (reddito <= 20000) { return(2); } else { return(3); } }
private void BtnComando_Click(object sender, EventArgs e) { lblTitolo.Text = txtTesto.Text; var persona = new Persona(); persona.Nome = "Mario"; persona.Cognome = "Rossi"; linee.Add(persona.NomeCompleto()); var studente = new Studente(); studente.Nome = "Anna"; studente.Cognome = "Verdi"; studente.Matricola = "3456765"; linee.Add(studente.NomeCompleto()); studente.Iscrizione("Dev C#"); txtOutput.Lines = linee.ToArray(); }
public void Put(int id, Studente StudenteModificato) { worker.ModificaStudente(StudenteModificato); }
public void Post(Studente studente) { worker.CreaStudente(studente); }
public StudenteManager(string id) { idStudente = id; s = new Studente(); InitializeComponent(); }