MODIFICAR CLIENTEPROVEEDORPRODUCTOVENTAS
LES VOY A PONER COMO EJEMPLO EL PRODUCTOS PARA AÑADIR EN LOS 4 VA EL MISMO CODIGO
CODIGO QUE SE UTILIZA DENTRO DEL BOTON.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");            }        }
ESTE CODIGO SE UTLIZA DENTRO DEL FORM.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();            }        }
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
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");                    }                }            }        }
ESTE ES CODIGO PARA LEER EL PRODUCTO DENTRO DE LA BASE DE DATOSprivate stringleerPRODUCTOSstringcolumna)        {string liga = "";            SqlCommand ORDEN = new SqlCommand("SELECT c." + columna + " from PROVEEDORES as c wherec.ID_PROVEEDORES = " + comboBox1.Text.ToString(), con);ORDEN.Connection.Open();ORDEN.ExecuteNonQuery();SqlDataReaderreader = ORDEN.ExecuteReader();reader.Read();            try            {                if (reader.HasRows)                { liga = reader.GetString(0); }            }            catch (Exception)            {                liga = "";            }reader.Close();ORDEN.Connection.Close();return liga;        }
Modificar
Modificar
Modificar

Modificar

  • 1.
  • 2.
    LES VOY APONER COMO EJEMPLO EL PRODUCTOS PARA AÑADIR EN LOS 4 VA EL MISMO CODIGO
  • 4.
    CODIGO QUE SEUTILIZA DENTRO DEL BOTON.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"); } }
  • 5.
    ESTE CODIGO SEUTLIZA DENTRO DEL FORM.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(); } }
  • 6.
    DLSKKDKS private voidbutton2_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
  • 7.
    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"); } } } }
  • 8.
    ESTE ES CODIGOPARA LEER EL PRODUCTO DENTRO DE LA BASE DE DATOSprivate stringleerPRODUCTOSstringcolumna) {string liga = ""; SqlCommand ORDEN = new SqlCommand("SELECT c." + columna + " from PROVEEDORES as c wherec.ID_PROVEEDORES = " + comboBox1.Text.ToString(), con);ORDEN.Connection.Open();ORDEN.ExecuteNonQuery();SqlDataReaderreader = ORDEN.ExecuteReader();reader.Read(); try { if (reader.HasRows) { liga = reader.GetString(0); } } catch (Exception) { liga = ""; }reader.Close();ORDEN.Connection.Close();return liga; }