private void btnEliminar_Click_1(object sender, EventArgs e) { if (tablaAutomoviles.Rows.Count > 0) { if (autoSeleccionado.habilitado == 1) { DialogResult dialogResult = MessageBox.Show("Esta seguro?", "Esta seguro que quiere dar de baja este Automovil?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int response = SQLAutomovil.eliminarAutomovil(autoSeleccionado); if (response > 0) { MessageBox.Show("El automovil " + autoSeleccionado.idautomovil + " ha sido eliminado"); tablaAutomoviles.DataSource = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados(); } else { MessageBox.Show("El automovil " + autoSeleccionado.idautomovil + " no ha podido eliminarse"); } } } else { MessageBox.Show("El auto ya esta eliminado", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Debe seleccionar algun automovil", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void recargar() { DataTable autos; if (modificacion) { autos = SQLAutomovil.obtenerTodosLosAutomoviles(); } else { autos = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados(); } tablaAutomoviles.DataSource = autos; selectMarca.Items.Clear(); tablaMarcas = SQLAutomovil.obtenerTodasLasMarcas(); foreach (DataRow row in tablaMarcas.Rows) { selectMarca.Items.Add(row["nombre"].ToString()); } this.tablaAutomoviles.Columns[0].Visible = false; //autoID this.tablaAutomoviles.Columns[3].Visible = false; //marcaID this.tablaAutomoviles.Columns[9].Visible = false; //choferID DataGridViewRow autoRow = tablaAutomoviles.Rows[0]; autoSeleccionado = new Automovil(autoRow); selectMarca.Text = ""; txtModelo.Text = ""; txtPatente.Text = ""; txtChoferNombre.Text = ""; }
private void ListaAutomoviles_Load(object sender, EventArgs e) { //Obtener todos los automoviles cuando se carga el formulario DataTable autos; if (modificacion) { autos = SQLAutomovil.obtenerTodosLosAutomoviles(); } else { autos = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados(); } tablaAutomoviles.DataSource = autos; selectMarca.Items.Clear(); tablaMarcas = SQLAutomovil.obtenerTodasLasMarcas(); foreach (DataRow row in tablaMarcas.Rows) { selectMarca.Items.Add(row["nombre"].ToString()); } this.tablaAutomoviles.Columns[0].Visible = false; //autoID this.tablaAutomoviles.Columns[3].Visible = false; //marcaID this.tablaAutomoviles.Columns[9].Visible = false; //choferID DataGridViewRow autoRow = tablaAutomoviles.Rows[0]; autoSeleccionado = new Automovil(autoRow); }
private void btnLimpiar_Click(object sender, EventArgs e) { DataTable autos; if (modificacion) { autos = SQLAutomovil.obtenerTodosLosAutomoviles(); } else { autos = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados(); } tablaAutomoviles.DataSource = autos; selectMarca.Text = ""; txtModelo.Text = ""; txtPatente.Text = ""; txtChoferNombre.Text = ""; txtApellidoChofer.Text = ""; this.tablaAutomoviles.Columns[0].Visible = false; //autoID this.tablaAutomoviles.Columns[3].Visible = false; //marcaID this.tablaAutomoviles.Columns[9].Visible = false; //choferID }