Modificar

11
CLIENTE PROVEEDOR PRODUCTO VENTAS MODIFICAR

Transcript of Modificar

Page 1: Modificar

CLIENTEPROVEEDORPRODUCTO

VENTAS

MODIFICAR

Page 2: Modificar

LES VOY A PONER COMO EJEMPLO EL PRODUCTOS PARA AÑADIR EN LOS 4 VA EL

MISMO CODIGO

Page 3: Modificar
Page 4: Modificar

private void button1_Click(object sender, EventArgs e) { if (comboBox1.Text != "") { textBox1.Text = leerClientes("ID_PROVEEDORES").Trim(); textBox1.Text = leerClientes("nombre").Trim(); textBox2.Text = leerClientes("telefono").Trim(); textBox3.Text = leerClientes("calle").Trim(); textBox4.Text = leerClientes("interior").Trim(); textBox5.Text = leerClientes("exterior").Trim(); textBox6.Text = leerClientes("colonia").Trim(); textBox7.Text = leerClientes("codigoPostal").Trim(); textBox8.Text = leerClientes("estado").Trim(); textBox9.Text = leerClientes("pais").Trim(); textBox10.Text = leerClientes("ciudad").Trim(); textBox11.Text = leerClientes("poblacion").Trim();

} else { MessageBox.Show("La CLAVE especificada no existe"); } }

CODIGO QUE SE UTILIZA DENTRO DEL BOTON.

Page 5: Modificar

private void Form16_Load(object sender, EventArgs e) { con = new System.Data.SqlClient.SqlConnection(); con.ConnectionString = vgloba.liga; llenarComboBox(); limpiar(); try { con.Open();

label14.Text = "LA BASE DE DATOS ESTA CONECTADA"; string stsql = "select count (ID_PROVEEDORES) from PROVEEDORES"; SqlCommand coman = new SqlCommand(stsql, con); int numRegistros = ((int)coman.ExecuteScalar()) + 1; con.Close(); label13.Text = "registros contados" + (numRegistros - 1).ToString();

} catch (Exception) { MessageBox.Show("Conexion fallida"); this.Close(); }

}

ESTE CODIGO SE UTLIZA DENTRO DEL FORM.

Page 6: Modificar

DLSKKDKS private void button2_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox9.Text == "" || textBox10.Text == "" || textBox11.Text == "") { MessageBox.Show("Faltan datos por llenar"); } else {

DialogResult res = MessageBox.Show("Modificar registro de la Base de Datos?", "Modificar PROVEEDORES", MessageBoxButtons.YesNo);

if (res == DialogResult.Yes) { con = new System.Data.SqlClient.SqlConnection(); con.ConnectionString = vgloba.liga; try {string q = "update PROVEEDORES set nombre=@nombre,telefono=@telefono,calle=@calle,exterior=@exterior,interior=@interior,colonia=@colonia,codigoPostal=@codigoPostal,estado=@estado,pais=@pais,ciudad=@ciudad,poblacion=@poblacion WHERE

Page 7: Modificar

SqlCommand ORDER; ORDER = new SqlCommand(q, con);

ORDER.Parameters.Add(new SqlParameter("@ID_PROVEEDORES", comboBox1.Text)); ORDER.Parameters.Add(new SqlParameter("@nombre", textBox1.Text)); ORDER.Parameters.Add(new SqlParameter("@telefono", Int32.Parse(textBox2.Text))); ORDER.Parameters.Add(new SqlParameter("@calle", textBox3.Text)); ORDER.Parameters.Add(new SqlParameter("@interior", Int32.Parse(textBox4.Text))); ORDER.Parameters.Add(new SqlParameter("@exterior", Int32.Parse(textBox5.Text))); ORDER.Parameters.Add(new SqlParameter("@colonia", textBox6.Text)); ORDER.Parameters.Add(new SqlParameter("@codigoPostal", Int32.Parse(textBox7.Text))); ORDER.Parameters.Add(new SqlParameter("@estado", textBox8.Text)); ORDER.Parameters.Add(new SqlParameter("@pais", textBox9.Text)); ORDER.Parameters.Add(new SqlParameter("@ciudad", textBox10.Text)); ORDER.Parameters.Add(new SqlParameter("@poblacion", textBox11.Text));

MessageBox.Show("Registro modificado"); this.Close();

} catch (Exception) { MessageBox.Show("conexion nula"); } }

} }

Page 8: Modificar

private string leerPRODUCTOSstring columna) { string liga = ""; SqlCommand ORDEN = new SqlCommand("SELECT c." + columna + " from PROVEEDORES as c where c.ID_PROVEEDORES = " + comboBox1.Text.ToString(), con); ORDEN.Connection.Open(); ORDEN.ExecuteNonQuery(); SqlDataReader reader = ORDEN.ExecuteReader(); reader.Read(); try { if (reader.HasRows) { liga = reader.GetString(0); } } catch (Exception) { liga = ""; } reader.Close(); ORDEN.Connection.Close(); return liga; }

ESTE ES CODIGO PARA LEER EL PRODUCTO DENTRO DE LA BASE DE DATOS

Page 9: Modificar
Page 10: Modificar
Page 11: Modificar