Borrar
-
Upload
ilian-patricia-bocanegra-alfaro -
Category
Technology
-
view
1.148 -
download
0
Transcript of Borrar
borrar
CLIENTEPROVEEDORPRODUCTO
VENTAS
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";
}
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.
//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(); } }
ESTE MISMO CODIGO SE UTILIZA EN LAS DEMAS VENTANAS PERO CON SU RESPECTIVOS DATOS DE LA BASE DE DATOS.