Example #1
0
 public bool actualizarPeriodo(int id, string nombre, DateTime fechainicio, DateTime fechafin)
 {
     using (MERSembrarDataContext bd = new MERSembrarDataContext())
     {
         try
         {
             if (fechainicio < fechafin)
             {
                 if (nombre != "")
                 {
                     PERIODO reu = bd.PERIODO.First(r => r.IDPERIODO == id);
                     reu.FECHAFINPERIODO    = fechainicio;
                     reu.FECHAINICIOPERIODO = fechafin;
                     reu.NOMBREPERIODO      = nombre;
                     bd.SubmitChanges();
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
         catch
         {
             return(false);
         }
     }
 }
Example #2
0
 public bool ingresarPeriodoConFechas(clsNPeriodo objPeriodo)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             if (objPeriodo.FECHAINICIOPERIODO < objPeriodo.FECHAFINPERIODO)
             {
                 PERIODO p = new PERIODO();
                 p.NOMBREPERIODO      = objPeriodo.NOMBREPERIODO.ToUpper();
                 p.IDTIPOPERIODO      = 1;
                 p.FECHAINICIOPERIODO = objPeriodo.FECHAINICIOPERIODO;
                 p.FECHAFINPERIODO    = objPeriodo.FECHAFINPERIODO;
                 p.ESTADOPERIODO      = objPeriodo.ACTIVO;
                 bd.PERIODO.InsertOnSubmit(p);
                 bd.SubmitChanges();
                 trans.Complete();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Example #3
0
 public bool ingresarPeriodo(clsNPeriodo objPeriodo)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             if (objPeriodo.NOMBREPERIODO != "")
             {
                 PERIODO p = new PERIODO();
                 p.NOMBREPERIODO      = objPeriodo.NOMBREPERIODO.ToUpper();
                 p.IDTIPOPERIODO      = 1;
                 p.FECHAINICIOPERIODO = DateTime.Now.Date;
                 p.FECHAFINPERIODO    = null;
                 p.ESTADOPERIODO      = true;
                 bd.PERIODO.InsertOnSubmit(p);
                 bd.SubmitChanges();
                 trans.Complete();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Example #4
0
        public string GuardarModificarPeriodo(PERIODO model)
        {
            using (ASIS_PRODEntities entities = new ASIS_PRODEntities())
            {
                string Respuesta = string.Empty;
                var    poPeriodo = entities.PERIODO.FirstOrDefault(x =>
                                                                   x.IdPeriodo == model.IdPeriodo);

                if (poPeriodo != null)
                {
                    poPeriodo.Descripcion             = model.Descripcion.ToUpper();
                    poPeriodo.Estado                  = model.Estado;
                    poPeriodo.FechaDesde              = model.FechaDesde;
                    poPeriodo.FechaHasta              = model.FechaHasta;
                    poPeriodo.FechaModificacionLog    = DateTime.Now;
                    poPeriodo.UsuarioModificacionLog  = model.UsuarioIngresoLog;
                    poPeriodo.TerminalModificacionLog = model.TerminalIngresoLog;
                }
                else
                {
                    entities.PERIODO.Add(model);
                }
                entities.SaveChanges();
                Respuesta = clsAtributos.MsjRegistroGuardado;
                return(Respuesta);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PERIODO pERIODO = db.PERIODO.Find(id);

            db.PERIODO.Remove(pERIODO);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #6
0
        private PERIODO getPeriodById(int periodId)
        {
            bienestarEntities db = new bienestarEntities();

            PERIODO period = db.PERIODOes.Single(a => a.PRDCODIGOI == periodId);

            return(period);
        }
 public ActionResult Edit([Bind(Include = "cod_per,des_per,fei_per,fef_per")] PERIODO pERIODO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pERIODO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pERIODO));
 }
 public ActionResult Edit([Bind(Include = "NUMPERIODO,DEBE_,FIN_PERIODO")] PERIODO pERIODO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pERIODO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pERIODO));
 }
Example #9
0
        public bool ingresaPersonaFamilia(List <clsasignarfamilia> lista, clsRepresentante repre)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    REPRESENTANTE r = new REPRESENTANTE();
                    r.IDPERSONA = repre.IDPERSONA;
                    bd.REPRESENTANTE.InsertOnSubmit(r);
                    bd.SubmitChanges();

                    PERIODO actualFamilia = new PERIODO();
                    actualFamilia.FECHAINICIOPERIODO = DateTime.Now;
                    actualFamilia.IDTIPOPERIODO      = 2;
                    actualFamilia.NOMBREPERIODO      = "NOMBRE";
                    bd.PERIODO.InsertOnSubmit(actualFamilia);
                    bd.SubmitChanges();

                    PERSONA_FAMILIA pf = new PERSONA_FAMILIA();
                    pf.IDFAMILIA = lista.First().CodigoFamilia;
                    PERIODO_PERSONA_FAMILIA ppf = new PERIODO_PERSONA_FAMILIA();
                    ppf.IDFAMILIA = lista.First().CodigoFamilia;
                    ppf.IDPERIODO = actualFamilia.IDPERIODO;
                    foreach (clsasignarfamilia relacion in lista)
                    {
                        pf.IDPERSONA = relacion.CodigoPersona;
                        bd.PERSONA_FAMILIA.InsertOnSubmit(pf);
                        bd.SubmitChanges();

                        ppf.IDPERSONA = relacion.CodigoPersona;

                        if (ppf.IDPERSONA == repre.IDPERSONA)
                        {
                            ppf.REPRESENTANTE = true;
                        }
                        else
                        {
                            ppf.REPRESENTANTE = false;
                        }
                        bd.PERIODO_PERSONA_FAMILIA.InsertOnSubmit(ppf);
                        bd.SubmitChanges();
                    }
                    trans.Complete();
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
                finally
                {
                    clsConexion.cerrarConexion();
                }
            }
        }
        public ActionResult Create([Bind(Include = "NUMPERIODO,DEBE_,FIN_PERIODO")] PERIODO pERIODO)
        {
            if (ModelState.IsValid)
            {
                db.PERIODO.Add(pERIODO);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pERIODO));
        }
        public ActionResult Create([Bind(Include = "cod_per,des_per,fei_per,fef_per")] PERIODO pERIODO)
        {
            if (ModelState.IsValid)
            {
                db.PERIODO.Add(pERIODO);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pERIODO));
        }
Example #12
0
        static clsNPeriodo transformar(PERIODO newPeriodo)
        {
            clsNPeriodo periodo = new clsNPeriodo();

            periodo.IDPeriodo          = newPeriodo.IDPERIODO;
            periodo.IDTIPOPERIODO      = int.Parse(newPeriodo.IDTIPOPERIODO.ToString());
            periodo.FECHAINICIOPERIODO = newPeriodo.FECHAINICIOPERIODO;
            periodo.FECHAFINPERIODO    = DateTime.Parse(newPeriodo.FECHAFINPERIODO.ToString());
            periodo.ACTIVO             = newPeriodo.ESTADOPERIODO;
            return(periodo);
        }
Example #13
0
    public int deletePeriodo(int periodoId)
    {
        int     result        = 0;
        PERIODO periodoDelete = obtainPeriodoById(periodoId);

        if (periodoDelete != null)
        {
            Datos.PERIODOes.Remove(periodoDelete);
            result = Datos.SaveChanges();
        }
        return(result);
    }
    private void cargarPeriodos()
    {
        PERIODO        periodo  = new PERIODO();
        List <PERIODO> periodos = periodo.obtainAllPeriodos();

        if (periodos != null && periodos.Count() > 0)
        {
            gridPeriodos.DataSource = periodos;
            gridPeriodos.DataBind();
        }
        limpiar();
    }
Example #15
0
        private void nuevo()
        {
            Response          response = new Response(true, "", "", "", null);
            bienestarEntities db       = new bienestarEntities();

            try
            {
                var becas = db.BE_BECA_SOLICITUD.Select(be => new
                {
                    be.CODIGO,
                    be.OBSERVACION,
                    be.APROBADA,
                    be.CEDULA,
                    BECA       = be.BE_BECA_TIPO.NOMBRE,
                    TIPOCODIGO = be.BE_BECA_TIPO.CODIGO,
                    NOMBRE     = be.DATOSPERSONALE.DTPNOMBREC.Trim() + " " + be.DATOSPERSONALE.DTPAPELLIC.Trim() + " " + be.DATOSPERSONALE.DTPAPELLIC2.Trim(),
                    be.BE_BECA_SOLICITUD_HISTORIAL,
                    NIVELCARRERA = new NivelCarrera(),
                    PERIODO      = new Periodo(),
                }).OrderBy(o => o.CODIGO).ToList();

                if (becas != null && becas.Count > 0)
                {
                    foreach (var beca in becas)
                    {
                        var temp = this.getNivelCarrera(beca.CEDULA);
                        beca.NIVELCARRERA.PERIODO       = temp.PERIODO;
                        beca.NIVELCARRERA.CODIGONIVEL   = temp.CODIGONIVEL;
                        beca.NIVELCARRERA.NIVEL         = temp.NIVEL;
                        beca.NIVELCARRERA.CODIGOCARRERA = temp.CODIGOCARRERA;
                        beca.NIVELCARRERA.CARRERA       = temp.CARRERA;
                        BE_BECA_SOLICITUD_HISTORIAL bsh = beca.BE_BECA_SOLICITUD_HISTORIAL.FirstOrDefault();
                        beca.PERIODO.ID = Utils.getPeriodo(bsh != null ? bsh.FECHA : DateTime.Now);
                        PERIODO period = getPeriodById(beca.PERIODO.ID);
                        beca.PERIODO.NOMBRE = period.PRDCODIGOI + " - " + period.PRDFECINIF.ToString("MMMM yyyy") + " - " + period.PRDFECFINF.ToString("MMMM yyyy");
                    }
                    int periodo = 0;
                    becas = becas.Where(w => (periodo == 0 || w.NIVELCARRERA.PERIODO == periodo) || true).ToList();

                    response = new Response(true, "", "", "", becas);
                }
                else
                {
                    response = new Response(false, "info", "Informaci\u00F3n", "No se han encontrado becas registradas", null);
                }
            }
            catch (Exception e)
            {
                response = new Response(false, "error", "Error", "Error al obtener las becas", e);
                writeResponseObject(response);
            }
        }
Example #16
0
    public PERIODO refreshPeriodo(int periodoId, String nombre, DateTime fechaInicio, DateTime fechaFin)
    {
        PERIODO periodo = null;

        PERIODO periodoRefresh = obtainPeriodoById(periodoId);

        if (periodoRefresh != null)
        {
            deletePeriodo(periodoId);
            periodo = addPeriodo(nombre, fechaInicio, fechaFin);
        }
        return(periodo);
    }
        // GET: Periodo/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PERIODO pERIODO = db.PERIODO.Find(id);

            if (pERIODO == null)
            {
                return(HttpNotFound());
            }
            return(View(pERIODO));
        }
    private void cargarPeriodos()
    {
        PERIODO        periodo  = new PERIODO();
        List <PERIODO> periodos = periodo.obtainAllPeriodos();

        if (periodos != null && periodos.Count() > 0)
        {
            ListItem item = null;
            foreach (PERIODO cu in periodos)
            {
                item = new ListItem(cu.NOMBRE, cu.PERIDODOID.ToString());
                cbPeriodo.Items.Add(item);
            }
        }
    }
Example #19
0
        public List <PERIODO> ConsultaPeriodos(PERIODO Filtros)
        {
            using (ASIS_PRODEntities entities = new ASIS_PRODEntities())
            {
                IEnumerable <PERIODO> poPeriodo = entities.PERIODO;
                if (Filtros != null && Filtros.IdPeriodo > 0)
                {
                    poPeriodo = poPeriodo.Where(x => x.IdPeriodo == Filtros.IdPeriodo);
                }
                if (Filtros != null && !string.IsNullOrEmpty(Filtros.Estado))
                {
                    poPeriodo = poPeriodo.Where(x => x.Estado == Filtros.Estado);
                }

                return(poPeriodo.ToList());
            }
        }
Example #20
0
 public bool cerrarPeriodo(clsNPeriodo objPeriodo)
 {
     using (TransactionScope trans = new TransactionScope())
     {
         try
         {
             PERIODO p = bd.PERIODO.Where(per => per.IDPERIODO == objPeriodo.IDPeriodo).First();
             p.FECHAFINPERIODO = DateTime.Now;
             p.ESTADOPERIODO   = false;
             bd.SubmitChanges();
             trans.Complete();
             return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
    protected void btnEliminarPeriodo_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarPeriodo(true);
        if (textoValidacion.Equals(""))
        {
            PERIODO periodo = new PERIODO();
            periodo.deletePeriodo(Convert.ToInt32(lblPeriodoId.Text));
            cargarPeriodos();

            lblSucess.Text = "Se elimino Correctamente el Periodo";
            pnlSucess.Visible = true;

        }
        else
        {
            lblError.Text = textoValidacion;
            pnlError.Visible = true;
        }
    }
    protected void btnEliminarPeriodo_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarPeriodo(true);

        if (textoValidacion.Equals(""))
        {
            PERIODO periodo = new PERIODO();
            periodo.deletePeriodo(Convert.ToInt32(lblPeriodoId.Text));
            cargarPeriodos();

            lblSucess.Text    = "Se elimino Correctamente el Periodo";
            pnlSucess.Visible = true;
        }
        else
        {
            lblError.Text    = textoValidacion;
            pnlError.Visible = true;
        }
    }
Example #23
0
    public PERIODO addPeriodo(String nombre, DateTime fechaInicio, DateTime fechaFin)
    {
        PERIODO periodo = new PERIODO();

        try
        {
            periodo.PERIDODOID = 0;
            periodo.NOMBRE = nombre;
            periodo.FECHAINICIO = fechaInicio;
            periodo.FECHAFIN = fechaFin;

            Datos.PERIODOes.Add(periodo);
            Datos.SaveChanges();
        }
        catch (Exception ex)
        {
            string x = ex.Message;
        }

        return periodo;
    }
Example #24
0
    public PERIODO addPeriodo(String nombre, DateTime fechaInicio, DateTime fechaFin)
    {
        PERIODO periodo = new PERIODO();

        try
        {
            periodo.PERIDODOID  = 0;
            periodo.NOMBRE      = nombre;
            periodo.FECHAINICIO = fechaInicio;
            periodo.FECHAFIN    = fechaFin;

            Datos.PERIODOes.Add(periodo);
            Datos.SaveChanges();
        }
        catch (Exception ex)
        {
            string x = ex.Message;
        }

        return(periodo);
    }
    protected void btnEditarPeriodo_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarPeriodo(true);
        if (textoValidacion.Equals(""))
        {
            DateTime fechaInicio = Convert.ToDateTime(txtFechaInicio.Text);
            DateTime fechaFin = Convert.ToDateTime(txtFechaFin.Text);

            PERIODO periodo = new PERIODO();
            periodo.refreshPeriodo(Convert.ToInt32(lblPeriodoId.Text), txtNombrePeriodo.Text, fechaInicio, fechaFin);
            cargarPeriodos();

            lblSucess.Text = "Se edito Correctamente el Periodo";
            pnlSucess.Visible = true;

        }
        else
        {
            lblError.Text = textoValidacion;
            pnlError.Visible = true;
        }
    }
    protected void btnEditarPeriodo_Click(object sender, EventArgs e)
    {
        String textoValidacion = validarPeriodo(true);

        if (textoValidacion.Equals(""))
        {
            DateTime fechaInicio = Convert.ToDateTime(txtFechaInicio.Text);
            DateTime fechaFin    = Convert.ToDateTime(txtFechaFin.Text);

            PERIODO periodo = new PERIODO();
            periodo.refreshPeriodo(Convert.ToInt32(lblPeriodoId.Text), txtNombrePeriodo.Text, fechaInicio, fechaFin);
            cargarPeriodos();

            lblSucess.Text    = "Se edito Correctamente el Periodo";
            pnlSucess.Visible = true;
        }
        else
        {
            lblError.Text    = textoValidacion;
            pnlError.Visible = true;
        }
    }
    protected void btnGuardarPeriodo_Click(object sender, EventArgs e)
    {
        pnlError.Visible = false;
        pnlSucess.Visible = false;

        String textoValidacion = validarPeriodo(false);
        if (textoValidacion.Equals(""))
        {
            DateTime fechaInicio = Convert.ToDateTime(txtFechaInicio.Text);
            DateTime fechaFin = Convert.ToDateTime(txtFechaFin.Text);

            PERIODO periodo = new PERIODO();
            periodo = periodo.addPeriodo(txtNombrePeriodo.Text, fechaInicio, fechaFin);
            cargarPeriodos();
            lblSucess.Text = "Se creo Correctamente el Periodo";
            pnlSucess.Visible = true;
        }
        else
        {
            lblError.Text = textoValidacion;
            pnlError.Visible = true;
        }
    }
    protected void btnGuardarPeriodo_Click(object sender, EventArgs e)
    {
        pnlError.Visible  = false;
        pnlSucess.Visible = false;

        String textoValidacion = validarPeriodo(false);

        if (textoValidacion.Equals(""))
        {
            DateTime fechaInicio = Convert.ToDateTime(txtFechaInicio.Text);
            DateTime fechaFin    = Convert.ToDateTime(txtFechaFin.Text);

            PERIODO periodo = new PERIODO();
            periodo = periodo.addPeriodo(txtNombrePeriodo.Text, fechaInicio, fechaFin);
            cargarPeriodos();
            lblSucess.Text    = "Se creo Correctamente el Periodo";
            pnlSucess.Visible = true;
        }
        else
        {
            lblError.Text    = textoValidacion;
            pnlError.Visible = true;
        }
    }
Example #29
0
        public void exportExcelReport(string _carrera, string _nivel, string _beca, string _estado, int _rubro, int _periodo)
        {
            List <string[]> rows = new List <string[]>();

            string[] header = { "CEDULA", "NOMBRE", "CARRERA", "NIVEL", "TIPO BECA", "PORCENTAJE", "ESTADO", "RUBRO", "PERIODO" };

            try
            {
                bienestarEntities db = new bienestarEntities();
                var becas            = db.BE_BECA_SOLICITUD.Select(be => new
                {
                    be.CODIGO,
                    be.OBSERVACION,
                    be.APROBADA,
                    be.CEDULA,
                    BECA       = be.BE_BECA_TIPO.NOMBRE,
                    TIPOCODIGO = be.BE_BECA_TIPO.CODIGO,
                    NOMBRE     = be.DATOSPERSONALE.DTPNOMBREC.Trim() + " " + be.DATOSPERSONALE.DTPAPELLIC.Trim() + " " + be.DATOSPERSONALE.DTPAPELLIC2.Trim(),
                    be.BE_BECA_SOLICITUD_HISTORIAL,
                    NIVELCARRERA = new NivelCarrera(),
                    PERIODO      = new Periodo(),
                }).OrderBy(o => o.CODIGO).ToList();

                if (becas != null && becas.Count > 0)
                {
                    foreach (var beca in becas)
                    {
                        var temp = this.getNivelCarrera(beca.CEDULA);
                        beca.NIVELCARRERA.PERIODO       = temp.PERIODO;
                        beca.NIVELCARRERA.CODIGONIVEL   = temp.CODIGONIVEL;
                        beca.NIVELCARRERA.NIVEL         = temp.NIVEL;
                        beca.NIVELCARRERA.CODIGOCARRERA = temp.CODIGOCARRERA;
                        beca.NIVELCARRERA.CARRERA       = temp.CARRERA;
                        BE_BECA_SOLICITUD_HISTORIAL bsh = beca.BE_BECA_SOLICITUD_HISTORIAL.FirstOrDefault();
                        beca.PERIODO.ID = Utils.getPeriodo(bsh != null ? bsh.FECHA : DateTime.Now);
                        PERIODO period = getPeriodById(beca.PERIODO.ID);
                        beca.PERIODO.NOMBRE = period.PRDCODIGOI + " - " + period.PRDFECINIF.ToString("MMMM yyyy") + " - " + period.PRDFECFINF.ToString("MMMM yyyy");
                    }

                    becas = becas.Where(w =>
                                        (_carrera != "null" ? w.NIVELCARRERA.CARRERA == _carrera : true) &&
                                        (_nivel != "null" ? w.NIVELCARRERA.NIVEL == _nivel : true) &&
                                        (_beca != "null" ? w.BECA == _beca : true) &&
                                        (_estado != "null" ? (_estado == "Pendiente" ? w.APROBADA == 0 : _estado == "Procesando" ? w.APROBADA == 1 : _estado == "Aprobada" ? w.APROBADA == 2 : w.APROBADA == 3) : true) &&
                                        (_periodo != 0 ? w.PERIODO.ID == _periodo : true) &&
                                        ((w.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault() != null && _rubro != -1) ? w.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault().RUBRO == _rubro : true)
                                        ).ToList();
                }


                foreach (var beca in becas)
                {
                    string[] row = new string[9];
                    row[0] = beca.CEDULA;
                    row[1] = beca.NOMBRE;
                    row[2] = beca.NIVELCARRERA.CARRERA;
                    row[3] = beca.NIVELCARRERA.NIVEL;
                    row[4] = beca.BECA;
                    if (beca.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault() != null)
                    {
                        row[5] = beca.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault().OTORGADO + "%";
                        row[7] = beca.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault().RUBRO == 1 ? "Pensi\u00F3n" : beca.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault().RUBRO == 2 ? "Matr\u00EDcula" : beca.BE_BECA_SOLICITUD_HISTORIAL.LastOrDefault().RUBRO == 3 ? "Pensi\u00F3n y matr\u00EDcula" : "Ninguno";
                    }
                    row[6] = beca.APROBADA == 0 ? "Pendiente" : beca.APROBADA == 1 ? "Procesando" : beca.APROBADA == 2 ? "Aprobada" : "Rechazada";

                    PERIODO period = getPeriodById(beca.PERIODO.ID);
                    row[8] = period.PRDCODIGOI + " - " + period.PRDFECINIF.ToString("MMMM yyyy") + " - " + period.PRDFECFINF.ToString("MMMM yyyy");
                    rows.Add(row);
                }
            }
            catch (Exception e)
            {
                string[] row = new string[] { "Error al exportar becas... (" + e.ToString() + ")" };
                rows.Add(row);
            }

            // export data
            string response = Utils.MakeHtmlTable(header, rows);

            Utils.writeResponseExcel(response, "becas.xls");
        }
        public ActionResult Periodo(PERIODO model)
        {
            try
            {
                ViewBag.dataTableJS = "1";
                ViewBag.JavaScrip   = RouteData.Values["controller"] + "/" + RouteData.Values["action"];
                lsUsuario           = User.Identity.Name.Split('_');
                clsDPeriodo         = new clsDPeriodo();
                RespuestaGeneral Respuesta = new RespuestaGeneral();
                if (string.IsNullOrEmpty(model.Descripcion))
                {
                    Respuesta.Codigo  = 0;
                    Respuesta.Mensaje = "Ingrese un Codigo";
                    return(Json(Respuesta, JsonRequestBehavior.AllowGet));
                }
                if (string.IsNullOrEmpty(model.Descripcion))
                {
                    Respuesta.Codigo  = 0;
                    Respuesta.Mensaje = "Ingrese una Descripcion";
                    return(Json(Respuesta, JsonRequestBehavior.AllowGet));
                }
                if (model.FechaDesde > model.FechaHasta)
                {
                    Respuesta.Codigo  = 0;
                    Respuesta.Mensaje = "Fecha desde no puede ser mayor";
                    return(Json(Respuesta, JsonRequestBehavior.AllowGet));
                }
                if (clsDPeriodo.ValidarPeriodoFechaDesde(model.FechaDesde, model.FechaHasta, model.IdPeriodo))
                {
                    Respuesta.Codigo  = 0;
                    Respuesta.Mensaje = "Ya existe un periodo con ese rango de fechas";
                    return(Json(Respuesta, JsonRequestBehavior.AllowGet));
                }

                model.UsuarioIngresoLog = lsUsuario[0];
                model.FechaIngresoLog   = DateTime.Now;
                // model.EstadoRegistro = clsAtributos.EstadoRegistroActivo;
                model.TerminalIngresoLog = Request.UserHostAddress;
                string Mensaje = clsDPeriodo.GuardarModificarPeriodo(model);
                Respuesta.Codigo  = 1;
                Respuesta.Mensaje = Mensaje;
                return(Json(Respuesta, JsonRequestBehavior.AllowGet));
            }
            catch (DbEntityValidationException e)
            {
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;

                clsDError = new clsDError();
                lsUsuario = User.Identity.Name.Split('_');
                string Mensaje = clsDError.ControlError(lsUsuario[0], Request.UserHostAddress, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                        "Metodo: " + this.ControllerContext.RouteData.Values["action"].ToString(), null, e);
                return(Json(Mensaje, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.InternalServerError;

                clsDError = new clsDError();
                lsUsuario = User.Identity.Name.Split('_');
                string Mensaje = clsDError.ControlError(lsUsuario[0], Request.UserHostAddress, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                        "Metodo: " + this.ControllerContext.RouteData.Values["action"].ToString(), ex, null);
                return(Json(Mensaje, JsonRequestBehavior.AllowGet));
            }
        }
Example #31
0
        public bool modificarMiembrosFamilia(List <clsasignarfamilia> nuevaLista, clsRepresentante objRepresentante)
        {
            nuevaLista = nuevaLista.Distinct().ToList();
            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    bool existe = bd.REPRESENTANTE.Any(r => r.IDPERSONA == objRepresentante.IDPERSONA);
                    if (!existe)
                    {
                        REPRESENTANTE nuevoRep = new REPRESENTANTE();
                        nuevoRep.IDPERSONA = objRepresentante.IDPERSONA;
                        bd.REPRESENTANTE.InsertOnSubmit(nuevoRep);
                        bd.SubmitChanges();
                    }
                    PERIODO anterior = bd.PERIODO_PERSONA_FAMILIA.Where(ppf => ppf.IDFAMILIA == nuevaLista.First().CodigoFamilia&& ppf.PERIODO.ESTADOPERIODO == true && ppf.PERIODO.IDTIPOPERIODO == 2).Select(ppf => ppf.PERIODO).First();
                    anterior.FECHAFINPERIODO = DateTime.Now;
                    anterior.ESTADOPERIODO   = false;
                    bd.SubmitChanges();

                    PERIODO nuevoPeriodo = new PERIODO();
                    nuevoPeriodo.ESTADOPERIODO      = true;
                    nuevoPeriodo.IDTIPOPERIODO      = 2;
                    nuevoPeriodo.FECHAINICIOPERIODO = DateTime.Now;
                    nuevoPeriodo.NOMBREPERIODO      = nuevaLista.Select(n => n.NombreFamilia).First().ToUpper() + " - " + nuevoPeriodo.FECHAINICIOPERIODO.ToString().ToUpper();
                    bd.PERIODO.InsertOnSubmit(nuevoPeriodo);
                    bd.SubmitChanges();

                    foreach (clsasignarfamilia relacion in nuevaLista)
                    {
                        if (!bd.PERSONA_FAMILIA.Any(pf => pf.IDPERSONA == relacion.CodigoPersona && pf.IDFAMILIA == relacion.CodigoFamilia))
                        {
                            PERSONA_FAMILIA nuevaPF = new PERSONA_FAMILIA();
                            nuevaPF.IDFAMILIA = relacion.CodigoFamilia;
                            nuevaPF.IDPERSONA = relacion.CodigoPersona;
                            bd.PERSONA_FAMILIA.InsertOnSubmit(nuevaPF);
                        }

                        PERIODO_PERSONA_FAMILIA nuevaPPF = new PERIODO_PERSONA_FAMILIA();
                        nuevaPPF.IDPERSONA    = relacion.CodigoPersona;
                        nuevaPPF.IDFAMILIA    = relacion.CodigoFamilia;
                        nuevaPPF.IDPARENTEZCO = relacion.CodigoParentezco;
                        nuevaPPF.IDPERIODO    = nuevoPeriodo.IDPERIODO;
                        if (relacion.CodigoPersona == objRepresentante.IDPERSONA)
                        {
                            nuevaPPF.REPRESENTANTE = true;
                        }
                        else
                        {
                            nuevaPPF.REPRESENTANTE = false;
                        }
                        if (!bd.PERIODO_PERSONA_FAMILIA.Any(p => p.IDFAMILIA == nuevaPPF.IDFAMILIA && p.IDPERSONA == nuevaPPF.IDPERSONA && p.IDPERIODO == nuevaPPF.IDPERIODO))
                        {
                            bd.PERIODO_PERSONA_FAMILIA.InsertOnSubmit(nuevaPPF);
                        }


                        bool esMenor = bd.MENOREDAD.Any(men => men.IDPERSONA == relacion.CodigoPersona);
                        if (esMenor)
                        {
                            MENOREDAD menor = bd.MENOREDAD.Where(men => men.IDPERSONA == relacion.CodigoPersona).First();
                            menor.IDREPRESENTANTE = bd.REPRESENTANTE.Where(rep => rep.IDPERSONA == objRepresentante.IDPERSONA).First().IDREPRESENTANTE;
                        }
                    }
                    bd.SubmitChanges();
                    trans.Complete();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 private void cargarPeriodos()
 {
     PERIODO periodo = new PERIODO();
     List<PERIODO> periodos = periodo.obtainAllPeriodos();
     if (periodos != null && periodos.Count() > 0)
     {
         ListItem item = null;
         foreach (PERIODO cu in periodos)
         {
             item = new ListItem(cu.NOMBRE, cu.PERIDODOID.ToString());
             cbPeriodo.Items.Add(item);
         }
     }
 }
 private void cargarPeriodos()
 {
     PERIODO periodo = new PERIODO();
     List<PERIODO> periodos = periodo.obtainAllPeriodos();
     if (periodos != null && periodos.Count() > 0)
     {
         gridPeriodos.DataSource = periodos;
         gridPeriodos.DataBind();
     }
     limpiar();
 }