Ejemplo n.º 1
0
        //(int? id)
        public ActionResult fcajaMasivaOKSINnumExp(string nro_expediente, DateTime? fecha_ini, DateTime? fecha_fin, Int32? id_dependencia, Int32? id_subserie, Int32? caja)
        {
            List<Caja> Cajas = new List<Caja>();
            var listaAgrupada = db.t_hoja_control.Include(h => h.p_dependencia).Where(h => h.fecha_expediente_ini != null && h.nro_expediente.Contains(nro_expediente))
                .GroupBy(x => new { x.p_dependencia.id, x.p_dependencia.codigo, x.p_dependencia.nombre, x.id_subserie, x.caja }).Select(c => new
                {
                    Id_dependencia = c.Key.id,
                    Cod_dependencia = c.Key.codigo,
                    Nom_dependencia = c.Key.nombre,
                    num_caja = c.Key.caja,
                    id_subserie = c.Key.id_subserie
                }).OrderBy(o => o.Cod_dependencia).ThenBy(c => c.num_caja).AsEnumerable();
            //FILTRO X DEPENDENCIA
            if (!String.IsNullOrEmpty(id_dependencia.ToString()))
            { listaAgrupada = listaAgrupada.Where(g => g.Id_dependencia == id_dependencia); }
            //FILTRO POR SUBSERIE
            if (!String.IsNullOrEmpty(id_subserie.ToString()))
            { listaAgrupada = listaAgrupada.Where(g => g.id_subserie == id_subserie); }
            //FILTRO X CAJA
            if (!String.IsNullOrEmpty(caja.ToString()))
            { listaAgrupada = listaAgrupada.Where(g => g.num_caja == caja); }

            foreach (var item2 in listaAgrupada)
            {
                Caja Caja = new Caja();

                Caja.CodDependencia = item2.Cod_dependencia;
                Caja.NomDependencia = item2.Nom_dependencia;
                Caja.NumCaja = item2.num_caja;
                //CONSULTA LOS DATOS DEL DOCUMENTO INICIAL - INICIAL - INICIAL - INICIAL - INICIAL - INICIAL
                var RSt_doc_fecha_ini = db.t_hoja_control.Where(d => d.caja == Caja.NumCaja && d.id_dependencia == item2.Id_dependencia && d.id_subserie == item2.id_subserie)
                                        .OrderBy(d => d.num_carpeta).ThenBy(d => d.fecha_expediente_ini).Take(1);
                foreach (var item in RSt_doc_fecha_ini)
                {
                    //CALCULA SI INCLUYE EL NÙMERO DE EXPEDIENTE INICIAL
                    var RSt_fuid_hc_exp = db.t_fuid_hc_exp.Where(d => d.id_hoja_control == item.id).Select(c => new
                    {
                        incluye_num_exp = c.incluye_num_exp,
                        fecha_expediente_ini = c.t_hoja_control.fecha_expediente_ini
                    }).OrderBy(d => d.fecha_expediente_ini).Take(1);
                    foreach (var itemf in RSt_fuid_hc_exp)
                    {
                        Caja.incluye_num_expInicio = itemf.incluye_num_exp;
                    }
                    //TRAE EL NUMERO DE EXPEDIENTE INICIAL
                    Caja.nro_expedienteInicio = item.nro_expediente;
                    Caja.NumCarpetaInicio = item.num_carpeta;
                    //CONSULTA DOCUMENTO INICIAL DE LA HOJA DE CONTROL
                    var RSt_doc_fecha_Ini = db.t_documento.Where(d => d.id_hoja_control == item.id && d.fecha_doc_anio > 0).OrderBy(d => d.fecha_doc_anio).ThenBy(d => d.fecha_doc_mes).ThenBy(d => d.fecha_doc_dia).ThenBy(d => d.folio_ini).Take(1);
                    foreach (var item3 in RSt_doc_fecha_Ini)
                    {
                        if (item3.fecha_doc_anio == null)
                        {
                            Caja.FechaInicio = "Sin Fecha";
                        }
                        else
                        {
                            var dia = item3.fecha_doc_dia.ToString();
                            if (dia.Length == 1) dia = "0" + dia;
                            var mes = item3.fecha_doc_mes.ToString();
                            if (mes.Length == 1) mes = "0" + mes;
                            Caja.FechaInicio = dia + "/" + mes + "/" + item3.fecha_doc_anio.ToString();
                        }
                    }
                }
                //CONSULTA LOS DATOS DELDOCUMENTO FINAL - FINAL - FINAL - FINAL - FINAL - FINAL - FINAL
                var RSt_doc_fecha_fin = db.t_documento.Include(d => d.t_hoja_control)
                                .Where(d => d.t_hoja_control.caja == Caja.NumCaja && d.t_hoja_control.id_dependencia == item2.Id_dependencia && d.t_hoja_control.id_subserie == item2.id_subserie)
                                .Select(c => new
                                {
                                    num_carpeta = c.t_hoja_control.num_carpeta,
                                    fecha_doc_anio = c.fecha_doc_anio,
                                    fecha_doc_mes = c.fecha_doc_mes,
                                    fecha_doc_dia = c.fecha_doc_dia,
                                    nro_expedienteFin = c.t_hoja_control.nro_expediente,
                                    id_hoja_control = c.t_hoja_control.id
                                }).OrderByDescending(h => h.num_carpeta).ThenByDescending(d => d.fecha_doc_anio).ThenByDescending(d => d.fecha_doc_mes).ThenByDescending(d => d.fecha_doc_dia).Take(1);
                foreach (var item in RSt_doc_fecha_fin)
                {
                    //CALCULA SI INCLUYE EL NÙMERO DE EXPEDIENTE INICIAL
                    var RSt_fuid_hc_exp = db.t_fuid_hc_exp.Where(d => d.id_hoja_control == item.id_hoja_control).Select(c => new
                    {
                        incluye_num_exp = c.incluye_num_exp,
                        fecha_expediente_ini = c.t_hoja_control.fecha_expediente_ini
                    }).OrderByDescending(d => d.fecha_expediente_ini).Take(1);
                    foreach (var itemf in RSt_fuid_hc_exp)
                    {
                        Caja.incluye_num_expFin = itemf.incluye_num_exp;
                    }
                    //TRAE EL NUMERO DE EXPEDIENTE FINAL
                    Caja.nro_expedienteFin = item.nro_expedienteFin;
                    Caja.NumCarpetaFin = item.num_carpeta;
                    //TRAE LA FECHA DEL DOCUMENTO FINAL
                    var dia = item.fecha_doc_dia.ToString();
                    if (dia.Length == 1) dia = "0" + dia;

                    var mes = item.fecha_doc_mes.ToString();
                    if (mes.Length == 1) mes = "0" + mes;

                    Caja.FechaFin = dia + "/" + mes + "/" + item.fecha_doc_anio.ToString();
                }

                Cajas.Add(Caja);
            }

            return View(Cajas.ToList()); //Json(ResultadoQuery, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
 public ActionResult fcajaMasiva(Caja Caja)
 {
     if (Session["usuario"] != null)
     {
         var usuario = Session["usuario"] as User;
         if (usuario.Perfil != "ADMIN" && usuario.Perfil != "CARGUE")
         {
             return RedirectToAction("Index", "Home");
         }
     }
     else return RedirectToAction("Login", "Login");
     if (Request.Form["nro_expediente"] == null || Request.Form["nro_expediente"] == "")
     {
         if (Request.Form["AgruparAnio"] == "true")
         {
             return RedirectToAction("fcajaMasivaOK", new { nro_expediente = Request.Form["nro_expediente"], fecha_ini = Request.Form["fecha_elaboracion_ini"], fecha_fin = Request.Form["fecha_elaboracion_fin"], id_dependencia = Request.Form["id_dependencia"], id_subserie = Request.Form["id_subserie"], caja = Request.Form["caja"] });
         }
         else {
             return RedirectToAction("fcajaMasivaOKSIN", new { nro_expediente = Request.Form["nro_expediente"], fecha_ini = Request.Form["fecha_elaboracion_ini"], fecha_fin = Request.Form["fecha_elaboracion_fin"], id_dependencia = Request.Form["id_dependencia"], id_subserie = Request.Form["id_subserie"], caja = Request.Form["caja"] });
         }
     }
     else
     {
         if (Request.Form["AgruparAnio"] == "true")
         {
             return RedirectToAction("fcajaMasivaOKnumExp", new { nro_expediente = Request.Form["nro_expediente"], fecha_ini = Request.Form["fecha_elaboracion_ini"], fecha_fin = Request.Form["fecha_elaboracion_fin"], id_dependencia = Request.Form["id_dependencia"], id_subserie = Request.Form["id_subserie"], caja = Request.Form["caja"] });
         }
         else
         {
             return RedirectToAction("fcajaMasivaOKSINnumExp", new { nro_expediente = Request.Form["nro_expediente"], fecha_ini = Request.Form["fecha_elaboracion_ini"], fecha_fin = Request.Form["fecha_elaboracion_fin"], id_dependencia = Request.Form["id_dependencia"], id_subserie = Request.Form["id_subserie"], caja = Request.Form["caja"] });
         }
     }
 }