public JsonResult ReporteV3(string fd, string fh) { double to = 0; DateTime dt1 = DateTime.Parse(fd); DateTime dt2 = DateTime.Now; if (fh != null && fh != "") { dt2 = DateTime.Parse(fh); } Session["FechaRI3"] = dt1; Session["FechaRF3"] = dt2; TimeSpan ts = dt2.Subtract(dt1); int nd = (int)ts.Days; nd = nd + 1; if (dt1 > dt2) return Json("Fecha inicio debe ser menor que fecha fin", JsonRequestBehavior.AllowGet); List<ReporteModel.ReporteVentas3Model> lr = new List<ReporteModel.ReporteVentas3Model>(); List<Eventos> lv2 = db.Eventos.ToList(); List<Eventos> lev = lv2.Where(r => r.estado == "Activo" && r.fecha_inicio>=dt1.Date && r.fecha_inicio<=dt2.Date).ToList(); for (int i = 0; i < lev.Count; i++) { int ce = lev[i].codigo; List<Funcion> lf = db.Funcion.Where(c => c.codEvento == ce && c.estado == "ACTIVO").ToList(); for (int k = 0; k < lf.Count; k++) { ReporteModel.ReporteVentas3Model r = new ReporteModel.ReporteVentas3Model(); r.codigo = lev[i].codigo; r.nombre = lev[i].nombre; r.organizador = db.Organizador.Find(lev[i].idOrganizador).nombOrg; int cf=lf[k].codFuncion; double total = 0; int totale = 0; List<VentasXFuncion> lvxf = db.VentasXFuncion.Where(c => c.codFuncion == cf).ToList(); DateTime di = dt1; DateTime dat = di.Date; for (int j = 0; j < lvxf.Count; j++) { if (lvxf[j].cantEntradas > 0) { totale += (int)lvxf[j].cantEntradas; total += (double)lvxf[j].total; } } r.total = total; r.funcion = db.Funcion.Find(lf[k].codFuncion).fecha.Value.ToString("dd/MM/yyyy") + " - " + db.Funcion.Find(lf[k].codFuncion).horaIni.Value.ToString(@"hh\:mm\:ss"); r.total = total; r.cant = totale; to += total; lr.Add(r); } } Session["ReporteVentasTotal3"] = lr; Session["ReporteTotal3"] = to; return Json("Reporte Generado", JsonRequestBehavior.AllowGet); }
public JsonResult ReporteV3(string fd, string fh) { double to = 0; DateTime dt1 = DateTime.Parse(fd); DateTime dt2 = DateTime.Parse(fh); TimeSpan ts = dt2.Subtract(dt1); int nd = (int)ts.Days; nd = nd + 1; List<ReporteModel.ReporteVentas3Model> lr = new List<ReporteModel.ReporteVentas3Model>(); List<Eventos> lev = db.Eventos.ToList(); for (int i = 0; i < lev.Count; i++) { ReporteModel.ReporteVentas3Model r = new ReporteModel.ReporteVentas3Model(); r.codigo = lev[i].codigo; r.nombre = lev[i].nombre; r.organizador = db.Organizador.Find(lev[i].idOrganizador).nombOrg; int ce = lev[i].codigo; List<Funcion> lf = db.Funcion.Where(c => c.codEvento == ce).ToList(); for (int k = 0; k < lf.Count; k++) { double total = 0; int totale = 0; // DateTime di = dt1; // for (int j = 0; j < nd; j++) // { // List<Ventas> lven = db.Ventas.Where(c => c.fecha == di && c.Estado == "Pagado").ToList(); // for (int t = 0; t < lven.Count; t++) // { // total += (double)lven[t].MontoTotalSoles; // } // di = di.AddDays(1); // } // r.total = total; r.funcion = db.Funcion.Find(lf[k].codFuncion).horaIni.Value.ToString(@"hh\:mm\:ss"); ; r.total = total; r.cant = totale; to += total; lr.Add(r); } } Session["ReporteVentasTotal3"] = lr; Session["ReporteTotal3"] = to; return Json("Reporte Generado", JsonRequestBehavior.AllowGet); }