private void BModifica_Click(object sender, EventArgs e) { // Variables per a recollir dades String nom, pais; double premi; int any; // per recollir les dades del pilot dintre de l'objecte granPremi String nomGuanyador; pilot guanyador = new pilot(); // Omplim les variables //nomEscud = CBEscuderia.Text; nom = TBNom.Text; pais = TBPais.Text; any = Convert.ToInt32(TBAny.Text); premi = Convert.ToDouble(TBPremi.Text); nomGuanyador = CBGuanyador.Text; guanyador = guanyador.cercarPilot(nomGuanyador); // Construïm l'objecte granPremi gp = new granPremi(nom, pais, premi, guanyador, any); // Modifiquem gp sobre el fitxer gp.modificarGP(); // I tornem a l'estat inicial numGP = 0; carregaTextBox(); Botonera(); }
private void BBusca_Click(object sender, EventArgs e) { // recollim dades String nom_pilot = TBBusca.Text; // Creem l'objecte pilot p = new pilot(); // Cerquem la escuderia p = p.cercarPilot(nom_pilot); // Introduïm en els labels si existeix la pilot que hem buscat if (p != null) { LBEscuderia.Text = p.Nom; LBNom.Text = p.Nom; LBPais.Text = p.Nacionalitat; LBDorsal.Text = "( Dorsal: " + Convert.ToString(p.Dorsal) + " )"; BElimina.Enabled = true; } else { MessageBox.Show("No existeix el pilot" + nom_pilot, "error", MessageBoxButtons.OK, MessageBoxIcon.Error); BElimina.Enabled = false; } }
private void BTBuscaPilot_Click(object sender, EventArgs e) { //Recogemos los datos(nom escuderia) String nomPilot; nomPilot = TBNompilot.Text; //Creamos el objeto pilot pil = new pilot(); //buscamos la escuderia pil = pil.cercarPilot(nomPilot); TBNompilot.Text = pil.Nom; mostrarLabels(pil, nomPilot); }
private void BAfegeix_Click(object sender, EventArgs e) { // creem variables String nom, pais, pilotGuanyador = CBGuanyador.Text; double premi; pilot guanyador = new pilot(); int any; // recollim les dades dels text box nom = TBNom.Text; pais = TBPais.Text; premi = Convert.ToDouble(TBPremi.Text); any = Convert.ToInt32(TBAny.Text); if (pilotGuanyador.Equals("-")) { guanyador = null; } else { guanyador = guanyador.cercarPilot(CBGuanyador.Text); } // construim l'objecte granPremi gp = new granPremi(nom, pais, premi, guanyador, any); // guardem al fitxer gp.afegeiGranPremi(); // buidem els Text Box TBNom.Text = ""; TBPais.Text = ""; TBPremi.Text = ""; TBAny.Text = ""; CBGuanyador.Text = "-"; }