public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { ValueProviderResult value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); if (value == null) { return(null); } if (string.IsNullOrEmpty(value.AttemptedValue)) { return(null); } var listaId = value.AttemptedValue.Split(','); var lista = new List <Salario_CostoProduccion>(); foreach (var id in listaId) { int entityId; if (!int.TryParse(id, out entityId)) { return(null); } var entity = new PvraDataEntities().CostoProducciones.AsNoTracking().FirstOrDefault(p => p.Id == entityId); lista.Add(entity); } return(lista); }
public void CargarProducto(EntradaProductos producto) { var db = new PvraDataEntities(); Clear(); _index = producto.Id; var prodConfecc = new ProductoConfeccionado() { Fecha = producto.Fecha, ColorId = producto.ColorId, Cantidad = producto.Cantidad, Id = producto.Id, Observacion = producto.Observacion, ProductoId = producto.ProductoId }; foreach (var m in producto.ProductoConfeccionadoInventarioMaterial) { prodConfecc.AgregarMaterial(new MaterialesUtilizados() { Cantidad = m.Cantidad, InvertarioMaterialesId = m.InvertarioMateriasPrimasId, InvertarioMateriales = db.InvertarioMateriasPrimas.Find(m.InvertarioMateriasPrimasId) }); } foreach (var c in producto.Salario_CostoProduccion) { prodConfecc.CargarCosto(new CostoProduccion() { Fecha = c.Fecha, ConceptoCostoId = c.ConceptoCostoId, ConceptoCosto = db.ConceptoCosto.Find(c.ConceptoCostoId), Id = c.Id, Importe = c.Importe, TrabajadorPersonaId = c.TrabajadorPersonaId, Trabajador = db.Trabajadores.Find(c.TrabajadorPersonaId) }); } _productoConfeccionados.Add(_index, prodConfecc); }
public MaterialesUtilizados(PeriodoModel periodo) { InitializeComponent(); var db = new PvraDataEntities(); var materiales = from m in db.SalidaMateriales where m.Fecha >= periodo.FechaInicio && m.Fecha <= periodo.FechaFin group m by m.InvertarioMateriales.Material into pGroup select new { Material = pGroup.Key, Colores = from c in pGroup group c by c.InvertarioMateriales.Color into cGroup select new { Color = cGroup.Key, Cantidad = cGroup.Sum(u => u.Cantidad), Importe = cGroup.Sum(p => p.InvertarioMateriales.Precio * p.Cantidad) } }; var result = new List <MaterialModel>(); foreach (var p in materiales) { foreach (var c in p.Colores) { result.Add(new MaterialModel() { Material = p.Material.DescripcionCompleta + " Color: " + c.Color.DescricionCompleta, Cantidad = c.Cantidad, Importe = c.Importe }); } } periodoLabel.Text = "Desde: " + periodo.FechaInicio.ToShortDateString() + " hasta: " + periodo.FechaFin.ToShortDateString(); DataSource = result; this.materiaPrimaCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Material") }); this.cantidadCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Cantidad") }); this.importeCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Importe") }); totalCantidadCell.Text = result.Sum(i => i.Cantidad).ToString(); totalImporteCell.Text = result.Sum(i => i.Importe).ToString(); }
public SalarioPorTrabajador(PeriodoModel periodo) { InitializeComponent(); var db = new PvraDataEntities(); var trabajadores = from m in db.CostoProducciones where m.Fecha >= periodo.FechaInicio && m.Fecha <= periodo.FechaFin group m by m.Persona_Trabajador into pGroup select new { Trabajador = pGroup.Key, Trabajos = from c in pGroup group c by c.ConceptoCosto into cGroup select new { Trabajo = cGroup.Key, Importe = cGroup.Sum(u => u.Importe) } }; var result = new List <TrabajadorProveedorModel>(); foreach (var p in trabajadores) { var lista = new List <TrabajoModel>(); foreach (var m in p.Trabajos) { lista.Add(new TrabajoModel() { Trabajo = m.Trabajo.Nombre, Importe = m.Importe }); } result.Add(new TrabajadorProveedorModel() { Trabajador = p.Trabajador.NombreApellidos, Trabajos = lista }); } periodoLabel.Text = "Desde: " + periodo.FechaInicio.ToShortDateString() + " hasta: " + periodo.FechaFin.ToShortDateString(); DataSource = result; xrSubreport1.ReportSource = new TrabajoSubReport(); this.proveedorLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Trabajador") }); }
public CostoDeProductosEnPeriodo(PeriodoModel periodo) { InitializeComponent(); var db = new PvraDataEntities(); var productos = from v in db.EntradaProductos where v.Fecha >= periodo.FechaInicio && v.Fecha <= periodo.FechaFin group v by v.Producto into vGroup select new { Producto = vGroup.Key, Colores = from c in vGroup group c by c.Color into cGroup select new { Color = cGroup.Key, Cantidad = cGroup.Sum(p => p.Cantidad), Costo = cGroup.Sum(p => p.Importe) } }; var result = new List <CostoProductoModel>(); foreach (var p in productos) { result.AddRange(p.Colores.Select(c => new CostoProductoModel() { Producto = p.Producto.DescripcionCompleta + " Color: " + c.Color.DescricionCompleta, Cantidad = c.Cantidad, Costo = c.Costo })); } periodoLabel.Text = "Desde: " + periodo.FechaInicio.ToShortDateString() + " hasta: " + periodo.FechaFin.ToShortDateString(); DataSource = result.ToList(); this.productoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Producto") }); this.cantidadCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Cantidad") }); this.costoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Costo") }); totalCantidadCell.Text = result.Sum(p => p.Cantidad).ToString(); totalCostoCell.Text = result.Sum(p => p.Costo).ToString(); }
// // GET: /Reportes/GananciaMensual public ActionResult GananciaMensual() { var db = new PvraDataEntities(); var iniY = db.CompraMateriales.Min(f => f.Fecha); var finY = db.Ventas.Max(f => f.Fecha); var years = new List <dynamic>(); for (int i = iniY.Year; i <= finY.Year; i++) { years.Add(new { year = i }); } ViewBag.Year = new SelectList(years, "year", "year"); return(View("GananciaYear")); }
public JsonResult CheckUserName(string userName, string id = "") { var users = new ApplicationDbContext().Users; var db = new PvraDataEntities(); var result = false; if (id == "") { var item = users.FirstOrDefault(i => i.UserName.ToLower() == userName.ToLower()); if (item == null) { result = true; } } else { var item = users.FirstOrDefault(i => i.UserName.ToLower() == userName.ToLower() && i.Id != id); if (item == null) { result = true; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public VentasPorTrabajador(PeriodoModel periodo) { InitializeComponent(); var db = new PvraDataEntities(); var productos = from s in db.Ventas where s.Fecha >= periodo.FechaInicio && s.Fecha <= periodo.FechaFin group s by s.Persona_Trabajador into sGroup select new { Trabajador = sGroup.Key, Cantidad = sGroup.Sum(p => p.Cantidad), Costo = sGroup.Sum(p => p.Importe) }; DataSource = productos.ToList(); periodoLabel.Text = "Desde: " + periodo.FechaInicio.ToShortDateString() + " hasta " + periodo.FechaFin.ToShortDateString(); this.productoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Trabajador.NombreApellidos") }); this.cantidadCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Cantidad") }); this.importeCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Costo") }); totalCantidadCell.Text = productos.Sum(p => p.Cantidad).ToString(); importeTotalCell.Text = productos.Sum(p => p.Costo).ToString(); }
public MaterialesPorProveedor(PeriodoModel periodo) { InitializeComponent(); var db = new PvraDataEntities(); var materiales = from m in db.CompraMateriales where m.Fecha >= periodo.FechaInicio && m.Fecha <= periodo.FechaFin group m by m.Persona_Proveedor into pGroup select new { Proveedor = pGroup.Key, Materiales = from mat in pGroup group mat by mat.Material into mGroup select new { Material = mGroup.Key, Colores = from c in mGroup group c by c.Color into cGroup select new { Color = cGroup.Key, Cantidad = cGroup.Sum(u => u.Cantidad), Importe = cGroup.Sum(u => u.Importe) } } }; var result = new List <MaterialProveedorModel>(); foreach (var p in materiales) { foreach (var m in p.Materiales) { var lista = new List <MaterialModel>(); foreach (var c in m.Colores) { lista.Add(new MaterialModel() { Material = m.Material.DescripcionCompleta + " Color: " + c.Color.DescricionCompleta, Cantidad = c.Cantidad, Importe = c.Importe }); } result.Add(new MaterialProveedorModel() { Proveedor = p.Proveedor.NombreApellidos, Materiales = lista }); } } periodoLabel.Text = "Desde: " + periodo.FechaInicio.ToShortDateString() + " hasta: " + periodo.FechaFin.ToShortDateString(); DataSource = result; xrSubreport1.ReportSource = new MaterialesSubReport(); this.proveedorLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "Proveedor") }); }
public static IList <GraficoModelView> GetVentasCosto() { var series = new string[] { "Ventas", "Gastos" }; var meses = new string[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; var valores = new Dictionary <string, decimal[]>(); var db = new PvraDataEntities(); var ventas = from v in db.Ventas where v.Fecha.Year == DateTime.Now.Year group v by v.Fecha.Month into vGroup select new { Mes = vGroup.Key, Importe = vGroup.Sum(u => u.Importe) }; var salarios = from s in db.Salario where s.Fecha.Year == DateTime.Now.Year group s by s.Fecha.Month into sGroup select new { Mes = sGroup.Key, Importe = sGroup.Sum(u => u.Importe) }; var compras = from v in db.CompraMateriales where v.Fecha.Year == DateTime.Now.Year group v by v.Fecha.Month into vGroup select new { Mes = vGroup.Key, Importe = vGroup.Sum(u => u.Importe) }; var gastos = from s in salarios join c in compras on s.Mes equals c.Mes select new { Mes = c.Mes, Importe = s.Importe + c.Importe }; valores.Add(series[0], new decimal[12]); valores.Add(series[1], new decimal[12]); foreach (var g in gastos) { valores[series[1]][g.Mes - 1] = g.Importe; } foreach (var v in ventas) { valores[series[0]][v.Mes - 1] = v.Importe; } var result = new List <GraficoModelView>(); foreach (string s in series) { for (int i = 0; i < meses.Length; i++) { result.Add(new GraficoModelView() { Mes = meses[i], Serie = s, Valor = valores[s][i] }); } } return(result); }