Esempio n. 1
0
        public void init()
        {
            lafabricaDao = new FabricaDAOSqlServer();
            laFabricaEntidades = new FabricaEntidades();
            laDireccion = laFabricaEntidades.ObtenerDireccion("Venezuela", "Miranda", "Guarenas", "Nueva Casarapa, Calle 5, Edif Casarapa", "3223");
            elTelefono = laFabricaEntidades.ObtenerTelefono("0424", "1188439");
            elCliente = laFabricaEntidades.ObtenerClienteNatural("Gonzalo", "Machado", "*****@*****.**", laDireccion, elTelefono, "10351484");

             laDireccion2 = laFabricaEntidades.ObtenerDireccion("Venezuela", "Miranda", "Guarenas", "La Callena, Calle 3, Edif La Flor", "3293");
            elTelefono2 = laFabricaEntidades.ObtenerTelefono("0424", "1138419");
            elCliente2 = laFabricaEntidades.ObtenerClienteNatural("Jose","Oberto","*****@*****.**",laDireccion2,elTelefono2,"9381223");

            elCliente3 = laFabricaEntidades.ObtenerClienteNatural();
        }
Esempio n. 2
0
        public void init()
        {
            fabricaDAOContacto = new FabricaDAOSqlServer();
            entidadContacto = new FabricaEntidades();
            elContacto = (Contacto)entidadContacto.ObtenerContacto();
            elContacto2 = (Contacto)entidadContacto.ObtenerContacto();
            elContactoAuxiliar = (Contacto)entidadContacto.ObtenerContacto();
            elCliente = (ClienteJuridico)entidadContacto.ObtenerClienteJuridico();
            elTelefono = (Telefono)entidadContacto.ObtenerTelefono();
            laDireccion = (Direccion)entidadContacto.ObtenerDireccion();
            laListaDeContactos =new List<Contacto>();

            elTelefono.Numero = "5555555";
            elTelefono.Codigo = "0414";
            laDireccion.CodigoPostal = null;
            laDireccion.LaDireccion = "Parroquia Caricuao UD 3, Bloque 6, piso 1, apt 01";
            laDireccion.LaCiudad = "Caracas";
            laDireccion.ElEstado = "Distrito Capital";
            laDireccion.ElPais = "Venezuela";

            elContacto.ConCedula = "1000000";
            elContacto.Con_Nombre = "Prueba";
            elContacto.Con_Apellido = "Unitaria";
            elContacto.ConCargo = "Gerente";

            elContacto.Con_Telefono = elTelefono;
            elContacto.ConClienteJurid = elCliente;
            elContacto.ConClienteNat = null;

            elCliente.Id = 1;
            elCliente.Jur_Rif = "J-11111111-1";
            elCliente.Jur_Nombre = "Locatel";
            laListaDeContactos.Add(elContacto);
            elCliente.Jur_Contactos = laListaDeContactos;
            elCliente.Jur_Direccion = laDireccion;
            elCliente.Jur_Logo = null;
        }
Esempio n. 3
0
        /// <summary>
        /// metodo para manejar el evento para agregar un cliente juridico
        /// </summary>
        /// <returns>booleano que refleja el exito de la operacion</returns>
        public bool agregarEmpresa()
        {
            List<String> alfabeticos = new List<String>();
            List<String> alfanumericos = new List<String>();
            List<String> numericos = new List<String>();
            alfabeticos.Add(vista.apellidoContacto);
            alfabeticos.Add(vista.nombreContacto);
            alfanumericos.Add(vista.direccionEmpresa);
            alfanumericos.Add(vista.nombreEmpresa);
            alfanumericos.Add(vista.rifEmpresa);
            numericos.Add(vista.cedulaContacto);
            numericos.Add(vista.codTelefono);
            numericos.Add(vista.telefonoCliente);
            Regex expresion = new Regex(@"[0-9]{1,9}(\.[0-9]{0,2})?$");

            if (Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(alfabeticos) &&
                Validaciones.ValidarCamposVacios(numericos))
            {
                if (Validaciones.ValidarCaracteresAlfabeticos(alfabeticos))
                {
                        if (Validaciones.ValidarExpresionRegular(numericos,expresion))
                        {
                                FabricaEntidades fabrica = new FabricaEntidades();
                                List<Entidad> contactos = new List<Entidad>();
                            try
                            {
                                Entidad direccion = fabrica.ObtenerDireccion(vista.comboPais.SelectedValue,
                                    vista.comboEstado.SelectedValue, vista.comboCiudad.SelectedValue,
                                    vista.direccionEmpresa, vista.codigoPostalEmpresa);
                                Entidad telefono = fabrica.ObtenerTelefono(vista.codTelefono, vista.telefonoCliente);
                                Entidad contacto = fabrica.ObtenerContacto(vista.cedulaContacto, vista.nombreContacto,
                                    vista.apellidoContacto, vista.comboCargo.SelectedValue, telefono);
                                contactos.Add(contacto);
                                Entidad clientej = fabrica.ObtenerClienteJuridico(vista.nombreEmpresa, contactos, direccion, vista.rifEmpresa, "aquivaellogo");
                                Comando<Entidad, bool> comando = FabricaComandos.CrearComandoAgregarClienteJuridico();
                                if (comando.Ejecutar(clientej))
                                    HttpContext.Current.Response.Redirect(RecursoInterfazM2.ListarEmpresas +
                                        RecursoInterfazM2.Codigo_Exito_Agregar);
                                return true;
                            }
                            catch (Exception ex)
                            {
                                vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                                vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                                vista.alerta = RecursoInterfazM2.Alerta_Html +
                                    ex.Message +
                                    RecursoInterfazM2.Alerta_Html_Final;
                                return false;
                            }
                        }
                        else
                        {
                            vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                            vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                            vista.alerta = RecursoInterfazM2.Alerta_Html +
                                RecursoInterfazM2.Alerta_Error_Numericos +
                            RecursoInterfazM2.Alerta_Html_Final;
                            return false;

                        }
                }
                else
                {
                    vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                    vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                    vista.alerta = RecursoInterfazM2.Alerta_Html +
                        RecursoInterfazM2.Alerta_Error_Alfabeticos +
                    RecursoInterfazM2.Alerta_Html_Final;
                    return false;

                }
            }
            else
            {
                vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                vista.alerta = RecursoInterfazM2.Alerta_Html +
                    RecursoInterfazM2.Alerta_Error_CamposVacios +
                RecursoInterfazM2.Alerta_Html_Final;
                return false;

            }
        }
        /// <summary>
        /// metodo para modificar al contacto
        /// </summary>
        public void modificarContacto()
        {
            String detalleContacto = HttpContext.Current.Request.QueryString["id"];
            String paginaRedirect = HttpContext.Current.Request.QueryString["pag"];
            List<String> alfabeticos = new List<String>();
            List<String> numericos = new List<String>();
            Regex expresion = new Regex(@"[0-9]{1,9}(\.[0-9]{0,2})?$");

            alfabeticos.Add(vista.apellidoContacto);
            alfabeticos.Add(vista.nombreContacto);
            alfabeticos.Add(vista.comboCargo.SelectedValue);

            numericos.Add(vista.cedulaContacto);
            numericos.Add(vista.telefonoContacto);
            numericos.Add(vista.codTelefono);

            if (Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(numericos))
            {
                if (Validaciones.ValidarCaracteresAlfabeticos(alfabeticos))
                {
                    if (Validaciones.ValidarExpresionRegular(numericos, expresion))
                    {
                        FabricaEntidades fabrica = new FabricaEntidades();

                        try
                        {
                            Entidad telefono = fabrica.ObtenerTelefono(vista.codTelefono, vista.telefonoContacto);
                            Entidad elContacto = fabrica.ObtenerContacto(vista.cedulaContacto, vista.nombreContacto,
                                vista.apellidoContacto, vista.comboCargo.SelectedValue, telefono);
                            elContacto.Id = int.Parse(detalleContacto);

                            Comando<Entidad, bool> elComando = FabricaComandos.CrearComandoModificarContacto();
                            if (elComando.Ejecutar(elContacto))
                                HttpContext.Current.Response.Redirect(paginaRedirect +
                                    RecursoInterfazM2.Codigo_Exito_ModficiarContacto);
                        }
                        catch(Exception ex)
                        {
                            vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                            vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                            vista.alerta = RecursoInterfazM2.Alerta_Html +
                                ex.Message +
                                RecursoInterfazM2.Alerta_Html_Final;
                        }
                    }
                    else
                    {
                        vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                        vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                        vista.alerta = RecursoInterfazM2.Alerta_Html +
                            RecursoInterfazM2.Alerta_Error_Numericos +
                        RecursoInterfazM2.Alerta_Html_Final;
                    }
                }
                else
                {
                    vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                    vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                    vista.alerta = RecursoInterfazM2.Alerta_Html +
                        RecursoInterfazM2.Alerta_Error_Alfabeticos +
                    RecursoInterfazM2.Alerta_Html_Final;
                }
            }
            else
            {
                vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                vista.alerta = RecursoInterfazM2.Alerta_Html +
                    RecursoInterfazM2.Alerta_Error_CamposVacios +
                RecursoInterfazM2.Alerta_Html_Final;

            }
        }
Esempio n. 5
0
        /// <summary>
        /// Metodo para consultar todos los datos de un cliente natural
        /// dado un id
        /// </summary>
        /// <param name="parametro">entidad que posee el id del que se desean saber
        /// todos los datos</param>
        /// <returns>cliente natural con todos sus datos</returns>
        public Entidad ConsultarXId(Entidad parametro)
        {
            FabricaEntidades laFabrica = new FabricaEntidades();
            DataTable resultado = new DataTable();
            List<Parametro> parametros = new List<Parametro>();
            Parametro elParametro;
            Direccion laDireccion;
            Telefono elTelefono;

            try
            {
                ClienteNatural elCliente = (ClienteNatural)laFabrica.ObtenerClienteNatural();
                elParametro = new Parametro(RecursoBDModulo2.ParamIDClienteNat,
                SqlDbType.Int, parametro.Id.ToString(), false);
                parametros.Add(elParametro);
                resultado = EjecutarStoredProcedureTuplas(RecursoBDModulo2.ConsultarDatosClienteNat,
                                                                     parametros);
                if (resultado == null)
                {
                    Logger.EscribirError(Convert.ToString(this.GetType()),
                                           new ClienteInexistenteException());
                    throw new ClienteInexistenteException(RecursoBDModulo2.CodigoClienteInexistente,
                                                          RecursoBDModulo2.MensajeClienteInexistente,
                                                          new ClienteInexistenteException());
                }

                foreach (DataRow row in resultado.Rows)
                {
                    laDireccion = (Direccion)laFabrica.ObtenerDireccion();
                    elTelefono = (Telefono)laFabrica.ObtenerTelefono();
                    elCliente = (ClienteNatural)laFabrica.ObtenerClienteNatural();
                    elCliente.Id = int.Parse(row[RecursoBDModulo2.AliasIDClienteNat].ToString());
                    elCliente.Nat_Nombre = row[RecursoBDModulo2.AliasNombreClienteNat].ToString();
                    elCliente.Nat_Apellido = row[RecursoBDModulo2.AliasApellidoClienteNat].ToString();
                    elCliente.Nat_Cedula = row[RecursoBDModulo2.AliasCedulaClienteNat].ToString();
                    elCliente.Nat_Correo = row[RecursoBDModulo2.AliasCorreoClienteNat].ToString();
                    elTelefono.Codigo = row[RecursoBDModulo2.AliasCodigoTelefono].ToString();
                    elTelefono.Numero = row[RecursoBDModulo2.AliasNumTelefono].ToString();
                    elCliente.Nat_Telefono = elTelefono;
                    laDireccion.LaDireccion = row[RecursoBDModulo2.AliasNombreDireccion].ToString();
                    laDireccion.CodigoPostal = row[RecursoBDModulo2.AliasCodPostalDireccion].ToString();
                    laDireccion.LaCiudad = row[RecursoBDModulo2.AliasNombreCiudad].ToString();
                    laDireccion.ElEstado = row[RecursoBDModulo2.AliasNombreEstado].ToString();
                    laDireccion.ElPais = row[RecursoBDModulo2.AliasNombrePais].ToString();
                    elCliente.Nat_Direccion = laDireccion;

                }

                return elCliente;

            }
            #region catches
            catch (SqlException ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()), ex);

                throw new ExcepcionesTotem.ExceptionTotemConexionBD(
                    RecursoGeneralDAO.Codigo_Error_BaseDatos,
                    RecursoGeneralDAO.Mensaje_Error_BaseDatos,
                    ex);
            }
            catch (ClienteInexistenteException ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()), ex);
                throw ex;

            }
            catch (ExcepcionesTotem.ExceptionTotemConexionBD ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()), ex);
                throw ex;
            }
            catch (Exception ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()), ex);

                throw new ExceptionTotem(RecursoBDModulo2.CodigoExcepcionGeneral,
                                         RecursoBDModulo2.MensajeExcepcionGeneral,
                                         ex);
            }
            #endregion
        }
Esempio n. 6
0
        /// <summary>
        /// Metodo para consultar la lista de contactos que posee una empresa
        /// </summary>
        /// <param name="parametro">empresa de la que se desean conocer sus contactos</param>
        /// <returns>lista de contactos asociados a esa empresa</returns>
        public List<Entidad> consultarListaDeContactosJuridico(Entidad parametro)
        {
            FabricaEntidades laFabrica = new FabricaEntidades();
            List<Entidad> laLista = new List<Entidad>();
            Contacto elContacto;
            Telefono elTelefono;
            List<Parametro> parametros = new List<Parametro>();

            try
            {
                Parametro parametroStored = new Parametro(RecursoBDModulo2.ParamIDClienteJur, SqlDbType.Int,
                    parametro.Id.ToString(), false);
                parametros.Add(parametroStored);
                DataTable resultado = EjecutarStoredProcedureTuplas(RecursoBDModulo2.ConsultarListaContactosJurID,
                    parametros);

                foreach (DataRow row in resultado.Rows)
                {
                    elContacto = (Contacto)laFabrica.ObtenerContacto();
                    elTelefono = (Telefono)laFabrica.ObtenerTelefono();
                    elContacto.Id = int.Parse(row[RecursoBDModulo2.AliasContactoID].ToString());
                    elContacto.Con_Nombre = row[RecursoBDModulo2.AliasContactoNombre].ToString();
                    elContacto.Con_Apellido = row[RecursoBDModulo2.AliasContactoApellido].ToString();
                    elContacto.ConCargo = row[RecursoBDModulo2.AliasCargoContacto].ToString();
                    elContacto.ConCedula = row[RecursoBDModulo2.AliasContactoCedula].ToString();
                    elTelefono.Codigo = row[RecursoBDModulo2.AliasCodigoTelefono].ToString();
                    elTelefono.Numero = row[RecursoBDModulo2.AliasNumTelefono].ToString();
                    elContacto.Con_Telefono = elTelefono;
                    laLista.Add(elContacto);
                }
                return laLista;
            }
            #region Catches
            catch (SqlException ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()),
                    ex);

                throw new ExcepcionesTotem.ExceptionTotemConexionBD(
                    RecursoGeneralDAO.Codigo_Error_BaseDatos,
                    RecursoGeneralDAO.Mensaje_Error_BaseDatos,
                    ex);
            }
            catch (ExcepcionesTotem.ExceptionTotemConexionBD ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()),
                    ex);

                throw ex;
            }
            catch (Exception ex)
            {
                Logger.EscribirError(Convert.ToString(this.GetType()),
                    ex);

                throw new ExceptionTotem(RecursoBDModulo2.CodigoExcepcionGeneral,
                    RecursoBDModulo2.MensajeExcepcionGeneral,
                    ex);
            }
            #endregion
        }
Esempio n. 7
0
        /// <summary>
        /// metodo que se encarga del evento del boton para agregar un cliente
        /// </summary>
        /// <returns></returns>
        public bool agregarCliente()
        {
            List<String> alfabeticos = new List<String>();
            List<String> alfanumericos = new List<String>();
            List<String> numericos = new List<String>();
            List<String> correo = new List<String>();

            alfabeticos.Add(vista.apellidoNatural);
            alfabeticos.Add(vista.nombreNatural);

            correo.Add(vista.correoCliente);
            alfanumericos.Add(vista.direccionCliente);

            numericos.Add(vista.cedulaNatural);
            numericos.Add(vista.codigoPostalCliente);
            numericos.Add(vista.codTelefono);
            numericos.Add(vista.telefonoCliente);
            Regex expresion = new Regex(@"[0-9]{1,9}(\.[0-9]{0,2})?$");
            Regex expresion2 = new Regex(@"\d{1,5}\s\w.\s(\b\w*\b\s){1,2}\w*\.");
            Regex expresion3 = new Regex(@"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z");

            if (Validaciones.ValidarCamposVacios(alfabeticos) && Validaciones.ValidarCamposVacios(alfabeticos) &&
                Validaciones.ValidarCamposVacios(numericos) && Validaciones.ValidarCamposVacios(correo))
            {
                if (Validaciones.ValidarCaracteresAlfabeticos(alfabeticos))
                {
                    if (Validaciones.ValidarExpresionRegular(correo, expresion3))
                    {
                        if (Validaciones.ValidarExpresionRegular(numericos, expresion))
                        {
                            FabricaEntidades fabrica = new FabricaEntidades();

                            try
                            {
                                Entidad laDireccion = fabrica.ObtenerDireccion(vista.comboPais.SelectedValue,
                                    vista.comboEstado.SelectedValue, vista.comboCiudad.SelectedValue,
                                    vista.direccionCliente, vista.codigoPostalCliente);
                                Entidad elTelefono = fabrica.ObtenerTelefono(vista.codTelefono, vista.telefonoCliente);
                                Entidad elCliente = fabrica.ObtenerClienteNatural(vista.nombreNatural,
                                    vista.apellidoNatural, vista.correoCliente, laDireccion, elTelefono,
                                    vista.cedulaNatural);
                                Comando<Entidad, bool> comando = FabricaComandos.CrearComandoAgregarClienteNatural();
                                if (comando.Ejecutar(elCliente))
                                    HttpContext.Current.Response.Redirect(RecursoInterfazM2.ListarClientes +
                                        RecursoInterfazM2.Codigo_Exito_Agregar);
                                return true;
                            }
                            catch (Exception ex)
                            {
                                vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                                vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                                vista.alerta = RecursoInterfazM2.Alerta_Html +
                                    ex.Message +
                                    RecursoInterfazM2.Alerta_Html_Final;
                                return false;
                            }
                        }
                        else
                        {
                            vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                            vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                            vista.alerta = RecursoInterfazM2.Alerta_Html +
                                RecursoInterfazM2.Alerta_Error_Numericos +
                            RecursoInterfazM2.Alerta_Html_Final;
                            return false;
                        }
                    }
                    else
                    {
                        vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                        vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                        vista.alerta = RecursoInterfazM2.Alerta_Html +
                            RecursoInterfazM2.Alerta_Error_Correo +
                        RecursoInterfazM2.Alerta_Html_Final;
                        return false;
                    }
                }
                else
                {
                    vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                    vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                    vista.alerta = RecursoInterfazM2.Alerta_Html +
                        RecursoInterfazM2.Alerta_Error_Alfabeticos +
                    RecursoInterfazM2.Alerta_Html_Final;
                    return false;
                }
            }
            else
            {
                vista.alertaClase = RecursoInterfazM2.Alerta_Clase_Error;
                vista.alertaRol = RecursoInterfazM2.Alerta_Rol;
                vista.alerta = RecursoInterfazM2.Alerta_Html +
                    RecursoInterfazM2.Alerta_Error_CamposVacios +
                RecursoInterfazM2.Alerta_Html_Final;
                return false;
            }
        }