public Modificar() { InitializeComponent(); db = new DBGestion(dbLocation); int res = db.openDB(); if (res != 0) { MessageBox.Show("Error abriendo la base de datos."); } }
public bbdd() { InitializeComponent(); db = new DBGestion(dbLocation); int res = db.openDB(); if (res == -1) { MessageBox.Show("Error abriendo la base de datos"); } }
//Constructor public FormPrincipal() { InitializeComponent(); //Desactivar algunos componentes del menu ja que no hay imagen cargada. this.guardarToolStripMenuItem.Enabled = false; this.guardarComoToolStripMenuItem.Enabled = false; this.editarToolStripMenuItem.Enabled = false; this.deshacerToolStripMenuItem.Enabled = false; this.detallesImagenToolStripMenuItem.Enabled = false; //Iniciar conexión con la base de datos. this.db = new DBGestion(rutaDB); int res = this.db.openDB(); if (res != 0) { MessageBox.Show("No se ha podido establecer una conexión con la base de datos porque no ha podido ser encontrada."); System.Environment.Exit(-1); } }
private void evento(object sender, EventArgs e) //Listar los datos de un avion al hacer click sobre él { PictureBox p = (PictureBox)sender; int tag = (int)p.Tag; string id = lista.GetAvion(tag).GetIdentificador(); string co = lista.GetAvion(tag).GetCompañia(); int posx = lista.GetAvion(tag).GetPosicionX(); int posy = lista.GetAvion(tag).GetPosicionY(); float destx = lista.GetAvion(tag).GetDestinoX(); float desty = lista.GetAvion(tag).GetDestinoY(); float vel = lista.GetAvion(tag).GetVelocidad(); string dbLocation = "..\\..\\..\\PROYECTO_0\\MiDatabase.sdf"; DBGestion db; db = new DBGestion(dbLocation); int res = db.openDB(); if (res == -1) { MessageBox.Show("Error abriendo la base de datos"); } DataTable dt = db.getByCompania(co); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; MessageBox.Show("Este es el avión: " + id + "." + "\nCon coordenadas: " + "(" + posx + "," + posy + ")." + "\nCon destino: " + "(" + destx + "," + desty + ")." + "\nCon velocidad: " + vel + " nudos." + "\nCon compañía: " + co + "." + "\nEmail: " + row[2] + "."); } else { MessageBox.Show("Este es el avión: " + id + "." + "\nCon coordenadas: " + "(" + posx + "," + posy + ")." + "\nCon destino: " + "(" + destx + "," + desty + ")." + "\nCon velocidad: " + vel + " nudos." + "\nCon compañía: " + co + "." + "\nEmail: No disponible."); } db.closeDB(); }