private void bwInsert_DoWork(object sender, DoWorkEventArgs e) { foreach (OutsoleOutputModel model in outsoleOutputToInsertList) { OutsoleOutputController.Insert(model); } }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { assemblyReleaseAllList = AssemblyReleaseController.Select(reportId, null); orderAllList = OrdersController.SelectByAssemblyRelease(reportId); sewingOutputAllList = SewingOutputController.SelectByAssemblyRelease(reportId); outsoleOutputAllList = OutsoleOutputController.SelectByAssemblyRelease(reportId); sizeRunAllList = SizeRunController.SelectByAssemblyRelease(reportId); }
private void bwAddMore_DoWork(object sender, DoWorkEventArgs e) { string productNo = ""; txtProductNo.Dispatcher.Invoke((Action)(() => { productNo = txtProductNo.Text; })); orderSearch = OrdersController.SelectTop1(productNo); sizeRunSearchList = SizeRunController.Select(productNo); assemblyReleaseSearchList = AssemblyReleaseController.Select(productNo); sewingOutputSearchList = SewingOutputController.Select(productNo); outsoleOutputSearchList = OutsoleOutputController.Select(productNo); }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { outsoleMaterialList = OutsoleMaterialController.Select(); outsoleReleaseMaterialList = OutsoleReleaseMaterialController.SelectByOutsoleMaterial(); outsoleOutputList = OutsoleOutputController.SelectByAssemblyMaster(); outsoleMasterList = OutsoleMasterController.Select(); orderList = OrdersController.Select(); outsoleSupplierList = OutsoleSuppliersController.Select(); assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster(); sizeRunList = SizeRunController.SelectIsEnable(); inventoryByOSCodeList = ReportController.InventoryByOutsoleCode(); inventoryByOSLineList = ReportController.InventoryByOutsoleLine(); foreach (var inven in inventoryByOSCodeList) { inven.ProductNoList = orderList.Where(w => w.OutsoleCode == inven.OutsoleCode).Select(s => s.ProductNo).Distinct().ToList(); } foreach (var inven in inventoryByOSLineList) { inven.ProductNoList = outsoleMasterList.Where(w => w.OutsoleLine == inven.OutsoleLine).Select(s => s.ProductNo).Distinct().ToList(); inven.OutsoleCode = inven.OutsoleLine; } }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { outsoleMaterialList = OutsoleMaterialController.Select(); outsoleReleaseMaterialList = OutsoleReleaseMaterialController.SelectByOutsoleMaterial(); outsoleOutputList = OutsoleOutputController.SelectByAssemblyMaster(); // lay ra nhung order co outsolematerial roi. orderList = OrdersController.SelectByOutsoleMaterial(); outsoleSupplierList = OutsoleSuppliersController.Select(); assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster(); var outsoleWHInventoryViewList = new List <OutsoleWHInventoryViewModel>(); // lay ra outsolecode tu orderlist(la nhung order co outsolematerial roi) var outsoleCodeList = orderList.Select(o => o.OutsoleCode).Distinct().ToList(); foreach (string outsoleCode in outsoleCodeList) { var productNoList = orderList.Where(o => o.OutsoleCode == outsoleCode).Select(o => o.ProductNo).Distinct().ToList(); var outsoleMaterialList_D1 = outsoleMaterialList.Where(o => productNoList.Contains(o.ProductNo)).ToList(); var outsoleReleaseMaterialList_D1 = outsoleReleaseMaterialList.Where(o => productNoList.Contains(o.ProductNo)).ToList(); var supplierIdList = outsoleMaterialList_D1.Select(o => o.OutsoleSupplierId).Distinct().ToList(); var qtyTotalList = new List <Int32>(); var outsoleOutputList_D1 = outsoleOutputList.Where(o => productNoList.Contains(o.ProductNo) == true).ToList(); var assemblyReleaseList_D1 = assemblyReleaseList.Where(a => productNoList.Contains(a.ProductNo) == true).ToList(); // add Finished Outsole Column int qtyOutsoleTotal = 0; foreach (string productNo in productNoList) { var sizeNoList = outsoleMaterialList.Where(o => o.ProductNo == productNo).Select(o => o.SizeNo).Distinct().ToList(); var outsoleOutputList_D2 = outsoleOutputList_D1.Where(o => o.ProductNo == productNo).ToList(); var assemblyReleaseList_D2 = assemblyReleaseList_D1.Where(a => a.ProductNo == productNo).ToList(); foreach (string sizeNo in sizeNoList) { int qtyRelease = assemblyReleaseList_D2.Where(a => a.SizeNo == sizeNo).Sum(a => a.Quantity); int qtyOutsole = outsoleOutputList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity) - qtyRelease; qtyOutsoleTotal += qtyOutsole; } } foreach (Int32 supplierId in supplierIdList) { var outsoleMaterialList_D2 = outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == supplierId).ToList(); int qtyTotal = 0; foreach (string productNo in productNoList) { var outsoleMaterialList_D3 = outsoleMaterialList_D2.Where(o => o.ProductNo == productNo).ToList(); var outsoleReleaseMaterialList_D3 = outsoleReleaseMaterialList_D1.Where(o => o.ProductNo == productNo).ToList(); var sizeNoList = outsoleMaterialList.Where(o => o.ProductNo == productNo).Select(o => o.SizeNo).Distinct().ToList(); foreach (string sizeNo in sizeNoList) { int qtyMax = outsoleMaterialList_D3.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity - o.QuantityReject); int qtyRelease = outsoleReleaseMaterialList_D3.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qty = qtyMax - qtyRelease; if (qty < 0) { qty = 0; } qtyTotal += qty; } } qtyTotalList.Add(qtyTotal); } int qtyMatchTotal = 0; foreach (string productNo in productNoList) { var outsoleMaterialList_D2 = outsoleMaterialList_D1.Where(o => o.ProductNo == productNo).ToList(); var outsoleReleaseMaterialList_D2 = outsoleReleaseMaterialList_D1.Where(o => o.ProductNo == productNo).ToList(); var sizeNoList = outsoleMaterialList.Where(o => o.ProductNo == productNo).Select(o => o.SizeNo).Distinct().ToList(); foreach (string sizeNo in sizeNoList) { int qtyMin = outsoleMaterialList_D2.Where(o => o.SizeNo == sizeNo).Select(o => o.Quantity - o.QuantityReject).Min(); int qtyRelease = outsoleReleaseMaterialList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMatch = qtyMin - qtyRelease; if (qtyMatch < 0) { qtyMatch = 0; } qtyMatchTotal += qtyMatch; } } var outsoleWHInventoryView = new OutsoleWHInventoryViewModel { OutsoleCode = outsoleCode, ProductNoList = productNoList, SupplierIdList = supplierIdList, Quantity = qtyTotalList.Max(), Matching = qtyMatchTotal, FinishedOutsoleQuantity = qtyOutsoleTotal, }; if (outsoleWHInventoryView.Quantity != 0) { outsoleWHInventoryViewList.Add(outsoleWHInventoryView); } } e.Result = outsoleWHInventoryViewList; }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { assemblyMasterList = AssemblyMasterController.Select(); sewingOutputList = SewingOutputController.SelectByAssemblyMaster(); outsoleOutputList = OutsoleOutputController.SelectByAssemblyMaster(); assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster(); orderList = OrdersController.Select(); sockliningInputList = SockliningInputController.SelectByAssemblyMaster(); sizeRunList = SizeRunController.SelectIsEnable(); rawMaterialViewModelNewList = RawMaterialController.Select_1(); List <UpperWHInventoryViewModel> upperWHInventoryList = new List <UpperWHInventoryViewModel>(); List <UpperWHInventoryViewModel> upperWHInventoryList_1 = new List <UpperWHInventoryViewModel>(); var POList = orderList.Select(s => s.ProductNo).Distinct().ToList(); foreach (var productNo in POList) { var assemblyMaster_PO = assemblyMasterList.FirstOrDefault(w => w.ProductNo == productNo); var assemblyRelease_PO = assemblyReleaseList.Where(w => w.ProductNo == productNo).ToList(); var sewingOutput_PO = sewingOutputList.Where(w => w.ProductNo == productNo).ToList(); var outsoleOutput_PO = outsoleOutputList.Where(w => w.ProductNo == productNo).ToList(); var sockliningInput_PO = sockliningInputList.Where(w => w.ProductNo == productNo).ToList(); var sizeNoList = sizeRunList.Where(w => w.ProductNo == productNo).Select(s => s.SizeNo).ToList(); int qtyUpper_PO = 0, qtyOutsole_PO = 0, qtySocklining_PO = 0, qtyMatch_PO = 0, qtyMatchWithSocklining_PO = 0; foreach (var sizeNo in sizeNoList) { int qtyAssemblyRelease_Size = assemblyRelease_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity); int qtySewingOutput_Size = sewingOutput_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity); int qtyOutsoleOutput_Size = outsoleOutput_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity); int qtySocklining_Size = sockliningInput_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity); int qtyUpper = qtySewingOutput_Size - qtyAssemblyRelease_Size; if (qtyUpper < 0) { qtyUpper = 0; } qtyUpper_PO += qtyUpper; int qtyOutsole = qtyOutsoleOutput_Size - qtyAssemblyRelease_Size; if (qtyOutsole < 0) { qtyOutsole = 0; } qtyOutsole_PO += qtyOutsole; int qtySocklining = qtySocklining_Size - qtyAssemblyRelease_Size; if (qtySocklining < 0) { qtySocklining = 0; } qtySocklining_PO += qtySocklining; int qtyMatch = Math.Min(qtySewingOutput_Size, qtyOutsoleOutput_Size) - qtyAssemblyRelease_Size; if (qtyMatch < 0) { qtyMatch = 0; } qtyMatch_PO += qtyMatch; List <Int32> materialList = new List <Int32>(); materialList.Add(qtySewingOutput_Size > 0 ? qtySewingOutput_Size : 0); materialList.Add(qtyOutsoleOutput_Size > 0 ? qtyOutsoleOutput_Size : 0); materialList.Add(qtySocklining_Size > 0 ? qtySocklining_Size : 0); int qtyMatchWithSocklining = materialList.Min() - qtyAssemblyRelease_Size; if (qtyMatchWithSocklining < 0) { qtyMatchWithSocklining = 0; } qtyMatchWithSocklining_PO += qtyMatchWithSocklining; } string assemblyLine_PO = assemblyMaster_PO != null ? assemblyMaster_PO.AssemblyLine : ""; var upperInventory_PO = new UpperWHInventoryViewModel() { AssemblyLine = assemblyLine_PO, SewingOutput = qtyUpper_PO, OutsoleOutput = qtyOutsole_PO, SockliningInput = qtySocklining_PO, Matching = qtyMatch_PO, MatchingWithSocklining = qtyMatchWithSocklining_PO, }; upperWHInventoryList.Add(upperInventory_PO); } var assemblyLineList = upperWHInventoryList.Select(s => s.AssemblyLine).Distinct().ToList(); if (assemblyLineList.Count() > 0) { assemblyLineList = assemblyLineList.OrderBy(o => o).ToList(); } var regex = new Regex(@"\D"); var assemblyLineCustomList = assemblyLineList.Select(s => new { Line = s, LineNumber = regex.IsMatch(s) ? regex.Replace(s, "") : s }).ToList(); if (assemblyLineCustomList.Count() > 0) { assemblyLineCustomList = assemblyLineCustomList.OrderBy(o => String.IsNullOrEmpty(o.LineNumber) ? 100 : Int32.Parse(o.LineNumber)).ThenBy(th => th.Line).ToList(); } foreach (var assemblyLineCustom in assemblyLineCustomList) { var assemblyLine = assemblyLineCustom.Line; var upperWHInventoryByAssemblyLine = upperWHInventoryList.Where(w => w.AssemblyLine == assemblyLine).ToList(); var productNoList_Assembly = assemblyMasterList.Where(w => w.AssemblyLine == assemblyLine).Select(s => s.ProductNo).Distinct().ToList(); var upperInventory = new UpperWHInventoryViewModel() { AssemblyLine = assemblyLine, ProductNoList = productNoList_Assembly, SewingOutput = upperWHInventoryByAssemblyLine.Sum(s => s.SewingOutput), OutsoleOutput = upperWHInventoryByAssemblyLine.Sum(s => s.OutsoleOutput), SockliningInput = upperWHInventoryByAssemblyLine.Sum(s => s.SockliningInput), Matching = upperWHInventoryByAssemblyLine.Sum(s => s.Matching), }; upperWHInventoryViewList.Add(upperInventory); var upperInventory_1 = new UpperWHInventoryViewModel() { AssemblyLine = assemblyLine, ProductNoList = productNoList_Assembly, SewingOutput = upperWHInventoryByAssemblyLine.Sum(s => s.SewingOutput), OutsoleOutput = upperWHInventoryByAssemblyLine.Sum(s => s.OutsoleOutput), SockliningInput = upperWHInventoryByAssemblyLine.Sum(s => s.SockliningInput), Matching = upperWHInventoryByAssemblyLine.Sum(s => s.MatchingWithSocklining), }; upperWHInventoryViewList_WithSocklining.Add(upperInventory_1); } }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { outsoleOutputList = OutsoleOutputController.Select(productNo); sizeRunList = SizeRunController.Select(productNo); offDayList = OffDayController.SelectDate(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { DataTable dt = new UpperWHInventoryDetailDataSet().Tables["UpperWHInventoryDetailTable"]; assemblyMasterList = AssemblyMasterController.Select(); sewingOutputList = SewingOutputController.SelectByAssemblyMaster(); outsoleOutputList = OutsoleOutputController.SelectByAssemblyMaster(); assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster(); orderList = OrdersController.SelectByAssemblyMaster(); List <UpperWHInventoryViewModel> upperWHInventoryViewList = new List <UpperWHInventoryViewModel>(); assemblyLineList = assemblyMasterList.Where(a => String.IsNullOrEmpty(a.AssemblyLine) == false).Select(a => a.AssemblyLine).Distinct().OrderBy(l => l).ToList(); // Total value //int upperTotal = 0; //int outsoleTotal = 0; //int matchingTotal = 0; // Sum value int upperSum, outsoleSum, matchingSum; foreach (string assemblyLine in assemblyLineList) { List <String> productNoList = assemblyMasterList.Where(a => a.AssemblyLine == assemblyLine).Select(o => o.ProductNo).OrderBy(l => l).Distinct().ToList(); List <UpperWHInventoryDetailViewModel> upperWHInventoryDetailViewList = new List <UpperWHInventoryDetailViewModel>(); foreach (string productNo in productNoList) { UpperWHInventoryDetailViewModel upperWHInventoryDetailView = new UpperWHInventoryDetailViewModel(); OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault(); if (order != null) { upperWHInventoryDetailView.ProductNo = productNo; upperWHInventoryDetailView.ShoeName = order.ShoeName; upperWHInventoryDetailView.ArticleNo = order.ArticleNo; } int qtyUpperTotal = 0; int qtyOutsoleTotal = 0; int qtyMatchTotal = 0; int qtyQuantity = order.Quantity; int qtyReleaseTotal = 0; List <AssemblyReleaseModel> assemblyReleaseList_D1 = assemblyReleaseList.Where(a => a.ProductNo == productNo).ToList(); List <SewingOutputModel> sewingOutputList_D1 = sewingOutputList.Where(s => s.ProductNo == productNo).ToList(); List <OutsoleOutputModel> outsoleOutputList_D1 = outsoleOutputList.Where(o => o.ProductNo == productNo).ToList(); List <String> sizeNoList = sewingOutputList_D1.Select(s => s.SizeNo).Distinct().ToList(); if (sizeNoList.Count == 0) { sizeNoList = outsoleOutputList_D1.Select(o => o.SizeNo).Distinct().ToList(); } foreach (string sizeNo in sizeNoList) { int qtyRelease = assemblyReleaseList_D1.Where(a => a.SizeNo == sizeNo).Sum(a => a.Quantity); int qtyUpper = sewingOutputList_D1.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity) - qtyRelease; int qtyOutsole = outsoleOutputList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity) - qtyRelease; int qtyMatch = MatchingHelper.Calculate(sewingOutputList_D1.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity), outsoleOutputList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity), sizeNo) - qtyRelease; if (qtyUpper < 0) { qtyUpper = 0; } qtyUpperTotal += qtyUpper; if (qtyOutsole < 0) { qtyOutsole = 0; } qtyOutsoleTotal += qtyOutsole; if (qtyMatch < 0) { qtyMatch = 0; } qtyMatchTotal += qtyMatch; if (qtyRelease < 0) { qtyRelease = 0; } qtyReleaseTotal += qtyRelease; } upperWHInventoryDetailView.Quantity = qtyQuantity; upperWHInventoryDetailView.ReleaseQuantity = qtyReleaseTotal; upperWHInventoryDetailView.SewingOutput = qtyUpperTotal; upperWHInventoryDetailView.OutsoleOutput = qtyOutsoleTotal; upperWHInventoryDetailView.Matching = qtyMatchTotal; //UpperWHInventoryViewModel upperWHInventoryView = new UpperWHInventoryViewModel //{ // AssemblyLine = assemblyLine, // ProductNoList = productNoList, // SewingOutput = qtyUpperTotal, // OutsoleOutput = qtyOutsoleTotal, // Matching = qtyMatchTotal, //}; //upperWHInventoryViewList.Add(upperWHInventoryView); if (upperWHInventoryDetailView.SewingOutput != 0 || upperWHInventoryDetailView.OutsoleOutput != 0) { upperWHInventoryDetailViewList.Add(upperWHInventoryDetailView); } } Int32.TryParse(upperWHInventoryDetailViewList.Sum(o => o.SewingOutput).ToString(), out upperSum); Int32.TryParse(upperWHInventoryDetailViewList.Sum(o => o.OutsoleOutput).ToString(), out outsoleSum); Int32.TryParse(upperWHInventoryDetailViewList.Sum(o => o.Matching).ToString(), out matchingSum); //List<int> upperSumList = upperWHInventoryDetailViewList.Where(o => o.SewingOutput != 0).Select(p => p.SewingOutput).ToList(); //List<int> ousoleSumList = upperWHInventoryDetailViewList.Where(o => o.OutsoleOutput != 0).Select(p => p.OutsoleOutput).ToList(); //List<int> matchingSumList = upperWHInventoryDetailViewList.Where(o => o.Matching != 0).Select(p => p.Matching).ToList(); foreach (UpperWHInventoryDetailViewModel print in upperWHInventoryDetailViewList) { DataRow dr = dt.NewRow(); dr["ProductNo"] = print.ProductNo; dr["ShoeName"] = print.ShoeName; dr["ArticleNo"] = print.ArticleNo; dr["AssemblyLine"] = assemblyLine; //dr["AssemblyLineSum"] = assemblyLine; dr["Quantity"] = print.Quantity; dr["Release"] = print.ReleaseQuantity; dr["Upper"] = print.SewingOutput; dr["OutSole"] = print.OutsoleOutput; dr["Matching"] = print.Matching; //dr["UpperSum"] = upperWHInventoryDetailViewList.Sum(o => o.SewingOutput).ToString(); //dr["OutSoleSum"] = upperWHInventoryDetailViewList.Sum(o => o.OutsoleOutput).ToString(); //dr["MatchingSum"] = upperWHInventoryDetailViewList.Sum(o => o.Matching).ToString(); dr["UpperSum"] = upperSum; dr["OutSoleSum"] = outsoleSum; dr["MatchingSum"] = matchingSum; dt.Rows.Add(dr); } } ReportDataSource rds = new ReportDataSource(); rds.Name = "UpperWHInventoryDetail_DataSetV9"; //rds.Name = "UpperWHInventoryDetailFinal"; rds.Value = dt; //reportViewer.LocalReport.ReportPath = @"C:\Users\IT02\Documents\Visual Studio 2010\Projects\Saoviet Master Schedule Solution\MasterSchedule\Reports\DelayReport.rdlc"; reportViewer.LocalReport.ReportPath = @"Reports\UpperWHInventoryDetailReport.rdlc"; //reportViewer.LocalReport.ReportPath = @"Reports\UpperWHInventoryDetailReportV11.rdlc"; reportViewer.LocalReport.DataSources.Add(rds); reportViewer.RefreshReport(); this.Cursor = null; }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); productNoList = orderList.Select(s => s.ProductNo).Distinct().ToList(); outsoleMasterList = OutsoleMasterController.Select(); outsoleOutputList = OutsoleOutputController.SelectByIsEnable(); sizeRunList = SizeRunController.SelectIsEnable(); var regex = new Regex("[a-z]|[A-Z]"); sizeNoList = new List <String>(); var sizeNoIsDouble = sizeRunList.Where(w => regex.IsMatch(w.SizeNo) == false).Select(s => s.SizeNo).Distinct().ToList(); sizeNoIsDouble = sizeNoIsDouble.OrderBy(s => Double.Parse(s)).ToList(); sizeNoList.AddRange(sizeNoIsDouble); var sizeNoIsCharacter = sizeRunList.Where(w => regex.IsMatch(w.SizeNo)).OrderBy(o => o.SizeNo).Select(s => s.SizeNo).Distinct().ToList(); sizeNoIsCharacter = sizeNoIsCharacter.OrderBy(s => regex.IsMatch(s) ? Double.Parse(regex.Replace(s, "")) : Double.Parse(s)).ToList(); sizeNoList.AddRange(sizeNoIsCharacter); // Collect Data outsoleOutputBalanceViewModelList = new List <OutsoleOutputBalanceViewModel>(); foreach (var po in productNoList) { var order = orderList.FirstOrDefault(f => f.ProductNo == po); var outsoleMaster_PO = outsoleMasterList.FirstOrDefault(f => f.ProductNo == po); var sizeRun_POList = sizeRunList.Where(w => w.ProductNo == po).ToList(); var outsoleOutput_POList = outsoleOutputList.Where(w => w.ProductNo == po).ToList(); if (order == null || outsoleMaster_PO == null || sizeRun_POList.Count == 0) { continue; } if (outsoleOutput_POList.Sum(s => s.Quantity) >= sizeRun_POList.Sum(s => s.Quantity)) { continue; } var outsoleOutputBalanceViewModel = new OutsoleOutputBalanceViewModel() { ProductNo = po, Country = order.Country, ShoeName = order.ShoeName, ArticleNo = order.ArticleNo, ETD = order.ETD, OutsoleLine = outsoleMaster_PO.OutsoleLine, OutsoleCode = order.OutsoleCode }; var outsoleOutputBalanceValueList = new List <OutsoleOutputBalanceValue>(); for (int i = 0; i <= sizeNoList.Count - 1; i++) { var sizeNoBinding = sizeNoList[i].Contains(".") == true ? sizeNoList[i].Replace(".", "@") : sizeNoList[i]; var outsoleOutputBalanceValue = new OutsoleOutputBalanceValue(); outsoleOutputBalanceValue.SizeNo = sizeNoList[i]; outsoleOutputBalanceValue.ForeColor = Brushes.Black; var sizeRun_Size = sizeRun_POList.FirstOrDefault(f => f.SizeNo == sizeNoList[i]); if (sizeRun_Size == null) { continue; } //PO not yet make if (outsoleOutput_POList.Count == 0) { outsoleOutputBalanceValue.Value = sizeRun_Size.Quantity; } else { var outsoleOutput_PO_SizeNo = outsoleOutput_POList.FirstOrDefault(f => f.SizeNo == sizeNoList[i]); int osOutput_PO_Size = outsoleOutput_PO_SizeNo != null ? outsoleOutput_PO_SizeNo.Quantity : 0; int qtyShow = sizeRun_Size.Quantity - osOutput_PO_Size; if (qtyShow > 0) { outsoleOutputBalanceValue.Value = qtyShow; } if (osOutput_PO_Size > 0) { outsoleOutputBalanceValue.ForeColor = Brushes.Red; } } if (outsoleOutputBalanceValue.Value > 0) { outsoleOutputBalanceValueList.Add(outsoleOutputBalanceValue); } } outsoleOutputBalanceViewModel.Values = outsoleOutputBalanceValueList; outsoleOutputBalanceViewModelList.Add(outsoleOutputBalanceViewModel); } }
// Notifications private void bwLoadDelivery_DoWork(object sender, DoWorkEventArgs e) { outsoleSupplierList = OutsoleSuppliersController.Select(); outsoleMaterialList = OutsoleMaterialController.Select(); outsoleReleaseMaterialList = OutsoleReleaseMaterialController.SelectByOutsoleMaterial(); outsoleOutputList = OutsoleOutputController.SelectByAssemblyMaster(); sewingMasterList = SewingMasterController.Select(); assemblyMasterList = AssemblyMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); orderList = OrdersController.Select(); outsoleRawMaterialList = OutsoleRawMaterialController.Select(); var outsoleCodeList = orderList.Select(o => o.OutsoleCode).Distinct().ToList(); DateTime dtNow = DateTime.Now; DateTime dtDefault = new DateTime(2000, 1, 1); DateTime deliveryEFDDate = dtDefault; // Delay Shipment Notifications foreach (var order in orderList) { bool needToShow = false; int assemblyBalance = 0, sewingBalance = 0, outsoleBalance = 0; var assemblyMaster = assemblyMasterList.FirstOrDefault(f => f.ProductNo == order.ProductNo); var sewingMaster = sewingMasterList.FirstOrDefault(f => f.ProductNo == order.ProductNo); var outsoleMaster = outsoleMasterList.FirstOrDefault(f => f.ProductNo == order.ProductNo); if (assemblyMaster == null || sewingMaster == null || outsoleMaster == null) { continue; } if (assemblyMaster.AssemblyBalance != "") { Int32.TryParse(assemblyMaster.AssemblyBalance, out assemblyBalance); } else { assemblyBalance = order.Quantity; } if (sewingMaster.SewingBalance != "") { Int32.TryParse(sewingMaster.SewingBalance, out sewingBalance); } else { sewingBalance = order.Quantity; } if (outsoleMaster.OutsoleBalance != "") { Int32.TryParse(outsoleMaster.OutsoleBalance, out outsoleBalance); } else { outsoleBalance = order.Quantity; } if (dtNow.AddDays(5) < order.ETD) { needToShow = false; } else { if (assemblyBalance > 0 || sewingBalance > 0 || outsoleBalance > 0) { needToShow = true; } if (assemblyBalance > 0 && sewingBalance == 0 && outsoleBalance == 0) { needToShow = false; } } if (needToShow == true) { var delayShipment = new DelayShipmentViewModel(); delayShipment.Style = order.ShoeName; delayShipment.ProductNo = order.ProductNo; delayShipment.OrderCSD = order.ETD.AddDays(10); if (assemblyBalance > 0) { delayShipment.AssemblyBalance = assemblyBalance; } if (sewingBalance > 0) { delayShipment.SewingBalance = sewingBalance; } if (outsoleBalance > 0) { delayShipment.OutsoleBalance = outsoleBalance; } if (delayShipment.OrderCSD < DateTime.Now.Date) { delayShipmentList.Add(delayShipment); } } } // OSWH Notifications foreach (string outsoleCode in outsoleCodeList) { var productNoList = orderList.Where(o => o.OutsoleCode == outsoleCode && o.IsEnable == true).Select(o => o.ProductNo).Distinct().ToList(); foreach (var productNo in productNoList) { var sewingMasterModel = sewingMasterList.Where(w => w.ProductNo == productNo).FirstOrDefault(); var orderModel = orderList.Where(w => w.ProductNo == productNo).FirstOrDefault(); if (sewingMasterModel == null || orderModel == null) { continue; } var outsoleMaterialList_D1 = outsoleMaterialList.Where(w => w.ProductNo == productNo).ToList(); var supplierIdList = outsoleMaterialList_D1.Select(s => s.OutsoleSupplierId).Distinct().ToList(); foreach (var supplierId in supplierIdList) { int quantityDelivery = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == supplierId).Sum(s => s.Quantity) - outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == supplierId).Sum(s => s.QuantityReject); int quantityDelivery1 = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == supplierId).Sum(s => s.Quantity - s.QuantityReject); var outsoleMaterialDelivery = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == supplierId).FirstOrDefault(); if (quantityDelivery > 0) { var outsoleRawMaterialModel = outsoleRawMaterialList.Where(w => w.ProductNo == productNo && w.OutsoleSupplierId == supplierId).FirstOrDefault(); if (outsoleRawMaterialModel != null) { deliveryEFDDate = outsoleRawMaterialModel.ETD; } if (deliveryEFDDate != dtDefault && deliveryEFDDate > dtNow.AddDays(15) && sewingMasterModel.SewingStartDate > dtNow.AddDays(25)) { var deliveryEarly = new NoticeOutsoleWHInventoryViewModel() { Style = orderModel.ShoeName, ProductNo = productNo, QuantityDelivery = quantityDelivery, Supplier = outsoleSupplierList.Where(w => w.OutsoleSupplierId == supplierId).Select(s => s.Name).FirstOrDefault(), OutsoleCode = outsoleCode, DeliveryEFDDate = deliveryEFDDate, SewingStartDate = sewingMasterModel.SewingStartDate, }; noticeOSWHInventoryDeliveryEarlyList.Add(deliveryEarly); } } var outsoleRawMaterialLateModel = outsoleRawMaterialList.Where(w => w.ETD <= dtNow && w.ProductNo == productNo && w.OutsoleSupplierId == supplierId).FirstOrDefault(); if (outsoleRawMaterialLateModel != null) { int quantityOrder = orderModel.Quantity; if (quantityOrder - quantityDelivery > 0) { var notDelivery = new NoticeOutsoleWHInventoryViewModel() { Style = orderModel.ShoeName, ProductNo = productNo, QuantityNotDelivery = quantityOrder - quantityDelivery, Supplier = outsoleSupplierList.Where(w => w.OutsoleSupplierId == supplierId).Select(s => s.Name).FirstOrDefault(), OutsoleCode = outsoleCode, DeliveryEFDDate = outsoleRawMaterialLateModel.ETD, OrderCSD = orderModel.ETD.AddDays(10) }; noticeOSWHInventoryNotDeliveryList.Add(notDelivery); } } int quantityReject = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == supplierId).Sum(s => s.QuantityReject); var outsoleMaterialReject = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == supplierId).FirstOrDefault(); // allways not null var outsoleRawMaterialReject = outsoleRawMaterialList.Where(w => w.ETD <= dtNow && w.ProductNo == productNo && w.OutsoleSupplierId == supplierId).FirstOrDefault(); if (quantityReject > 0 && outsoleMaterialReject.ModifiedTimeReject < dtNow.AddDays(-2) && outsoleRawMaterialReject != null) { var reject = new NoticeOutsoleWHInventoryViewModel() { Style = orderModel.ShoeName, ProductNo = productNo, OrderEFD = orderModel.ETD, QuantityReject = quantityReject, Supplier = outsoleSupplierList.Where(w => w.OutsoleSupplierId == supplierId).Select(s => s.Name).FirstOrDefault(), OutsoleCode = outsoleCode, DeliveryEFDDate = outsoleRawMaterialReject.ETD }; noticeOSWHInventoryRejectList.Add(reject); } } } } }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { assemblyMasterList = AssemblyMasterController.Select(); sewingOutputList = SewingOutputController.SelectByAssemblyMaster(); outsoleOutputList = OutsoleOutputController.SelectByAssemblyMaster(); assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster(); orderList = OrdersController.SelectByAssemblyMaster(); List <UpperWHInventoryViewModel> upperWHInventoryViewList = new List <UpperWHInventoryViewModel>(); assemblyLineList = assemblyMasterList.Where(a => String.IsNullOrEmpty(a.AssemblyLine) == false).Select(a => a.AssemblyLine).Distinct().OrderBy(l => l).ToList(); foreach (string assemblyLine in assemblyLineList) { List <String> productNoList = assemblyMasterList.Where(a => a.AssemblyLine == assemblyLine).Select(o => o.ProductNo).Distinct().ToList(); List <AssemblyReleaseModel> assemblyReleaseList_D1 = assemblyReleaseList.Where(a => productNoList.Contains(a.ProductNo) == true).ToList(); List <SewingOutputModel> sewingOutputList_D1 = sewingOutputList.Where(s => productNoList.Contains(s.ProductNo) == true).ToList(); List <OutsoleOutputModel> outsoleOutputList_D1 = outsoleOutputList.Where(o => productNoList.Contains(o.ProductNo) == true).ToList(); int qtyUpperTotal = 0; int qtyOutsoleTotal = 0; int qtyMatchTotal = 0; foreach (string productNo in productNoList) { List <AssemblyReleaseModel> assemblyReleaseList_D2 = assemblyReleaseList_D1.Where(a => a.ProductNo == productNo).ToList(); List <SewingOutputModel> sewingOutputList_D2 = sewingOutputList_D1.Where(s => s.ProductNo == productNo).ToList(); List <OutsoleOutputModel> outsoleOutputList_D2 = outsoleOutputList_D1.Where(o => o.ProductNo == productNo).ToList(); List <String> sizeNoList = sewingOutputList_D2.Select(s => s.SizeNo).Distinct().ToList(); if (sizeNoList.Count == 0) { sizeNoList = outsoleOutputList_D2.Select(o => o.SizeNo).Distinct().ToList(); } foreach (string sizeNo in sizeNoList) { int qtyRelease = assemblyReleaseList_D2.Where(a => a.SizeNo == sizeNo).Sum(a => a.Quantity); int qtyUpper = sewingOutputList_D2.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity) - qtyRelease; int qtyOutsole = outsoleOutputList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity) - qtyRelease; int qtyMatch = MatchingHelper.Calculate(sewingOutputList_D2.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity), outsoleOutputList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity), sizeNo) - qtyRelease; if (qtyUpper < 0) { qtyUpper = 0; } qtyUpperTotal += qtyUpper; if (qtyOutsole < 0) { qtyOutsole = 0; } qtyOutsoleTotal += qtyOutsole; if (qtyMatch < 0) { qtyMatch = 0; } qtyMatchTotal += qtyMatch; } } UpperWHInventoryViewModel upperWHInventoryView = new UpperWHInventoryViewModel { AssemblyLine = assemblyLine, ProductNoList = productNoList, SewingOutput = qtyUpperTotal, OutsoleOutput = qtyOutsoleTotal, Matching = qtyMatchTotal, }; upperWHInventoryViewList.Add(upperWHInventoryView); } e.Result = upperWHInventoryViewList; }