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 threadLoad_DoWork(object sender, DoWorkEventArgs e) { object[] args = e.Argument as object[]; string sectionId = args[2] as string; if ((sectionId == sewing || sectionId == cuta || sectionId == cutb) && sewingMasterList.Count <= 0) { sewingMasterList = SewingMasterController.Select(); } if (sectionId == assembly || sectionId == cuta || sectionId == cutb && assemblyMasterList.Count <= 0) { assemblyMasterList = AssemblyMasterController.Select(); } if (sectionId == outsole && outsoleMasterList.Count <= 0) { outsoleMasterList = OutsoleMasterController.Select(); } if (sectionId == socklining && sockliningMasterList.Count <= 0) { sockliningMasterList = SockliningMasterController.Select(); } var lineList = new List <string>(); Regex regex = new Regex(@"\D"); var regexNotString = new Regex("[^a-zA-Z]"); dt = new LeadTimeReportDataSet().Tables["LeadTimeTable"]; #region SEWING if (currentSection == sewing) { //var sewingLineList = sewingMasterList // .Where(w => w.SewingLine.Contains("sewing")) // .Select(s => new { line = s.SewingLine, sort = Int32.Parse(regex.Replace(s.SewingLine, "0")) }) // .OrderBy(o => o.sort) // .ThenBy(t => t.line) // .Distinct() // .ToList(); lineList = sewingMasterList.Where(w => w.SewingLine.Contains("sew")).Select(s => s.SewingLine).Distinct().ToList(); var lineCustomList = lineList.Select(s => new { Line = s, LineNumber = regex.IsMatch(s) ? regex.Replace(s, "") : s }).ToList(); if (lineCustomList.Count() > 0) { lineCustomList = lineCustomList//.OrderBy(o => regexNotString.IsMatch(o.Line) ? regexNotString.Replace(o.Line, "") : o.Line) .OrderBy(o => String.IsNullOrEmpty(o.LineNumber) ? 100 : Int64.Parse(o.LineNumber)) .ThenBy(th => th.Line).ToList(); } foreach (var line in lineCustomList) { int qtyXDay = 0; int qtyQuota = 0; var productNoList = sewingMasterList.Where(w => w.SewingLine == line.Line).Select(s => s.ProductNo).ToList(); foreach (string productNo in productNoList) { var sewingModel = sewingMasterList.FirstOrDefault(f => f.ProductNo == productNo && TimeHelper.Convert(f.SewingActualFinishDateAuto) >= dateFrom && TimeHelper.Convert(f.SewingActualFinishDateAuto) < dateTo); if (sewingModel != null) { DateTime sewingActualStartDate = TimeHelper.Convert(sewingModel.SewingActualStartDateAuto); DateTime sewingActualFinishDate = TimeHelper.Convert(sewingModel.SewingActualFinishDateAuto); if (sewingActualStartDate != dtDefault && sewingActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing) { qtyXDay += CalculateDateRange(sewingActualStartDate, sewingActualFinishDate) * sewingModel.SewingQuota; qtyQuota += sewingModel.SewingQuota; } } } CreateData(qtyXDay, qtyQuota, line.Line); } Dispatcher.Invoke(new Action(() => { ExportReport(); })); } #endregion #region ASSEMBLY if (currentSection == assembly) { var assyLineList = assemblyMasterList .Where(w => w.AssemblyLine.Contains("assy")) .Select(s => new { line = s.AssemblyLine, sort = Int32.Parse(regex.Replace(s.AssemblyLine, "")) }) .OrderBy(o => o.sort) .ThenBy(t => t.line) .Distinct() .ToList(); lineList = assyLineList.Select(s => s.line).ToList(); foreach (string line in lineList) { int qtyXDay = 0; int qtyQuota = 0; var assemblyMasterListPerLine = assemblyMasterList.Where(w => w.AssemblyLine == line).ToList(); var productNoList = assemblyMasterList.Where(w => w.AssemblyLine == line).Select(s => s.ProductNo).ToList(); foreach (string productNo in productNoList) { var assemblyModel = assemblyMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.AssemblyActualFinishDate) >= dateFrom && TimeHelper.Convert(w.AssemblyActualFinishDate) < dateTo) .FirstOrDefault(); if (assemblyModel != null) { DateTime assemblyActualStartDate = TimeHelper.Convert(assemblyModel.AssemblyActualStartDate); DateTime assemblyActualFinishDate = TimeHelper.Convert(assemblyModel.AssemblyActualFinishDate); if (assemblyActualStartDate != dtDefault && assemblyActualStartDate != dtNothing && assemblyActualFinishDate != dtDefault && assemblyActualFinishDate != dtNothing) { qtyXDay += CalculateDateRange(assemblyActualStartDate, assemblyActualFinishDate) * assemblyModel.AssemblyQuota; qtyQuota += assemblyModel.AssemblyQuota; } } } CreateData(qtyXDay, qtyQuota, line); } Dispatcher.Invoke(new Action(() => { ExportReport(); })); } #endregion #region OUTSOLE if (currentSection == outsole) { var outSoleLineList = outsoleMasterList .Where(w => w.OutsoleLine.Contains("stockfit")) .Select(s => new { line = s.OutsoleLine, sort = Int32.Parse(regex.Replace(s.OutsoleLine, "")) }) .OrderBy(o => o.sort) .ThenBy(t => t.line) .Distinct() .ToList(); lineList = outSoleLineList.Select(s => s.line).ToList(); foreach (string line in lineList) { int qtyXDay = 0; int qtyQuota = 0; var productNoList = outsoleMasterList.Where(w => w.OutsoleLine == line).Select(s => s.ProductNo).ToList(); foreach (string productNo in productNoList) { var outsoleModel = outsoleMasterList .Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.OutsoleActualFinishDateAuto) >= dateFrom && TimeHelper.Convert(w.OutsoleActualFinishDateAuto) < dateTo) .FirstOrDefault(); if (outsoleModel != null) { DateTime outsoleModelActualStartDate = TimeHelper.Convert(outsoleModel.OutsoleActualStartDateAuto); DateTime outsoleModelActualFinishDate = TimeHelper.Convert(outsoleModel.OutsoleActualFinishDateAuto); if (outsoleModelActualStartDate != dtDefault && outsoleModelActualStartDate != dtNothing && outsoleModelActualFinishDate != dtDefault && outsoleModelActualFinishDate != dtNothing) { qtyXDay += CalculateDateRange(outsoleModelActualStartDate, outsoleModelActualFinishDate) * outsoleModel.OutsoleQuota; qtyQuota += outsoleModel.OutsoleQuota; } } } CreateData(qtyXDay, qtyQuota, line); } Dispatcher.Invoke(new Action(() => { ExportReport(); })); } #endregion #region SOCKLINING if (currentSection == socklining) { var sockliningLineList = sockliningMasterList .Where(w => w.SockliningLine.Contains("insock cell")) .Select(s => new { line = s.SockliningLine, sort = Int32.Parse(regex.Replace(s.SockliningLine, "")) }) .OrderBy(o => o.sort) .ThenBy(t => t.line) .Distinct() .ToList(); lineList = sockliningLineList.Select(s => s.line).ToList(); foreach (string line in lineList) { int qtyXDay = 0; int qtyQuota = 0; var productNoList = sockliningMasterList.Where(w => w.SockliningLine == line).Select(s => s.ProductNo).ToList(); foreach (string productNo in productNoList) { var sockliningModel = sockliningMasterList .Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.SockliningActualFinishDate) >= dateFrom && TimeHelper.Convert(w.SockliningActualFinishDate) < dateTo) .FirstOrDefault(); if (sockliningModel != null) { DateTime sockliningModelActualStartDate = TimeHelper.Convert(sockliningModel.SockliningActualStartDate); DateTime sockliningModelActualFinishDate = TimeHelper.Convert(sockliningModel.SockliningActualFinishDate); if (sockliningModelActualStartDate != dtDefault && sockliningModelActualStartDate != dtNothing && sockliningModelActualFinishDate != dtDefault && sockliningModelActualFinishDate != dtNothing) { qtyXDay += CalculateDateRange(sockliningModelActualStartDate, sockliningModelActualFinishDate) * sockliningModel.SockliningQuota; qtyQuota += sockliningModel.SockliningQuota; } } } CreateData(qtyXDay, qtyQuota, line); } Dispatcher.Invoke(new Action(() => { ExportReport(); })); } #endregion #region CUTA if (currentSection == cuta) { var cutALineList = sewingMasterList .Where(w => w.SewingLine.Contains("sewing")) .Select(s => new { line = s.SewingLine, sort = Int32.Parse(regex.Replace(s.SewingLine, "")) }) .OrderBy(o => o.sort) .ThenBy(t => t.line) .Distinct() .ToList(); lineList = cutALineList.Select(s => s.line).ToList(); foreach (string line in lineList) { var productNoList = sewingMasterList.Where(w => w.SewingLine == line).Select(s => s.ProductNo).ToList(); int qtyXDay = 0; int qtyQuota = 0; foreach (var productNo in productNoList) { var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo).FirstOrDefault(); var assyModel = assemblyMasterList .Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.AssemblyActualFinishDate) >= dateFrom && TimeHelper.Convert(w.AssemblyActualFinishDate) < dateTo) .FirstOrDefault(); if (sewingModel != null && assyModel != null) { DateTime cutAActualStartDate = TimeHelper.Convert(sewingModel.CutAActualStartDate); DateTime sewingActualFinishDate = TimeHelper.Convert(sewingModel.SewingActualFinishDate); DateTime assyActualStartDate = TimeHelper.Convert(assyModel.AssemblyActualStartDate); DateTime assyActualFinishDate = TimeHelper.Convert(assyModel.AssemblyActualFinishDate); int timeRange = 0; if (cutAActualStartDate != dtNothing && cutAActualStartDate != dtDefault && assyActualFinishDate != dtNothing && assyActualFinishDate != dtDefault) { if (assyActualStartDate != dtDefault && assyActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing && assyActualStartDate > sewingActualFinishDate) { //timeRange = TimeHelper.CalculateDate(sewingActualFinishDate, assyActualStartDate); timeRange = (Int32)((assyActualStartDate - sewingActualFinishDate).TotalDays); qtyXDay += (CalculateDateRange(cutAActualStartDate, assyActualFinishDate) - timeRange) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } else { qtyXDay += CalculateDateRange(cutAActualStartDate, assyActualFinishDate) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } } } } CreateData(qtyXDay, qtyQuota, line); } Dispatcher.Invoke(new Action(() => { ExportReport(); })); } #endregion #region CUTB if (currentSection == cutb) { var cutBLineList = sewingMasterList .Where(w => w.SewingLine.Contains("sewing")) .Select(s => new { line = s.SewingLine, sort = Int32.Parse(regex.Replace(s.SewingLine, "")) }) .OrderBy(o => o.sort) .ThenBy(t => t.line) .Distinct() .ToList(); lineList = cutBLineList.Select(s => s.line).ToList(); foreach (string line in lineList) { var productNoList = sewingMasterList.Where(w => w.SewingLine == line).Select(s => s.ProductNo).ToList(); int qtyXDay = 0; int qtyQuota = 0; foreach (var productNo in productNoList) { var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo).FirstOrDefault(); var assyModel = assemblyMasterList .Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.AssemblyActualFinishDate) >= dateFrom && TimeHelper.Convert(w.AssemblyActualFinishDate) < dateTo) .FirstOrDefault(); if (sewingModel != null && assyModel != null) { DateTime cutBActualStartDate = TimeHelper.Convert(sewingModel.CutBActualStartDate); DateTime sewingActualFinishDate = TimeHelper.Convert(sewingModel.SewingActualFinishDateAuto); DateTime assyActualStartDate = TimeHelper.Convert(assyModel.AssemblyActualStartDate); DateTime assyActualFinishDate = TimeHelper.Convert(assyModel.AssemblyActualFinishDate); int timeRange = 0; if (cutBActualStartDate != dtNothing && cutBActualStartDate != dtDefault && assyActualFinishDate != dtNothing && assyActualFinishDate != dtDefault) { if (assyActualStartDate != dtDefault && assyActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing && assyActualStartDate > sewingActualFinishDate) { //timeRange = TimeHelper.CalculateDate(sewingActualFinishDate, assyActualStartDate); timeRange = (Int32)((assyActualStartDate - sewingActualFinishDate).TotalDays); qtyXDay += (CalculateDateRange(cutBActualStartDate, assyActualFinishDate) - timeRange) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } else { qtyXDay += CalculateDateRange(cutBActualStartDate, assyActualFinishDate) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } } } } CreateData(qtyXDay, qtyQuota, line); } Dispatcher.Invoke(new Action(() => { ExportReport(); })); } #endregion #region None //#region ARTICLE //if (currentSection == article) //{ // var articleNoList = ordersList.Select(s => new { article = s.ArticleNo.Contains("-") ? s.ArticleNo.Split('-')[0] : s.ArticleNo }).OrderBy(o => o.article).Distinct().Select(s => s.article).ToList(); // foreach (var articleNo in articleNoList) // { // int qtyXDay = 0; // int qtyQuota = 0; // var productNoList = ordersList.Where(w => w.ArticleNo.Contains(articleNo)).Select(s => s.ProductNo).ToList(); // foreach (var productNo in productNoList) // { // var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo).FirstOrDefault(); // var assyModel = assemblyMasterList // .Where(w => w.ProductNo == productNo // && TimeHelper.ConvertOldData(w.AssemblyActualFinishDate) >= dateFrom // && TimeHelper.ConvertOldData(w.AssemblyActualFinishDate) < dateTo) // .FirstOrDefault(); // if (sewingModel != null && assyModel != null) // { // DateTime cutAActualStartDate = TimeHelper.ConvertOldData(sewingModel.CutAActualStartDate); // DateTime sewingActualFinishDate = TimeHelper.ConvertOldData(sewingModel.SewingActualFinishDate); // DateTime assyActualStartDate = TimeHelper.ConvertOldData(assyModel.AssemblyActualStartDate); // DateTime assyActualFinishDate = TimeHelper.ConvertOldData(assyModel.AssemblyActualFinishDate); // int timeRange = 0; // if (cutAActualStartDate != dtNothing && cutAActualStartDate != dtDefault && assyActualFinishDate != dtNothing && assyActualFinishDate != dtDefault) // { // if (assyActualStartDate != dtDefault && assyActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing && assyActualStartDate > sewingActualFinishDate) // { // timeRange = TimeHelper.CalculateDate(sewingActualFinishDate, assyActualStartDate); // qtyXDay += (CalculateDateRange(cutAActualStartDate, assyActualFinishDate) - timeRange) * sewingModel.CutAQuota; // qtyQuota += sewingModel.CutAQuota; // } // else // { // qtyXDay += CalculateDateRange(cutAActualStartDate, assyActualFinishDate) * sewingModel.CutAQuota; // qtyQuota += sewingModel.CutAQuota; // } // } // } // } // if (qtyXDay > 0) // { // CreateData(qtyXDay, qtyQuota, "", articleNo); // } // } // ExportReport(); //} //#endregion //#region PM //if (currentSection == pm) //{ // var pmNoList = ordersList.Select(s => s.PatternNo).Distinct().ToList(); // foreach (var pmNo in pmNoList) // { // int qtyXDay = 0; // int qtyQuota = 0; // var productNoList = ordersList.Where(w => w.PatternNo == pmNo).Select(s => s.ProductNo).ToList(); // foreach (var productNo in productNoList) // { // var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo).FirstOrDefault(); // var assyModel = assemblyMasterList // .Where(w => w.ProductNo == productNo // && TimeHelper.ConvertOldData(w.AssemblyActualFinishDate) >= dateFrom // && TimeHelper.ConvertOldData(w.AssemblyActualFinishDate) < dateTo) // .FirstOrDefault(); // if (sewingModel != null && assyModel != null) // { // DateTime cutAActualStartDate = TimeHelper.ConvertOldData(sewingModel.CutAActualStartDate); // DateTime sewingActualFinishDate = TimeHelper.ConvertOldData(sewingModel.SewingActualFinishDate); // DateTime assyActualStartDate = TimeHelper.ConvertOldData(assyModel.AssemblyActualStartDate); // DateTime assyActualFinishDate = TimeHelper.ConvertOldData(assyModel.AssemblyActualFinishDate); // int timeRange = 0; // if (cutAActualStartDate != dtNothing && cutAActualStartDate != dtDefault && assyActualFinishDate != dtNothing && assyActualFinishDate != dtDefault) // { // if (assyActualStartDate != dtDefault && assyActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing && assyActualStartDate > sewingActualFinishDate) // { // timeRange = TimeHelper.CalculateDate(sewingActualFinishDate, assyActualStartDate); // qtyXDay += (CalculateDateRange(cutAActualStartDate, assyActualFinishDate) - timeRange) * sewingModel.CutAQuota; // qtyQuota += sewingModel.CutAQuota; // } // else // { // qtyXDay += CalculateDateRange(cutAActualStartDate, assyActualFinishDate) * sewingModel.CutAQuota; // qtyQuota += sewingModel.CutAQuota; // } // } // } // } // if (qtyXDay > 0) // { // CreateData(qtyXDay, qtyQuota, "", pmNo); // } // } // ExportReport(); //} //#endregion #endregion }
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 bwSearch_DoWork(object sender, DoWorkEventArgs e) { if (modePerStyle == "PM") { reportTitle = pm; orderList = OrdersController.Select().Where(w => w.PatternNo == pm).ToList(); } if (modePerStyle == "Article") { reportTitle = "Article: " + articleNo; orderList = OrdersController.Select().Where(w => w.ArticleNo.Contains(articleNo)).ToList(); } sewingMasterList = SewingMasterController.Select(); sockliningMasterList = SockliningMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); assemblyMasterList = AssemblyMasterController.Select(); DataTable dt = new LeadTimePerStyleDataSet().Tables["LeadTimePerStyleTable"]; List <string> productNoList = orderList.Select(s => s.ProductNo).Distinct().ToList(); double timeAverage = 0; foreach (string phase in phaseList) { int qtyXDay = 0, qtyQuota = 0; timeAverage = 0; // Sewing if (phase == phaseList[0]) { foreach (string productNo in productNoList) { var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.SewingActualStartDateAuto) != dtNothing && TimeHelper.Convert(w.SewingActualStartDateAuto) != dtDefault && TimeHelper.Convert(w.SewingActualFinishDateAuto) != dtNothing && TimeHelper.Convert(w.SewingActualFinishDateAuto) != dtDefault).FirstOrDefault(); if (sewingModel != null) { DateTime sewingActualStartDate = TimeHelper.Convert(sewingModel.SewingActualStartDateAuto); DateTime sewingActualFinishDate = TimeHelper.Convert(sewingModel.SewingActualFinishDateAuto); qtyXDay += CalculateDateRange(sewingActualStartDate, sewingActualFinishDate) * sewingModel.SewingQuota; qtyQuota += sewingModel.SewingQuota; } } timeAverage = (double)qtyXDay / (double)qtyQuota; } // Socklining if (phase == phaseList[1]) { timeAverage = 0; foreach (string productNo in productNoList) { var sockliningModel = sockliningMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.SockliningActualStartDate) != dtNothing && TimeHelper.Convert(w.SockliningActualStartDate) != dtDefault && TimeHelper.Convert(w.SockliningActualFinishDate) != dtNothing && TimeHelper.Convert(w.SockliningActualFinishDate) != dtDefault).FirstOrDefault(); if (sockliningModel != null) { DateTime sockliningActualStartDate = TimeHelper.Convert(sockliningModel.SockliningActualStartDate); DateTime sockliningActualFinishDate = TimeHelper.Convert(sockliningModel.SockliningActualFinishDate); qtyXDay += CalculateDateRange(sockliningActualStartDate, sockliningActualFinishDate) * sockliningModel.SockliningQuota; qtyQuota += sockliningModel.SockliningQuota; } } timeAverage = (double)qtyXDay / (double)qtyQuota; } // Outsole if (phase == phaseList[2]) { timeAverage = 0; foreach (string productNo in productNoList) { var outsoleModel = outsoleMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.OutsoleActualStartDateAuto) != dtNothing && TimeHelper.Convert(w.OutsoleActualStartDateAuto) != dtDefault && TimeHelper.Convert(w.OutsoleActualFinishDateAuto) != dtNothing && TimeHelper.Convert(w.OutsoleActualFinishDateAuto) != dtDefault).FirstOrDefault(); if (outsoleModel != null) { DateTime outsoleActualStartDate = TimeHelper.Convert(outsoleModel.OutsoleActualStartDateAuto); DateTime outsoleActualFinishDate = TimeHelper.Convert(outsoleModel.OutsoleActualFinishDateAuto); qtyXDay += CalculateDateRange(outsoleActualStartDate, outsoleActualFinishDate) * outsoleModel.OutsoleQuota; qtyQuota += outsoleModel.OutsoleQuota; } } timeAverage = (double)qtyXDay / (double)qtyQuota; } // Assembly if (phase == phaseList[3]) { timeAverage = 0; foreach (string productNo in productNoList) { var assemblyModel = assemblyMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.AssemblyActualStartDate) != dtNothing && TimeHelper.Convert(w.AssemblyActualStartDate) != dtDefault && TimeHelper.Convert(w.AssemblyActualFinishDate) != dtNothing && TimeHelper.Convert(w.AssemblyActualFinishDate) != dtDefault).FirstOrDefault(); if (assemblyModel != null) { DateTime assemblyActualStartDate = TimeHelper.Convert(assemblyModel.AssemblyActualStartDate); DateTime assemblyActualFinishDate = TimeHelper.Convert(assemblyModel.AssemblyActualFinishDate); qtyXDay += CalculateDateRange(assemblyActualStartDate, assemblyActualFinishDate) * assemblyModel.AssemblyQuota; qtyQuota += assemblyModel.AssemblyQuota; } } timeAverage = (double)qtyXDay / (double)qtyQuota; } // Cut A To Box if (phase == phaseList[4]) { timeAverage = 0; foreach (string productNo in productNoList) { var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.CutAActualStartDate) != dtNothing && TimeHelper.Convert(w.CutAActualStartDate) != dtDefault).FirstOrDefault(); var assemblyModel = assemblyMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.AssemblyActualFinishDate) != dtNothing && TimeHelper.Convert(w.AssemblyActualFinishDate) != dtDefault).FirstOrDefault(); if (sewingModel != null && assemblyModel != null) { DateTime cutAActualStartDate = TimeHelper.Convert(sewingModel.CutAActualStartDate); DateTime sewingActualFinishDate = TimeHelper.Convert(sewingModel.SewingActualFinishDateAuto); DateTime assyActualStartDate = TimeHelper.Convert(assemblyModel.AssemblyActualStartDate); DateTime assyActualFinishDate = TimeHelper.Convert(assemblyModel.AssemblyActualFinishDate); int timeRange = 0; if (assyActualStartDate != dtDefault && assyActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing && assyActualStartDate > sewingActualFinishDate) { //timeRange = TimeHelper.CalculateDate(sewingActualFinishDate, assyActualStartDate); timeRange = (Int32)((assyActualStartDate - sewingActualFinishDate).TotalDays); qtyXDay += (CalculateDateRange(cutAActualStartDate, assyActualFinishDate) - timeRange) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } else { qtyXDay += CalculateDateRange(cutAActualStartDate, assyActualFinishDate) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } } } timeAverage = (double)qtyXDay / (double)qtyQuota; } // Cut B To Box if (phase == phaseList[4]) { timeAverage = 0; foreach (string productNo in productNoList) { var sewingModel = sewingMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.CutBActualStartDate) != dtNothing && TimeHelper.Convert(w.CutBActualStartDate) != dtDefault).FirstOrDefault(); var assemblyModel = assemblyMasterList.Where(w => w.ProductNo == productNo && TimeHelper.Convert(w.AssemblyActualFinishDate) != dtNothing && TimeHelper.Convert(w.AssemblyActualFinishDate) != dtDefault).FirstOrDefault(); if (sewingModel != null && assemblyModel != null) { DateTime cutBActualStartDate = TimeHelper.Convert(sewingModel.CutBActualStartDate); DateTime sewingActualFinishDate = TimeHelper.Convert(sewingModel.SewingActualFinishDateAuto); DateTime assyActualStartDate = TimeHelper.Convert(assemblyModel.AssemblyActualStartDate); DateTime assyActualFinishDate = TimeHelper.Convert(assemblyModel.AssemblyActualFinishDate); int timeRange = 0; if (assyActualStartDate != dtDefault && assyActualStartDate != dtNothing && sewingActualFinishDate != dtDefault && sewingActualFinishDate != dtNothing && assyActualStartDate > sewingActualFinishDate) { //timeRange = TimeHelper.CalculateDate(sewingActualFinishDate, assyActualStartDate); timeRange = (Int32)((assyActualStartDate - sewingActualFinishDate).TotalDays); qtyXDay += (CalculateDateRange(cutBActualStartDate, assyActualFinishDate) - timeRange) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } else { qtyXDay += CalculateDateRange(cutBActualStartDate, assyActualFinishDate) * sewingModel.CutAQuota; qtyQuota += sewingModel.CutAQuota; } } } timeAverage = (double)qtyXDay / (double)qtyQuota; } string timeAverageString = ""; if (timeAverage > 0) { timeAverageString = string.Format("{0:0.00}", timeAverage); } DataRow dr = dt.NewRow(); dr["Phase"] = phase; dr["TimeAverage"] = timeAverageString; dt.Rows.Add(dr); } e.Result = dt; }
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) { 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(); 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); } }
void threadLoad_DoWork(object sender, DoWorkEventArgs e) { orderList = OrdersController.Select(); sewingMasterList = SewingMasterController.Select(); outsoleMasterList = OutsoleMasterController.Select(); assemblyMasterList = AssemblyMasterController.Select(); orderExtraList = OrderExtraController.Select(); List <String> productNoList = sewingMasterList.Select(r => r.ProductNo).Distinct().ToList(); foreach (string productNo in productNoList) { var order = orderList.FirstOrDefault(f => f.ProductNo == productNo); //var order1 = orderList.Where(w => w.ProductNo == productNo).FirstOrDefault(); var sewingMaster = sewingMasterList.FirstOrDefault(f => f.ProductNo == productNo); var outsoleMaster = outsoleMasterList.FirstOrDefault(f => f.ProductNo == productNo); var assemblyMaster = assemblyMasterList.FirstOrDefault(f => f.ProductNo == productNo); var orderExtra = orderExtraList.FirstOrDefault(f => f.ProductNo == productNo); CompletionStatusViewModel completionStatusView = new CompletionStatusViewModel { ProductNo = order.ProductNo, Country = order.Country, ShoeName = order.ShoeName, ArticleNo = order.ArticleNo, ETD = order.ETD, Quantity = order.Quantity, }; if (orderExtra != null) { DateTime loadingDate = dtDefault; if (DateTime.TryParse(orderExtra.LoadingDate, out loadingDate) == true) { completionStatusView.LoadingDate = string.Format(new CultureInfo("en-US"), "{0:dd-MMM}", loadingDate); } else { completionStatusView.LoadingDate = ""; } } if (sewingMaster != null) { completionStatusView.SewingLine = sewingMaster.SewingLine; completionStatusView.CutAFinishDate = sewingMaster.CutBBalance; completionStatusView.SewingFinishDate = sewingMaster.SewingActualFinishDate; if (string.IsNullOrEmpty(sewingMaster.SewingActualFinishDate.Trim()) == true) { completionStatusView.SewingFinishDate = sewingMaster.SewingBalance; } } else { completionStatusView.SewingLine = ""; completionStatusView.CutAFinishDate = ""; completionStatusView.SewingFinishDate = ""; } if (outsoleMaster != null) { completionStatusView.OutsoleLine = outsoleMaster.OutsoleLine; completionStatusView.OutsoleFinishDate = outsoleMaster.OutsoleActualFinishDate; if (string.IsNullOrEmpty(outsoleMaster.OutsoleActualFinishDate.Trim()) == true) { completionStatusView.OutsoleFinishDate = outsoleMaster.OutsoleBalance; } } else { completionStatusView.OutsoleLine = ""; completionStatusView.OutsoleFinishDate = ""; } completionStatusView.IsFinished = false; if (assemblyMaster != null) { completionStatusView.AssemblyLine = assemblyMaster.AssemblyLine; completionStatusView.AssemblyFinishDate = assemblyMaster.AssemblyActualFinishDate.Contains("/")? TimeHelper.ConvertDateToView(assemblyMaster.AssemblyActualFinishDate) : assemblyMaster.AssemblyActualFinishDate; if (string.IsNullOrEmpty(assemblyMaster.AssemblyActualFinishDate.Trim()) == true) { completionStatusView.AssemblyFinishDate = assemblyMaster.AssemblyBalance; } if (string.IsNullOrEmpty(assemblyMaster.AssemblyActualFinishDate.Trim()) == false || assemblyMaster.AssemblyBalance.ToLower() == "OK".ToLower()) { completionStatusView.IsFinished = true; } } else { completionStatusView.AssemblyLine = ""; completionStatusView.AssemblyFinishDate = ""; } completionStatusViewList.Add(completionStatusView); } }
// 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); } } } } }