Esempio n. 1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            var table = util.tableQuery("SELECT id FROM LOS_SIN_VOZ.Rubro WHERE nombre = @no", "@no", rubro.Text);

            string rubroId;

            if (table.Rows.Count == 0)
            {
                util.execCommand("INSERT LOS_SIN_VOZ.Rubro VALUES (@no)", "@no", rubro.Text);
                rubroId = util.getVal("SELECT @@IDENTITY").ToString();
            }
            else
            {
                rubroId = table.Rows[0].ItemArray[0].ToString();
            }
            try
            {
                var command = new SqlCommand("UPDATE LOS_SIN_VOZ.Proveedor SET RS=@RS,dom=@di,ciudad=@ci," +
                                             "telefono=@te,CUIT=@CU,mail=@ma, codigoPostal=@co,rubro=@ru " +
                                             "WHERE id=@id", Program.con);

                command.Parameters.AddWithValue("@RS", razonSocial.Text);
                command.Parameters.AddWithValue("@di", direccion.Text);
                command.Parameters.AddWithValue("@ci", ciudad.Text);
                command.Parameters.AddWithValue("@te", telefono.Text);
                command.Parameters.AddWithValue("@cu", CUIT.Text);
                command.Parameters.AddWithValue("@ma", mail.Text == ""?DBNull.Value:(object)mail.Text);
                command.Parameters.AddWithValue("@co", codigoPostal.Text == "" ? DBNull.Value : (object)codigoPostal.Text);
                command.Parameters.AddWithValue("@ru", rubroId);
                command.Parameters.AddWithValue("@no", contacto.Text);
                command.Parameters.AddWithValue("@id", userId);

                command.ExecuteNonQuery();
            }
            catch (SqlException er)
            {
                if (er.Number == 2627)
                {
                    MessageBox.Show("un usuario con esos datos ya existe");
                }
                else
                {
                    MessageBox.Show("datos faltantes o mal ingresados"); //tira el mismo error para datos vacios y malos sql
                }
            }

            if (contraseña.Text != "")
            {
                CambioContraseña.cambiarContraseña(contraseña.Text, userId);
            }

            parent.doQuery();
            Close();
        }
Esempio n. 2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                util.execCommand("UPDATE LOS_SIN_VOZ.Cliente SET dni=@dn,nombre=@no,apellido=@ap,direccion=@di, " +
                                 "telefono=@te,mail=@ma,ciudad=@ci, fecha_Nac=@fe " +
                                 "WHERE id=@id",
                                 "@no", nombre.Text,
                                 "@ap", apellido.Text,
                                 "@dn", dni.Text,
                                 "@di", direccion.Text,
                                 "@te", telefono.Text,
                                 "@ma", mail.Text,
                                 "@ci", ciudad.Text,
                                 "@fe", util.flipDayMonth(fnac.Text),
                                 "@id", userId);
            }
            catch (SqlException er)
            {
                if (er.Number == 2627)
                {
                    MessageBox.Show("un usuario con esos datos ya existe");
                }
                else
                {
                    MessageBox.Show("datos faltantes o mal ingresados"); //tira el mismo error para datos vacios y malos sql
                }
            }
            if (contraseña.Text != "")
            {
                CambioContraseña.cambiarContraseña(contraseña.Text, userId);
            }


            parent.doQuery();
            Close();
        }
Esempio n. 3
0
 public MenuPrincipal()
 {
     InitializeComponent();
     cambioContraseña = new CambioContraseña();
 }