Ejemplo n.º 1
0
        private void btn_Agregar_Agregarproveedor_Click_1(object sender, EventArgs e)
        {
            form_Proveedores pro      = new form_Proveedores();
            Home             home     = new Home();
            string           consulta = cb_ciudad_Agregarproveedor.Text;
            string           nombre   = "select p.nombre from Proveedor p JOIN telefonoProveedor tp ON p.cedula=tp.cedProveedor WHERE tp.telefono=" + txt_telefono_Agregarproveedor.Text + "";
            string           nombre1  = datos.consultarDato(nombre);

            try
            {
                if (verifivarVacio() == true)
                {
                    if (txt_cedula_Agregarproveedor.Text != logica.comprobarSiYaExiste("cedula", "Proveedor", txt_cedula_Agregarproveedor.Text))
                    {
                        if (txt_telefono_Agregarproveedor.Text != logica.comprobarSiYaExiste("telefono", "telefonoProveedor", txt_telefono_Agregarproveedor.Text))
                        {
                            try
                            {
                                logica.insertarDatos("INSERT INTO Proveedor (`cedula`, `nombre`, `apellido`, `direccion`, `cargo`, `correo`, `codCiudad`, `observaciones`) VALUES('" + txt_cedula_Agregarproveedor.Text + "',' " + txt_nombres_Agregarproveedor.Text + "',' " + txt_apellidos_Agregarproveedor.Text + "',' " + txt_direccion_Agregarproveedor.Text + "','" + txt_cargo_Agregarproveedor.Text + "',' " + txt_correo_Agregarproveedor.Text + "',' " + logica.covertirCiudad("select id from ciudad where upper(nombre)=upper('" + consulta + "')") + "', '" + txt_descripcion_Agregarproveedor.Text + "')");
                                logica.insertarDatos("INSERT INTO telefonoProveedor (`id`,`telefono`,`cedProveedor`) VALUES (null,'" + txt_telefono_Agregarproveedor.Text + "','" + txt_cedula_Agregarproveedor.Text + "')");
                                constructor();
                                pro.proveedor();
                                home.AbrirFormEnPanel(pro);
                                MessageBox.Show("Correcto");
                                home.limpiarPanel();
                                this.Refresh();
                                this.Close();
                            }
                            catch
                            {
                                MessageBox.Show("Error");
                                constructor();
                            }
                        }
                        else
                        {
                            MessageBox.Show("El telefono " + txt_telefono_Agregarproveedor.Text + " ya esta registrado y le pertenece al proveedor  " + nombre1);
                        }
                    }
                    else
                    {
                        MessageBox.Show("El proveedor " + txt_nombres_Agregarproveedor.Text + " " + txt_apellidos_Agregarproveedor.Text + " ya esta registrado con cedula  " + txt_cedula_Agregarproveedor.Text);
                    }
                }
                else
                {
                    constructor();
                    lbl_ErrorApellidos.Visible = false;
                    lbl_ErrorCedula.Visible    = false;
                    lbl_ErrorCiudad.Visible    = false;
                    lbl_ErrorCorreo.Visible    = false;
                    lbl_ErrorDireccion.Visible = false;
                    lbl_ErrorNombres.Visible   = false;
                    lbl_ErrorCargo.Visible     = false;
                    lbl_ErrorTelefono.Visible  = false;
                }
            }
            catch
            {
                MessageBox.Show("Por favor llene los campos");
            }
        }