private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { materialTypeList = MaterialTypeController.Select().Where(w => w.MaterialGroup.Contains("UPPER")).ToList(); orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.SelectByProductNo(); DataTable dt = new DelayDataSet().Tables["DelayTable"]; List <String> productNoList = rawMaterialList.Select(r => r.ProductNo).Distinct().ToList(); var materialUpperIdList = materialTypeList.Select(s => s.MaterialTypeId).Distinct().ToList(); foreach (string productNo in productNoList) { OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault(); List <Int32> materialTypeIdList = rawMaterialList.Where(w => materialUpperIdList.Contains(w.MaterialTypeId)).Select(r => r.MaterialTypeId).Distinct().ToList(); // get assemblyline from productNo //AssemblyMasterModel assemblyMaster = assemblyMasterList.Where(o => o.ProductNo == productNo).FirstOrDefault(); // get sewingLing from productNo SewingMasterModel sewingMaster = sewingMasterList.Where(o => o.ProductNo == productNo).FirstOrDefault(); //materialTypeIdList.Remove(6); //materialTypeIdList.Remove(11); //materialTypeIdList.Remove(12); //materialTypeIdList.Remove(13); //materialTypeIdList.Remove(14); foreach (int materialTypeId in materialTypeIdList) { RawMaterialModel rawMaterial = rawMaterialList.Where(r => r.ProductNo == productNo && r.MaterialTypeId == materialTypeId).FirstOrDefault(); if (rawMaterial != null && rawMaterial.ETD.Date != new DateTime(2000, 1, 1) && rawMaterial.ETD.Date < DateTime.Now.Date && rawMaterial.ActualDate.Date == new DateTime(2000, 1, 1)) { DataRow dr = dt.NewRow(); // binding data to reportviewer dr["SewingLine"] = sewingMaster.SewingLine; dr["ProductNo"] = productNo; if (order != null) { dr["ArticleNo"] = order.ArticleNo; dr["ShoeName"] = order.ShoeName; dr["Quantity"] = order.Quantity; dr["ETD"] = order.ETD; } dr["SupplierETD"] = rawMaterial.ETD; dr["Remarks"] = rawMaterial.Remarks; MaterialTypeModel materialType = materialTypeList.Where(m => m.MaterialTypeId == rawMaterial.MaterialTypeId).FirstOrDefault(); if (materialType != null) { dr["Supplier"] = materialType.Name; } dt.Rows.Add(dr); } } } e.Result = dt; }
private void bwImport_DoWork(object sender, DoWorkEventArgs e) { var importList = e.Argument as List <RawMaterialModel>; progressBar.Dispatcher.Invoke((Action)(() => progressBar.Maximum = importList.Count())); int indexPrg = 1; foreach (var import in importList) { var productNoRevise = new ProductNoReviseModel { ProductNo = import.ProductNo, SectionId = "WH", ReviseDate = DateTime.Now, }; // db excute RawMaterialController.InsertFromExcel(import); ProductNoReviseController.Insert(productNoRevise); Dispatcher.Invoke(new Action(() => { dgUpperMaterialSchedule.SelectedItem = import; dgUpperMaterialSchedule.ScrollIntoView(import); })); progressBar.Dispatcher.Invoke((Action)(() => progressBar.Value = indexPrg)); indexPrg++; } }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { //materialTypeList = MaterialTypeController.Select(); materialTypeList = MaterialTypeController.Select().Where(w => w.MaterialGroup.Contains("UPPER")).ToList(); orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); }
void threadLoad_DoWork(object sender, DoWorkEventArgs e) { materialTypeList = MaterialTypeController.Select(); orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); List <String> productNoList = rawMaterialList.Select(r => r.ProductNo).Distinct().ToList(); foreach (string productNo in productNoList) { OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault(); List <Int32> materialTypeIdList = rawMaterialList.Select(r => r.MaterialTypeId).Distinct().ToList(); //Red! materialTypeIdList.Remove(6); materialTypeIdList.Remove(11); materialTypeIdList.Remove(12); materialTypeIdList.Remove(13); foreach (int materialTypeId in materialTypeIdList) { RawMaterialModel rawMaterial = rawMaterialList.Where(r => r.ProductNo == productNo && r.MaterialTypeId == materialTypeId).FirstOrDefault(); if (rawMaterial != null && rawMaterial.ETD.Date != dtDefault //&& rawMaterial.ActualDate.Date == dtDefault ) { DeliveryStatusViewModel deliveryStatusView = new DeliveryStatusViewModel(); deliveryStatusView.ProductNo = productNo; if (order != null) { deliveryStatusView.Country = order.Country; deliveryStatusView.ArticleNo = order.ArticleNo; deliveryStatusView.ShoeName = order.ShoeName; deliveryStatusView.Quantity = order.Quantity; deliveryStatusView.ETD = order.ETD; } MaterialTypeModel materialType = materialTypeList.Where(m => m.MaterialTypeId == rawMaterial.MaterialTypeId).FirstOrDefault(); if (materialType != null) { deliveryStatusView.Supplier = materialType.Name; } deliveryStatusView.SupplierETD = rawMaterial.ETD; if (rawMaterial.ActualDate != dtDefault) { deliveryStatusView.Actual = string.Format("{0:MM/dd/yyyy}", rawMaterial.ActualDate); deliveryStatusView.IsFinished = true; } else { deliveryStatusView.Actual = rawMaterial.Remarks; deliveryStatusView.IsFinished = false; } deliveryStatusViewList.Add(deliveryStatusView); } } } }
private void threadUpdateRawMaterial_DoWork(object sender, DoWorkEventArgs e) { RawMaterialController.Insert(rawMaterial); }
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 bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sockliningMasterList = SockliningMasterController.Select(); sewingMasterList = SewingMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); assemblyMasterList = AssemblyMasterController.Select(); //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); sockliningMasterList = sockliningMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; int[] materialIdAssemblyArray = { 8 }; int[] materialIdSockliningArray = { 9 }; foreach (SockliningMasterModel sockliningMaster in sockliningMasterList) { SockliningMasterExportViewModel sockliningMasterExportView = new SockliningMasterExportViewModel(); sockliningMasterExportView.Sequence = sockliningMaster.Sequence; sockliningMasterExportView.ProductNo = sockliningMaster.ProductNo; OrdersModel order = orderList.Where(o => o.ProductNo == sockliningMaster.ProductNo).FirstOrDefault(); if (order != null) { sockliningMasterExportView.Country = order.Country; sockliningMasterExportView.ShoeName = order.ShoeName; sockliningMasterExportView.ArticleNo = order.ArticleNo; sockliningMasterExportView.PatternNo = order.PatternNo; sockliningMasterExportView.Quantity = order.Quantity; sockliningMasterExportView.ETD = order.ETD; } MaterialArrivalViewModel materialArrivalSocklining = MaterialArrival(order.ProductNo, materialIdSockliningArray); sockliningMasterExportView.IsSockliningMatsArrivalOk = false; if (materialArrivalSocklining != null) { sockliningMasterExportView.SockliningMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalSocklining.Date); sockliningMasterExportView.IsSockliningMatsArrivalOk = materialArrivalSocklining.IsMaterialArrivalOk; } sockliningMasterExportView.SockliningLine = sockliningMaster.SockliningLine; sockliningMasterExportView.SockliningQuota = sockliningMaster.SockliningQuota; sockliningMasterExportView.SockliningStartDate = sockliningMaster.SockliningStartDate; sockliningMasterExportView.SockliningFinishDate = sockliningMaster.SockliningFinishDate; sockliningMasterExportView.InsoleBalance = sockliningMaster.InsoleBalance; sockliningMasterExportView.InsockBalance = sockliningMaster.InsockBalance; SewingMasterModel sewingMaster = sewingMasterList.Where(o => o.ProductNo == sockliningMaster.ProductNo).FirstOrDefault(); if (sewingMaster != null) { sockliningMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; sockliningMasterExportView.SewingBalance = sewingMaster.SewingBalance; } else { sockliningMasterExportView.SewingStartDate = dtDefault; sockliningMasterExportView.SewingBalance = ""; } OutsoleMasterModel outsoleMaster = outsoleMasterList.Where(o => o.ProductNo == sockliningMaster.ProductNo).FirstOrDefault(); if (outsoleMaster != null) { sockliningMasterExportView.OutsoleStartDate = outsoleMaster.OutsoleStartDate; sockliningMasterExportView.OutsoleBalance = outsoleMaster.OutsoleBalance; } else { sockliningMasterExportView.OutsoleStartDate = dtDefault; sockliningMasterExportView.OutsoleBalance = ""; } AssemblyMasterModel assemblyMaster = assemblyMasterList.Where(o => o.ProductNo == sockliningMaster.ProductNo).FirstOrDefault(); if (assemblyMaster != null) { sockliningMasterExportView.AssemblyStartDate = assemblyMaster.AssemblyStartDate; } else { sockliningMasterExportView.AssemblyStartDate = dtDefault; } sockliningMasterExportViewList.Add(sockliningMasterExportView); } }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { try { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.Select(); productionMemoList = ProductionMemoController.Select(); offDayList = OffDayController.Select(); privateDefine = PrivateDefineController.GetDefine(); } catch (Exception ex) { Dispatcher.Invoke(new Action(() => { MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error); })); return; } _SEW_VS_OTHERS_CUT_A = privateDefine.SewingVsOthersCutTypeA; _SEW_VS_OTHERS_CUT_B = privateDefine.SewingVsOthersCutTypeB; //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); sewingMasterList = sewingMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; foreach (SewingMasterModel sewingMaster in sewingMasterList) { CutprepMasterExportViewModel cutprepMasterExportView = new CutprepMasterExportViewModel(); cutprepMasterExportView.Sequence = sewingMaster.Sequence; cutprepMasterExportView.ProductNo = sewingMaster.ProductNo; OrdersModel order = orderList.FirstOrDefault(f => f.ProductNo == sewingMaster.ProductNo); string memoId = ""; if (order != null) { cutprepMasterExportView.Country = order.Country; cutprepMasterExportView.ShoeName = order.ShoeName; cutprepMasterExportView.ArticleNo = order.ArticleNo; cutprepMasterExportView.PatternNo = order.PatternNo; cutprepMasterExportView.Quantity = order.Quantity; cutprepMasterExportView.ETD = order.ETD; List <ProductionMemoModel> productionMemoByProductionNumberList = productionMemoList.Where(p => p.ProductionNumbers.Contains(order.ProductNo) == true).ToList(); for (int p = 0; p <= productionMemoByProductionNumberList.Count - 1; p++) { ProductionMemoModel productionMemo = productionMemoByProductionNumberList[p]; memoId += productionMemo.MemoId; if (p < productionMemoByProductionNumberList.Count - 1) { memoId += "\n"; } } cutprepMasterExportView.MemoId = memoId; } MaterialArrivalViewModel materialArrivalUpper = MaterialArrival(order.ProductNo, materialIdUpperArray); cutprepMasterExportView.IsUpperMatsArrivalOk = false; if (materialArrivalUpper != null) { cutprepMasterExportView.UpperMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalUpper.Date); cutprepMasterExportView.IsUpperMatsArrivalOk = materialArrivalUpper.IsMaterialArrivalOk; } cutprepMasterExportView.SewingLine = sewingMaster.SewingLine; cutprepMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; cutprepMasterExportView.SewingQuota = sewingMaster.SewingQuota; cutprepMasterExportView.SewingBalance = sewingMaster.SewingBalance; cutprepMasterExportView.CutAStartDate = sewingMaster.CutAStartDate; cutprepMasterExportView.CutAFinishDate = sewingMaster.CutAFinishDate; cutprepMasterExportView.CutAQuota = sewingMaster.CutAQuota; cutprepMasterExportView.AutoCut = sewingMaster.AutoCut; cutprepMasterExportView.LaserCut = sewingMaster.LaserCut; cutprepMasterExportView.HuasenCut = sewingMaster.HuasenCut; cutprepMasterExportView.CutABalance = sewingMaster.CutABalance; cutprepMasterExportView.PrintingBalance = sewingMaster.PrintingBalance; cutprepMasterExportView.H_FBalance = sewingMaster.H_FBalance; cutprepMasterExportView.EmbroideryBalance = sewingMaster.EmbroideryBalance; cutprepMasterExportView.CutBBalance = sewingMaster.CutBBalance; // Cut type A before sewing 18days var cutTypeABeforeSewing = sewingMaster.SewingStartDate.AddDays(-_SEW_VS_OTHERS_CUT_A); var dtCheckOffDateCutTypeAList = CheckOffDay(cutTypeABeforeSewing, sewingMaster.SewingStartDate); // Cut type B before sewing 10days var cutTypeBBeforeSewing = sewingMaster.SewingStartDate.AddDays(-_SEW_VS_OTHERS_CUT_B); var dtCheckOffDateCutTypeBList = CheckOffDay(cutTypeBBeforeSewing, sewingMaster.SewingStartDate); var firstDateCheckOffCutTypeA = String.Format("{0:M/d}", dtCheckOffDateCutTypeAList.FirstOrDefault()); var firstDateCheckOffCutTypeB = String.Format("{0:M/d}", dtCheckOffDateCutTypeBList.FirstOrDefault()); if (!String.IsNullOrEmpty(sewingMaster.CutBStartDate)) { cutprepMasterExportView.CutBStartDate = sewingMaster.CutBStartDate; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.CutBStartDate = firstDateCheckOffCutTypeB; } else { cutprepMasterExportView.CutBStartDate = ""; } if (!String.IsNullOrEmpty(sewingMaster.AtomCutA)) { cutprepMasterExportView.AtomCutA = sewingMaster.AtomCutA; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.AtomCutA = firstDateCheckOffCutTypeA; } else { cutprepMasterExportView.AtomCutA = ""; } if (!String.IsNullOrEmpty(sewingMaster.AtomCutB)) { cutprepMasterExportView.AtomCutB = sewingMaster.AtomCutB; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.AtomCutB = firstDateCheckOffCutTypeB; } else { cutprepMasterExportView.AtomCutB = ""; } if (!String.IsNullOrEmpty(sewingMaster.LaserCutA)) { cutprepMasterExportView.LaserCutA = sewingMaster.LaserCutA; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.LaserCutA = firstDateCheckOffCutTypeA; } else { cutprepMasterExportView.LaserCutA = ""; } if (!String.IsNullOrEmpty(sewingMaster.LaserCutB)) { cutprepMasterExportView.LaserCutB = sewingMaster.LaserCutB; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.LaserCutB = firstDateCheckOffCutTypeB; } else { cutprepMasterExportView.LaserCutB = ""; } if (!String.IsNullOrEmpty(sewingMaster.HuasenCutA)) { cutprepMasterExportView.HuasenCutA = sewingMaster.HuasenCutA; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.HuasenCutA = firstDateCheckOffCutTypeA; } else { cutprepMasterExportView.HuasenCutA = ""; } if (!String.IsNullOrEmpty(sewingMaster.HuasenCutB)) { cutprepMasterExportView.HuasenCutB = sewingMaster.HuasenCutB; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.HuasenCutB = firstDateCheckOffCutTypeB; } else { cutprepMasterExportView.HuasenCutB = ""; } if (!String.IsNullOrEmpty(sewingMaster.ComelzCutA)) { cutprepMasterExportView.ComelzCutA = sewingMaster.ComelzCutA; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.ComelzCutA = firstDateCheckOffCutTypeA; } else { cutprepMasterExportView.ComelzCutA = ""; } if (!String.IsNullOrEmpty(sewingMaster.ComelzCutB)) { cutprepMasterExportView.ComelzCutB = sewingMaster.ComelzCutB; } else if (sewingMaster.SewingStartDate != dtDefault) { cutprepMasterExportView.ComelzCutB = firstDateCheckOffCutTypeB; } else { cutprepMasterExportView.ComelzCutB = ""; } cutprepMasterExportViewList.Add(cutprepMasterExportView); } }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); sockliningMasterList = SockliningMasterController.Select(); assemblyMasterList = AssemblyMasterController.Select(); productionMemoList = ProductionMemoController.Select(); outsoleRawMaterialList = OutsoleRawMaterialController.Select(); rawMaterialViewModelNewList = RawMaterialController.Select_1(); //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); assemblyMasterList = assemblyMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; int[] materialIdAssemblyArray = { 8, 9 }; int[] materialIdCartonArray = { 11 }; foreach (AssemblyMasterModel assemblyMaster in assemblyMasterList) { AssemblyMasterExportViewModel assemblyMasterExportView = new AssemblyMasterExportViewModel(); assemblyMasterExportView.Sequence = assemblyMaster.Sequence; assemblyMasterExportView.ProductNo = assemblyMaster.ProductNo; OrdersModel order = orderList.Where(o => o.ProductNo == assemblyMaster.ProductNo).FirstOrDefault(); string memoId = ""; if (order != null) { assemblyMasterExportView.Country = order.Country; assemblyMasterExportView.ShoeName = order.ShoeName; assemblyMasterExportView.ArticleNo = order.ArticleNo; assemblyMasterExportView.LastCode = order.LastCode; assemblyMasterExportView.Quantity = order.Quantity; assemblyMasterExportView.ETD = order.ETD; List <ProductionMemoModel> productionMemoByProductionNumberList = productionMemoList.Where(p => p.ProductionNumbers.Contains(order.ProductNo) == true).ToList(); for (int p = 0; p <= productionMemoByProductionNumberList.Count - 1; p++) { ProductionMemoModel productionMemo = productionMemoByProductionNumberList[p]; memoId += productionMemo.MemoId; if (p < productionMemoByProductionNumberList.Count - 1) { memoId += "\n"; } } assemblyMasterExportView.MemoId = memoId; } //MaterialArrivalViewModel materialArrivalOutsole = MaterialArrival(order.ProductNo, materialIdOutsoleArray); //assemblyMasterExportView.IsOutsoleMatsArrivalOk = false; //if (materialArrivalOutsole != null) //{ // assemblyMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalOutsole.Date); // assemblyMasterExportView.IsOutsoleMatsArrivalOk = materialArrivalOutsole.IsMaterialArrivalOk; //} //// follow OutsoleRawMaterial //var osRawMaterial = outsoleRawMaterialList.Where(w => w.ProductNo == order.ProductNo).ToList(); //var actualDateList = osRawMaterial.Select(s => s.ActualDate).ToList(); //assemblyMasterExportView.IsOutsoleMatsArrivalOk = false; //if (actualDateList.Count() > 0 && actualDateList.Contains(dtDefault) == false) //{ // assemblyMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", actualDateList.Max()); // assemblyMasterExportView.IsOutsoleMatsArrivalOk = true; //} //else //{ // var etdDateList = osRawMaterial.Select(s => s.ETD).ToList(); // if (etdDateList.Count() > 0) // { // assemblyMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", etdDateList.Max()); // } //} assemblyMasterExportView.IsOutsoleMatsArrivalOk = false; var rawMaterialViewModelNew = rawMaterialViewModelNewList.FirstOrDefault(f => f.ProductNo == order.ProductNo); if (String.IsNullOrEmpty(rawMaterialViewModelNew.OUTSOLE_Remarks) && !String.IsNullOrEmpty(rawMaterialViewModelNew.OUTSOLE_ActualDate)) { assemblyMasterExportView.OutsoleMatsArrival = rawMaterialViewModelNew.OUTSOLE_ActualDate; assemblyMasterExportView.IsOutsoleMatsArrivalOk = true; } else { assemblyMasterExportView.OutsoleMatsArrival = rawMaterialViewModelNew.OUTSOLE_ETD; } MaterialArrivalViewModel materialArrivalAssembly = MaterialArrival(order.ProductNo, materialIdAssemblyArray); assemblyMasterExportView.IsAssemblyMatsArrivalOk = false; if (materialArrivalAssembly != null) { assemblyMasterExportView.AssemblyMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalAssembly.Date); assemblyMasterExportView.IsAssemblyMatsArrivalOk = materialArrivalAssembly.IsMaterialArrivalOk; } MaterialArrivalViewModel materialArrivalCarton = MaterialArrival(order.ProductNo, materialIdCartonArray); if (materialArrivalCarton != null) { assemblyMasterExportView.CartonMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalCarton.Date); } assemblyMasterExportView.AssemblyLine = assemblyMaster.AssemblyLine; assemblyMasterExportView.AssemblyStartDate = assemblyMaster.AssemblyStartDate; assemblyMasterExportView.AssemblyFinishDate = assemblyMaster.AssemblyFinishDate; assemblyMasterExportView.AssemblyQuota = assemblyMaster.AssemblyQuota; assemblyMasterExportView.AssemblyBalance = assemblyMaster.AssemblyBalance; SewingMasterModel sewingMaster = sewingMasterList.Where(o => o.ProductNo == assemblyMaster.ProductNo).FirstOrDefault(); if (sewingMaster != null) { assemblyMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; assemblyMasterExportView.SewingFinishDate = sewingMaster.SewingFinishDate; assemblyMasterExportView.SewingBalance = sewingMaster.SewingBalance; } else { assemblyMasterExportView.SewingStartDate = dtDefault; assemblyMasterExportView.SewingFinishDate = dtDefault; assemblyMasterExportView.SewingBalance = ""; } OutsoleMasterModel outsoleMaster = outsoleMasterList.Where(o => o.ProductNo == assemblyMaster.ProductNo).FirstOrDefault(); if (outsoleMaster != null) { assemblyMasterExportView.OutsoleBalance = outsoleMaster.OutsoleBalance; } else { assemblyMasterExportView.OutsoleBalance = ""; } SockliningMasterModel sockliningMaster = sockliningMasterList.Where(o => o.ProductNo == assemblyMaster.ProductNo).FirstOrDefault(); if (sockliningMaster != null) { assemblyMasterExportView.InsoleBalance = sockliningMaster.InsoleBalance; assemblyMasterExportView.InsockBalance = sockliningMaster.InsockBalance; } else { assemblyMasterExportView.InsoleBalance = ""; assemblyMasterExportView.InsockBalance = ""; } assemblyMasterExportViewList.Add(assemblyMasterExportView); } }
private void threadLoad_DoWork(object sender, DoWorkEventArgs e) { //Get offdate offDateList = OffDayController.SelectDate(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdAssemblyArray = { 8 }; int[] materialIdOutsoleArray = { 6 }; object[] args = e.Argument as object[]; DateTime dateFrom = (args[0] as DateTime?).Value; DateTime dateTo = (args[1] as DateTime?).Value; string sectionId = args[2] as string; if (orderList.Count <= 0) { orderList = OrdersController.Select(); } if (sectionId == sewing && sewingMasterList.Count <= 0) { sewingMasterList = SewingMasterController.Select(); } if (sectionId == assembly && assemblyMasterList.Count <= 0) { assemblyMasterList = AssemblyMasterController.Select(); } if (sectionId == outsole && outsoleMasterList.Count <= 0) { outsoleMasterList = OutsoleMasterController.Select(); } if (rawMaterialList.Count <= 0) { rawMaterialList = RawMaterialController.Select(); } string[] lineArray = null; string[] tempArray = null; if (sectionId == sewing) { //lineArray = sewingMasterList.Select(s => s.SewingLine).Distinct().OrderBy(s => s).ToArray(); tempArray = sewingMasterList.Select(s => s.SewingLine).Distinct().ToArray(); SortArray(tempArray); lineArray = tempArray; } if (sectionId == assembly) { //lineArray = assemblyMasterList.Select(s => s.AssemblyLine).Distinct().OrderBy(s => s).ToArray(); tempArray = assemblyMasterList.Select(s => s.AssemblyLine).Distinct().ToArray(); SortArray(tempArray); lineArray = tempArray; } if (sectionId == outsole) { lineArray = outsoleMasterList.Select(s => s.OutsoleLine).Distinct().OrderBy(s => s).ToArray(); } foreach (string line in lineArray) { DataRow dr = dt.NewRow(); dr["Line"] = line; if (sectionId == sewing) { List <SewingMasterModel> sewingMasterTempList = sewingMasterList.Where(s => s.SewingLine == line && ((dateFrom <= s.SewingStartDate && s.SewingStartDate <= dateTo) || (dateFrom <= s.SewingFinishDate && s.SewingFinishDate <= dateTo))).ToList(); foreach (SewingMasterModel sewingMaster in sewingMasterTempList) { OrdersModel order = orderList.Where(o => o.ProductNo == sewingMaster.ProductNo).FirstOrDefault(); CompareDate(order, dateFrom, dateTo, sewingMaster.SewingStartDate, sewingMaster.SewingFinishDate, ref dr, materialIdUpperArray); } } if (sectionId == assembly) { List <AssemblyMasterModel> sewingMasterTempList = assemblyMasterList.Where(s => s.AssemblyLine == line && ((dateFrom <= s.AssemblyStartDate && s.AssemblyStartDate <= dateTo) || (dateFrom <= s.AssemblyFinishDate && s.AssemblyFinishDate <= dateTo))).ToList(); foreach (AssemblyMasterModel sewingMaster in sewingMasterTempList) { OrdersModel order = orderList.Where(o => o.ProductNo == sewingMaster.ProductNo).FirstOrDefault(); CompareDate(order, dateFrom, dateTo, sewingMaster.AssemblyStartDate, sewingMaster.AssemblyFinishDate, ref dr, materialIdAssemblyArray); } } if (sectionId == outsole) { List <OutsoleMasterModel> sewingMasterTempList = outsoleMasterList.Where(s => s.OutsoleLine == line && ((dateFrom <= s.OutsoleStartDate && s.OutsoleStartDate <= dateTo) || (dateFrom <= s.OutsoleFinishDate && s.OutsoleFinishDate <= dateTo))).ToList(); foreach (OutsoleMasterModel sewingMaster in sewingMasterTempList) { OrdersModel order = orderList.Where(o => o.ProductNo == sewingMaster.ProductNo).FirstOrDefault(); CompareDate(order, dateFrom, dateTo, sewingMaster.OutsoleStartDate, sewingMaster.OutsoleFinishDate, ref dr, materialIdOutsoleArray); } } dt.Rows.Add(dr); } }
private void BwLoad_DoWork(object sender, DoWorkEventArgs e) { try { offDayList = OffDayController.Select(); productionMemoList = ProductionMemoController.Select(); sewingMasterViewModelNewList = ReportController.GetSewingSummaryReport(); rawMaterialViewModelNewList = RawMaterialController.Select_1(); } catch (Exception ex) { Dispatcher.Invoke(new Action(() => { MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error); })); return; } _SEW_VS_OTHERS_CUT_A = privateDefine.SewingVsOthersCutTypeA; _SEW_VS_OTHERS_CUT_B = privateDefine.SewingVsOthersCutTypeB; //int index = 1; DataTable dt = new SewingSummaryDataset().Tables["SewingSummaryDatatable"]; foreach (var sewNew in sewingMasterViewModelNewList) { var memoByPOList = productionMemoList.Where(p => p.ProductionNumbers.Contains(sewNew.ProductNo) == true).Select(s => s.MemoId).ToList(); var sewingMasterView = new SewingMasterViewModel(); // Order Information sewingMasterView.ProductNoBackground = Brushes.Transparent; sewingMasterView.ProductNo = sewNew.ProductNo; sewingMasterView.Country = sewNew.Country; sewingMasterView.ShoeName = sewNew.ShoeName; sewingMasterView.ArticleNo = sewNew.ArticleNo; sewingMasterView.PatternNo = sewNew.PatternNo; sewingMasterView.Quantity = sewNew.Quantity; sewingMasterView.ETD = sewNew.ETD; // Sewing Master Information sewingMasterView.Sequence = sewNew.Sequence; sewingMasterView.SewingLine = sewNew.SewingLine; sewingMasterView.SewingQuota = sewNew.SewingQuota; sewingMasterView.SewingStartDate = sewNew.SewingStartDate; sewingMasterView.SewingFinishDate = sewNew.SewingFinishDate; sewingMasterView.SewingPrep = sewNew.SewingPrep; sewingMasterView.SewingActualStartDate = sewNew.SewingActualStartDate; sewingMasterView.SewingActualFinishDate = sewNew.SewingActualFinishDate; sewingMasterView.SewingActualStartDateAuto = sewNew.SewingActualStartDateAuto; sewingMasterView.SewingActualFinishDateAuto = sewNew.SewingActualFinishDateAuto; sewingMasterView.SewingBalance = sewNew.SewingBalance; sewingMasterView.CutAStartDate = sewNew.CutAStartDate; sewingMasterView.CutAFinishDate = sewNew.CutAFinishDate; sewingMasterView.CutAQuota = sewNew.CutAQuota; sewingMasterView.CutAActualStartDate = sewNew.CutAActualStartDate; sewingMasterView.CutAActualFinishDate = sewNew.CutAActualFinishDate; sewingMasterView.PrintingBalance = sewNew.PrintingBalance; sewingMasterView.H_FBalance = sewNew.H_FBalance; sewingMasterView.EmbroideryBalance = sewNew.EmbroideryBalance; sewingMasterView.CutBBalance = sewNew.CutBBalance; sewingMasterView.AutoCut = sewNew.AutoCut; sewingMasterView.LaserCut = sewNew.LaserCut; sewingMasterView.HuasenCut = sewNew.HuasenCut; sewingMasterView.AssemblyBalance = sewNew.AssemblyBalance; // Outsole Master Infor sewingMasterView.OSFinishDate = sewNew.OSFinishDate; sewingMasterView.OSBalance = sewNew.OSBalance; sewingMasterView.SewingStartDateForeground = Brushes.Black; sewingMasterView.SewingFinishDateForeground = Brushes.Black; sewingMasterView.CutAStartDateForeground = Brushes.Black; //var bfSew10 = sewNew.SewingStartDate.AddDays(-10); var bfSew10 = sewNew.SewingStartDate.AddDays(-_SEW_VS_OTHERS_CUT_B); var bfSew10IncludeHolidayList = CheckOffDay(bfSew10, sewNew.SewingStartDate); //var bfSew15 = sewNew.SewingStartDate.AddDays(-15); var bfSew15 = sewNew.SewingStartDate.AddDays(-_SEW_VS_OTHERS_CUT_A); var bfSew15IncludeHolidayList = CheckOffDay(bfSew15, sewNew.SewingStartDate); var bf10 = bfSew10IncludeHolidayList.FirstOrDefault(); var bf15 = bfSew15IncludeHolidayList.FirstOrDefault(); if (string.IsNullOrEmpty(sewNew.CutBStartDate) == false) { sewingMasterView.CutBStartDate = sewNew.CutBStartDate; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.CutBStartDate = TimeHelper.ConvertDateToView(new DateTime(bf10.Year, bf10.Month, bf10.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.CutBStartDate = ""; } } if (string.IsNullOrEmpty(sewNew.AtomCutA) == false) { sewingMasterView.AtomCutA = sewNew.AtomCutA; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.AtomCutA = TimeHelper.ConvertDateToView(new DateTime(bf15.Year, bf15.Month, bf15.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.AtomCutA = ""; } } if (string.IsNullOrEmpty(sewNew.AtomCutB) == false) { sewingMasterView.AtomCutB = sewNew.AtomCutB; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.AtomCutB = TimeHelper.ConvertDateToView(new DateTime(bf10.Year, bf10.Month, bf10.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.AtomCutB = ""; } } if (string.IsNullOrEmpty(sewNew.LaserCutA) == false) { sewingMasterView.LaserCutA = sewNew.LaserCutA; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.LaserCutA = TimeHelper.ConvertDateToView(new DateTime(bf15.Year, bf15.Month, bf15.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.LaserCutA = ""; } } if (string.IsNullOrEmpty(sewNew.LaserCutB) == false) { sewingMasterView.LaserCutB = sewNew.LaserCutB; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.LaserCutB = TimeHelper.ConvertDateToView(new DateTime(bf10.Year, bf10.Month, bf10.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.LaserCutB = ""; } } if (string.IsNullOrEmpty(sewNew.HuasenCutA) == false) { sewingMasterView.HuasenCutA = sewNew.HuasenCutA; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.HuasenCutA = TimeHelper.ConvertDateToView(new DateTime(bf15.Year, bf15.Month, bf15.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.HuasenCutA = ""; } } if (string.IsNullOrEmpty(sewNew.HuasenCutB) == false) { sewingMasterView.HuasenCutB = sewNew.HuasenCutB; } else { if (sewNew.SewingStartDate != dtDefault) { sewingMasterView.HuasenCutB = TimeHelper.ConvertDateToView(new DateTime(bf10.Year, bf10.Month, bf10.Day).ToString("MM/dd/yyyy")); } else { sewingMasterView.HuasenCutB = ""; } } // UpperMaterial 1, 2, 3, 4, 10 if (sewNew.UpperMaterialFinisedDate != dtDefault) { sewingMasterView.UpperMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.UpperMaterialFinisedDate); } else if (sewNew.UpperMaterialETD != dtDefault) { sewingMasterView.UpperMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.UpperMaterialETD); } //Sewing Material 5, 7 if (sewNew.SewingMaterialFinisedDate != dtDefault) { sewingMasterView.SewingMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.SewingMaterialFinisedDate); } else if (sewNew.SewingMaterialETD != dtDefault) { sewingMasterView.SewingMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.SewingMaterialETD); } // Assembly Material 8, 9 if (sewNew.AssemblyMaterialFinisedDate != dtDefault) { sewingMasterView.AssemblyMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.AssemblyMaterialFinisedDate); } else if (sewNew.AssemblyMaterialETD != dtDefault) { sewingMasterView.AssemblyMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.AssemblyMaterialETD); } //// Outsole Material 6 //if (sewNew.OutsoleMaterialFinisedDate != dtDefault) // sewingMasterView.OSMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.OutsoleMaterialFinisedDate); //else if (sewNew.OutsoleMaterialETD != dtDefault) // sewingMasterView.OSMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", sewNew.OutsoleMaterialETD); // Base on rawmaterial sewingMasterView.OSMatsArrival = ""; var osMaterial = rawMaterialViewModelNewList.FirstOrDefault(f => f.ProductNo == sewNew.ProductNo); if (String.IsNullOrEmpty(osMaterial.OUTSOLE_Remarks) && !String.IsNullOrEmpty(osMaterial.OUTSOLE_ActualDate)) { sewingMasterView.OSMatsArrival = osMaterial.OUTSOLE_ActualDate; } else if (osMaterial.OUTSOLE_ETD_DATE != dtDefault) { sewingMasterView.OSMatsArrival = osMaterial.OUTSOLE_ETD; } sewingMasterView.OutsoleStartDate = sewNew.OutsoleStartDate; sewingMasterView.OutsoleFinishDate = sewNew.OutsoleFinishDate; sewingMasterView.AssemblyStartDate = sewNew.AssemblyStartDate; sewingMasterView.AssemblyFinishDate = sewNew.AssemblyFinishDate; sewingMasterView.OutsoleCode = sewNew.OutsoleCode; sewingMasterViewList.Add(sewingMasterView); DataRow dr = dt.NewRow(); dr["MemoId"] = memoByPOList.Count() > 0 ? String.Join("\n", memoByPOList) : ""; dr["ProductNo"] = sewNew.ProductNo; dr["Country"] = sewNew.Country; dr["ShoeName"] = sewNew.ShoeName; dr["ArticleNo"] = sewNew.ArticleNo; dr["PatternNo"] = sewNew.PatternNo; dr["Quantity"] = sewNew.Quantity; dr["ETD"] = sewNew.ETD; dr["CSD"] = sewNew.ETD.AddDays(10); dr["UpperMatsArrival"] = sewingMasterView.UpperMatsArrival; dr["SewingMatsArrival"] = sewingMasterView.SewingMatsArrival; dr["OutsoleMatsArrival"] = sewingMasterView.OSMatsArrival; dr["AssemblyMatsArrival"] = sewingMasterView.AssemblyMatsArrival; dr["SewingLine"] = sewNew.SewingLine; dr["SewingStartDate"] = sewNew.SewingStartDate; dr["SewingFinishDate"] = sewNew.SewingFinishDate; dr["SewingActualStartDate"] = sewNew.SewingActualStartDate; dr["SewingActualFinishDate"] = sewNew.SewingActualFinishDate; dr["SewingActualStartDateAuto"] = sewNew.SewingActualStartDateAuto; dr["SewingActualFinishDateAuto"] = sewNew.SewingActualFinishDateAuto; dr["SewingBalance"] = sewNew.SewingBalance; dr["CutAStartDate"] = sewNew.CutAStartDate; dr["CutAFinishDate"] = sewNew.CutAFinishDate; dr["CutAQuota"] = sewNew.CutAQuota; dr["CutAActualStartDate"] = sewNew.CutAActualStartDate; dr["CutAActualFinishDate"] = sewNew.CutAActualFinishDate; dr["CutABalance"] = sewNew.CutABalance; dr["PrintingBalance"] = sewNew.PrintingBalance; dr["H_FBalance"] = sewNew.H_FBalance; dr["EmbroideryBalance"] = sewNew.EmbroideryBalance; dr["AutoCut"] = sewNew.AutoCut; dr["LaserCut"] = sewNew.LaserCut; dr["HuasenCut"] = sewNew.HuasenCut; dr["CutBStartDate"] = sewNew.CutBStartDate; dr["AtomCutA"] = sewingMasterView.AtomCutA; dr["AtomCutB"] = sewingMasterView.AtomCutB; dr["LaserCutA"] = sewingMasterView.LaserCutA; dr["LaserCutB"] = sewingMasterView.LaserCutB; dr["HuasenCutA"] = sewingMasterView.HuasenCutA; dr["HuasenCutB"] = sewingMasterView.HuasenCutB; dr["OutsoleStartDate"] = sewNew.OutsoleStartDate; dr["OutsoleFinishDate"] = sewNew.OutsoleFinishDate; dr["AssemblyStartDate"] = sewNew.AssemblyStartDate; dr["AssemblyFinishDate"] = sewNew.AssemblyFinishDate; dr["SewingPrep"] = sewNew.SewingPrep; dr["StockfitFinishDate"] = sewNew.OutsoleFinishDate; dr["StockfitBalance"] = sewNew.OSBalance; dr["CutprepBalance"] = sewNew.H_FBalance; dr["SewingQuota"] = sewNew.SewingQuota; dr["OutsoleCode"] = sewNew.OutsoleCode; dr["AssemblyBalance"] = sewNew.AssemblyBalance; dt.Rows.Add(dr); } sewingMasterViewList = sewingMasterViewList.OrderBy(s => s.SewingLine).ThenBy(s => s.Sequence).ToList(); e.Result = dt; }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { materialTypeList = MaterialTypeController.Select(); orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); productionMemoList = ProductionMemoController.Select(); outsoleRawMaterialList = OutsoleRawMaterialController.Select(); rawMaterialViewModelNewList = RawMaterialController.Select_1(); //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); sewingMasterList = sewingMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; foreach (SewingMasterModel sewingMaster in sewingMasterList) { SewingMasterExportViewModel sewingMasterExportView = new SewingMasterExportViewModel(); sewingMasterExportView.Sequence = sewingMaster.Sequence; sewingMasterExportView.ProductNo = sewingMaster.ProductNo; OrdersModel order = orderList.Where(o => o.ProductNo == sewingMaster.ProductNo).FirstOrDefault(); string memoId = ""; if (order != null) { sewingMasterExportView.Country = order.Country; sewingMasterExportView.ShoeName = order.ShoeName; sewingMasterExportView.ArticleNo = order.ArticleNo; sewingMasterExportView.PatternNo = order.PatternNo; sewingMasterExportView.Quantity = order.Quantity; sewingMasterExportView.ETD = order.ETD; List <ProductionMemoModel> productionMemoByProductionNumberList = productionMemoList.Where(p => p.ProductionNumbers.Contains(order.ProductNo) == true).ToList(); for (int p = 0; p <= productionMemoByProductionNumberList.Count - 1; p++) { ProductionMemoModel productionMemo = productionMemoByProductionNumberList[p]; memoId += productionMemo.MemoId; if (p < productionMemoByProductionNumberList.Count - 1) { memoId += "\n"; } } sewingMasterExportView.MemoId = memoId; } MaterialArrivalViewModel materialArrivalUpper = MaterialArrival(order.ProductNo, materialIdUpperArray); sewingMasterExportView.IsUpperMatsArrivalOk = false; if (materialArrivalUpper != null) { sewingMasterExportView.UpperMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalUpper.Date); sewingMasterExportView.IsUpperMatsArrivalOk = materialArrivalUpper.IsMaterialArrivalOk; } MaterialArrivalViewModel materialArrivalSewing = MaterialArrival(order.ProductNo, materialIdSewingArray); sewingMasterExportView.IsSewingMatsArrivalOk = false; if (materialArrivalSewing != null) { sewingMasterExportView.SewingMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalSewing.Date); sewingMasterExportView.IsSewingMatsArrivalOk = materialArrivalSewing.IsMaterialArrivalOk; } //MaterialArrivalViewModel materialArrivalOutsole = MaterialArrival(order.ProductNo, materialIdOutsoleArray); //sewingMasterExportView.IsOSMatsArrivalOk = false; //if (materialArrivalOutsole != null) //{ // sewingMasterExportView.OSMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalOutsole.Date); // sewingMasterExportView.IsOSMatsArrivalOk = materialArrivalOutsole.IsMaterialArrivalOk; //} // For Outsole Material //var osRawMaterial = outsoleRawMaterialList.Where(w => w.ProductNo == order.ProductNo).ToList(); //var actualDateList = osRawMaterial.Select(s => s.ActualDate).ToList(); //sewingMasterExportView.IsOSMatsArrivalOk = false; //if (actualDateList.Count() > 0 && actualDateList.Contains(dtDefault) == false) //{ // sewingMasterExportView.OSMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", actualDateList.Max()); // sewingMasterExportView.IsOSMatsArrivalOk = true; //} //else //{ // var etdDateList = osRawMaterial.Select(s => s.ETD).ToList(); // if (etdDateList.Count() > 0) // { // sewingMasterExportView.OSMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", etdDateList.Max()); // } //} var rawMaterialViewModelNew = rawMaterialViewModelNewList.FirstOrDefault(f => f.ProductNo == order.ProductNo); sewingMasterExportView.IsOSMatsArrivalOk = false; if (String.IsNullOrEmpty(rawMaterialViewModelNew.OUTSOLE_Remarks) && !String.IsNullOrEmpty(rawMaterialViewModelNew.OUTSOLE_ActualDate)) { sewingMasterExportView.OSMatsArrival = rawMaterialViewModelNew.OUTSOLE_ActualDate; sewingMasterExportView.IsOSMatsArrivalOk = true; } else { sewingMasterExportView.OSMatsArrival = rawMaterialViewModelNew.OUTSOLE_ETD; } sewingMasterExportView.SewingLine = sewingMaster.SewingLine; sewingMasterExportView.CutAStartDate = sewingMaster.CutAStartDate; sewingMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; sewingMasterExportView.SewingFinishDate = sewingMaster.SewingFinishDate; sewingMasterExportView.SewingQuota = sewingMaster.SewingQuota; sewingMasterExportView.SewingBalance = sewingMaster.SewingBalance; sewingMasterExportView.CutABalance = sewingMaster.CutABalance; sewingMasterExportView.CutBBalance = sewingMaster.CutBBalance; OutsoleMasterModel outsoleMaster = outsoleMasterList.Where(o => o.ProductNo == sewingMaster.ProductNo).FirstOrDefault(); if (outsoleMaster != null) { sewingMasterExportView.OSBalance = outsoleMaster.OutsoleBalance; } else { sewingMasterExportView.OSBalance = ""; } sewingMasterExportViewList.Add(sewingMasterExportView); } }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); outsoleReleaseMaterialList = OutsoleReleaseMaterialController.SelectByOutsoleMaster(); productionMemoList = ProductionMemoController.Select(); //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); outsoleMasterList = outsoleMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; foreach (OutsoleMasterModel outsoleMaster in outsoleMasterList) { OutsoleMasterExportViewModel outsoleMasterExportView = new OutsoleMasterExportViewModel(); outsoleMasterExportView.Sequence = outsoleMaster.Sequence; outsoleMasterExportView.ProductNo = outsoleMaster.ProductNo; OrdersModel order = orderList.Where(o => o.ProductNo == outsoleMaster.ProductNo).FirstOrDefault(); string memoId = ""; if (order != null) { outsoleMasterExportView.Country = order.Country; outsoleMasterExportView.ShoeName = order.ShoeName; outsoleMasterExportView.ArticleNo = order.ArticleNo; outsoleMasterExportView.OutsoleCode = order.OutsoleCode; outsoleMasterExportView.Quantity = order.Quantity; outsoleMasterExportView.ETD = order.ETD; List <ProductionMemoModel> productionMemoByProductionNumberList = productionMemoList.Where(p => p.ProductionNumbers.Contains(order.ProductNo) == true).ToList(); for (int p = 0; p <= productionMemoByProductionNumberList.Count - 1; p++) { ProductionMemoModel productionMemo = productionMemoByProductionNumberList[p]; memoId += productionMemo.MemoId; if (p < productionMemoByProductionNumberList.Count - 1) { memoId += "\n"; } } outsoleMasterExportView.MemoId = memoId; } MaterialArrivalViewModel materialArrivalOutsole = MaterialArrival(order.ProductNo, materialIdOutsoleArray); outsoleMasterExportView.IsOutsoleMatsArrivalOk = false; if (materialArrivalOutsole != null) { outsoleMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalOutsole.Date); outsoleMasterExportView.IsOutsoleMatsArrivalOk = materialArrivalOutsole.IsMaterialArrivalOk; } outsoleMasterExportView.OutsoleLine = outsoleMaster.OutsoleLine; outsoleMasterExportView.OutsoleStartDate = outsoleMaster.OutsoleStartDate; outsoleMasterExportView.OutsoleFinishDate = outsoleMaster.OutsoleFinishDate; outsoleMasterExportView.OutsoleQuota = outsoleMaster.OutsoleQuota; outsoleMasterExportView.OutsoleBalance = outsoleMaster.OutsoleBalance; RawMaterialModel outsoleRawMaterial = rawMaterialList.Where(r => r.ProductNo == outsoleMaster.ProductNo && materialIdOutsoleArray.Contains(r.MaterialTypeId)).FirstOrDefault(); if (outsoleRawMaterial != null) { outsoleMasterExportView.OutsoleWHBalance = outsoleRawMaterial.Remarks; } else { outsoleMasterExportView.OutsoleWHBalance = ""; } SewingMasterModel sewingMaster = sewingMasterList.Where(o => o.ProductNo == outsoleMaster.ProductNo).FirstOrDefault(); if (sewingMaster != null) { outsoleMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; outsoleMasterExportView.SewingFinishDate = sewingMaster.SewingFinishDate; outsoleMasterExportView.SewingQuota = sewingMaster.SewingQuota; outsoleMasterExportView.SewingBalance = sewingMaster.SewingBalance; } else { outsoleMasterExportView.SewingStartDate = dtDefault; outsoleMasterExportView.SewingFinishDate = dtDefault; outsoleMasterExportView.SewingQuota = 0; outsoleMasterExportView.SewingBalance = ""; } List <OutsoleReleaseMaterialModel> outsoleReleaseMaterialList_D1 = outsoleReleaseMaterialList.Where(o => o.ProductNo == outsoleMaster.ProductNo).ToList(); int qtyReleased = outsoleReleaseMaterialList_D1.Sum(o => o.Quantity); outsoleMasterExportView.ReleasedQuantity = qtyReleased.ToString(); if (qtyReleased <= 0) { outsoleMasterExportView.ReleasedQuantity = ""; } if (qtyReleased >= outsoleMasterExportView.Quantity && outsoleReleaseMaterialList_D1.Count > 0) { DateTime releasedDate = outsoleReleaseMaterialList_D1.FirstOrDefault().ModifiedTime; outsoleMasterExportView.ReleasedQuantity = string.Format("{0:M/d}", releasedDate); } outsoleMasterExportViewList.Add(outsoleMasterExportView); } }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); outsoleRawMaterialList = OutsoleRawMaterialController.Select(); outsoleReleaseMaterialList = OutsoleReleaseMaterialController.SelectByOutsoleMaster(); productionMemoList = ProductionMemoController.Select(); outsoleMaterialList = OutsoleMaterialController.Select(); rawMaterialViewModelNewList = RawMaterialController.Select_1(); //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); outsoleMasterList = outsoleMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; foreach (OutsoleMasterModel outsoleMaster in outsoleMasterList) { OutsoleMasterExportViewModel outsoleMasterExportView = new OutsoleMasterExportViewModel(); outsoleMasterExportView.Sequence = outsoleMaster.Sequence; outsoleMasterExportView.ProductNo = outsoleMaster.ProductNo; OrdersModel order = orderList.FirstOrDefault(f => f.ProductNo == outsoleMaster.ProductNo); string memoId = ""; if (order != null) { outsoleMasterExportView.Country = order.Country; outsoleMasterExportView.ShoeName = order.ShoeName; outsoleMasterExportView.ArticleNo = order.ArticleNo; outsoleMasterExportView.OutsoleCode = order.OutsoleCode; outsoleMasterExportView.PatternNo = order.PatternNo; outsoleMasterExportView.Quantity = order.Quantity; outsoleMasterExportView.ETD = order.ETD; List <ProductionMemoModel> productionMemoByProductionNumberList = productionMemoList.Where(p => p.ProductionNumbers.Contains(order.ProductNo) == true).ToList(); for (int p = 0; p <= productionMemoByProductionNumberList.Count - 1; p++) { ProductionMemoModel productionMemo = productionMemoByProductionNumberList[p]; memoId += productionMemo.MemoId; if (p < productionMemoByProductionNumberList.Count - 1) { memoId += "\n"; } } outsoleMasterExportView.MemoId = memoId; } //MaterialArrivalViewModel materialArrivalOutsole = MaterialArrival(order.ProductNo, materialIdOutsoleArray); //outsoleMasterExportView.IsOutsoleMatsArrivalOk = false; //if (materialArrivalOutsole != null) //{ // outsoleMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalOutsole.Date); // outsoleMasterExportView.IsOutsoleMatsArrivalOk = materialArrivalOutsole.IsMaterialArrivalOk; //} // Update follow OutsoleRawMaterial //var osRawMaterial = outsoleRawMaterialList.Where(w => w.ProductNo == order.ProductNo).ToList(); //var actualDateList = osRawMaterial.Select(s => s.ActualDate).ToList(); //outsoleMasterExportView.IsOutsoleMatsArrivalOk = false; //if (actualDateList.Count() > 0 && actualDateList.Contains(dtDefault) == false) //{ // outsoleMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", actualDateList.Max()); // outsoleMasterExportView.IsOutsoleMatsArrivalOk = true; //} //else //{ // var etdDateList = osRawMaterial.Select(s => s.ETD).ToList(); // if (etdDateList.Count() > 0) // { // outsoleMasterExportView.OutsoleMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", etdDateList.Max()); // } //} outsoleMasterExportView.IsOutsoleMatsArrivalOk = false; var rawMaterialViewModelNew = rawMaterialViewModelNewList.FirstOrDefault(f => f.ProductNo == order.ProductNo); if (String.IsNullOrEmpty(rawMaterialViewModelNew.OUTSOLE_Remarks) && !String.IsNullOrEmpty(rawMaterialViewModelNew.OUTSOLE_ActualDate)) { outsoleMasterExportView.OutsoleMatsArrival = rawMaterialViewModelNew.OUTSOLE_ActualDate; outsoleMasterExportView.IsOutsoleMatsArrivalOk = true; } else { outsoleMasterExportView.OutsoleMatsArrival = rawMaterialViewModelNew.OUTSOLE_ETD; } outsoleMasterExportView.OutsoleLine = outsoleMaster.OutsoleLine; outsoleMasterExportView.OutsoleStartDate = outsoleMaster.OutsoleStartDate; outsoleMasterExportView.OutsoleFinishDate = outsoleMaster.OutsoleFinishDate; outsoleMasterExportView.OutsoleQuota = outsoleMaster.OutsoleQuota; outsoleMasterExportView.OutsoleBalance = outsoleMaster.OutsoleBalance; //RawMaterialModel outsoleRawMaterial = rawMaterialList.FirstOrDefault(f => f.ProductNo == outsoleMaster.ProductNo && materialIdOutsoleArray.Contains(f.MaterialTypeId)); //if (outsoleRawMaterial != null) //{ // outsoleMasterExportView.OutsoleWHBalance = outsoleRawMaterial.Remarks; //} //else //{ // outsoleMasterExportView.OutsoleWHBalance = ""; //} // Load Outsole_Remarks from OutsoleMaterial var outsoleMaterial_PO = outsoleMaterialList.Where(w => w.ProductNo == order.ProductNo).ToList(); var osMaterialSumBySupplier = outsoleMaterial_PO.GroupBy( g => g.OutsoleSupplierId) .Select(s => new { PO = order.ProductNo, Supplier = s.Key, ActualDelivery = outsoleMaterial_PO.Where(w => w.OutsoleSupplierId == s.Key) .Sum(su => su.Quantity - su.QuantityReject) }).ToList(); // if pot no one delivery. not show the balance quantity. if (osMaterialSumBySupplier.Count > 0 && order.Quantity - osMaterialSumBySupplier.Min(m => m.ActualDelivery) > 0) { // show the balance outsoleMasterExportView.OutsoleWHBalance = (order.Quantity - osMaterialSumBySupplier.Min(m => m.ActualDelivery)).ToString(); // if no one delivery, show blank if (outsoleMaterial_PO.Sum(s => s.Quantity) == 0) { outsoleMasterExportView.OutsoleWHBalance = ""; } } SewingMasterModel sewingMaster = sewingMasterList.FirstOrDefault(f => f.ProductNo == outsoleMaster.ProductNo); if (sewingMaster != null) { outsoleMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; outsoleMasterExportView.SewingFinishDate = sewingMaster.SewingFinishDate; outsoleMasterExportView.SewingQuota = sewingMaster.SewingQuota; outsoleMasterExportView.SewingBalance = sewingMaster.SewingBalance; } else { outsoleMasterExportView.SewingStartDate = dtDefault; outsoleMasterExportView.SewingFinishDate = dtDefault; outsoleMasterExportView.SewingQuota = 0; outsoleMasterExportView.SewingBalance = ""; } List <OutsoleReleaseMaterialModel> outsoleReleaseMaterialList_D1 = outsoleReleaseMaterialList.Where(o => o.ProductNo == outsoleMaster.ProductNo).ToList(); int qtyReleased = outsoleReleaseMaterialList_D1.Sum(o => o.Quantity); outsoleMasterExportView.ReleasedQuantity = qtyReleased.ToString(); if (qtyReleased <= 0) { outsoleMasterExportView.ReleasedQuantity = ""; } if (qtyReleased >= outsoleMasterExportView.Quantity && outsoleReleaseMaterialList_D1.Count > 0) { DateTime releasedDate = outsoleReleaseMaterialList_D1.FirstOrDefault().ModifiedTime; outsoleMasterExportView.ReleasedQuantity = string.Format("{0:M/d}", releasedDate); } outsoleMasterExportViewList.Add(outsoleMasterExportView); } }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); rawMaterialList = RawMaterialController.Select(); sewingMasterList = SewingMasterController.Select(); productionMemoList = ProductionMemoController.Select(); //sewingMasterList.RemoveAll(s => DateTimeHelper.Create(s.SewingBalance) != dtDefault && DateTimeHelper.Create(s.SewingBalance) != dtNothing); sewingMasterList = sewingMasterList.OrderBy(s => s.Sequence).ToList(); int[] materialIdUpperArray = { 1, 2, 3, 4, 10 }; int[] materialIdSewingArray = { 5, 7 }; int[] materialIdOutsoleArray = { 6 }; foreach (SewingMasterModel sewingMaster in sewingMasterList) { CutprepMasterExportViewModel cutprepMasterExportView = new CutprepMasterExportViewModel(); cutprepMasterExportView.Sequence = sewingMaster.Sequence; cutprepMasterExportView.ProductNo = sewingMaster.ProductNo; OrdersModel order = orderList.Where(o => o.ProductNo == sewingMaster.ProductNo).FirstOrDefault(); string memoId = ""; if (order != null) { cutprepMasterExportView.Country = order.Country; cutprepMasterExportView.ShoeName = order.ShoeName; cutprepMasterExportView.ArticleNo = order.ArticleNo; cutprepMasterExportView.PatternNo = order.PatternNo; cutprepMasterExportView.Quantity = order.Quantity; cutprepMasterExportView.ETD = order.ETD; List <ProductionMemoModel> productionMemoByProductionNumberList = productionMemoList.Where(p => p.ProductionNumbers.Contains(order.ProductNo) == true).ToList(); for (int p = 0; p <= productionMemoByProductionNumberList.Count - 1; p++) { ProductionMemoModel productionMemo = productionMemoByProductionNumberList[p]; memoId += productionMemo.MemoId; if (p < productionMemoByProductionNumberList.Count - 1) { memoId += "\n"; } } cutprepMasterExportView.MemoId = memoId; } MaterialArrivalViewModel materialArrivalUpper = MaterialArrival(order.ProductNo, materialIdUpperArray); cutprepMasterExportView.IsUpperMatsArrivalOk = false; if (materialArrivalUpper != null) { cutprepMasterExportView.UpperMatsArrival = String.Format(new CultureInfo("en-US"), "{0:dd-MMM}", materialArrivalUpper.Date); cutprepMasterExportView.IsUpperMatsArrivalOk = materialArrivalUpper.IsMaterialArrivalOk; } cutprepMasterExportView.SewingLine = sewingMaster.SewingLine; cutprepMasterExportView.SewingStartDate = sewingMaster.SewingStartDate; cutprepMasterExportView.SewingQuota = sewingMaster.SewingQuota; cutprepMasterExportView.SewingBalance = sewingMaster.SewingBalance; cutprepMasterExportView.CutAStartDate = sewingMaster.CutAStartDate; cutprepMasterExportView.CutAFinishDate = sewingMaster.CutAFinishDate; cutprepMasterExportView.CutAQuota = sewingMaster.CutAQuota; cutprepMasterExportView.AutoCut = sewingMaster.AutoCut; cutprepMasterExportView.LaserCut = sewingMaster.LaserCut; cutprepMasterExportView.HuasenCut = sewingMaster.HuasenCut; cutprepMasterExportView.CutABalance = sewingMaster.CutABalance; cutprepMasterExportView.PrintingBalance = sewingMaster.PrintingBalance; cutprepMasterExportView.H_FBalance = sewingMaster.H_FBalance; cutprepMasterExportView.EmbroideryBalance = sewingMaster.EmbroideryBalance; cutprepMasterExportView.CutBBalance = sewingMaster.CutBBalance; cutprepMasterExportViewList.Add(cutprepMasterExportView); } }