Borrar

8
borrar CLIENTE PROVEEDOR PRODUCTO VENTAS

Transcript of Borrar

Page 1: Borrar

borrar

CLIENTEPROVEEDORPRODUCTO

VENTAS

Page 2: Borrar
Page 3: Borrar

private void Form20_Load(object sender, EventArgs e) { DataSet TABLA; SqlDataAdapter ORDEN; con = new SqlConnection(); con.ConnectionString = vgloba.liga;

string q = "select * from PRODUCTOS"; ORDEN = new SqlDataAdapter(q, con);

// Creando el dataset y cargandolo TABLA = new DataSet(); ORDEN.Fill(TABLA, "PRODUCTOS");

// Cargando el datagridview

dataGridView1.DataSource = TABLA; dataGridView1.DataMember = "PRODUCTOS";

}

Page 4: Borrar

private void button3_Click(object sender, EventArgs e) { con = new SqlConnection(); con.ConnectionString = vgloba.liga;

try { con.Open(); con = new SqlConnection(); con.ConnectionString = vgloba.liga; string buscar = "SELECT * from PRODUCTOS where ID_PRODUCTO= '" + textBox1.Text + "'"; SqlCommand ORDEN = new SqlCommand(buscar, con); ORDEN.Connection.Open(); ORDEN.ExecuteNonQuery(); SqlDataReader reader = ORDEN.ExecuteReader(); reader.Read(); if (reader.HasRows) {

ESTE CODIGO VA DENTRO DEL BOTON.

Page 5: Borrar

//SqlCommand ORDER; con = new SqlConnection(); con.ConnectionString = vgloba.liga;

if (MessageBox.Show("¿Eliminar el PRODUCTO" + textBox1.Text + "?", "Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes) { string eliminar = "DELETE FROM PRODUCTOS WHERE ID_PRODUCTO='" + textBox1.Text + "'"; SqlCommand ORDEN2 = new SqlCommand(eliminar, con); ORDEN2.Connection.Open(); ORDEN2.ExecuteNonQuery();

MessageBox.Show("PRODUCTO ELIMINADO"); textBox1.Text = ""; } else { MessageBox.Show("No se puede eliminar el PRODUCTO"); } } else { MessageBox.Show("El ID proporcionado no existe"); textBox1.Text = ""; } } catch { MessageBox.Show("Conexion fallida"); } Form18 ventana = new Form18(); ventana.Show(); this.Close(); } }

Page 6: Borrar

ESTE MISMO CODIGO SE UTILIZA EN LAS DEMAS VENTANAS PERO CON SU RESPECTIVOS DATOS DE LA BASE DE DATOS.

Page 7: Borrar
Page 8: Borrar