Exemplo n.º 1
0
        public ActionResult DeleteConfirmed(long id)
        {
            RHUt09_persona rHUt09_persona = db.RHUt09_persona.Find(id);

            db.RHUt09_persona.Remove(rHUt09_persona);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        // GET: Persona/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RHUt09_persona rHUt09_persona = db.RHUt09_persona.Find(id);

            if (rHUt09_persona == null)
            {
                return(HttpNotFound());
            }
            return(View(rHUt09_persona));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "idPersona,tipoPersoneria,nombreRepresentante,nombrePersona,apellidoPaterno,apellidoMaterno,numDocIdentidad,razonSocial,fecNacimiento,nombreVia,numVia,nombreZona,direccion01,direccion02,numTelefonico01,numTelefonico02,email01,email02,sexo,difunto,fecDefuncion,pathFoto,activo,fecRegistro,fecModificacion,fecEliminacion,idUsuario,idUsuarioModificar,idUsuarioEliminar,idVia,idZona,idTipoDocIdentidad,idDistrito,idEstadoCivil,obsvPersona")] RHUt09_persona rHUt09_persona)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rHUt09_persona).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idEstadoCivil      = new SelectList(db.RHUt05_estadoCivil, "idEstadoCivil", "descEstadoCivil", rHUt09_persona.idEstadoCivil);
     ViewBag.idTipoDocIdentidad = new SelectList(db.RHUt12_tipoDocIdentidad, "idTipoDocIdentidad", "codTipoDocIdentidad", rHUt09_persona.idTipoDocIdentidad);
     ViewBag.idDistrito         = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", rHUt09_persona.idDistrito);
     ViewBag.idVia  = new SelectList(db.UBIt04_via, "idVia", "descVia", rHUt09_persona.idVia);
     ViewBag.idZona = new SelectList(db.UBIt05_zona, "idZona", "descZona", rHUt09_persona.idZona);
     return(View(rHUt09_persona));
 }
Exemplo n.º 4
0
        //CAMBIAR DE ESTADO PERSONA
        public ActionResult Estado(long?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                RHUt09_persona rHUt09_persona = db.RHUt09_persona.Find(id);
                if (rHUt09_persona == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    if (rHUt09_persona.activo == false)
                    {
                        rHUt09_persona.activo = true;
                        //FECHA DE MODIFICACION DELETE
                        rHUt09_persona.fecModificacion = DateTime.Today;
                        db.Entry(rHUt09_persona).State = EntityState.Modified;
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        rHUt09_persona.activo = false;
                        //FECHA DE ELIMINACIÓN
                        rHUt09_persona.fecEliminacion  = DateTime.Today;
                        db.Entry(rHUt09_persona).State = EntityState.Modified;
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message + "";
                return(View("Error"));

                throw;
            }
        }
Exemplo n.º 5
0
        // GET: Persona/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RHUt09_persona rHUt09_persona = db.RHUt09_persona.Find(id);

            if (rHUt09_persona == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idEstadoCivil      = new SelectList(db.RHUt05_estadoCivil, "idEstadoCivil", "descEstadoCivil", rHUt09_persona.idEstadoCivil);
            ViewBag.idTipoDocIdentidad = new SelectList(db.RHUt12_tipoDocIdentidad, "idTipoDocIdentidad", "codTipoDocIdentidad", rHUt09_persona.idTipoDocIdentidad);
            ViewBag.idDistrito         = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", rHUt09_persona.idDistrito);
            ViewBag.idVia  = new SelectList(db.UBIt04_via, "idVia", "descVia", rHUt09_persona.idVia);
            ViewBag.idZona = new SelectList(db.UBIt05_zona, "idZona", "descZona", rHUt09_persona.idZona);
            return(View(rHUt09_persona));
        }
Exemplo n.º 6
0
        public ActionResult Create(RHUt09_persona objPersona, string validar, HttpPostedFileBase pathFoto = null, int idProvincia = 0, int idRegion = 0)
        {
            try
            {
                //DEFAULT DATA CREATE
                objPersona.difunto     = false;
                objPersona.activo      = true;
                objPersona.fecRegistro = DateTime.Today;
                objPersona.idUsuario   = "1";

                //VALIDATION OF VIEW
                var valorValidar = validar;

                if (objPersona.sexo != null)
                {
                    objPersona.sexo = objPersona.sexo.Substring(0, 1);
                }
                else
                {
                    objPersona.sexo = "N";
                }

                if (objPersona.idTipoDocIdentidad == 3)
                {
                    objPersona.tipoPersoneria = "J";
                }
                else
                {
                    objPersona.tipoPersoneria = "N";
                }

                if (ModelState.IsValid)
                {
                    if (validar == "2")
                    {
                        objPersona.sexo        = objPersona.sexo;
                        objPersona.difunto     = false;
                        objPersona.activo      = true;
                        objPersona.fecRegistro = DateTime.Today;
                        objPersona.idUsuario   = "1";
                        string idDistritot = objPersona.idDistrito + "";
                        db.RHUt09_persona.Add(objPersona);
                        db.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else if (validar == "1")
                    {
                        var idRegionFind1    = idRegion;
                        var idProvinciaFind1 = idProvincia;
                        var idDistrito1      = objPersona.idDistrito;
                        if (idRegionFind1 > 0)
                        {
                            ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion", idRegion);

                            ViewBag.idProvincia = new SelectList(db.UBIt02_provincia.Where(p => p.idRegion == idRegionFind1), "idProvincia", "nombreProvincia");
                            if (idProvinciaFind1 > 0)
                            {
                                ViewBag.idProvincia = new SelectList(db.UBIt02_provincia, "idProvincia", "nombreProvincia", idProvinciaFind1);

                                ViewBag.idDistrito = new SelectList(db.UBIt01_distrito.Where(p => p.idProvincia == idProvinciaFind1), "idDistrito", "nombreDistrito");
                                if (idDistrito1 > 0)
                                {
                                    List <SelectListItem> list_dists = new List <SelectListItem>();
                                    ViewBag.idDistrito = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", idDistrito1);;
                                }
                            }
                            else
                            {
                                List <SelectListItem> list_dists = new List <SelectListItem>();
                                ViewBag.idDistrito = list_dists;
                            }
                        }
                        else
                        {
                            ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion");
                            List <SelectListItem> provs = new List <SelectListItem>();
                            ViewBag.idProvincia = provs;
                            List <SelectListItem> list_dists = new List <SelectListItem>();
                            ViewBag.idDistrito = list_dists;
                        }

                        ViewBag.idVia              = new SelectList(db.UBIt04_via, "idVia", "descVia");
                        ViewBag.idZona             = new SelectList(db.UBIt05_zona, "idZona", "descZona");
                        ViewBag.idEstadoCivil      = new SelectList(db.RHUt05_estadoCivil, "idEstadoCivil", "descEstadoCivil", objPersona.idEstadoCivil);
                        ViewBag.idTipoDocIdentidad = new SelectList(db.RHUt12_tipoDocIdentidad, "idTipoDocIdentidad", "descTipoDocIdentidad", objPersona.idTipoDocIdentidad);
                        ViewBag.idDistrito         = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", objPersona.idDistrito);
                        ViewBag.idVia              = new SelectList(db.UBIt04_via, "idVia", "descVia", objPersona.idVia);
                        ViewBag.idZona             = new SelectList(db.UBIt05_zona, "idZona", "descZona", objPersona.idZona);
                        ViewBag.validar            = "2";

                        return(View(objPersona));
                    }
                }

                //WHEN THE MODEL ISN'T VALID
                if (validar == "1")
                {
                    ViewBag.validar = "0";
                }
                else
                {
                    ViewBag.validar = "2";
                }
                var idRegionFind    = idRegion;
                var idProvinciaFind = idProvincia;
                var idDistrito      = objPersona.idDistrito;
                if (idRegionFind > 0)
                {
                    ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion", idRegion);

                    ViewBag.idProvincia = new SelectList(db.UBIt02_provincia.Where(p => p.idRegion == idRegionFind), "idProvincia", "nombreProvincia");
                    if (idProvinciaFind > 0)
                    {
                        ViewBag.idProvincia = new SelectList(db.UBIt02_provincia, "idProvincia", "nombreProvincia", idProvinciaFind);

                        ViewBag.idDistrito = new SelectList(db.UBIt01_distrito.Where(p => p.idProvincia == idProvinciaFind), "idDistrito", "nombreDistrito");
                        if (idDistrito > 0)
                        {
                            List <SelectListItem> list_dists = new List <SelectListItem>();
                            ViewBag.idDistrito = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", idDistrito);;
                        }
                        else
                        {
                            List <SelectListItem> list_dists = new List <SelectListItem>();
                            ViewBag.idDistrito = list_dists;
                        }
                    }
                    else
                    {
                        List <SelectListItem> provs = new List <SelectListItem>();
                        ViewBag.idProvincia = provs;
                        List <SelectListItem> list_dists = new List <SelectListItem>();
                        ViewBag.idDistrito = list_dists;
                    }
                }
                else
                {
                    ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion");
                    List <SelectListItem> provs = new List <SelectListItem>();
                    ViewBag.idProvincia = provs;
                    List <SelectListItem> list_dists = new List <SelectListItem>();
                    ViewBag.idDistrito = list_dists;
                }

                ViewBag.idVia              = new SelectList(db.UBIt04_via, "idVia", "descVia");
                ViewBag.idZona             = new SelectList(db.UBIt05_zona, "idZona", "descZona");
                ViewBag.idEstadoCivil      = new SelectList(db.RHUt05_estadoCivil, "idEstadoCivil", "descEstadoCivil", objPersona.idEstadoCivil);
                ViewBag.idTipoDocIdentidad = new SelectList(db.RHUt12_tipoDocIdentidad, "idTipoDocIdentidad", "descTipoDocIdentidad", objPersona.idTipoDocIdentidad);
                //ViewBag.idDistrito = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", objPersona.idDistrito);
                ViewBag.idVia  = new SelectList(db.UBIt04_via, "idVia", "descVia", objPersona.idVia);
                ViewBag.idZona = new SelectList(db.UBIt05_zona, "idZona", "descZona", objPersona.idZona);

                //CLEAR MODELSTATE
                ModelState.Clear();
                return(View(objPersona));
            }
            catch (Exception e)
            {
                ViewBag.Error = e.Message + "";
                return(View("Error"));

                throw;
            }
        }
Exemplo n.º 7
0
        public ActionResult Create(RHUt09_persona objPersona, string validar, HttpPostedFileBase pathFoto = null, int idProvincia = 0, int idRegion = 0)
        {
            var valorValidar = validar;

            if (objPersona.sexo != null)
            {
                objPersona.sexo = objPersona.sexo.Substring(0, 1);
            }
            else
            {
                objPersona.sexo = "N";
            }


            if (ModelState.IsValid)
            {
                if (validar == "2")
                {
                    objPersona.sexo        = objPersona.sexo;
                    objPersona.difunto     = false;
                    objPersona.activo      = true;
                    objPersona.fecRegistro = DateTime.Today;
                    objPersona.idUsuario   = "1";
                    string idDistritot = objPersona.idDistrito + "";
                    objPersona.idVia         = 1;
                    objPersona.idZona        = 1;
                    objPersona.idVia         = 1;
                    objPersona.idEstadoCivil = 1;
                    db.RHUt09_persona.Add(objPersona);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else if (validar == "1")
                {
                    var idRegionFind1    = idRegion;
                    var idProvinciaFind1 = idProvincia;
                    var idDistrito1      = objPersona.idDistrito;
                    if (idRegionFind1 > 0)
                    {
                        ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion", idRegion);
                        if (idProvinciaFind1 > 0)
                        {
                            ViewBag.idProvincia = new SelectList(db.UBIt02_provincia, "idProvincia", "nombreProvincia", idProvinciaFind1);
                            if (idDistrito1 > 0)
                            {
                                List <SelectListItem> list_dists = new List <SelectListItem>();
                                ViewBag.idDistrito = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", idDistrito1);;
                            }
                            else
                            {
                                List <SelectListItem> list_dists = new List <SelectListItem>();
                                ViewBag.idDistrito = list_dists;
                            }
                        }
                        else
                        {
                            List <SelectListItem> provs = new List <SelectListItem>();
                            ViewBag.idProvincia = provs;
                            List <SelectListItem> list_dists = new List <SelectListItem>();
                            ViewBag.idDistrito = list_dists;
                        }
                    }
                    else
                    {
                        ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion");
                        List <SelectListItem> provs = new List <SelectListItem>();
                        ViewBag.idProvincia = provs;
                        List <SelectListItem> list_dists = new List <SelectListItem>();
                        ViewBag.idDistrito = list_dists;
                    }

                    ViewBag.idVia              = new SelectList(db.UBIt04_via, "idVia", "descVia");
                    ViewBag.idZona             = new SelectList(db.UBIt05_zona, "idZona", "descZona");
                    ViewBag.idEstadoCivil      = new SelectList(db.RHUt05_estadoCivil, "idEstadoCivil", "descEstadoCivil", objPersona.idEstadoCivil);
                    ViewBag.idTipoDocIdentidad = new SelectList(db.RHUt12_tipoDocIdentidad, "idTipoDocIdentidad", "descTipoDocIdentidad", objPersona.idTipoDocIdentidad);
                    ViewBag.idDistrito         = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", objPersona.idDistrito);
                    ViewBag.idVia              = new SelectList(db.UBIt04_via, "idVia", "descVia", objPersona.idVia);
                    ViewBag.idZona             = new SelectList(db.UBIt05_zona, "idZona", "descZona", objPersona.idZona);
                    ViewBag.validar            = "2";
                    return(View(objPersona));
                }
            }

            ///
            if (validar == "1")
            {
                ViewBag.validar = "0";
            }
            else
            {
                ViewBag.validar = "2";
            }
            var idRegionFind    = idRegion;
            var idProvinciaFind = idProvincia;
            var idDistrito      = objPersona.idDistrito;

            if (idRegionFind > 0)
            {
                //ViewBag.idRegion = new SelectList(db., "idRegion", "nombreRegion", idRegion);
                if (idProvinciaFind > 0)
                {
                    ViewBag.idProvincia = new SelectList(db.UBIt02_provincia, "idProvincia", "nombreProvincia", idProvinciaFind);
                    if (idDistrito > 0)
                    {
                        List <SelectListItem> list_dists = new List <SelectListItem>();
                        ViewBag.idDistrito = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", idDistrito);;
                    }
                    else
                    {
                        List <SelectListItem> list_dists = new List <SelectListItem>();
                        ViewBag.idDistrito = list_dists;
                    }
                }
                else
                {
                    List <SelectListItem> provs = new List <SelectListItem>();
                    ViewBag.idProvincia = provs;
                    List <SelectListItem> list_dists = new List <SelectListItem>();
                    ViewBag.idDistrito = list_dists;
                }
            }
            else
            {
                ViewBag.idRegion = new SelectList(db.UBIt03_region, "idRegion", "nombreRegion");
                List <SelectListItem> provs = new List <SelectListItem>();
                ViewBag.idProvincia = provs;
                List <SelectListItem> list_dists = new List <SelectListItem>();
                ViewBag.idDistrito = list_dists;
            }

            ViewBag.idVia              = new SelectList(db.UBIt04_via, "idVia", "descVia");
            ViewBag.idZona             = new SelectList(db.UBIt05_zona, "idZona", "descZona");
            ViewBag.idEstadoCivil      = new SelectList(db.RHUt05_estadoCivil, "idEstadoCivil", "descEstadoCivil", objPersona.idEstadoCivil);
            ViewBag.idTipoDocIdentidad = new SelectList(db.RHUt12_tipoDocIdentidad, "idTipoDocIdentidad", "descTipoDocIdentidad", objPersona.idTipoDocIdentidad);
            //ViewBag.idDistrito = new SelectList(db.UBIt01_distrito, "idDistrito", "nombreDistrito", objPersona.idDistrito);
            ViewBag.idVia  = new SelectList(db.UBIt04_via, "idVia", "descVia", objPersona.idVia);
            ViewBag.idZona = new SelectList(db.UBIt05_zona, "idZona", "descZona", objPersona.idZona);
            return(View(objPersona));
        }