Exemple #1
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Proveedor consultaProveedor = new Proveedor(txtEliminar.Text);

                if (consultaProveedor != null)
                {
                    PersonaContacto   personaContacto          = new PersonaContacto(consultaProveedor);
                    Telefono          telefono                 = new Telefono();
                    List <Telefono>   listaTelefono            = telefono.Leer(consultaProveedor);
                    List <Telefono>   listaTelefonoPerContacto = telefono.Leer(personaContacto);
                    CorreoElectronico correo = new CorreoElectronico(consultaProveedor.CodigoCorreoElectronico);

                    foreach (Telefono numero in listaTelefono)
                    {
                        numero.Eliminar();
                    }

                    foreach (Telefono numero in listaTelefonoPerContacto)
                    {
                        numero.Eliminar();
                    }

                    Producto        todosProductos = new Producto();
                    List <Producto> listaProducto  = todosProductos.Todos();

                    foreach (Producto producto in listaProducto)
                    {
                        consultaProveedor.EliminarProducto(producto);
                    }

                    personaContacto.Eliminar();
                    consultaProveedor.Eliminar();
                    correo.Eliminar();

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El proveedor ha sido eliminado');" +
                                                        "window.location ='Proveedores.aspx';", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El Proveedor no existe');", true);
                }
            }
            catch (Exception ex)
            {
                Session["mensajeError"] = "Ha ocurrido un error con la base de datos. " + ex;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('No hay conexión con la base de datos');", true);
            }
        }
Exemple #2
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Cliente clienteNatural = new Cliente(txtEliminar.Text);

                if (clienteNatural != null)
                {
                    Natural           personaNatural = new Natural(txtEliminar.Text);
                    Telefono          telefono       = new Telefono();
                    List <Telefono>   listaTelefono  = telefono.Leer(clienteNatural);
                    CorreoElectronico correo         = new CorreoElectronico(clienteNatural.CodigoCorreoElectronico);

                    foreach (Telefono numero in listaTelefono)
                    {
                        numero.Eliminar();
                    }
                    personaNatural.Eliminar();
                    clienteNatural.Eliminar();
                    correo.Eliminar();

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('la persona ha sido eliminada');" +
                                                        "window.location ='Clientes_Admin.aspx';", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('La persona no existe');", true);
                }
            }
            catch (Exception ex)
            {
                Session["mensajeError"] = "Ha ocurrido un error con la base de datos. " + ex;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('No hay conexión con la base de datos');", true);
            }
        }
Exemple #3
0
        protected void btnGuardarCambios(object sender, EventArgs e)
        {
            try
            {
                int   CodLug1 = this.CodLugar(dplParroquia, dplMunicipio, dplEstado);
                Lugar lugar   = new Lugar(CodLug1);

                Natural ClienteNatural = new Natural(dplRif.SelectedValue + txtRif.Text);


                CorreoElectronico ctrlCorreo = new CorreoElectronico(ClienteNatural.CodigoCorreoElectronico);
                ctrlCorreo.Direccion = txtCorreo.Text;
                ctrlCorreo.Actualizar();

                //Cliente datosCliente = new Cliente(dplRif.SelectedValue + txtRif.Text, txtContraseña.Text, ctrlCorreo, null);
                //datosCliente.Actualizar();

                ClienteNatural.Password  = txtContraseña.Text;
                ClienteNatural.Cedula    = dplCedula.SelectedValue + txtCedula.Text;
                ClienteNatural.Nombre1   = Nombre1.Text;
                ClienteNatural.Nombre2   = Nombre2.Text;
                ClienteNatural.Apellido1 = Apellido1.Text;
                ClienteNatural.Apellido2 = Apellido2.Text;
                ClienteNatural.Direccion = lugar.Codigo;

                //Natural natural = new Natural(dplRif.SelectedValue + txtRif.Text, txtContraseña.Text,ctrlCorreo, dplCedula.SelectedValue + txtCedula.Text,Nombre1.Text,Nombre2.Text,Apellido1.Text,Apellido2.Text,lugar);
                ClienteNatural.Actualizar();

                Telefono        telefono  = new Telefono();
                List <Telefono> telefonos = telefono.Leer(ClienteNatural);


                Telefono telefono1 = new Telefono(int.Parse(CodigoPais1.SelectedValue), int.Parse(CodAre.Text), int.Parse(txtTelefono1.Text), TipoTelf.Text, ClienteNatural);
                Telefono telefono2 = new Telefono(int.Parse(CodigoPais2.SelectedValue), int.Parse(CodAre2.Text), int.Parse(txtTelefono2.Text), TipoTelf2.Text, ClienteNatural);

                if (!VerificarCambiosTelefono(telefonos[0], telefono1))
                {
                    telefonos[0].Eliminar();
                    telefono1.Insertar();
                }

                if (!VerificarCambiosTelefono(telefonos[1], telefono2))
                {
                    telefonos[1].Eliminar();
                    telefono2.Insertar();
                }

                //Response.Redirect("/Views/Clientes_Admin.aspx", false);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El cliente se ha sido modificado exitosamente');" +
                                                    "window.location ='Clientes_Admin';", true);
            }
            catch (Exception ex)
            {
                Session["mensajeError"] = "Ha ocurrido un error al modificar el cliente natural. " + ex;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('NO DEBE HABER CAMPOS VACÍOS');", true);
            }
        }
Exemple #4
0
        protected void btnGuardarCambios(object sender, EventArgs e)
        {
            try
            {
                //CLIENTE JURIDICO

                int CodLug1 = this.CodLugar(dplParroquia, dplMunicipio, dplEstado);
                int CodLug2 = this.CodLugar(dplParroquia2, dplMunicipio2, dplEstado2);


                Juridico ClienteJuridico = new Juridico(dplRif.SelectedValue + txtRif.Text);
                ClienteJuridico.DenominacionComercial = txtDenoComercial.Text;
                ClienteJuridico.RazonSocial           = txtRazonSocial.Text;
                ClienteJuridico.PaginaWeb             = txtPaginaWeb.Text;
                ClienteJuridico.Capital         = float.Parse(txtCapitalDisponible.Text);
                ClienteJuridico.Password        = txtContraseña.Text;
                ClienteJuridico.DireccionFiscal = CodLug1;
                ClienteJuridico.DireccionFisica = CodLug2;


                CorreoElectronico ctrlCorreo = new CorreoElectronico(ClienteJuridico.CodigoCorreoElectronico);
                ctrlCorreo.Direccion = txtCorreo.Text;
                ctrlCorreo.Actualizar();

                ClienteJuridico.Actualizar();

                Telefono        telefono  = new Telefono();
                List <Telefono> telefonos = telefono.Leer(ClienteJuridico);


                Telefono telefono1 = new Telefono(int.Parse(CodigoPais1.SelectedValue), int.Parse(CodAre.Text), int.Parse(txtTelefono1.Text), TipoTelf.Text, ClienteJuridico);
                Telefono telefono2 = new Telefono(int.Parse(CodigoPais2.SelectedValue), int.Parse(CodAre2.Text), int.Parse(txtTelefono2.Text), TipoTelf2.Text, ClienteJuridico);

                if (!VerificarCambiosTelefono(telefonos[0], telefono1))
                {
                    telefonos[0].Eliminar();
                    telefono1.Insertar();
                }

                if (!VerificarCambiosTelefono(telefonos[1], telefono2))
                {
                    telefonos[1].Eliminar();
                    telefono2.Insertar();
                }

                //PERSONA DE CONTACTO

                PersonaContacto contacto = ClienteJuridico.PersonaContacto();
                contacto.Nombre1   = Nombre1.Text;
                contacto.Nombre2   = Nombre2.Text;
                contacto.Apellido1 = Apellido1.Text;
                contacto.Apellido2 = Apellido2.Text;
                contacto.Cedula    = dplCedula.SelectedValue + txtCedula.Text;

                contacto.Actualizar();


                telefonos = telefono.Leer(contacto);


                Telefono telefono3 = new Telefono(int.Parse(CodigoPais3.SelectedValue), int.Parse(CodAre3.Text), int.Parse(txtTelefono3.Text), TipoTelf3.Text, contacto);
                Telefono telefono4 = new Telefono(int.Parse(CodigoPais4.SelectedValue), int.Parse(CodAre4.Text), int.Parse(txtTelefono4.Text), TipoTelf4.Text, contacto);

                if (!VerificarCambiosTelefono(telefonos[0], telefono3))
                {
                    telefonos[0].Eliminar();
                    telefono3.Insertar();
                }

                if (!VerificarCambiosTelefono(telefonos[1], telefono4))
                {
                    telefonos[1].Eliminar();
                    telefono4.Insertar();
                }

                //Response.Redirect("/Views/Clientes_Admin.aspx", false);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El cliente se ha sido modificado exitosamente');" +
                                                    "window.location ='Clientes_Admin';", true);
            }
            catch (Exception ex)
            {
                Session["mensajeError"] = "Ha ocurrido un error al modificar el cliente juridico. " + ex;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('NO DEBE HABER CAMPOS VACÍOS');", true);
            }
        }
Exemple #5
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            Juridico cliente = new Juridico(BuscarRif.Text);

            if (cliente.RazonSocial != null)
            {
                //RIF
                char[] a = new char[1];
                cliente.RIF.CopyTo(0, a, 0, 1);
                char[] NumRif = new char[15];
                cliente.RIF.CopyTo(1, NumRif, 0, cliente.RIF.Length - 1);

                dplRif.SelectedValue = new String(a).Replace("\0", "");
                dplRif.Enabled       = true;
                txtRif.Text          = new String(NumRif).Replace("\0", "");
                txtRif.Enabled       = true;


                txtDenoComercial.Text        = cliente.DenominacionComercial;
                txtDenoComercial.Enabled     = true;
                txtRazonSocial.Text          = cliente.RazonSocial;
                txtRazonSocial.Enabled       = true;
                txtPaginaWeb.Text            = cliente.PaginaWeb;
                txtPaginaWeb.Enabled         = true;
                txtCapitalDisponible.Text    = cliente.Capital.ToString();
                txtCapitalDisponible.Enabled = true;


                //CORREO
                CorreoElectronico correo = new CorreoElectronico(cliente.CodigoCorreoElectronico);
                txtCorreo.Text    = correo.Direccion;
                txtCorreo.Enabled = true;

                //TELEFONOS

                Telefono        telefono1 = new Telefono();
                List <Telefono> telefonos = telefono1.Leer(cliente);


                foreach (ListItem item in CodigoPais1.Items)
                {
                    if (item.Value == telefonos[0].Numero[NumeroTelefono.Pais].ToString())
                    {
                        CodigoPais1.SelectedValue = item.Value;
                    }
                }
                CodigoPais1.Enabled = true;

                TipoTelf.SelectedValue = telefonos[0].Tipo;
                TipoTelf.Enabled       = true;
                CodAre.Text            = telefonos[0].Numero[NumeroTelefono.Area].ToString();
                CodAre.Enabled         = true;
                txtTelefono1.Text      = telefonos[0].Numero[NumeroTelefono.Numero].ToString();
                txtTelefono1.Enabled   = true;

                if (telefonos.Count > 1)
                {
                    foreach (ListItem item in CodigoPais2.Items)
                    {
                        if (item.Value == telefonos[1].Numero[NumeroTelefono.Pais].ToString())
                        {
                            CodigoPais2.SelectedValue = item.Value;
                        }
                    }
                    CodigoPais2.Enabled = true;

                    TipoTelf2.SelectedValue = telefonos[1].Tipo;
                    TipoTelf2.Enabled       = true;
                    CodAre2.Text            = telefonos[1].Numero[NumeroTelefono.Area].ToString();
                    CodAre2.Enabled         = true;
                    txtTelefono2.Text       = telefonos[1].Numero[NumeroTelefono.Numero].ToString();
                    txtTelefono2.Enabled    = true;
                }


                //DIRECCION FISCAL
                Lugar parroquia = new Lugar(cliente.DireccionFiscal);
                Lugar Municipio = new Lugar(parroquia.CodigoUbicacion);
                Lugar Estado    = new Lugar(Municipio.CodigoUbicacion);
                dplEstado.SelectedValue = Estado.Nombre;
                dplEstado.Enabled       = true;
                this.dplEstado_SelectedIndexChanged(sender, e);
                dplMunicipio.SelectedValue = Municipio.Nombre;
                dplMunicipio.Enabled       = true;
                this.dplMunicipio_SelectedIndexChanged(sender, e);
                dplParroquia.SelectedValue = parroquia.Nombre;
                dplParroquia.Enabled       = true;

                //DIRECCION FISICA PRINCIPAL
                Lugar parroquia2 = new Lugar(cliente.DireccionFisica);
                Lugar Municipio2 = new Lugar(parroquia2.CodigoUbicacion);
                Lugar Estado2    = new Lugar(Municipio2.CodigoUbicacion);
                dplEstado2.SelectedValue = Estado2.Nombre;
                dplEstado2.Enabled       = true;
                this.dplEstado2_SelectedIndexChanged(sender, e);
                dplMunicipio2.SelectedValue = Municipio2.Nombre;
                dplMunicipio2.Enabled       = true;
                this.dplMunicipio2_SelectedIndexChanged(sender, e);
                dplParroquia2.SelectedValue = parroquia2.Nombre;
                dplParroquia2.Enabled       = true;

                //CONTRASEÑA
                txtContraseña.Text           = cliente.Password;
                txtContraseña.Enabled        = true;
                txtRepetirContraseña.Text    = cliente.Password;
                txtRepetirContraseña.Enabled = true;

                //PERSONA DE CONTACTO

                PersonaContacto contacto = cliente.PersonaContacto();

                //CEDULA
                char[] c = new char[1];
                contacto.Cedula.CopyTo(0, c, 0, 1);
                char[] NumCed = new char[15];
                contacto.Cedula.CopyTo(1, NumCed, 0, contacto.Cedula.Length - 1);

                dplCedula.SelectedValue = new String(c).Replace("\0", "");
                dplCedula.Enabled       = true;
                txtCedula.Text          = new String(NumCed).Replace("\0", "");
                txtCedula.Enabled       = true;

                //NOMBRE Y APELLIDO DE LA PERSONA DE CONTACTO
                Nombre1.Text    = contacto.Nombre1;
                Nombre1.Enabled = true;
                Nombre2.Text    = contacto.Nombre2;
                Nombre2.Enabled = true;

                Apellido1.Text    = contacto.Apellido1;
                Apellido1.Enabled = true;
                Apellido2.Text    = contacto.Apellido2;
                Apellido2.Enabled = true;


                //TELEFONOS DE LA PERSONA DE CONTACTO

                Telefono        telefono3   = new Telefono();
                List <Telefono> telefonosPC = telefono3.Leer(contacto);


                foreach (ListItem item in CodigoPais3.Items)
                {
                    if (item.Value == telefonosPC[0].Numero[NumeroTelefono.Pais].ToString())
                    {
                        CodigoPais3.SelectedValue = item.Value;
                    }
                }
                CodigoPais3.Enabled = true;

                TipoTelf3.SelectedValue = telefonosPC[0].Tipo;
                TipoTelf3.Enabled       = true;
                CodAre3.Text            = telefonosPC[0].Numero[NumeroTelefono.Area].ToString();
                CodAre3.Enabled         = true;
                txtTelefono3.Text       = telefonosPC[0].Numero[NumeroTelefono.Numero].ToString();
                txtTelefono3.Enabled    = true;

                if (telefonosPC.Count > 1)
                {
                    foreach (ListItem item in CodigoPais4.Items)
                    {
                        if (item.Value == telefonosPC[1].Numero[NumeroTelefono.Pais].ToString())
                        {
                            CodigoPais4.SelectedValue = item.Value;
                        }
                    }
                    CodigoPais4.Enabled = true;

                    TipoTelf4.SelectedValue = telefonosPC[1].Tipo;
                    TipoTelf4.Enabled       = true;
                    CodAre4.Text            = telefonosPC[1].Numero[NumeroTelefono.Area].ToString();
                    CodAre4.Enabled         = true;
                    txtTelefono4.Text       = telefonosPC[1].Numero[NumeroTelefono.Numero].ToString();
                    txtTelefono4.Enabled    = true;
                }

                btnModificar.Enabled = true;
            }
            else
            {
                //PERSONA DE CONTACTO
                dplCedula.Enabled  = false;
                dplCedula.CssClass = "input-group-prepend be-addon";
                txtCedula.Enabled  = false;
                txtCedula.CssClass = "form-control";

                Nombre1.Enabled  = false;
                Nombre1.CssClass = "form-control";
                Nombre2.Enabled  = false;
                Nombre2.CssClass = "form-control";

                Apellido1.Enabled  = false;
                Apellido1.CssClass = "form-control";
                Apellido2.Enabled  = false;
                Apellido2.CssClass = "form-control";

                CodigoPais3.Enabled   = false;
                CodigoPais3.CssClass  = "input-group-prepend be-addon";
                TipoTelf3.Enabled     = false;
                TipoTelf3.CssClass    = "input-group-prepend be-addon";
                CodAre3.Enabled       = false;
                CodAre3.CssClass      = "form-control";
                txtTelefono3.Enabled  = false;
                txtTelefono3.CssClass = "form-control";

                CodigoPais4.Enabled   = false;
                CodigoPais4.CssClass  = "input-group-prepend be-addon";
                TipoTelf4.Enabled     = false;
                TipoTelf4.CssClass    = "input-group-prepend be-addon";
                CodAre4.Enabled       = false;
                CodAre4.CssClass      = "form-control";
                txtTelefono4.Enabled  = false;
                txtTelefono4.CssClass = "form-control";

                //DATOS DEL CLIENTE JURIDICO
                dplRif.Enabled  = false;
                dplRif.CssClass = "input-group-prepend be-addon";
                txtRif.Enabled  = false;
                txtRif.CssClass = "form-control";

                txtDenoComercial.Enabled  = false;
                txtDenoComercial.CssClass = "form-control";

                txtRazonSocial.Enabled  = false;
                txtRazonSocial.CssClass = "form-control";

                txtPaginaWeb.Enabled  = false;
                txtPaginaWeb.CssClass = "form-control";

                txtCapitalDisponible.Enabled  = false;
                txtCapitalDisponible.CssClass = "form-control";

                txtCorreo.Enabled  = false;
                txtCorreo.CssClass = "form-control";

                CodigoPais1.Enabled   = false;
                CodigoPais1.CssClass  = "input-group-prepend be-addon";
                TipoTelf.Enabled      = false;
                TipoTelf.CssClass     = "input-group-prepend be-addon";
                CodAre.Enabled        = false;
                CodAre.CssClass       = "form-control";
                txtTelefono1.Enabled  = false;
                txtTelefono1.CssClass = "form-control";

                CodigoPais2.Enabled   = false;
                CodigoPais2.CssClass  = "input-group-prepend be-addon";
                TipoTelf2.Enabled     = false;
                TipoTelf2.CssClass    = "input-group-prepend be-addon";
                CodAre2.Enabled       = false;
                CodAre2.CssClass      = "form-control";
                txtTelefono2.Enabled  = false;
                txtTelefono2.CssClass = "form-control";

                dplEstado.Enabled     = false;
                dplEstado.CssClass    = "input-group-prepend be-addon";
                dplMunicipio.Enabled  = false;
                dplMunicipio.CssClass = "input-group-prepend be-addon";
                dplParroquia.Enabled  = false;
                dplParroquia.CssClass = "input-group-prepend be-addon";

                dplEstado2.Enabled     = false;
                dplEstado2.CssClass    = "input-group-prepend be-addon";
                dplMunicipio2.Enabled  = false;
                dplMunicipio2.CssClass = "input-group-prepend be-addon";
                dplParroquia2.Enabled  = false;
                dplParroquia2.CssClass = "input-group-prepend be-addon";

                txtContraseña.Enabled         = false;
                txtContraseña.CssClass        = "form-control";
                txtRepetirContraseña.Enabled  = false;
                txtRepetirContraseña.CssClass = "form-control";

                btnModificar.Enabled  = false;
                btnModificar.CssClass = "btn btn-primary btn-user btn-block";

                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El cliente no existe');", true);
            }
        }
Exemple #6
0
        protected void btnGuardarCambios(object sender, EventArgs e)
        {
            try
            {
                int   CodLug1 = this.CodLugar(dplParroquia, dplMunicipio, dplEstado);
                Lugar lugar   = new Lugar(CodLug1);

                Empleado empleado = new Empleado(int.Parse(BuscarCod.Text));

                empleado.Password        = txtContraseña.Text;
                empleado.Cedula          = dplCedula.SelectedValue + txtCedula.Text;
                empleado.RIF             = dplrif.SelectedValue + txtRif.Text;
                empleado.Nombre1         = Nombre1.Text;
                empleado.Nombre2         = Nombre2.Text;
                empleado.Apellido1       = Apellido1.Text;
                empleado.Apellido2       = Apellido2.Text;
                empleado.CodigoDireccion = lugar.Codigo;
                empleado.CodigoJefe      = int.Parse(Jefe.Text);


                CorreoElectronico ctrlCorreo = new CorreoElectronico(empleado.CodigoCorreoElectronico);
                ctrlCorreo.Direccion = txtCorreo.Text;
                ctrlCorreo.Actualizar();


                Departamento departamento    = new Departamento();
                int          CodDepartamento = departamento.Get_CodDepartamento(Departamentos.SelectedValue);
                empleado.CodigoDepartamento = CodDepartamento;

                Tienda tienda    = new Tienda();
                int    CodTienda = tienda.Get_CodTienda(Tiendas.SelectedValue);
                empleado.CodigoTienda = CodTienda;


                //CARGO

                //ACTUALIZAR CARGO VIEJO
                MuchosAMuchos emple_muchos = new MuchosAMuchos();
                Cargo         cargo        = empleado.CargoActual();
                emple_muchos.Actualizar(empleado, cargo);


                //COLOCAR NUEVO CARGO
                Cargo NuevoCargo    = new Cargo();
                int   CodNuevoCargo = NuevoCargo.Get_CodCargo(Cargos.SelectedValue);
                if (cargo.Codigo != CodNuevoCargo)
                {
                    emple_muchos.Insertar(empleado, new Cargo(CodNuevoCargo), int.Parse(TextMonto.Text));
                }

                //HORARIOS
                this.Delete_Horarios(empleado);
                this.AssignHorarios(empleado);

                //BENEFICIOS
                this.Delete_Beneficios(empleado);
                this.AssignBeneficios(empleado);

                //TELEFONOS
                Telefono        telefono  = new Telefono();
                List <Telefono> telefonos = telefono.Leer(empleado);


                Telefono telefono1 = new Telefono(int.Parse(CodigoPais1.SelectedValue), int.Parse(CodAre.Text), int.Parse(txtTelefono1.Text), TipoTelf.Text, empleado);
                Telefono telefono2 = new Telefono(int.Parse(CodigoPais2.SelectedValue), int.Parse(CodAre2.Text), int.Parse(txtTelefono2.Text), TipoTelf2.Text, empleado);

                if (!VerificarCambiosTelefono(telefonos[0], telefono1))
                {
                    telefonos[0].Eliminar();
                    telefono1.Insertar();
                }

                if (!VerificarCambiosTelefono(telefonos[1], telefono2))
                {
                    telefonos[1].Eliminar();
                    telefono2.Insertar();
                }

                empleado.Actualizar();

                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El cliente se ha sido modificado exitosamente');" +
                                                    "window.location ='../Nomina_Admin.aspx';", true);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('NO DEBE HABER CAMPOS VACÍOS');", true);
            }
        }
Exemple #7
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            this.EnableFields(true);

            Empleado empleado = new Empleado(int.Parse(BuscarCod.Text));

            Nombre1.Text = empleado.Nombre1;
            Nombre2.Text = empleado.Nombre2;

            Apellido1.Text = empleado.Apellido1;
            Apellido2.Text = empleado.Apellido2;

            //RIF
            char[] a = new char[1];
            empleado.RIF.CopyTo(0, a, 0, 1);
            char[] NumRif = new char[15];
            empleado.RIF.CopyTo(1, NumRif, 0, empleado.RIF.Length - 1);

            dplrif.SelectedValue = new String(a).Replace("\0", "");
            txtRif.Text          = new String(NumRif).Replace("\0", "");

            //CEDULA
            char[] c = new char[1];
            empleado.Cedula.CopyTo(0, c, 0, 1);
            char[] NumCed = new char[15];
            empleado.Cedula.CopyTo(1, NumCed, 0, empleado.Cedula.Length - 1);

            dplCedula.SelectedValue = new String(c).Replace("\0", "");
            txtCedula.Text          = new String(NumCed).Replace("\0", "");

            //CORREO
            CorreoElectronico correo = new CorreoElectronico(empleado.CodigoCorreoElectronico);

            txtCorreo.Text = correo.Direccion;


            //TELEFONOS

            Telefono        telefono1 = new Telefono();
            List <Telefono> telefonos = telefono1.Leer(empleado);


            foreach (ListItem item in CodigoPais1.Items)
            {
                if (item.Value == telefonos[0].Numero[NumeroTelefono.Pais].ToString())
                {
                    CodigoPais1.SelectedValue = item.Value;
                }
            }

            TipoTelf.SelectedValue = telefonos[0].Tipo;
            CodAre.Text            = telefonos[0].Numero[NumeroTelefono.Area].ToString();
            txtTelefono1.Text      = telefonos[0].Numero[NumeroTelefono.Numero].ToString();

            if (telefonos.Count > 1)
            {
                foreach (ListItem item in CodigoPais2.Items)
                {
                    if (item.Value == telefonos[1].Numero[NumeroTelefono.Pais].ToString())
                    {
                        CodigoPais2.SelectedValue = item.Value;
                    }
                }

                TipoTelf2.SelectedValue = telefonos[1].Tipo;
                CodAre2.Text            = telefonos[1].Numero[NumeroTelefono.Area].ToString();
                txtTelefono2.Text       = telefonos[1].Numero[NumeroTelefono.Numero].ToString();
            }


            //LUGAR Y CONTRASEÑA
            Lugar parroquia = new Lugar(empleado.CodigoDireccion);
            Lugar Municipio = new Lugar(parroquia.CodigoUbicacion);
            Lugar Estado    = new Lugar(Municipio.CodigoUbicacion);

            dplEstado.SelectedValue = Estado.Nombre;
            this.dplEstado_SelectedIndexChanged(sender, e);
            dplMunicipio.SelectedValue = Municipio.Nombre;
            this.dplMunicipio_SelectedIndexChanged(sender, e);
            dplParroquia.SelectedValue = parroquia.Nombre;


            txtContraseña.Text        = empleado.Password;
            txtRepetirContraseña.Text = empleado.Password;

            //DEPARTAMENTO

            Departamento departamento = new Departamento(empleado.CodigoDepartamento);

            Departamentos.SelectedValue = departamento.Nombre;

            //TIENDA

            Tienda tienda = new Tienda(empleado.CodigoTienda);

            Tiendas.SelectedValue = tienda.Nombre;

            //JEFE

            Empleado jefe = new Empleado(empleado.CodigoJefe);

            Jefe.Text = jefe.Codigo.ToString();

            //CARGO
            Cargo cargo = empleado.CargoActual();

            Cargos.SelectedValue = cargo.Nombre;
            TextMonto.Text       = empleado.SueldoActual().ToString();


            //Horarios
            List <Horario> horarios = empleado.Horarios();

            HoraInicio.Text     = horarios[0].HoraEntrada.ToString();
            HoraFin.Text        = horarios[0].HoraSalida.ToString();
            Turno.SelectedValue = horarios[0].Turno;

            foreach (Horario horario in horarios)
            {
                foreach (ListItem item in Dias.Items)
                {
                    if (item.Text == horario.Dia)
                    {
                        item.Selected = true;
                    }
                }
            }

            //BENEFICIOS
            List <Beneficio> beneficios = empleado.Beneficios();

            foreach (Beneficio beneficio in beneficios)
            {
                foreach (ListItem item in Options.Items)
                {
                    if (item.Text == beneficio.Nombre)
                    {
                        item.Selected = true;
                    }
                }
            }
        }
Exemple #8
0
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            Natural cliente = new Natural(BuscarRif.Text);

            if (cliente.Cedula != null)
            {
                //NOMBRE Y APELLIDO
                Nombre1.Text    = cliente.Nombre1;
                Nombre1.Enabled = true;
                Nombre2.Text    = cliente.Nombre2;
                Nombre2.Enabled = true;

                Apellido1.Text    = cliente.Apellido1;
                Apellido1.Enabled = true;
                Apellido2.Text    = cliente.Apellido2;
                Apellido2.Enabled = true;

                //RIF
                char[] a = new char[1];
                cliente.RIF.CopyTo(0, a, 0, 1);
                char[] NumRif = new char[15];
                cliente.RIF.CopyTo(1, NumRif, 0, cliente.RIF.Length - 1);

                dplRif.SelectedValue = new String(a).Replace("\0", "");
                dplRif.Enabled       = true;
                txtRif.Text          = new String(NumRif).Replace("\0", "");
                txtRif.Enabled       = true;

                //Cedula
                char[] c = new char[1];
                cliente.Cedula.CopyTo(0, c, 0, 1);
                char[] NumCed = new char[15];
                cliente.Cedula.CopyTo(1, NumCed, 0, cliente.Cedula.Length - 1);

                dplCedula.SelectedValue = new String(c).Replace("\0", "");
                dplCedula.Enabled       = true;
                txtCedula.Text          = new String(NumCed).Replace("\0", "");
                txtCedula.Enabled       = true;

                //CORREO
                CorreoElectronico correo = new CorreoElectronico(cliente.CodigoCorreoElectronico);
                txtCorreo.Text    = correo.Direccion;
                txtCorreo.Enabled = true;

                //TELEFONOS

                Telefono        telefono1 = new Telefono();
                List <Telefono> telefonos = telefono1.Leer(cliente);


                foreach (ListItem item in CodigoPais1.Items)
                {
                    if (item.Value == telefonos[0].Numero[NumeroTelefono.Pais].ToString())
                    {
                        CodigoPais1.SelectedValue = item.Value;
                    }
                }
                CodigoPais1.Enabled = true;

                TipoTelf.SelectedValue = telefonos[0].Tipo;
                TipoTelf.Enabled       = true;
                CodAre.Text            = telefonos[0].Numero[NumeroTelefono.Area].ToString();
                CodAre.Enabled         = true;
                txtTelefono1.Text      = telefonos[0].Numero[NumeroTelefono.Numero].ToString();
                txtTelefono1.Enabled   = true;

                if (telefonos.Count > 1)
                {
                    foreach (ListItem item in CodigoPais2.Items)
                    {
                        if (item.Value == telefonos[1].Numero[NumeroTelefono.Pais].ToString())
                        {
                            CodigoPais2.SelectedValue = item.Value;
                        }
                    }
                    CodigoPais2.Enabled = true;

                    TipoTelf2.SelectedValue = telefonos[1].Tipo;
                    TipoTelf2.Enabled       = true;
                    CodAre2.Text            = telefonos[1].Numero[NumeroTelefono.Area].ToString();
                    CodAre2.Enabled         = true;
                    txtTelefono2.Text       = telefonos[1].Numero[NumeroTelefono.Numero].ToString();
                    txtTelefono2.Enabled    = true;
                }


                //LUGAR Y CONTRASEÑA
                Lugar parroquia = new Lugar(cliente.Direccion);
                Lugar Municipio = new Lugar(parroquia.CodigoUbicacion);
                Lugar Estado    = new Lugar(Municipio.CodigoUbicacion);
                dplEstado.SelectedValue = Estado.Nombre;
                dplEstado.Enabled       = true;
                this.dplEstado_SelectedIndexChanged(sender, e);
                dplMunicipio.SelectedValue = Municipio.Nombre;
                dplMunicipio.Enabled       = true;
                this.dplMunicipio_SelectedIndexChanged(sender, e);
                dplParroquia.SelectedValue = parroquia.Nombre;
                dplParroquia.Enabled       = true;

                txtContraseña.Text           = cliente.Password;
                txtContraseña.Enabled        = true;
                txtRepetirContraseña.Text    = cliente.Password;
                txtRepetirContraseña.Enabled = true;

                btnModificar.Enabled = true;
            }
            else
            {
                Nombre1.Enabled  = false;
                Nombre1.CssClass = "form-control";
                Nombre2.Enabled  = false;
                Nombre2.CssClass = "form-control";

                Apellido1.Enabled  = false;
                Apellido1.CssClass = "form-control";
                Apellido2.Enabled  = false;
                Apellido2.CssClass = "form-control";

                dplRif.Enabled  = false;
                dplRif.CssClass = "input-group-prepend be-addon";
                txtRif.Enabled  = false;
                txtRif.CssClass = "form-control";

                dplCedula.Enabled  = false;
                dplCedula.CssClass = "input-group-prepend be-addon";
                txtCedula.Enabled  = false;
                txtCedula.CssClass = "form-control";

                txtCorreo.Enabled  = false;
                txtCorreo.CssClass = "form-control";

                CodigoPais1.Enabled   = false;
                CodigoPais1.CssClass  = "input-group-prepend be-addon";
                TipoTelf.Enabled      = false;
                TipoTelf.CssClass     = "input-group-prepend be-addon";
                CodAre.Enabled        = false;
                CodAre.CssClass       = "form-control";
                txtTelefono1.Enabled  = false;
                txtTelefono1.CssClass = "form-control";


                CodigoPais2.Enabled   = false;
                CodigoPais2.CssClass  = "input-group-prepend be-addon";
                TipoTelf2.Enabled     = false;
                TipoTelf2.CssClass    = "input-group-prepend be-addon";
                CodAre2.Enabled       = false;
                CodAre2.CssClass      = "form-control";
                txtTelefono2.Enabled  = false;
                txtTelefono2.CssClass = "form-control";


                dplEstado.Enabled     = false;
                dplEstado.CssClass    = "input-group-prepend be-addon";
                dplMunicipio.Enabled  = false;
                dplMunicipio.CssClass = "input-group-prepend be-addon";
                dplParroquia.Enabled  = false;
                dplParroquia.CssClass = "input-group-prepend be-addon";

                btnModificar.Enabled  = false;
                btnModificar.CssClass = "btn btn-primary btn-user btn-block";

                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El cliente no existe');", true);
            }
        }
Exemple #9
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Empleado empleado = new Empleado(txtEliminar.Text);

                if (empleado != null)
                {
                    Telefono          telefono      = new Telefono();
                    List <Telefono>   listaTelefono = telefono.Leer(empleado);
                    CorreoElectronico correo        = new CorreoElectronico(empleado.CodigoCorreoElectronico);

                    foreach (Telefono numero in listaTelefono)
                    {
                        numero.Eliminar();
                    }

                    Beneficio     beneficio       = new Beneficio();
                    List <int>    listaBeneficios = beneficio.codigoBeneficios(empleado.Codigo);
                    MuchosAMuchos empleadoM_M     = new MuchosAMuchos();

                    foreach (int codigoBeneficios in listaBeneficios)
                    {
                        beneficio = beneficio.Leer(codigoBeneficios);
                        empleadoM_M.Eliminar(empleado, beneficio);
                    }

                    Horario    horario      = new Horario();
                    List <int> listaHorario = horario.codHorario(empleado);

                    foreach (int codigoHorario in listaHorario)
                    {
                        horario = horario.Leer(codigoHorario);
                        empleadoM_M.Eliminar(empleado, horario);
                        horario.Eliminar();
                    }

                    List <int> listaCargo = empleado.BuscarEnCargo();

                    foreach (int codigoCargo in listaCargo)
                    {
                        Cargo nombreCargo = new Cargo(codigoCargo);
                        empleadoM_M.Eliminar(empleado, nombreCargo);
                    }


                    empleado.Eliminar();
                    correo.Eliminar();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El empleado ha sido eliminada');" +
                                                        "window.location ='../Nomina_Admin.aspx';", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('El empleado no existe');", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Hubo un error al eliminar');", true);
            }
        }
Exemple #10
0
        protected void btnGuardarCambios(object sender, EventArgs e)
        {
            //CLIENTE JURIDICO

            int CodLug1 = this.CodLugar(dplParroquia, dplMunicipio, dplEstado);
            int CodLug2 = this.CodLugar(dplParroquia2, dplMunicipio2, dplEstado2);


            Proveedor proveedor = new Proveedor(dplRif.SelectedValue + txtRif.Text);

            proveedor.DenominacionComercial = txtDenoComercial.Text;
            proveedor.RazonSocial           = txtRazonSocial.Text;
            proveedor.PaginaWeb             = txtPaginaWeb.Text;
            proveedor.DireccionFiscal       = CodLug1;
            proveedor.DireccionFisica       = CodLug2;


            CorreoElectronico ctrlCorreo = new CorreoElectronico(proveedor.CodigoCorreoElectronico);

            ctrlCorreo.Direccion = txtCorreo.Text;
            ctrlCorreo.Actualizar();

            Telefono        telefono  = new Telefono();
            List <Telefono> telefonos = telefono.Leer(proveedor);


            Telefono telefono1 = new Telefono(int.Parse(CodigoPais1.SelectedValue), int.Parse(CodAre.Text), int.Parse(txtTelefono1.Text), TipoTelf.Text, proveedor);
            Telefono telefono2 = new Telefono(int.Parse(CodigoPais2.SelectedValue), int.Parse(CodAre2.Text), int.Parse(txtTelefono2.Text), TipoTelf2.Text, proveedor);

            if (!VerificarCambiosTelefono(telefonos[0], telefono1))
            {
                telefonos[0].Eliminar();
                telefono1.Insertar();
            }

            if (!VerificarCambiosTelefono(telefonos[1], telefono2))
            {
                telefonos[1].Eliminar();
                telefono2.Insertar();
            }

            //PERSONA DE CONTACTO

            PersonaContacto contacto = proveedor.PersonaContacto();

            contacto.Nombre1   = Nombre1.Text;
            contacto.Nombre2   = Nombre2.Text;
            contacto.Apellido1 = Apellido1.Text;
            contacto.Apellido2 = Apellido2.Text;
            contacto.Cedula    = dplCedula.SelectedValue + txtCedula.Text;

            contacto.Actualizar();


            telefonos = telefono.Leer(contacto);


            Telefono telefono3 = new Telefono(int.Parse(CodigoPais3.SelectedValue), int.Parse(CodAre3.Text), int.Parse(txtTelefono3.Text), TipoTelf3.Text, contacto);
            Telefono telefono4 = new Telefono(int.Parse(CodigoPais4.SelectedValue), int.Parse(CodAre4.Text), int.Parse(txtTelefono4.Text), TipoTelf4.Text, contacto);

            if (!VerificarCambiosTelefono(telefonos[0], telefono3))
            {
                telefonos[0].Eliminar();
                telefono3.Insertar();
            }

            if (!VerificarCambiosTelefono(telefonos[1], telefono4))
            {
                telefonos[1].Eliminar();
                telefono4.Insertar();
            }

            Response.Redirect("/Views/Clientes_Admin.aspx", false);
        }