public OutsoleMaterialWHCheckingAddQuantitySizeWindow(string poSearch, OutsoleSuppliersModel supplierClicked, DateTime checkingDate, ErrorModel errorPressed, List <OutsoleMaterialCheckingModel> currentOSMCheckListBySupp, List <OutsoleMaterialModel> outsoleMaterialListBySupplier, string workerId, List <SizeRunModel> sizeRunList) { this.poSearch = poSearch; this.supplierClicked = supplierClicked; this.checkingDate = checkingDate; this.errorPressed = errorPressed; this.currentOSMCheckListBySupp = currentOSMCheckListBySupp; this.outsoleMaterialListBySupplier = outsoleMaterialListBySupplier; this.workerId = workerId; this.sizeRunList = sizeRunList; outsoleMaterialCheckingUpdatedBySizeList = new List <OutsoleMaterialCheckingModel>(); bwInsert = new BackgroundWorker(); bwInsert.DoWork += BwInsert_DoWork; bwInsert.RunWorkerCompleted += BwInsert_RunWorkerCompleted; bwLoad = new BackgroundWorker(); bwLoad.DoWork += BwLoad_DoWork; bwLoad.RunWorkerCompleted += BwLoad_RunWorkerCompleted; InitializeComponent(); }
public AddOutsoleMaterialRackPositionWindow(string productNo, OutsoleSuppliersModel supplier, List <OutsoleMaterialRackPositionModel> rackUpdateList, List <OutsoleMaterialDeliveryDetailModel> osMaterialDeliveryDetailList) { this.supplier = supplier; this.rackUpdateList = rackUpdateList; this.productNo = productNo; this.osMaterialDeliveryDetailList = osMaterialDeliveryDetailList; bwSave = new BackgroundWorker(); bwSave.DoWork += new DoWorkEventHandler(bwSave_DoWork); bwSave.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwSave_RunWorkerCompleted); bwRemove = new BackgroundWorker(); bwRemove.DoWork += new DoWorkEventHandler(bwRemove_DoWork); bwRemove.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwRemove_RunWorkerCompleted); sizeNoList = new List <String>(); quantityList = new List <String>(); rackPositionCurrentList = new List <OutsoleMaterialRackPositionModel>(); actionType = ActionType.CREATE; InitializeComponent(); }
private void btnSupplier_Click(object sender, RoutedEventArgs e) { var btnSupplierClicked = sender as Button; int supplierIdClicked = (int)btnSupplierClicked.Tag; supplierClicked = outsoleSupplierList.FirstOrDefault(f => f.OutsoleSupplierId == supplierIdClicked); groupAddIndexNo.Header = "Nhập Số Liệu Kiểm Kê: " + supplierClicked.Name; btnAddIndexNo.IsEnabled = true; btnAddIndexNo.IsDefault = true; txtIndexNo.IsEnabled = true; txtIndexNo.Focus(); txtCreatedBy.Text = ""; dgAdd.Columns.Clear(); dgAdd.ItemsSource = null; btnSave.IsEnabled = false; if (bwLoad.IsBusy == false) { this.Cursor = null; bwLoadDetail.RunWorkerAsync(); } }
public OutsoleWHDeliveryDetailWindow_1(string outsoleCode, List <OutsoleMaterialModel> outsoleMaterialList, List <OutsoleReleaseMaterialModel> outsoleReleaseList, List <SizeRunModel> sizeRunList, OutsoleSuppliersModel supplier, List <OrdersModel> orderList) { this.outsoleCode = outsoleCode; this.orderList = orderList; this.outsoleMaterialList = outsoleMaterialList; this.outsoleReleaseList = outsoleReleaseList; this.sizeRunList = sizeRunList; this.supplier = supplier; bwLoad = new BackgroundWorker(); bwLoad.DoWork += new DoWorkEventHandler(bwLoad_DoWork); bwLoad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoad_RunWorkerCompleted); bwExportExcel = new BackgroundWorker(); bwExportExcel.DoWork += new DoWorkEventHandler(bwExportExcel_DoWork); bwExportExcel.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwExportExcel_RunWorkerCompleted); bwExportExcel.WorkerSupportsCancellation = true; sewingMasterList = new List <SewingMasterModel>(); outsoleRawMaterial = new List <OutsoleRawMaterialModel>(); excelExportList = new List <ExportExcelModel>(); def = new PrivateDefineModel(); InitializeComponent(); }
public OSMaterialWHCheckViewDetailWindow(List <OutsoleMaterialCheckingModel> osMatCheckingList, List <ErrorModel> errorSourceList, OrdersModel orderInformation, OutsoleSuppliersModel supplierClicked) { this.osMatCheckingList = osMatCheckingList; this.errorSourceList = errorSourceList; this.orderInformation = orderInformation; this.supplierClicked = supplierClicked; InitializeComponent(); }
private void cboSupplier_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (bwLoadReport.IsBusy == false) { outsoleSupplierSelected = cboSupplier.SelectedItem as OutsoleSuppliersModel; this.Cursor = Cursors.Wait; bwLoadReport.RunWorkerAsync(); } }
public AddOutsoleMaterialRejectToRackWindow(string productNo, OutsoleSuppliersModel supplier, List <OutsoleMaterialDeliveryDetailModel> osMaterialDeliveryDetailList) { this.productNo = productNo; this.supplier = supplier; this.osMaterialDeliveryDetailList = osMaterialDeliveryDetailList; bwLoad = new BackgroundWorker(); bwLoad.DoWork += new DoWorkEventHandler(bwLoad_DoWork); bwLoad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoad_RunWorkerCompleted); InitializeComponent(); }
public BorrowOutsoleWHMaterialWindow(List <OutsoleMaterialCheckingModel> oswhCheckList, OutsoleSuppliersModel supplier, List <OutsoleMaterialCheckingModel> oswhCheckBySupplier) { this.supplier = supplier; this.oswhCheckList = oswhCheckList; this.oswhCheckBySupplier = oswhCheckBySupplier; oswhAfterBorrow = new List <OutsoleMaterialCheckingModel>(); //oswhBorrowedList = new List<OSMaterialBorrowModel>(); currentBorrowedList = new List <OSMaterialBorrowModel>(); InitializeComponent(); }
private void bwLoadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { DataTable dt = new OutsoleMaterialRejectDataSet().Tables["OutsoleMaterialRejectTable"]; var regex = new Regex(@"[a-z]|[A-Z]"); foreach (OutsoleMaterialModel outsoleMaterialReject in outsoleMaterialRejectList) { OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList.Where(o => o.OutsoleSupplierId == outsoleMaterialReject.OutsoleSupplierId).FirstOrDefault(); OrdersModel order = orderList.Where(o => o.ProductNo == outsoleMaterialReject.ProductNo).FirstOrDefault(); OutsoleRawMaterialModel outsoleRawMaterial = outsoleRawMaterialList.Where(o => o.ProductNo == outsoleMaterialReject.ProductNo && o.OutsoleSupplierId == outsoleMaterialReject.OutsoleSupplierId).FirstOrDefault(); DataRow dr = dt.NewRow(); dr["ProductNo"] = outsoleMaterialReject.ProductNo; if (order != null) { dr["OutsoleCode"] = order.OutsoleCode; dr["ETD"] = order.ETD; } if (outsoleRawMaterial != null) { dr["SupplierETD"] = outsoleRawMaterial.ETD; } if (outsoleSupplier != null) { dr["OutsoleSupplier"] = outsoleSupplier.Name; } string sizeNoString = regex.IsMatch(outsoleMaterialReject.SizeNo) == true?regex.Replace(outsoleMaterialReject.SizeNo, "") : outsoleMaterialReject.SizeNo; double sizeNoDouble = 0; Double.TryParse(sizeNoString, out sizeNoDouble); dr["SizeNoDouble"] = sizeNoDouble; dr["SizeNo"] = outsoleMaterialReject.SizeNo; dr["QuantityReject"] = outsoleMaterialReject.QuantityReject; dt.Rows.Add(dr); } // bo 3.5 thanh 35 roi orderby theo sizeno //Regex regex = new Regex(@"[^\d\.]"); //dt = dt.AsEnumerable().OrderBy(r => double.Parse(regex.Replace(r.Field<String>("SizeNo"), ""))).CopyToDataTable(); ReportDataSource rds = new ReportDataSource(); rds.Name = "OutsoleMaterialReject"; rds.Value = dt; //reportViewer.LocalReport.ReportPath = @"C:\Users\IT02\Documents\Visual Studio 2010\Projects\Saoviet Master Schedule Solution\MasterSchedule\Reports\OutsoleMaterialRejectReport.rdlc"; reportViewer.LocalReport.ReportPath = @"Reports\OutsoleMaterialRejectReport.rdlc"; reportViewer.LocalReport.DataSources.Add(rds); reportViewer.RefreshReport(); this.Cursor = null; }
private void bwReport_DoWork(object sender, DoWorkEventArgs e) { outsoleRawMaterialList = OutsoleRawMaterialController.Select(); outsoleMaterialList = OutsoleMaterialController.SelectByOutsoleRawMaterial(); sizeRunList = SizeRunController.SelectByOutsoleRawMaterial(); outsoleSupplierList = OutsoleSuppliersController.Select(); ordersList = OrdersController.SelectByOutsoleRawMaterial(); DataTable dt = new OutsoleDeliveryDataSet().Tables["OutsoleDeliveryTable"]; List <String> productNoList = outsoleRawMaterialList.Select(r => r.ProductNo).Distinct().ToList(); foreach (string productNo in productNoList) { OrdersModel order = ordersList.Where(o => o.ProductNo == productNo).FirstOrDefault(); List <OutsoleRawMaterialModel> outsoleRawMaterialOfProductNoList = outsoleRawMaterialList.Where(o => o.ProductNo == productNo).ToList(); List <SizeRunModel> sizeRunOfProductNoList = sizeRunList.Where(s => s.ProductNo == productNo).ToList(); List <OutsoleMaterialModel> outsoleMaterialOfProductNoList = outsoleMaterialList.Where(o => o.ProductNo == productNo).ToList(); foreach (OutsoleRawMaterialModel outsoleRawMaterial in outsoleRawMaterialOfProductNoList) { DateTime etd = outsoleRawMaterial.ETD.Date; bool isFull = OutsoleRawMaterialController.IsFull(sizeRunOfProductNoList, new List <OutsoleRawMaterialModel>() { outsoleRawMaterial, }, outsoleMaterialOfProductNoList); if (etd != new DateTime(2000, 1, 1) && etd == dateSearch.Date && isFull == false) { DataRow dr = dt.NewRow(); dr["ProductNo"] = productNo; if (order != null) { dr["ArticleNo"] = order.ArticleNo; dr["OutsoleCode"] = order.OutsoleCode; dr["Quantity"] = order.Quantity; dr["ETD"] = order.ETD; } dr["SupplierETD"] = etd; dr["Remarks"] = sizeRunOfProductNoList.Sum(s => (s.Quantity - outsoleMaterialOfProductNoList.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId && o.SizeNo == s.SizeNo).Sum(o => (o.Quantity - o.QuantityReject)))).ToString(); OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).FirstOrDefault(); if (outsoleSupplier != null) { dr["Supplier"] = outsoleSupplier.Name; } dt.Rows.Add(dr); } } } e.Result = dt; }
public OutsoleInputMaterialDetailWindow(AccountModel account) { bwLoad = new BackgroundWorker(); bwLoad.DoWork += new DoWorkEventHandler(bwLoad_DoWork); bwLoad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoad_RunWorkerCompleted); bwLoadDetail = new BackgroundWorker(); bwLoadDetail.DoWork += new DoWorkEventHandler(bwLoadDetail_DoWork); bwLoadDetail.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoadDetail_RunWorkerCompleted); bwAddMore = new BackgroundWorker(); bwAddMore.DoWork += new DoWorkEventHandler(bwAddMore_DoWork); bwAddMore.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwAddMore_RunWorkerCompleted); bwInsert = new BackgroundWorker(); bwInsert.DoWork += new DoWorkEventHandler(bwInsert_DoWork); bwInsert.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwInsert_RunWorkerCompleted); bwUpdateOutsoleMaterial = new BackgroundWorker(); bwUpdateOutsoleMaterial.DoWork += new DoWorkEventHandler(bwUpdateOutsoleMaterial_DoWork); bwUpdateOutsoleMaterial.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwUpdateOutsoleMaterial_RunWorkerCompleted); outsoleMaterialList = new List <OutsoleMaterialModel>(); outsoleMaterialRejectUpdateList = new List <OutsoleMaterialModel>(); outsoleMaterialDetailList = new List <OutsoleMaterialDetailModel>(); outsoleMaterialReloadList = new List <OutsoleMaterialDetailModel>(); outsoleSupplierList = new List <OutsoleSuppliersModel>(); outsoleMaterialDetailToInsertList = new List <OutsoleMaterialDetailModel>(); sizeRunList = new List <SizeRunModel>(); accountList = new List <AccountModel>(); orderSearch = new OrdersModel(); supplierClicked = new OutsoleSuppliersModel(); dtDefault = new DateTime(2000, 1, 1); this.account = account; timer = new DispatcherTimer(); timer.Start(); timer.Tick += new EventHandler(timer_Tick); InitializeComponent(); }
public OutsoleMaterialInputRejectDetailWindow(string productNo, OutsoleSuppliersModel supplierClicked, List <SizeRunModel> sizeRunList, AccountModel account, List <AccountModel> accountList, string INDEXNO, int ROUND, bool showReport) { this.productNo = productNo; this.supplierClicked = supplierClicked; this.sizeRunList = sizeRunList; this.INDEXNO = INDEXNO; this.ROUND = ROUND; this.account = account; this.accountList = accountList; this.showReport = showReport; rejectIssuesList = new List <OutsoleMaterialRejectIssuesModel>(); dt = new DataTable(); bwLoad = new BackgroundWorker(); bwLoad.DoWork += new DoWorkEventHandler(bwLoad_DoWork); bwLoad.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwLoad_RunWorkerCompleted); bwInsert = new BackgroundWorker(); bwInsert.DoWork += new DoWorkEventHandler(bwInsert_DoWork); bwInsert.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bwInsert_RunWorkerCompleted); InitializeComponent(); }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { int baseColumn = 0; Dispatcher.Invoke(new Action(() => { DataTable dt = new DataTable(); dt.Columns.Add("ProductNo", typeof(String)); DataGridTextColumn column1 = new DataGridTextColumn(); column1.Header = "PO No."; column1.Binding = new Binding("ProductNo"); column1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1); Binding bindingWidth1 = new Binding(); bindingWidth1.Source = column1; bindingWidth1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1 = new ColumnDefinition(); cd1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1); gridTotal.ColumnDefinitions.Add(cd1); dt.Columns.Add("ArticleNo", typeof(String)); DataGridTextColumn column1_1_1 = new DataGridTextColumn(); column1_1_1.Header = "Article No."; column1_1_1.Binding = new Binding("ArticleNo"); dgInventory.Columns.Add(column1_1_1); Binding bindingWidth1_1_1 = new Binding(); bindingWidth1_1_1.Source = column1_1_1; bindingWidth1_1_1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_1_1 = new ColumnDefinition(); cd1_1_1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1_1); gridTotal.ColumnDefinitions.Add(cd1_1_1); dt.Columns.Add("OutsoleCode", typeof(String)); DataGridTextColumn column_OutsoleCode = new DataGridTextColumn(); column_OutsoleCode.Header = "O/S Code"; column_OutsoleCode.Binding = new Binding("OutsoleCode"); dgInventory.Columns.Add(column_OutsoleCode); Binding bindingWidth_OutsoleCode = new Binding(); bindingWidth_OutsoleCode.Source = column_OutsoleCode; bindingWidth_OutsoleCode.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd_OutsoleCode = new ColumnDefinition(); cd_OutsoleCode.SetBinding(ColumnDefinition.WidthProperty, bindingWidth_OutsoleCode); if (viewByOutsoleLine == false) { baseColumn = 0; column_OutsoleCode.Visibility = Visibility.Collapsed; } else { baseColumn = 1; column_OutsoleCode.Visibility = Visibility.Visible; gridTotal.ColumnDefinitions.Add(cd_OutsoleCode); } dt.Columns.Add("ETD", typeof(DateTime)); DataGridTextColumn column1_1 = new DataGridTextColumn(); column1_1.Header = "EFD"; Binding binding = new Binding(); binding.Path = new PropertyPath("ETD"); binding.StringFormat = "dd-MMM"; column1_1.Binding = binding; column1_1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_1); Binding bindingWidth1_1 = new Binding(); bindingWidth1_1.Source = column1_1; bindingWidth1_1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_1 = new ColumnDefinition(); cd1_1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1); gridTotal.ColumnDefinitions.Add(cd1_1); dt.Columns.Add("Quantity", typeof(Int32)); DataGridTextColumn column1_2 = new DataGridTextColumn(); column1_2.Header = "Quantity"; Binding bindingQuantity = new Binding(); bindingQuantity.Path = new PropertyPath("Quantity"); column1_2.Binding = bindingQuantity; dgInventory.Columns.Add(column1_2); Binding bindingWidth1_2 = new Binding(); bindingWidth1_2.Source = column1_2; bindingWidth1_2.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_2 = new ColumnDefinition(); cd1_2.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_2); gridTotal.ColumnDefinitions.Add(cd1_2); dt.Columns.Add("Release", typeof(Int32)); DataGridTextColumn column1_3 = new DataGridTextColumn(); column1_3.Header = "Release"; Binding bindingRelease = new Binding(); bindingRelease.Path = new PropertyPath("Release"); column1_3.Binding = bindingRelease; dgInventory.Columns.Add(column1_3); Binding bindingWidth1_3 = new Binding(); bindingWidth1_3.Source = column1_3; bindingWidth1_3.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_3 = new ColumnDefinition(); cd1_3.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_3); gridTotal.ColumnDefinitions.Add(cd1_3); for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList[i]; dt.Columns.Add(String.Format("Column{0}", i), typeof(Int32)); DataGridTextColumn column = new DataGridTextColumn(); column.Header = outsoleSupplier.Name; column.Binding = new Binding(String.Format("Column{0}", i)); Style style = new Style(typeof(DataGridCell)); style.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center)); Setter setterForeground = new Setter(); setterForeground.Property = DataGridCell.ForegroundProperty; setterForeground.Value = Brushes.Black; style.Setters.Add(setterForeground); Setter setterBackground = new Setter(); setterBackground.Property = DataGridCell.BackgroundProperty; setterBackground.Value = new Binding(String.Format("Column{0}Background", i)); style.Setters.Add(setterBackground); column.CellStyle = style; dgInventory.Columns.Add(column); Binding bindingWidth = new Binding(); bindingWidth.Source = column; bindingWidth.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd = new ColumnDefinition(); cd.SetBinding(ColumnDefinition.WidthProperty, bindingWidth); gridTotal.ColumnDefinitions.Add(cd); DataColumn columnBackground = new DataColumn(String.Format("Column{0}Background", i), typeof(SolidColorBrush)); columnBackground.DefaultValue = Brushes.Transparent; dt.Columns.Add(columnBackground); } dt.Columns.Add("Matching", typeof(Int32)); DataGridTextColumn column2 = new DataGridTextColumn(); column2.Header = "Matching"; column2.Binding = new Binding("Matching"); dgInventory.Columns.Add(column2); Binding bindingWidth2 = new Binding(); bindingWidth2.Source = column2; bindingWidth2.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd2 = new ColumnDefinition(); cd2.SetBinding(ColumnDefinition.WidthProperty, bindingWidth2); gridTotal.ColumnDefinitions.Add(cd2); dt.Columns.Add("FinishedOutsole", typeof(Int32)); DataGridTextColumn columnFinishedOutsole = new DataGridTextColumn(); columnFinishedOutsole.Header = "Finished Outsole"; columnFinishedOutsole.Binding = new Binding("FinishedOutsole"); dgInventory.Columns.Add(columnFinishedOutsole); Binding bindingWith3 = new Binding(); bindingWith3.Source = columnFinishedOutsole; bindingWith3.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd3 = new ColumnDefinition(); cd3.SetBinding(ColumnDefinition.WidthProperty, bindingWith3); gridTotal.ColumnDefinitions.Add(cd3); foreach (string productNo in productNoList) { var outsoleMaterialListByPO = outsoleMaterialList.Where(w => w.ProductNo == productNo).ToList(); var outsoleOutputListByPO = outsoleOutputList.Where(w => w.ProductNo == productNo).ToList(); var assemblyReleaseListByPO = assemblyReleaseList.Where(w => w.ProductNo == productNo).ToList(); var outsoleReleaseListByPO = outsoleReleaseMaterialList.Where(w => w.ProductNo == productNo).ToList(); DataRow dr = dt.NewRow(); dr["ProductNo"] = productNo; OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault(); if (order != null) { dr["ETD"] = order.ETD; dr["ArticleNo"] = order.ArticleNo; dr["Quantity"] = order.Quantity; dr["OutsoleCode"] = order.OutsoleCode; } List <String> sizeNoList = outsoleMaterialListByPO.Where(o => o.ProductNo == productNo).Select(o => o.SizeNo).Distinct().ToList(); int qtyMaterialTotalToCheck = 0; for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { var supplier = outsoleSupplierList[i]; var outsoleMaterialListBySupp = outsoleMaterialListByPO.Where(w => w.OutsoleSupplierId == supplier.OutsoleSupplierId).ToList(); if (outsoleMaterialListBySupp.Count() == 0) { continue; } int qtyMaterialTotal = 0; int qtyReleaseTotal = 0; foreach (string sizeNo in sizeNoList) { int qtyDelivery = outsoleMaterialListBySupp.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity - s.QuantityReject); int qtyRelease = outsoleReleaseListByPO.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMaterial = qtyDelivery - qtyRelease; if (qtyMaterial < 0) { qtyMaterial = 0; } qtyMaterialTotal += qtyMaterial; qtyMaterialTotalToCheck += qtyMaterial; qtyReleaseTotal += qtyRelease; } dr["Release"] = qtyReleaseTotal; dr[String.Format("Column{0}", i)] = qtyMaterialTotal; } int qtyMatchingTotal = 0; foreach (string sizeNo in sizeNoList) { //int qtyMin = outsoleMaterialList_D1.Where(o => o.SizeNo == sizeNo).Select(o => (o.Quantity - o.QuantityReject)).Min(); int qtyMin = outsoleMaterialListByPO.Where(o => o.SizeNo == sizeNo).Select(o => (o.Quantity - o.QuantityReject)).Min(); int qtyRelease = outsoleReleaseListByPO.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMatching = qtyMin - qtyRelease; if (qtyMatching < 0) { qtyMatching = 0; } qtyMatchingTotal += qtyMatching; } dr["Matching"] = qtyMatchingTotal; int osOutput = outsoleOutputListByPO.Where(w => w.ProductNo == productNo).Sum(s => s.Quantity); int assRelease = assemblyReleaseListByPO.Sum(s => s.Quantity); int finishedOutsole = osOutput - assRelease; dr["FinishedOutsole"] = finishedOutsole > 0 ? finishedOutsole : 0; if (finishedOutsole == 0 && qtyMatchingTotal == 0 && qtyMaterialTotalToCheck == 0) { continue; } dt.Rows.Add(dr); } TextBlock lblTotal = new TextBlock(); lblTotal.Text = "TOTAL"; lblTotal.Margin = new Thickness(1, 0, 0, 0); lblTotal.FontWeight = FontWeights.Bold; Border bdrTotal = new Border(); Grid.SetColumn(bdrTotal, 2); Grid.SetColumnSpan(bdrTotal, baseColumn + 4); bdrTotal.BorderThickness = new Thickness(1, 0, 1, 1); bdrTotal.BorderBrush = Brushes.Black; bdrTotal.Child = lblTotal; gridTotal.Children.Add(bdrTotal); TextBlock lblQuantityTotal = new TextBlock(); lblQuantityTotal.Text = dt.Compute("Sum(Quantity)", "").ToString(); lblQuantityTotal.Margin = new Thickness(1, 0, 0, 0); lblQuantityTotal.FontWeight = FontWeights.Bold; Border bdrQuantityTotal = new Border(); Grid.SetColumn(bdrQuantityTotal, baseColumn + 5); bdrQuantityTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrQuantityTotal.BorderBrush = Brushes.Black; bdrQuantityTotal.Child = lblQuantityTotal; gridTotal.Children.Add(bdrQuantityTotal); dgInventory.ItemsSource = dt.AsDataView(); TextBlock lblReleaseTotal = new TextBlock(); lblReleaseTotal.Text = dt.Compute("Sum(Release)", "").ToString(); lblReleaseTotal.Margin = new Thickness(1, 0, 0, 0); lblReleaseTotal.FontWeight = FontWeights.Bold; Border bdrReleaseTotal = new Border(); Grid.SetColumn(bdrReleaseTotal, baseColumn + 6); bdrReleaseTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrReleaseTotal.BorderBrush = Brushes.Black; bdrReleaseTotal.Child = lblReleaseTotal; gridTotal.Children.Add(bdrReleaseTotal); dgInventory.ItemsSource = dt.AsDataView(); for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { TextBlock lblSupplierTotal = new TextBlock(); lblSupplierTotal.Text = dt.Compute(String.Format("Sum(Column{0})", i), "").ToString(); lblSupplierTotal.Margin = new Thickness(1, 0, 0, 0); lblSupplierTotal.FontWeight = FontWeights.Bold; Border bdrSupplierTotal = new Border(); Grid.SetColumn(bdrSupplierTotal, baseColumn + 7 + i); bdrSupplierTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrSupplierTotal.BorderBrush = Brushes.Black; bdrSupplierTotal.Child = lblSupplierTotal; gridTotal.Children.Add(bdrSupplierTotal); } TextBlock lblMatchingTotal = new TextBlock(); lblMatchingTotal.Text = dt.Compute("Sum(Matching)", "").ToString(); lblMatchingTotal.Margin = new Thickness(1, 0, 0, 0); lblMatchingTotal.FontWeight = FontWeights.Bold; Border brMT = new Border(); Grid.SetColumn(brMT, baseColumn + 7 + outsoleSupplierList.Count()); brMT.BorderThickness = new Thickness(0, 0, 1, 1); brMT.BorderBrush = Brushes.Black; brMT.Child = lblMatchingTotal; gridTotal.Children.Add(brMT); dgInventory.ItemsSource = dt.AsDataView(); TextBlock lblFinishedOutsoleTotal = new TextBlock(); lblFinishedOutsoleTotal.Text = dt.Compute("Sum(FinishedOutsole)", "").ToString(); lblFinishedOutsoleTotal.Margin = new Thickness(1, 0, 0, 0); lblFinishedOutsoleTotal.FontWeight = FontWeights.Bold; Border brFOT = new Border(); Grid.SetColumn(brFOT, baseColumn + 8 + outsoleSupplierList.Count()); brFOT.BorderThickness = new Thickness(0, 0, 1, 1); brFOT.BorderBrush = Brushes.Black; brFOT.Child = lblFinishedOutsoleTotal; gridTotal.Children.Add(brFOT); dgInventory.ItemsSource = dt.AsDataView(); })); }
void threadLoad_DoWork(object sender, DoWorkEventArgs e) { //outsoleRawMaterialList = OutsoleRawMaterialController.Select(); outsoleRawMaterialList = OutsoleRawMaterialController.SelectFull(etdStartSelect, etdEndSelect); outsoleMaterialList = OutsoleMaterialController.SelectByOutsoleRawMaterialFull(etdStartSelect, etdEndSelect); sizeRunList = SizeRunController.SelectByOutsoleRawMaterialFull(etdStartSelect, etdEndSelect); outsoleSupplierList = OutsoleSuppliersController.Select(); orderList = OrdersController.SelectByOutsoleRawMaterialFull(etdStartSelect, etdEndSelect); sewingMasterList = SewingMasterController.SelectFull(etdStartSelect, etdEndSelect); List <String> productNoList = outsoleRawMaterialList.Select(r => r.ProductNo).Distinct().ToList(); foreach (string productNo in productNoList) { OrdersModel order = orderList.FirstOrDefault(f => f.ProductNo == productNo); List <OutsoleRawMaterialModel> outsoleRawMaterialList_D1 = outsoleRawMaterialList.Where(o => o.ProductNo == productNo).ToList(); List <SizeRunModel> sizeRunList_D1 = sizeRunList.Where(s => s.ProductNo == productNo).ToList(); List <OutsoleMaterialModel> outsoleMaterialList_D1 = outsoleMaterialList.Where(o => o.ProductNo == productNo).ToList(); var sewingMasterList_D1 = sewingMasterList.Where(w => w.ProductNo == productNo).ToList(); foreach (OutsoleRawMaterialModel outsoleRawMaterial in outsoleRawMaterialList_D1) { // 108a-2279 //bool isFull = OutsoleRawMaterialController.IsFull(sizeRunList_D1, new List<OutsoleRawMaterialModel>() { outsoleRawMaterial, }, outsoleMaterialList_D1); if ( //isFull == false && outsoleRawMaterial.ETD.Date != dtDefault //&& outsoleRawMaterial.ActualDate.Date == dtDefault ) { OutsoleDeliveryStatusViewModel outsoleDeliveryStatusView = new OutsoleDeliveryStatusViewModel(); outsoleDeliveryStatusView.ProductNo = productNo; if (order != null) { outsoleDeliveryStatusView.Country = order.Country; outsoleDeliveryStatusView.ShoeName = order.ShoeName; outsoleDeliveryStatusView.ArticleNo = order.ArticleNo; outsoleDeliveryStatusView.OutsoleCode = order.OutsoleCode; outsoleDeliveryStatusView.Quantity = order.Quantity; outsoleDeliveryStatusView.ETD = order.ETD; } OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList.FirstOrDefault(f => f.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId); if (outsoleSupplier != null) { outsoleDeliveryStatusView.Supplier = outsoleSupplier.Name; } outsoleDeliveryStatusView.SupplierETD = outsoleRawMaterial.ETD; //outsoleDeliveryStatusView.Actual = sizeRunList_D1.Sum(s => (s.Quantity - outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId && o.SizeNo == s.SizeNo).Sum(o => (o.Quantity - o.QuantityReject)))).ToString(); //int actualQty = sizeRunList_D1.Sum(s => (outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId && o.SizeNo == s.SizeNo).Sum(o => (o.Quantity - o.QuantityReject)))); //int actualQty = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).Sum(s => s.Quantity - s.QuantityReject); int actualQty = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).Sum(s => s.Quantity); if (actualQty > 0) { outsoleDeliveryStatusView.ActualQuantity = actualQty.ToString(); } int rejectQty = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).Sum(s => s.QuantityReject); if (rejectQty > 0) { outsoleDeliveryStatusView.RejectQuantity = rejectQty.ToString(); } outsoleDeliveryStatusView.IsFinished = true; int balance = order.Quantity - actualQty + rejectQty; if (balance > 0) { //outsoleDeliveryStatusView.Balance = balance.ToString(); outsoleDeliveryStatusView.IsFinished = false; } if (outsoleRawMaterial.ActualDate != dtDefault) { outsoleDeliveryStatusView.Actual = string.Format("{0:M/d}", outsoleRawMaterial.ActualDate); } outsoleDeliveryStatusView.SewingStartDate = dtDefault; var sewingMasterModel = sewingMasterList_D1.FirstOrDefault(); if (sewingMasterModel != null) { outsoleDeliveryStatusView.SewingStartDate = sewingMasterModel.SewingStartDate; } outsoleDeliveryStatusViewList.Add(outsoleDeliveryStatusView); } } } }
public AddOutsoleMaterialRackPositionWindow(string productNo, OutsoleSuppliersModel supplier) { this.supplier = supplier; this.productNo = productNo; InitializeComponent(); }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { outsoleSupplierList = OutsoleSuppliersController.Select(); if (outsoleSupplierList.Count < 1) { return; } Excel.Application excelApplication = new Excel.Application(); Excel.Workbook excelWorkbook = excelApplication.Workbooks.Open(filePath); //excelApplication.Visible = true; Excel.Worksheet excelWorksheet; Excel.Range excelRange; try { excelWorksheet = (Excel.Worksheet)excelWorkbook.Worksheets[1]; excelRange = excelWorksheet.UsedRange; progressBar.Dispatcher.Invoke((Action)(() => progressBar.Maximum = excelRange.Rows.Count)); List <OutsoleSupplierColumnModel> outsoleSupplierColumnList = new List <OutsoleSupplierColumnModel>(); for (int i = 3; i <= excelRange.Rows.Count; i++) { if ((excelRange.Cells[i, 1] as Excel.Range).Value2 == null || String.IsNullOrEmpty((excelRange.Cells[i, 1] as Excel.Range).Value2.ToString()) == true) { outsoleSupplierColumnList.Clear(); for (int j = 12; j <= 22; j++) { if ((excelRange.Cells[i, j] as Excel.Range).Value2 != null && String.IsNullOrEmpty((excelRange.Cells[i, j] as Excel.Range).Value2.ToString()) == false) { string supplierName = (excelRange.Cells[i, j] as Excel.Range).Value2.ToString(); OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList.FirstOrDefault(f => f.Name == supplierName); if (outsoleSupplier == null) { MessageBox.Show(String.Format("Supplier Name at R{0}C{1} Error!", i, j), "Message", MessageBoxButton.OK, MessageBoxImage.Warning); } else { outsoleSupplierColumnList.Add(new OutsoleSupplierColumnModel { Supplier = outsoleSupplier, ColumnIndex = j, }); } } } } else { string productNo = (excelRange.Cells[i, 1] as Excel.Range).Value2.ToString(); for (int j = 12; j <= 22; j++) { if ((excelRange.Cells[i, j] as Excel.Range).Value2 != null && String.IsNullOrEmpty((excelRange.Cells[i, j] as Excel.Range).Value2.ToString()) == false) { double etd = 0; double.TryParse((excelRange.Cells[i, j] as Excel.Range).Value2.ToString(), out etd); OutsoleSupplierColumnModel outsoleSupplierColumn = outsoleSupplierColumnList.FirstOrDefault(f => f.ColumnIndex == j); if (outsoleSupplierColumn != null && etd > 0) { DateTime etdReal = DateTime.FromOADate(etd); outsoleRawMaterialViewList.Add(new OutsoleRawMaterialViewModel { ProductNo = productNo, Supplier = outsoleSupplierColumn.Supplier, ETD = String.Format("{0:dd-MMM}", etdReal), ETDReal = etdReal, }); } } } } progressBar.Dispatcher.Invoke((Action)(() => progressBar.Value = i)); } } catch { outsoleRawMaterialViewList.Clear(); } finally { excelWorkbook.Close(false, Missing.Value, Missing.Value); excelApplication.Quit(); } }
private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) { var regex = new Regex(@"[a-z]|[A-Z]"); outsoleRawMaterialList = OutsoleRawMaterialController.Select(); outsoleMaterialList = OutsoleMaterialController.SelectByOutsoleRawMaterial(); sizeRunList = SizeRunController.SelectByOutsoleRawMaterial(); outsoleSupplierList = OutsoleSuppliersController.Select(); ordersList = OrdersController.SelectByOutsoleRawMaterial(); DataTable dt = new OutsoleDelayDataSet().Tables["OutsoleDelayTable"]; List <String> productNoList = outsoleRawMaterialList.Select(r => r.ProductNo).Distinct().ToList(); foreach (string productNo in productNoList) { OrdersModel order = ordersList.Where(o => o.ProductNo == productNo).FirstOrDefault(); List <OutsoleRawMaterialModel> outsoleRawMaterialList_D1 = outsoleRawMaterialList.Where(o => o.ProductNo == productNo).ToList(); List <SizeRunModel> sizeRunList_D1 = sizeRunList.Where(s => s.ProductNo == productNo).OrderBy(o => Double.Parse(regex.IsMatch(o.SizeNo) ? regex.Replace(o.SizeNo, "") : o.SizeNo)).ToList(); List <OutsoleMaterialModel> outsoleMaterialList_D1 = outsoleMaterialList.Where(o => o.ProductNo == productNo).ToList(); foreach (OutsoleRawMaterialModel outsoleRawMaterial in outsoleRawMaterialList_D1) { List <OutsoleMaterialModel> outsoleMaterialList_D2 = outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).ToList(); OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).FirstOrDefault(); DateTime etd = outsoleRawMaterial.ETD.Date; //bool isFull = OutsoleRawMaterialController.IsFull(sizeRunList_D1, new List<OutsoleRawMaterialModel>() { outsoleRawMaterial }, outsoleMaterialList_D1); //if (etd != new DateTime(2000, 1, 1) && etd < DateTime.Now.Date && isFull == false) if (etd != new DateTime(2000, 1, 1) && etd < DateTime.Now.Date) { foreach (SizeRunModel sizeRun in sizeRunList_D1) { int qtyDelay = sizeRun.Quantity - outsoleMaterialList_D2.Where(o => o.SizeNo == sizeRun.SizeNo).Sum(o => o.Quantity); if (qtyDelay > 0) { DataRow dr = dt.NewRow(); dr["ProductNo"] = productNo; string sizeNoString = regex.IsMatch(sizeRun.SizeNo) == true?regex.Replace(sizeRun.SizeNo, "") : sizeRun.SizeNo; double sizeNoDouble = 0; Double.TryParse(sizeNoString, out sizeNoDouble); dr["SizeNoDouble"] = sizeNoDouble; dr["SizeNo"] = sizeRun.SizeNo; dr["SupplierETD"] = outsoleRawMaterial.ETD; if (order != null) { dr["OutsoleCode"] = order.OutsoleCode; dr["ArticleNo"] = order.ArticleNo; dr["ETD"] = order.ETD; } if (outsoleSupplier != null) { dr["OutsoleSupplier"] = outsoleSupplier.Name; } dr["QuantityDelay"] = qtyDelay; dt.Rows.Add(dr); } } } } } e.Result = dt; }
private void bwLoad_DoWork(object sender, DoWorkEventArgs e) { outsoleMaterialList = OutsoleMaterialController.Select().Where(w => productNoList.Contains(w.ProductNo)).ToList(); Dispatcher.Invoke(new Action(() => { DataTable dt = new DataTable(); dt.Columns.Add("ProductNo", typeof(String)); DataGridTextColumn column1 = new DataGridTextColumn(); column1.Header = "PO No."; column1.Binding = new Binding("ProductNo"); column1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1); Binding bindingWidth1 = new Binding(); bindingWidth1.Source = column1; bindingWidth1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1 = new ColumnDefinition(); cd1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1); gridTotal.ColumnDefinitions.Add(cd1); dt.Columns.Add("ArticleNo", typeof(String)); DataGridTextColumn column1_1_1 = new DataGridTextColumn(); column1_1_1.Header = "Article No."; column1_1_1.Binding = new Binding("ArticleNo"); //column1_1_1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_1_1); Binding bindingWidth1_1_1 = new Binding(); bindingWidth1_1_1.Source = column1_1_1; bindingWidth1_1_1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_1_1 = new ColumnDefinition(); cd1_1_1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1_1); gridTotal.ColumnDefinitions.Add(cd1_1_1); dt.Columns.Add("ETD", typeof(DateTime)); DataGridTextColumn column1_1 = new DataGridTextColumn(); column1_1.Header = "EFD"; Binding binding = new Binding(); binding.Path = new PropertyPath("ETD"); binding.StringFormat = "dd-MMM"; column1_1.Binding = binding; column1_1.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_1); Binding bindingWidth1_1 = new Binding(); bindingWidth1_1.Source = column1_1; bindingWidth1_1.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_1 = new ColumnDefinition(); cd1_1.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1); gridTotal.ColumnDefinitions.Add(cd1_1); dt.Columns.Add("Quantity", typeof(Int32)); DataGridTextColumn column1_2 = new DataGridTextColumn(); column1_2.Header = "Quantity"; Binding bindingQuantity = new Binding(); bindingQuantity.Path = new PropertyPath("Quantity"); //binding.StringFormat = "dd-MMM"; column1_2.Binding = bindingQuantity; //column1_2.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_2); Binding bindingWidth1_2 = new Binding(); bindingWidth1_2.Source = column1_2; bindingWidth1_2.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_2 = new ColumnDefinition(); cd1_2.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_2); gridTotal.ColumnDefinitions.Add(cd1_2); dt.Columns.Add("Release", typeof(Int32)); DataGridTextColumn column1_3 = new DataGridTextColumn(); column1_3.Header = "Release"; Binding bindingRelease = new Binding(); bindingRelease.Path = new PropertyPath("Release"); //binding.StringFormat = "dd-MMM"; column1_3.Binding = bindingRelease; //column1_2.FontWeight = FontWeights.Bold; dgInventory.Columns.Add(column1_3); Binding bindingWidth1_3 = new Binding(); bindingWidth1_3.Source = column1_3; bindingWidth1_3.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd1_3 = new ColumnDefinition(); cd1_3.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_3); gridTotal.ColumnDefinitions.Add(cd1_3); for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList[i]; dt.Columns.Add(String.Format("Column{0}", i), typeof(Int32)); DataGridTextColumn column = new DataGridTextColumn(); //column.SetValue(TagProperty, sizeRun.SizeNo); column.Header = outsoleSupplier.Name; column.Binding = new Binding(String.Format("Column{0}", i)); Style style = new Style(typeof(DataGridCell)); style.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center)); Setter setterForeground = new Setter(); setterForeground.Property = DataGridCell.ForegroundProperty; setterForeground.Value = Brushes.Black; style.Setters.Add(setterForeground); Setter setterBackground = new Setter(); setterBackground.Property = DataGridCell.BackgroundProperty; setterBackground.Value = new Binding(String.Format("Column{0}Background", i)); style.Setters.Add(setterBackground); column.CellStyle = style; dgInventory.Columns.Add(column); Binding bindingWidth = new Binding(); bindingWidth.Source = column; bindingWidth.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd = new ColumnDefinition(); cd.SetBinding(ColumnDefinition.WidthProperty, bindingWidth); gridTotal.ColumnDefinitions.Add(cd); DataColumn columnBackground = new DataColumn(String.Format("Column{0}Background", i), typeof(SolidColorBrush)); columnBackground.DefaultValue = Brushes.Transparent; dt.Columns.Add(columnBackground); } dt.Columns.Add("Matching", typeof(Int32)); DataGridTextColumn column2 = new DataGridTextColumn(); column2.Header = "Matching"; column2.Binding = new Binding("Matching"); dgInventory.Columns.Add(column2); Binding bindingWidth2 = new Binding(); bindingWidth2.Source = column2; bindingWidth2.Path = new PropertyPath("ActualWidth"); ColumnDefinition cd2 = new ColumnDefinition(); cd2.SetBinding(ColumnDefinition.WidthProperty, bindingWidth2); gridTotal.ColumnDefinitions.Add(cd2); foreach (string productNo in productNoList) { var outsoleMaterialDetailPerPOList = OutsoleMaterialDetailController.Select(productNo).ToList(); if (productNo == "105-5900") { } List <OutsoleMaterialModel> outsoleMaterialList_D1 = outsoleMaterialList.Where(o => o.ProductNo == productNo).ToList(); List <OutsoleReleaseMaterialModel> outsoleReleaseMaterialList_D1 = outsoleReleaseMaterialList.Where(o => o.ProductNo == productNo).ToList(); DataRow dr = dt.NewRow(); dr["ProductNo"] = productNo; OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault(); if (order != null) { dr["ETD"] = order.ETD; dr["ArticleNo"] = order.ArticleNo; dr["Quantity"] = order.Quantity; } List <String> sizeNoList = outsoleMaterialList.Where(o => o.ProductNo == productNo).Select(o => o.SizeNo).Distinct().ToList(); int qtyMaterialTotalToCheck = 0; for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList[i]; List <OutsoleMaterialModel> outsoleMaterialList_D2 = outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleSupplier.OutsoleSupplierId).ToList(); int qtyMaterialTotal = 0; int qtyReleaseTotal = 0; foreach (string sizeNo in sizeNoList) { int qtyMax = outsoleMaterialList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => (o.Quantity - o.QuantityReject)); int qtyRelease = outsoleReleaseMaterialList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMaterial = qtyMax - qtyRelease; if (qtyMaterial < 0) { qtyMaterial = 0; } qtyMaterialTotal += qtyMaterial; qtyMaterialTotalToCheck += qtyMaterial; qtyReleaseTotal += qtyRelease; } dr["Release"] = qtyReleaseTotal; dr[String.Format("Column{0}", i)] = qtyMaterialTotal; var outsoleMaterialDetailPerPOPerSupplierList = outsoleMaterialDetailPerPOList.Where(w => w.OutsoleSupplierId == outsoleSupplierList[i].OutsoleSupplierId).ToList(); if (outsoleMaterialDetailPerPOPerSupplierList.Count > 0) { int qtyMaterialDetail = outsoleMaterialDetailPerPOPerSupplierList.Sum(s => s.Quantity); if (qtyMaterialDetail != 0 && qtyMaterialDetail < order.Quantity) { dr[String.Format("Column{0}Background", i)] = Brushes.Yellow; } if (qtyMaterialDetail != 0 && qtyMaterialDetail >= order.Quantity) { dr[String.Format("Column{0}Background", i)] = Brushes.Green; } } } int qtyMatchingTotal = 0; foreach (string sizeNo in sizeNoList) { int qtyMin = outsoleMaterialList_D1.Where(o => o.SizeNo == sizeNo).Select(o => (o.Quantity - o.QuantityReject)).Min(); int qtyRelease = outsoleReleaseMaterialList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity); int qtyMatching = qtyMin - qtyRelease; if (qtyMatching < 0) { qtyMatching = 0; } qtyMatchingTotal += qtyMatching; } dr["Matching"] = qtyMatchingTotal; if (qtyMaterialTotalToCheck != 0) { dt.Rows.Add(dr); } } TextBlock lblTotal = new TextBlock(); lblTotal.Text = "TOTAL"; lblTotal.Margin = new Thickness(1, 0, 0, 0); lblTotal.FontWeight = FontWeights.Bold; Border bdrTotal = new Border(); Grid.SetColumn(bdrTotal, 2); Grid.SetColumnSpan(bdrTotal, 3); bdrTotal.BorderThickness = new Thickness(1, 0, 1, 1); bdrTotal.BorderBrush = Brushes.Black; bdrTotal.Child = lblTotal; gridTotal.Children.Add(bdrTotal); TextBlock lblQuantityTotal = new TextBlock(); lblQuantityTotal.Text = dt.Compute("Sum(Quantity)", "").ToString(); lblQuantityTotal.Margin = new Thickness(1, 0, 0, 0); lblQuantityTotal.FontWeight = FontWeights.Bold; Border bdrQuantityTotal = new Border(); Grid.SetColumn(bdrQuantityTotal, 5); bdrQuantityTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrQuantityTotal.BorderBrush = Brushes.Black; bdrQuantityTotal.Child = lblQuantityTotal; gridTotal.Children.Add(bdrQuantityTotal); dgInventory.ItemsSource = dt.AsDataView(); TextBlock lblReleaseTotal = new TextBlock(); lblReleaseTotal.Text = dt.Compute("Sum(Release)", "").ToString(); lblReleaseTotal.Margin = new Thickness(1, 0, 0, 0); lblReleaseTotal.FontWeight = FontWeights.Bold; Border bdrReleaseTotal = new Border(); Grid.SetColumn(bdrReleaseTotal, 6); bdrReleaseTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrReleaseTotal.BorderBrush = Brushes.Black; bdrReleaseTotal.Child = lblReleaseTotal; gridTotal.Children.Add(bdrReleaseTotal); dgInventory.ItemsSource = dt.AsDataView(); for (int i = 0; i <= outsoleSupplierList.Count - 1; i++) { TextBlock lblSupplierTotal = new TextBlock(); lblSupplierTotal.Text = dt.Compute(String.Format("Sum(Column{0})", i), "").ToString(); lblSupplierTotal.Margin = new Thickness(1, 0, 0, 0); lblSupplierTotal.FontWeight = FontWeights.Bold; Border bdrSupplierTotal = new Border(); Grid.SetColumn(bdrSupplierTotal, 7 + i); bdrSupplierTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrSupplierTotal.BorderBrush = Brushes.Black; bdrSupplierTotal.Child = lblSupplierTotal; gridTotal.Children.Add(bdrSupplierTotal); } TextBlock lblMatchingTotal = new TextBlock(); lblMatchingTotal.Text = dt.Compute("Sum(Matching)", "").ToString(); lblMatchingTotal.Margin = new Thickness(1, 0, 0, 0); lblMatchingTotal.FontWeight = FontWeights.Bold; Border bdrMatchingTotal = new Border(); Grid.SetColumn(bdrMatchingTotal, 7 + outsoleSupplierList.Count()); bdrMatchingTotal.BorderThickness = new Thickness(0, 0, 1, 1); bdrMatchingTotal.BorderBrush = Brushes.Black; bdrMatchingTotal.Child = lblMatchingTotal; gridTotal.Children.Add(bdrMatchingTotal); dgInventory.ItemsSource = dt.AsDataView(); })); }