public IHttpActionResult Putordenes(int id, ordenes ordenes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ordenes.id_Orden) { return(BadRequest()); } db.Entry(ordenes).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ordenesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public bool CargaOracle(List <ordenes> listaOracle) { try { foreach (var item in listaOracle) { if (db.ordenes.Where(x => x.Orden == item.Orden).FirstOrDefault() == null) { if (item.Orden != "") { ordenes ordenes = new ordenes(); ordenes.FechaAlta = item.FechaAlta; ordenes.Orden = item.Orden; ordenes.User = item.User; ordenes.StatusOrdenImpresa_Id = 1; db.ordenes.Add(ordenes); db.SaveChanges(); } } } return(true); } catch (Exception) { return(false); } }
public ActionResult DeleteConfirmed(int id) { ordenes ordenes = db.ordenes.Find(id); db.ordenes.Remove(ordenes); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <bool> CerrarOrdenSinGuia(string orden, string picker) { ordenes ordenes = db.ordenes.Where(x => x.Orden.Equals(orden)).FirstOrDefault(); ordenes.StatusOrdenImpresa_Id = 2; ordenes.Picker = picker; await db.SaveChangesAsync(); return(true); }
public ActionResult Create([Bind(Include = "id,FechaAlta,Orden,User,StatusOrdenImpresa_Id,Picker")] ordenes ordenes) { if (ModelState.IsValid) { db.ordenes.Add(ordenes); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ordenes)); }
public IHttpActionResult Getordenes(int id) { ordenes ordenes = db.ordenes.Find(id); if (ordenes == null) { return(NotFound()); } return(Ok(ordenes)); }
public IHttpActionResult Postordenes(ordenes ordenes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ordenes.Add(ordenes); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = ordenes.id_Orden }, ordenes)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ordenes ordenes = db.ordenes.Find(id); if (ordenes == null) { return(HttpNotFound()); } return(View(ordenes)); }
public IHttpActionResult Deleteordenes(int id) { ordenes ordenes = db.ordenes.Find(id); if (ordenes == null) { return(NotFound()); } db.ordenes.Remove(ordenes); db.SaveChanges(); return(Ok(ordenes)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ordenes ordenes = db.ordenes.Find(id); ViewBag.StatusOrdenImpresa_Id = new SelectList(db.statusordenimpresa, "id", "descripcion", ordenes.StatusOrdenImpresa_Id); if (ordenes == null) { return(HttpNotFound()); } return(View(ordenes)); }
public bool CerrarOrden(string orden, string picker) { try { ordenes ordenes = db.ordenes.Where(x => x.Orden.Contains(orden)).FirstOrDefault(); ordenes.StatusOrdenImpresa_Id = 3; ordenes.Picker = picker; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult Edit(ordenes ordenes) { ordenes ordenes1 = db.ordenes.Find(ordenes.id); if (ordenes1 != null) { ordenes1.StatusOrdenImpresa_Id = ordenes.StatusOrdenImpresa_Id; ordenes1.FechaAlta = ordenes.FechaAlta; ordenes1.Orden = ordenes.Orden; //Oracle ID ordenes1.User = ordenes.User; ordenes1.Picker = ordenes.Picker; db.SaveChanges(); return(Json("Correcto", JsonRequestBehavior.AllowGet)); } else { return(View(ordenes)); } }
public List <ordenes> listByOrden(string orden) { string query = "SELECT dbo.ordenes.id, dbo.ordenes.Orden, dbo.ordenes.[User], dbo.ordenes.StatusOrdenImpresa_Id, dbo.ordenes.FechaAlta, dbo.ordenes.Picker " + "FROM dbo.ordenes " + "WHERE dbo.ordenes.Orden LIKE '%' + @Orden + '%'"; var sqlQuery1 = db.ordenes.SqlQuery(query, new System.Data.SqlClient.SqlParameter("@Orden", orden)).ToList(); List <ordenes> list = new List <ordenes>(); foreach (var item in sqlQuery1) { ordenes ordenesTemp = new ordenes(); ordenesTemp.Orden = item.Orden; ordenesTemp.User = item.User; ordenesTemp.Descripcion = item.statusordenimpresa.descripcion; list.Add(ordenesTemp); } return(list); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ordenes ordenes = db.ordenes.Find(id); if (ordenes == null) { return(HttpNotFound()); } var detuser = db.detusuariosordenes.Where(x => x.Ordenes_Id == id).FirstOrDefault(); if (detuser != null) { ViewBag.Auditor = detuser.usuarios.nombre.ToUpper(); } var detalleOrden = db.detordenproductoshd.Where(x => x.Ordenes_Id == id).ToList(); List <detordenproductoshd> lista = new List <detordenproductoshd>(); foreach (var item in detalleOrden) { detordenproductoshd detordenproductoshd = new detordenproductoshd(); detordenproductoshd.cantidad = item.cantidad; detordenproductoshd.SKU = item.skus.Sku; detordenproductoshd.SKUDescripcion = item.skus.Descripcion; lista.Add(detordenproductoshd); } ViewBag.Detalle = lista; return(View(ordenes)); }
public List <detordenproductoshd> ListaDetallesByOrden(string orden) { try { List <detordenproductoshd> lista = new List <detordenproductoshd>(); ordenes ordenes = db.ordenes.Where(x => x.Orden.Contains(orden)).FirstOrDefault(); foreach (var item in db.detordenproductoshd.Where(x => x.Ordenes_Id == ordenes.id).ToList()) { detordenproductoshd detordenproductoshd = new detordenproductoshd(); detordenproductoshd.SKU = item.skus.Sku; detordenproductoshd.cantidad = item.cantidad; detordenproductoshd.CantidadSKUS = 0; lista.Add(detordenproductoshd); } return(lista); } catch (Exception) { return(null); } }
public ActionResult ObtenerOrdenes() { try { var Draw = Request.Form.GetValues("draw").FirstOrDefault(); var Start = Request.Form.GetValues("start").FirstOrDefault(); var Length = Request.Form.GetValues("length").FirstOrDefault(); var SortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][data]").FirstOrDefault(); var SortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); var orden = Request.Form.GetValues("columns[0][search][value]").FirstOrDefault(); var fechaRegistro = Request.Form.GetValues("columns[1][search][value]").FirstOrDefault(); var status = Request.Form.GetValues("columns[2][search][value]").FirstOrDefault(); int PageSize = Length != null?Convert.ToInt32(Length) : 0; int Skip = Start != null?Convert.ToInt32(Start) : 0; int TotalRecords = 0; List <ordenes> listaOrdenes = new List <ordenes>(); using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { con.Open(); string sql = "exec SP_ConsultaOrdenes_ParametrosOpcionales @orden, @fechaOrdenes, @idstatus"; var query = new SqlCommand(sql, con); if (orden != "") { query.Parameters.AddWithValue("@orden", orden); } else { query.Parameters.AddWithValue("@orden", DBNull.Value); } if (fechaRegistro != "") { DateTime date = Convert.ToDateTime(fechaRegistro); query.Parameters.AddWithValue("@fechaOrdenes", date); } else { query.Parameters.AddWithValue("@fechaOrdenes", DBNull.Value); } if (status == "" || status == "0") { query.Parameters.AddWithValue("@idstatus", DBNull.Value); } else { query.Parameters.AddWithValue("@idstatus", status); } using (var dr = query.ExecuteReader()) { while (dr.Read()) { // facturas var ordenes = new ordenes(); ordenes.id = Convert.ToInt32(dr["id"]); ordenes.Orden = dr["Orden"].ToString(); ordenes.Picker = dr["Picker"].ToString(); ordenes.Auditor = dr["nombre"].ToString().ToUpper(); ordenes.StatusString = dr["descripcion"].ToString().ToUpper(); ordenes.FechaAltaString = dr["FechaAlta"].ToString(); listaOrdenes.Add(ordenes); } } } if (!(string.IsNullOrEmpty(SortColumn) && string.IsNullOrEmpty(SortColumnDir))) { listaOrdenes = listaOrdenes.OrderBy(SortColumn + " " + SortColumnDir).ToList(); } TotalRecords = listaOrdenes.ToList().Count(); var NewItems = listaOrdenes.Skip(Skip).Take(PageSize == -1 ? TotalRecords : PageSize).ToList(); return(Json(new { draw = Draw, recordsFiltered = TotalRecords, recordsTotal = TotalRecords, data = NewItems }, JsonRequestBehavior.AllowGet)); } catch (Exception _ex) { Console.WriteLine(_ex.Message.ToString()); return(null); } }
public ActionResult Index() { DateTime fechaHoy = DateTime.Now.Date; ViewBag.ConteoOrdenesAbiertas = db.ordenes.Where(x => x.StatusOrdenImpresa_Id == 1 && x.FechaAlta > fechaHoy).Count(); ViewBag.ConteoOrdenesCerradas = db.ordenes.Where(x => x.StatusOrdenImpresa_Id > 1 && x.StatusOrdenImpresa_Id <4 && x.FechaAlta> fechaHoy).Count(); ViewBag.ConteoOrdenesBackOrder = db.ordenes.Where(x => x.StatusOrdenImpresa_Id == 4 && x.FechaAlta > fechaHoy).Count(); ViewBag.ConteoOrdenes = db.ordenes.Where(x => x.FechaAlta > fechaHoy).Count(); var toppickers = db.ordenes.Where(x => x.StatusOrdenImpresa_Id > 1 && x.FechaAlta > fechaHoy).GroupBy(x => x.Picker); var topauditores = db.detusuariosordenes.Where(x => x.ordenes.StatusOrdenImpresa_Id > 1 && x.ordenes.FechaAlta > fechaHoy).GroupBy(x => x.usuarios.nombre); var piezas = db.detordenproductoshd.Where(x => x.ordenes.FechaAlta > fechaHoy); var errores = db.erroresordenes.Where(x => x.ordenes.FechaAlta > fechaHoy); List <ordenes> listaPickers = new List <ordenes>(); List <ordenes> listaAuditores = new List <ordenes>(); foreach (var item in toppickers) { if (item.Key != null) { ordenes ordenes = new ordenes(); decimal qty = (int)piezas.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Sum(x => x.cantidad); var porcentajeRounded = Math.Round(qty, 2); ordenes.CantidadPiezas = (int)porcentajeRounded; if (errores != null) { ordenes.CantidadErrores = (int)errores.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Count(); } else { ordenes.CantidadErrores = 0; } ordenes.Picker = item.Key.ToUpper(); ordenes.Cantidad = item.Count(); listaPickers.Add(ordenes); } } foreach (var item in topauditores) { if (item.Key != null) { ordenes ordenes = new ordenes(); ordenes.Auditor = item.Key.ToUpper(); ordenes.Cantidad = item.Count(); var ordenesTemp = from dt in db.detusuariosordenes where dt.usuarios.nombre.Equals(item.Key) && dt.ordenes.FechaAlta > fechaHoy select dt.Ordenes_Id; var detalleCantidad = from dt in db.detordenproductoshd where ordenesTemp.Contains(dt.Ordenes_Id) select dt; ordenes.CantidadPiezas = (int)detalleCantidad.Sum(x => x.cantidad); listaAuditores.Add(ordenes); } } ViewBag.ListaAuditores = listaAuditores.OrderBy(x => x.Cantidad); ViewBag.ListaPicker = listaPickers.OrderBy(x => x.CantidadPiezas); List <DataPoint> dataPoints = new List <DataPoint>(); foreach (var item in toppickers) { if (item.Key != null) { dataPoints.Add(new DataPoint(item.Key, (int)piezas.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Sum(x => x.cantidad) * -1)); } } ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints); return(View()); }
public void AgregarOrdenes() { List <ordenes> listaValidacion = db.ordenes.ToList(); DataTable dtOrden = new DataTable(); //Fecha Alta dtOrden.Columns.Add(new DataColumn() { ColumnName = "FechaAlta", DataType = typeof(DateTime) }); //Status Orden dtOrden.Columns.Add(new DataColumn() { ColumnName = "StatusOrdenImpresa_Id", DataType = typeof(int) }); //3 Orden dtOrden.Columns.Add(new DataColumn() { ColumnName = "Orden", DataType = typeof(string) }); //4 User dtOrden.Columns.Add(new DataColumn() { ColumnName = "User", DataType = typeof(string) }); List <ordenes> lista = new List <ordenes>(); foreach (DataRow row in dtCharge.Rows) { ordenes ordenes = new ordenes(); ordenes.FechaAlta = DateTime.Now; ordenes.Orden = row[3].ToString(); ordenes.User = row[4].ToString(); ordenes.StatusOrdenImpresa_Id = 1; //ordenes.TxnDate = DateTime.Parse(row[0].ToString()); //ordenes.TxnNumber = row[1].ToString(); var orden = listaValidacion.Where(x => x.Orden.Equals(ordenes.Orden.Trim())).FirstOrDefault(); if (orden == null) { lista.Add(ordenes); } else { Console.WriteLine("Orden Duplicada"); } } if (lista.Count > 0) { var grouping = lista.GroupBy(x => x.Orden).ToList(); foreach (var item in grouping) { var orden = lista.Where(x => x.Orden == item.Key).FirstOrDefault(); if (orden != null) { dtOrden.Rows.Add(new object[] { DateTime.Now, orden.StatusOrdenImpresa_Id, orden.Orden, //orden.TxnDate, //orden.TxnNumber, orden.User }); } else { Console.Write("La orden ya existe"); } } string connectionString = @"Data Source=SQL7001.site4now.net;Initial Catalog=DB_A3F19C_OG;User Id=DB_A3F19C_OG_admin;Password=xQ9znAhU;"; using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString)) { bulkCopy.DestinationTableName = "dbo.ordenes"; bulkCopy.ColumnMappings.Add("FechaAlta", "FechaAlta"); bulkCopy.ColumnMappings.Add("Orden", "Orden"); //bulkCopy.ColumnMappings.Add("TxnDate", "TxnDate"); //bulkCopy.ColumnMappings.Add("TxnNumber", "TxnNumber"); bulkCopy.ColumnMappings.Add("User", "User"); bulkCopy.ColumnMappings.Add("StatusOrdenImpresa_Id", "StatusOrdenImpresa_Id"); try { bulkCopy.WriteToServer(dtOrden); } catch (Exception ex) { Console.WriteLine(ex.Message); } } DataTable dtDetalles = new DataTable(); dtDetalles.Columns.Add(new DataColumn() { ColumnName = "Ordenes_Id", DataType = typeof(int) }); dtDetalles.Columns.Add(new DataColumn() { ColumnName = "Skus_Id", DataType = typeof(int) }); dtDetalles.Columns.Add(new DataColumn() { ColumnName = "cantidad", DataType = typeof(int) }); List <ordenes> listaOrdenes = db.ordenes.ToList(); List <skus> listaSKU = db.skus.ToList(); foreach (DataRow row in dtCharge.Rows) { string orden = row[3].ToString(); string sku = row[0].ToString(); var ordenTemp = lista.Where(x => x.Orden.Contains(orden)).FirstOrDefault(); if (ordenTemp != null) { int idOrden = listaOrdenes.Where(x => x.Orden.Contains(orden)).FirstOrDefault().id; int idSKU = listaSKU.Where(x => x.Sku.Contains(sku)).FirstOrDefault().id; dtDetalles.Rows.Add(new object[] { idOrden, idSKU, int.Parse(row[1].ToString()) }); } } using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString)) { bulkCopy.DestinationTableName = "dbo.detordenproductoshd"; bulkCopy.ColumnMappings.Add("Ordenes_Id", "Ordenes_Id"); bulkCopy.ColumnMappings.Add("Skus_Id", "Skus_Id"); bulkCopy.ColumnMappings.Add("cantidad", "cantidad"); try { bulkCopy.WriteToServer(dtDetalles); } catch (Exception ex) { Console.WriteLine(ex.Message); } } MessageBox.Show("Se han cargado los registros correctamente"); } else { MessageBox.Show("NO SE HAN ENCONTRADO REGISTROS NUEVOS"); } }
public ActionResult Cargar(HttpPostedFileBase postedFileBase) { try { string filePath = string.Empty; if (postedFileBase != null) { string path = Server.MapPath("~/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } filePath = path + Path.GetFileName(postedFileBase.FileName); string extension = Path.GetExtension(postedFileBase.FileName); postedFileBase.SaveAs(filePath); DataTable dtCharge = new DataTable(); dtCharge.Columns.AddRange(new DataColumn[5] { //1 new DataColumn("item", typeof(string)), //2 new DataColumn("qty", typeof(string)), //3 new DataColumn("ea", typeof(string)), //4 new DataColumn("order", typeof(string)), //5 new DataColumn("createdby", typeof(string)), }); string csvData = System.IO.File.ReadAllText(filePath); foreach (string row in csvData.Split('\n')) { if (!string.IsNullOrEmpty(row)) { dtCharge.Rows.Add(); int i = 0; //Execute a loop over the columns. foreach (string cell in row.Split(',')) { dtCharge.Rows[dtCharge.Rows.Count - 1][i] = cell; i++; } } } List <ordenes> listaValidacion = db.ordenes.ToList(); List <ordenes> lista = new List <ordenes>(); foreach (DataRow row in dtCharge.Rows) { ordenes ordenes = new ordenes(); ordenes.FechaAlta = DateTime.Now; ordenes.Orden = row[3].ToString(); ordenes.User = row[4].ToString(); ordenes.StatusOrdenImpresa_Id = 1; var orden = listaValidacion.Where(x => x.Orden.Equals(ordenes.Orden.Trim())).FirstOrDefault(); if (orden == null) { lista.Add(ordenes); } else { Console.WriteLine("Orden Duplicada"); } } if (lista.Count > 0) { var grouping = lista.GroupBy(x => x.Orden).ToList(); DataTable dtOrden = new DataTable(); dtOrden.Columns.AddRange(new DataColumn[4] { //1 new DataColumn("FechaAlta", typeof(DateTime)), //2 new DataColumn("StatusOrdenImpresa_Id", typeof(int)), //3 new DataColumn("Orden", typeof(string)), //4 new DataColumn("User", typeof(string)), }); foreach (var item in grouping) { var orden = lista.Where(x => x.Orden == item.Key).FirstOrDefault(); if (orden != null) { dtOrden.Rows.Add(new object[] { DateTime.Now, orden.StatusOrdenImpresa_Id, orden.Orden, orden.User }); } else { Console.Write("La orden ya existe"); } } string connectionString = @"Data Source=SQL7001.site4now.net;Initial Catalog=DB_A3F19C_OG;User Id=DB_A3F19C_OG_admin;Password=xQ9znAhU;"; using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString)) { bulkCopy.DestinationTableName = "dbo.ordenes"; bulkCopy.ColumnMappings.Add("FechaAlta", "FechaAlta"); bulkCopy.ColumnMappings.Add("Orden", "Orden"); bulkCopy.ColumnMappings.Add("User", "User"); bulkCopy.ColumnMappings.Add("StatusOrdenImpresa_Id", "StatusOrdenImpresa_Id"); try { bulkCopy.WriteToServer(dtOrden); } catch (Exception ex) { Console.WriteLine(ex.Message); } } DataTable dtDetalles = new DataTable(); dtDetalles.Columns.AddRange(new DataColumn[3] { //1 new DataColumn("Ordenes_Id", typeof(int)), //2 new DataColumn("Skus_Id", typeof(int)), //3 new DataColumn("cantidad", typeof(string)), }); List <ordenes> listaOrdenes = db.ordenes.ToList(); List <skus> listaSKU = db.skus.ToList(); foreach (DataRow row in dtCharge.Rows) { string orden = row[3].ToString(); string sku = row[0].ToString(); var ordenTemp = lista.Where(x => x.Orden.Contains(orden)).FirstOrDefault(); if (ordenTemp != null) { int idOrden = listaOrdenes.Where(x => x.Orden.Contains(orden)).FirstOrDefault().id; int idSKU = listaSKU.Where(x => x.Sku.Contains(sku)).FirstOrDefault().id; dtDetalles.Rows.Add(new object[] { idOrden, idSKU, int.Parse(row[1].ToString()) }); } } using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString)) { bulkCopy.DestinationTableName = "dbo.detordenproductoshd"; bulkCopy.ColumnMappings.Add("Ordenes_Id", "Ordenes_Id"); bulkCopy.ColumnMappings.Add("Skus_Id", "Skus_Id"); bulkCopy.ColumnMappings.Add("cantidad", "cantidad"); try { bulkCopy.WriteToServer(dtDetalles); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } else { Console.WriteLine("NO SE HAN ENCONTRADO REGISTROS NUEVOS"); } } return(RedirectToAction("Index")); } catch (Exception _ex) { string error = _ex.Message.ToString(); return(RedirectToAction("Error500", "Errores", new { error = error })); } }
public ActionResult ConteoMensual(int month) { DateTime fechaHoy = Convert.ToDateTime("2019/10/01"); //Cambiar mes var toppickers = db.ordenes.Where(x => (x.StatusOrdenImpresa_Id > 1 || x.StatusOrdenImpresa_Id < 5) && (x.FechaAlta.Value.Month == month)).GroupBy(x => x.Picker); //Cambiar mes var topauditores = db.detusuariosordenes.Where(x => (x.ordenes.StatusOrdenImpresa_Id > 1) && (x.ordenes.FechaAlta.Value.Month == month)).GroupBy(x => x.usuarios.nombre); //Cambiar mes var piezas = db.detordenproductoshd.Where(x => x.ordenes.FechaAlta.Value.Month == month); //Cambiar mes var errores = db.erroresordenes.Where(x => x.ordenes.FechaAlta.Value.Month == month); List <ordenes> listaPickers = new List <ordenes>(); List <ordenes> listaAuditores = new List <ordenes>(); List <DataPoint> dataPoints = new List <DataPoint>(); foreach (var item in toppickers) { if (item.Key != null) { ordenes ordenes = new ordenes(); var p = piezas.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Sum(x => x.cantidad); if (p != null) { var porcentajeRounded = Math.Round((decimal)p, 2); ordenes.CantidadPiezas = (int)porcentajeRounded; } else { ordenes.CantidadPiezas = 0; } if (errores != null) { ordenes.CantidadErrores = (int)errores.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Count(); } else { ordenes.CantidadErrores = 0; } ordenes.Picker = item.Key.ToUpper(); ordenes.Cantidad = item.Count(); listaPickers.Add(ordenes); } } foreach (var item in topauditores) { if (item.Key != null) { ordenes ordenes = new ordenes(); ordenes.Auditor = item.Key.ToUpper(); ordenes.Cantidad = item.Count(); var ordenesTemp = from dt in db.detusuariosordenes where dt.usuarios.nombre.Equals(item.Key) && dt.ordenes.FechaAlta > fechaHoy select dt.Ordenes_Id; var detalleCantidad = from dt in db.detordenproductoshd where ordenesTemp.Contains(dt.Ordenes_Id) select dt; ordenes.CantidadPiezas = (int)detalleCantidad.Sum(x => x.cantidad); listaAuditores.Add(ordenes); } } foreach (var item in toppickers) { if (item.Key != null) { var p = piezas.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Sum(x => x.cantidad); if (p != null) { dataPoints.Add(new DataPoint(item.Key, (int)piezas.Where(x => x.ordenes.Picker.Contains(item.Key.ToUpper())).Sum(x => x.cantidad) * -1)); } else { dataPoints.Add(new DataPoint(item.Key, 0)); } } } ViewBag.ListaPicker = listaPickers.OrderBy(x => x.CantidadPiezas); ViewBag.ListaAuditores = listaAuditores.OrderBy(x => x.CantidadPiezas); ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints.OrderByDescending(x => x.Y)); return(View()); }