public IHttpActionResult PostDailyTotal(DailyTotal dailyTotal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DailyTotals.Add(dailyTotal); try { db.SaveChanges(); } catch (DbUpdateException) { if (DailyTotalExists(dailyTotal.Total)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = dailyTotal.Total }, dailyTotal)); }
//delete one item from Inventory table public static List <DailyTotal> DeleteModel(DailyTotal e) { var model1 = (from model in db.DailyTotals where model.ModelNo.Contains(model.ModelNo) select model).SingleOrDefault(); db.DailyTotals.Remove(model1); db.SaveChanges(); return(GetAllModels()); }
public IHttpActionResult GetDailyTotal(int id) { DailyTotal dailyTotal = db.DailyTotals.Find(id); if (dailyTotal == null) { return(NotFound()); } return(Ok(dailyTotal)); }
private void DrawChart(int okNumber, int ngNumber) { int Total = okNumber + ngNumber; DailyTotal = Statistics_DailyNG + Statistics_DailyOK; labelStatisticNG.Text = ngNumber.ToString(); labelStatisticOK.Text = okNumber.ToString(); labelStatisticsTotal.Text = Total.ToString(); lbDailyNG.Text = Statistics_DailyNG.ToString(); lbDailyOK.Text = Statistics_DailyOK.ToString(); lbDailyTotal.Text = DailyTotal.ToString(); if (Total == 0) { Total = 10000000; } float okRadian = (float)360.0 / Total * okNumber; float ngRadian = (float)360.0 - okRadian; //rawResponse.Text = "Hàng OK: " + okNumber.ToString() + " Hàng NG: " + ngNumber.ToString() + " Tổng cộng" + Total.ToString() + "\r\n"; //rawResponse.Text += "Góc OK: " + okRadian.ToString() + " Góc NG: " + ngRadian.ToString(); int startRectY = pictureBox.Size.Height / 2 - pictureBox.Size.Width / 2; int startRectX = pictureBox.Size.Width / 2 - pictureBox.Size.Height / 2; int rectDimemtions = pictureBox.Size.Width; if (startRectY < 0) { startRectY = 0; rectDimemtions = pictureBox.Size.Height; } if (startRectX < 0) { startRectX = 0; rectDimemtions = pictureBox.Size.Width; } Rectangle rect = new Rectangle(startRectX, startRectY, rectDimemtions, rectDimemtions); Bitmap custormChart = new Bitmap(pictureBox.Size.Width, pictureBox.Size.Height); Graphics g = Graphics.FromImage(custormChart); //g.FillEllipse(Brushes.Red, pictureBox.Size.Width / 2 - pictureBox.Size.Height / 2, pictureBox.Size.Height / 2 - pictureBox.Size.Height / 2, pictureBox.Size.Height , pictureBox.Size.Height); g.FillPie(Brushes.Green, rect, 0, okRadian); g.FillPie(Brushes.Red, rect, okRadian, ngRadian); //g.FillEllipse(Brushes.White, pictureBox.Size.Width / 2 - pictureBox.Size.Height / 2 + 10, pictureBox.Size.Height / 2 - pictureBox.Size.Height / 2 + 10, pictureBox.Size.Height - 20, pictureBox.Size.Height - 20); if (pictureBox.Image != null) { pictureBox.Image.Dispose(); } pictureBox.Image = custormChart; }
public IHttpActionResult DeleteDailyTotal(int id) { DailyTotal dailyTotal = db.DailyTotals.Find(id); if (dailyTotal == null) { return(NotFound()); } db.DailyTotals.Remove(dailyTotal); db.SaveChanges(); return(Ok(dailyTotal)); }
//update one model into model table public static List <DailyTotal> UpdateInventory(DailyTotal e) { var model1 = (from model in db.ModelZoneMaps where model.Model.Contains(model.Model) select model).SingleOrDefault(); /*model1.MODELNO = e.MODELNO; * model1.VERSION = e.VERSION; * model1.FG = e.FG; * model1.MODEL1 = e.MODEL1; * model1.SOLE = e.SOLE; * model1.DESC = e.DESC; * model1.FP_DATE = e.FP_DATE; * model1.LABOR_W = e.LABOR_W; * model1.ViewFile= e.ViewFile; * model1.SPFile = e.SPFile; * model1.Commercial = e.Commercial; * model1.Brand = e.Brand;*/ db.SaveChanges(); return(GetAllModels()); }
//Insert one model into model table public static List <DailyTotal> InsertInventory(DailyTotal e) { db.DailyTotals.Add(e); db.SaveChanges(); return(GetAllModels()); }
//Get all model daily report from DB public static List <FGDailyReportDto> GetDailyReportByModels(DateTime date) { var query = (from model in db.ModelZoneMaps orderby model.Brand ascending, model.Category select model); var result = new List <FGDailyReportDto>(); int modelTotal = 0; int zone1Count = 0; int zone2Count = 0; int zone1Received = 0; var yesterday = date.AddDays(-1); var tomorrow = date.AddDays(1); var modelDailyTotal = new List <DailyTotal>(); foreach (ModelZoneMap i in query) { zone1Received = 0; FGDailyReportDto m = new FGDailyReportDto(); m.ModelNo = i.Model; m.ModelFG = i.FG; m.Brand = i.Brand; m.Category = i.Category; var shipped = (from ship in db.Histories where ship.ModelNo.Equals(i.Model) && ship.ShippedDate >= date && ship.ShippedDate < tomorrow select ship).ToList(); var shippedA = new List <Pallet>(); if (m.ModelNo.Equals("135416")) { shippedA = (from ship in db.Pallets where ship.ItemID.Equals("135416A") && ship.ShippedDate >= date && ship.ShippedDate < tomorrow select ship).ToList(); } var afterShipped = (from ship in db.Histories where ship.ModelNo.Equals(i.Model) && ship.ShippedDate >= tomorrow select ship).ToList(); m.Shipped = shipped.Count + shippedA.Count;; int receivedShip = 0; int afterShippingScanItem = afterShipped.Count; foreach (var ship in afterShipped) { if (ship.ScanDate != null && ship.ScanDate.Date == date.Date) { receivedShip++; } else if (ship.ScanDate.Date > date.Date) { afterShippingScanItem--; } } var receivedItemByDate = (from inventory in db.InventoryIns where inventory.ModelNo.Equals(i.Model) && !inventory.Location.Equals(Constants.ZONE_CODE_RETURN.ToString()) && inventory.Date >= date && inventory.Date < tomorrow select inventory ).ToList(); zone1Received = receivedShip + receivedItemByDate.Count(); int rts = 0; int showroom = 0; int unshippable = 0; foreach (var inventory in receivedItemByDate) { if (inventory.Location.Equals(Constants.ZONE_CODE_3_A.ToString()) || inventory.Location.Equals(Constants.ZONE_CODE_3_B.ToString()) || inventory.Location.Equals(Constants.ZONE_CODE_3_B.ToString()) || inventory.Location.Equals(Constants.ZONE_CODE_3_C.ToString())) { rts++; } else if (inventory.Location.Equals(Constants.ZONE_CODE_5_ONE.ToString())) { unshippable++; } else if (inventory.Location.Equals(Constants.ZONE_CODE_4_ONE.ToString())) { showroom++; } } var receivedCurrent = (from inventory in db.InventoryIns where inventory.ModelNo.Equals(i.Model) && inventory.Date < date join code in db.Locations on inventory.Location equals code.Code orderby code.ZoneCode ascending, inventory.SN.Substring(6, 10) ascending group inventory by code.ZoneCode); modelTotal = 0; zone1Count = 0; zone2Count = 0; int count = receivedCurrent.Count(); foreach (var inventory in receivedCurrent) { Console.WriteLine(inventory.Count()); //mapped all values if (inventory.Key == 1) { zone1Count = inventory.Count(); } else if (inventory.Key == 2) { zone2Count = inventory.Count(); } else if (inventory.Key == 3) { m.ReturnItem = inventory.Count(); } else if (inventory.Key == 4) { m.ShowRoom = inventory.Count(); } else if (inventory.Key == 5) { m.Rework = inventory.Count(); } else if (inventory.Key == 6) { m.QC = inventory.Count(); } else if (inventory.Key == 7) { m.Scrapped = inventory.Count(); } else if (inventory.Key == 9) { continue; } modelTotal += inventory.Count(); } if (showroom != 0) { m.ShowRoom += showroom; } if (unshippable != 0) { m.Rework += unshippable; } int afterSippedCnt = afterShippingScanItem - receivedShip; m.Received = zone1Received; m.OnHand = m.Received + zone1Count + zone2Count + afterSippedCnt - showroom - unshippable; m.Total = modelTotal + m.Received + afterSippedCnt; m.Previous = m.Total + m.Shipped - m.Received; if (m.Total > 0 || DailyModelHelper.isShowModel(m.ModelNo)) { result.Add(m); DailyTotal dailyTotal = new DailyTotal(); dailyTotal.ModelNo = m.ModelNo; dailyTotal.Date = date; dailyTotal.Total = modelTotal; modelDailyTotal.Add(dailyTotal); } } List <FGDailyReportDto> SortedList = result.OrderBy(o => o.Brand).ToList(); ModelDailyTotal.InsertInventory(modelDailyTotal); return(SortedList); }