Ejemplo n.º 1
0
        public ActionResult Create(String telefonoFijo, String telefonoCelular, String cedulaJuridica, String correo, string nombre_cliente, string username, string password,
                                   String telefonoFijo2, String telefonoCelular2, String correo2, String nombreCompleto, string cedula)
        {
            try
            {
                InformacionContacto informacionContacto            = new InformacionContacto(correo, telefonoFijo, telefonoCelular);
                Cliente             cliente                        = new Cliente(nombre_cliente, username, password);
                InformacionContacto informacionContactoResponsable = new InformacionContacto(correo2, telefonoFijo2, telefonoCelular2);
                ResponsableLegal    responsableLegal               = new ResponsableLegal(nombreCompleto, cedula, informacionContactoResponsable);
                responsableLegal.InformacionContacto = informacionContactoResponsable;
                Entidad entidad = new Entidad();
                entidad.CedulaJuridica      = cedulaJuridica;
                entidad.Cliente             = cliente;
                entidad.ResponsableLegal    = responsableLegal;
                entidad.InformacionContacto = informacionContacto;

                entidadDao.insertarEntidad(entidad);
                correoDao.generarCorreo(correo, username, password, nombreCompleto);

                return(RedirectToAction("Index"));
            }
            catch (MySqlException ex)
            {
                return(RedirectToAction("Error", "Entidad"));
            }
        }
Ejemplo n.º 2
0
        public List <Proveedor> getProveedorByName(string name)
        {
            List <Proveedor> list = new List <Proveedor>();

            using (MySqlConnection sqlCon = GetConnection())
            {
                sqlCon.Open();
                String query = "Select p.id_proveedor,p.nombre,p.identificacion, p.id_informacion_contacto, i.correo,i.telefonoFijo,i.telefonoCelular from " +
                               " proveedor p, informacion_contacto i where p.id_informacion_contacto= i.id_informacion_contacto AND p.nombre LIKE '" + name + "%';";
                MySqlCommand sqlSelect = new MySqlCommand(query, sqlCon);
                using (MySqlDataReader reader = sqlSelect.ExecuteReader())
                {
                    Proveedor           proveedor           = null;
                    InformacionContacto informacionContacto = null;
                    while (reader.Read())
                    {
                        proveedor                = new Proveedor();
                        proveedor.IdProveedor    = reader.GetInt32("id_proveedor");
                        proveedor.Nombre         = reader.GetString("nombre");
                        proveedor.Identificacion = reader.GetString("identificacion");
                        informacionContacto      = new InformacionContacto();
                        informacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contacto");
                        informacionContacto.Correo          = reader.GetString("correo");
                        informacionContacto.TelefonoFijo    = reader.GetString("telefonoFijo");
                        informacionContacto.TelefonoCelular = reader.GetString("telefonoCelular");

                        proveedor.InformacionContacto = informacionContacto;

                        list.Add(proveedor);
                    }
                    sqlCon.Close();
                }
            }
            return(list);
        }
        public async Task <IActionResult> PutInformacionContacto([FromRoute] int id, [FromBody] InformacionContacto informacionContacto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != informacionContacto.Id)
            {
                return(BadRequest());
            }

            _context.Entry(informacionContacto).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InformacionContactoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PostInformacionContacto([FromBody] InformacionContacto informacionContacto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.InformacionContacto.Add(informacionContacto);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetInformacionContacto", new { id = informacionContacto.Id }, informacionContacto));
        }
Ejemplo n.º 5
0
        public List <Entidad> getAllEntidades()
        {
            List <Entidad> list = new List <Entidad>();

            using (MySqlConnection sqlCon = GetConnection())
            {
                sqlCon.Open();
                String query = "Select e.id_entidad, e.id_cliente,e.cedulaJuridica,e.idResponsable_legal, e.id_informacion_contacto, i.correo,i.telefonoFijo,i.telefonoCelular, c.nombre_completo, c.username, c.password, e.idResponsable_legal,r.idResponsable_legal , r.nombreCompleto, r.cedula, r.id_informacion_contacto,ir.id_informacion_contacto AS id_informacion_contactoResponsable, ir.correo AS correoResponsable,ir.telefonoFijo AS telefonoFijoResponsable,ir.telefonoCelular AS telefonoCelularResponsable, r.idResponsable_legal from " +
                               "informacion_contacto ir,entidad e, informacion_contacto i, cliente c, responsable_legal r where e.id_informacion_contacto= i.id_informacion_contacto and c.id_cliente= e.id_cliente and e.idResponsable_legal = r.idResponsable_legal and r.id_informacion_contacto =ir.id_informacion_contacto;";
                MySqlCommand sqlSelect = new MySqlCommand(query, sqlCon);
                using (MySqlDataReader reader = sqlSelect.ExecuteReader())
                {
                    Entidad             entidad             = null;
                    InformacionContacto informacionContacto = null;
                    Cliente             cliente             = null;
                    ResponsableLegal    responsableLegal    = null;

                    while (reader.Read())
                    {
                        entidad                = new Entidad();
                        entidad.IdEntidad      = reader.GetInt32("id_entidad");
                        entidad.CedulaJuridica = reader.GetString("cedulaJuridica");
                        informacionContacto    = new InformacionContacto();
                        informacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contacto");
                        informacionContacto.Correo          = reader.GetString("correo");
                        informacionContacto.TelefonoFijo    = reader.GetString("telefonoFijo");
                        informacionContacto.TelefonoCelular = reader.GetString("telefonoCelular");
                        cliente                            = new Cliente();
                        cliente.IdCliente                  = reader.GetInt32("id_cliente");
                        cliente.Nombre_cliente             = reader.GetString("nombre_completo");
                        cliente.Username                   = reader.GetString("username");
                        cliente.Password                   = reader.GetString("password");
                        responsableLegal                   = new ResponsableLegal();
                        responsableLegal.Cedula            = reader.GetString("cedula");
                        responsableLegal.NombreCompleto    = reader.GetString("nombreCompleto");
                        responsableLegal.IdReponsableLegal = reader.GetInt32("idResponsable_legal");
                        responsableLegal.InformacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contactoResponsable");
                        responsableLegal.InformacionContacto.Correo          = reader.GetString("correoResponsable");
                        responsableLegal.InformacionContacto.TelefonoFijo    = reader.GetString("telefonoFijoResponsable");
                        responsableLegal.InformacionContacto.TelefonoCelular = reader.GetString("telefonoCelularResponsable");
                        entidad.InformacionContacto = informacionContacto;
                        entidad.Cliente             = cliente;
                        entidad.ResponsableLegal    = responsableLegal;
                        list.Add(entidad);
                    }
                    sqlCon.Close();
                }
            }
            return(list);
        }
Ejemplo n.º 6
0
        public ActionResult Crear(String telefonoFijo, String telefonoCelular, String correo, String nombre, String identificacion)
        {
            try
            {
                InformacionContacto informacionContacto = new InformacionContacto(correo, telefonoFijo, telefonoCelular);
                Proveedor           proveedor           = new Proveedor(identificacion, nombre, informacionContacto);
                proveedorDao.insertarProveedor(proveedor);

                return(RedirectToAction("Index"));
            }
            catch (MySqlException ex)
            {
                return(RedirectToAction("Error", "Proveedor"));
            }
        }
Ejemplo n.º 7
0
        public ActionResult Crear(String telefonoFijo, String telefonoCelular, String correo, String cedula
                                  , String nombre_completo, String username, String password)
        {
            try
            {
                PersonaDao          personaDao          = new PersonaDao();
                InformacionContacto informacionContacto = new InformacionContacto(correo, telefonoFijo, telefonoCelular);
                Cliente             cliente             = new Cliente(nombre_completo, username, password);
                Persona             persona             = new Persona(cliente, cedula, informacionContacto);
                personaDao.insertarPersona(persona);
                correoDao.generarCorreo(correo, username, password, nombre_completo);

                return(RedirectToAction("Index"));
            }
            catch (MySqlException ex)
            {
                return(RedirectToAction("Error", "Persona"));
            }
        }
Ejemplo n.º 8
0
        public List <Persona> getAllPersonas()
        {
            List <Persona> list = new List <Persona>();

            using (MySqlConnection sqlCon = GetConnection())
            {
                sqlCon.Open();
                String query = "Select p.id_cliente,p.cedula, p.id_informacion_contacto, i.correo, i.telefonoFijo, i.telefonoCelular, c.nombre_completo, c.username, c.password from " +
                               " persona p, informacion_contacto i, cliente c where p.id_informacion_contacto= i.id_informacion_contacto and p.id_cliente= c.id_cliente;";
                MySqlCommand sqlSelect = new MySqlCommand(query, sqlCon);
                using (MySqlDataReader reader = sqlSelect.ExecuteReader())
                {
                    Persona             persona             = null;
                    InformacionContacto informacionContacto = null;
                    Cliente             cliente             = null;

                    while (reader.Read())
                    {
                        persona             = new Persona();
                        persona.Cedula      = reader.GetString("cedula");
                        informacionContacto = new InformacionContacto();
                        informacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contacto");
                        informacionContacto.Correo          = reader.GetString("correo");
                        informacionContacto.TelefonoFijo    = reader.GetString("telefonoFijo");
                        informacionContacto.TelefonoCelular = reader.GetString("telefonoCelular");
                        cliente                     = new Cliente();
                        cliente.IdCliente           = reader.GetInt32("id_cliente");
                        cliente.Nombre_cliente      = reader.GetString("nombre_completo");
                        cliente.Username            = reader.GetString("username");
                        cliente.Password            = reader.GetString("password");
                        persona                     = new Persona();
                        persona.Cedula              = reader.GetString("cedula");
                        persona.InformacionContacto = informacionContacto;
                        persona.Cliente             = cliente;

                        list.Add(persona);
                    }
                    sqlCon.Close();
                }
            }
            return(list);
        }
Ejemplo n.º 9
0
        public List <Persona> getPersonaByNombre(string SearchString)
        {
            List <Persona>      personas            = new List <Persona>();
            Persona             persona             = null;
            InformacionContacto informacionContacto = null;
            Cliente             cliente             = null;

            using (MySqlConnection sqlCon = GetConnection())
            {
                sqlCon.Open();

                String query = "Select p.cedula, c.nombre_completo,p.id_informacion_contacto,c.id_cliente, c.username, c.password , i.correo, i.telefonoFijo,i.telefonoCelular from  persona p, cliente c, informacion_contacto i" +
                               " WHERE p.id_cliente= c.id_cliente AND p.id_informacion_contacto=i.id_informacion_contacto AND  nombre_completo like'" + SearchString + "%';";
                MySqlCommand sqlSelect = new MySqlCommand(query, sqlCon);
                using (MySqlDataReader reader = sqlSelect.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        persona             = new Persona();
                        persona.Cedula      = reader.GetString("cedula");
                        informacionContacto = new InformacionContacto();
                        informacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contacto");
                        informacionContacto.Correo          = reader.GetString("correo");
                        informacionContacto.TelefonoFijo    = reader.GetString("telefonoFijo");
                        informacionContacto.TelefonoCelular = reader.GetString("telefonoCelular");
                        cliente                     = new Cliente();
                        cliente.IdCliente           = reader.GetInt32("id_cliente");
                        cliente.Nombre_cliente      = reader.GetString("nombre_completo");
                        cliente.Username            = reader.GetString("username");
                        cliente.Password            = reader.GetString("password");
                        persona.InformacionContacto = informacionContacto;
                        persona.Cliente             = cliente;
                        personas.Add(persona);
                    }
                }
                sqlCon.Close();
            }
            return(personas);
        }
Ejemplo n.º 10
0
        public Persona getPersonaById(String id)
        {
            int                 idCliente           = 0;
            Persona             persona             = null;
            InformacionContacto informacionContacto = null;
            Cliente             cliente             = null;

            using (MySqlConnection sqlCon = GetConnection())
            {
                sqlCon.Open();

                String query = "Select p.cedula, c.nombre_completo,p.id_informacion_contacto,c.id_cliente, c.username, c.password , i.correo, i.telefonoFijo,i.telefonoCelular from  persona p, cliente c, informacion_contacto i" +
                               " where cedula ='" + id + "' and p.id_cliente= c.id_cliente and i.id_informacion_contacto= p.id_informacion_contacto";
                MySqlCommand sqlSelect = new MySqlCommand(query, sqlCon);
                using (MySqlDataReader reader = sqlSelect.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        persona             = new Persona();
                        persona.Cedula      = reader.GetString("cedula");
                        informacionContacto = new InformacionContacto();
                        informacionContacto.IdInformacionContacto = reader.GetInt32("id_informacion_contacto");
                        informacionContacto.Correo          = reader.GetString("correo");
                        informacionContacto.TelefonoFijo    = reader.GetString("telefonoFijo");
                        informacionContacto.TelefonoCelular = reader.GetString("telefonoCelular");
                        cliente                     = new Cliente();
                        cliente.IdCliente           = reader.GetInt32("id_cliente");
                        cliente.Nombre_cliente      = reader.GetString("nombre_completo");
                        cliente.Username            = reader.GetString("username");
                        cliente.Password            = reader.GetString("password");
                        persona.InformacionContacto = informacionContacto;
                        persona.Cliente             = cliente;
                    }
                }
                sqlCon.Close();
            }
            return(persona);
        }