Borrar

1,756 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,756
On SlideShare
0
From Embeds
0
Number of Embeds
1,141
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Borrar

  1. 1. borrar<br />CLIENTE<br />PROVEEDOR<br />PRODUCTO<br />VENTAS <br />
  2. 2.
  3. 3. private void Form20_Load(object sender, EventArgs e)<br /> {<br /> DataSet TABLA;<br /> SqlDataAdapter ORDEN;<br /> con = new SqlConnection();<br /> con.ConnectionString = vgloba.liga;<br /> string q = "select * from PRODUCTOS";<br /> ORDEN = new SqlDataAdapter(q, con);<br /> // Creando el dataset y cargandolo<br /> TABLA = new DataSet();<br /> ORDEN.Fill(TABLA, "PRODUCTOS");<br /> // Cargando el datagridview<br /> dataGridView1.DataSource = TABLA;<br /> dataGridView1.DataMember = "PRODUCTOS";<br /> }<br />
  4. 4. ESTE CODIGO VA DENTRO DEL BOTON.<br />private void button3_Click(object sender, EventArgs e)<br /> {<br /> con = new SqlConnection();<br /> con.ConnectionString = vgloba.liga;<br /> try<br /> {<br />con.Open();<br /> con = new SqlConnection();<br /> con.ConnectionString = vgloba.liga;<br /> string buscar = "SELECT * from PRODUCTOS where ID_PRODUCTO= '" + textBox1.Text + "'";<br />SqlCommand ORDEN = new SqlCommand(buscar, con);<br />ORDEN.Connection.Open();<br />ORDEN.ExecuteNonQuery();<br />SqlDataReaderreader = ORDEN.ExecuteReader();<br />reader.Read();<br />if (reader.HasRows)<br />{<br />
  5. 5. //SqlCommand ORDER;<br /> con = new SqlConnection();<br /> con.ConnectionString = vgloba.liga;<br />if (MessageBox.Show("¿Eliminar el PRODUCTO" + textBox1.Text + "?", "Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes)<br /> {<br /> string eliminar = "DELETE FROM PRODUCTOS WHERE ID_PRODUCTO='" + textBox1.Text + "'";<br />SqlCommand ORDEN2 = new SqlCommand(eliminar, con);<br /> ORDEN2.Connection.Open();<br /> ORDEN2.ExecuteNonQuery();<br />MessageBox.Show("PRODUCTO ELIMINADO");<br /> textBox1.Text = "";<br /> }<br />else<br /> {<br />MessageBox.Show("No se puede eliminar el PRODUCTO");<br /> }<br /> }<br />else<br /> {<br />MessageBox.Show("El ID proporcionado no existe");<br /> textBox1.Text = "";<br /> }<br /> }<br /> catch<br /> {<br />MessageBox.Show("Conexion fallida");<br /> }<br /> Form18 ventana = new Form18();<br />ventana.Show();<br />this.Close();<br /> }<br /> }<br />
  6. 6. ESTE MISMO CODIGO SE UTILIZA EN LAS DEMAS VENTANAS PERO CON SU RESPECTIVOS DATOS DE LA BASE DE DATOS.<br />

×