Пример #1
0
 private void bwInsert_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (var insertModel in outsoleMaterialDetailToInsertList)
     {
         OutsoleMaterialDetailController.Insert(insertModel, account);
     }
 }
Пример #2
0
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     sizeRunList               = SizeRunController.Select(productNo);
     outsoleMaterialList       = OutsoleMaterialController.Select(productNo);
     outsoleSupplierList       = OutsoleSuppliersController.Select();
     outsoleMaterialDetailList = OutsoleMaterialDetailController.Select(productNo);
     orderSearch               = OrdersController.SelectTop1(productNo);
     accountList               = AccountController.SelectAccount();
 }
Пример #3
0
        private void bwAddMore_DoWork(object sender, DoWorkEventArgs e)
        {
            // Excute Store.
            outsoleMaterialDetailList = OutsoleMaterialDetailController.Select(productNo).Where(w => w.OutsoleSupplierId == supplierClicked.OutsoleSupplierId && w.IndexNo == INDEXNO && w.Round == ROUND).ToList();

            // Create column
            Dispatcher.Invoke(new Action(() => {
                dtAdd.Columns.Add("Title", typeof(String));
                DataGridTextColumn colTitle = new DataGridTextColumn();
                colTitle.Header             = String.Format("Nhà cung cấp\n{0}\nCông đoạn: {1}\nLần kiểm: {2}", supplierClicked.Name, INDEXNO, ROUND.ToString());
                colTitle.IsReadOnly         = true;
                colTitle.Binding            = new Binding("Title");
                dgAdd.Columns.Add(colTitle);

                dtAdd.Columns.Add("Status", typeof(String));
                DataGridTextColumn colStatus = new DataGridTextColumn();
                colStatus.Header             = "Order Size\nO/S Size\nM/S Size\nSố lượng";
                colStatus.IsReadOnly         = true;
                colStatus.Binding            = new Binding("Status");
                dgAdd.Columns.Add(colStatus);

                for (int i = 0; i <= sizeRunList.Count - 1; i++)
                {
                    SizeRunModel sizeRun = sizeRunList[i];
                    dtAdd.Columns.Add(String.Format("Column{0}", i, typeof(String)));
                    DataGridTextColumn col = new DataGridTextColumn();
                    col.SetValue(TagProperty, sizeRun.SizeNo);
                    col.Header   = String.Format("{0}\n{1}\n{2}\n({3})", sizeRun.SizeNo, sizeRun.OutsoleSize, sizeRun.MidsoleSize, sizeRun.Quantity);
                    col.MinWidth = 40;
                    col.Binding  = new Binding(String.Format("Column{0}", i));
                    dgAdd.Columns.Add(col);
                }

                DataGridTemplateColumn buttonColumn   = new DataGridTemplateColumn();
                DataTemplate buttonTemplate           = new DataTemplate();
                FrameworkElementFactory buttonFactory = new FrameworkElementFactory(typeof(Button));
                buttonTemplate.VisualTree             = buttonFactory;
                buttonFactory.AddHandler(Button.ClickEvent, new RoutedEventHandler(btnOK_Click));
                buttonFactory.SetValue(ContentProperty, "OK");
                buttonColumn.CellTemplate = buttonTemplate;
                dgAdd.Columns.Add(buttonColumn);
            }));
        }
Пример #4
0
        private void bwUpdateOutsoleMaterial_DoWork(object sender, DoWorkEventArgs e)
        {
            outsoleMaterialRejectUpdateList = new List <OutsoleMaterialModel>();
            var outsoleMaterialDetailAferInsertList = OutsoleMaterialDetailController.Select(productNo).Where(w => w.OutsoleSupplierId == supplierClicked.OutsoleSupplierId).ToList();
            var sizeNoList = outsoleMaterialDetailAferInsertList.Select(s => s.SizeNo).Distinct().ToList();

            foreach (var sizeNo in sizeNoList)
            {
                var firstModel = outsoleMaterialDetailAferInsertList.FirstOrDefault();
                var outsoleMaterialUpdateReject = new OutsoleMaterialModel()
                {
                    ProductNo         = firstModel.ProductNo,
                    OutsoleSupplierId = firstModel.OutsoleSupplierId,
                    SizeNo            = sizeNo,
                    QuantityReject    = outsoleMaterialDetailAferInsertList.Where(w => w.SizeNo == sizeNo).Sum(s => s.Reject),
                };
                outsoleMaterialRejectUpdateList.Add(outsoleMaterialUpdateReject);
            }
            foreach (var updateModel in outsoleMaterialRejectUpdateList)
            {
                OutsoleMaterialController.UpdateRejectFromOutsoleMaterialDetail(updateModel);
            }

            // Update Outsole RawMaterial. If Reject > 0 => Remove Actual Date
            var POAndSupplierHasRejectList = outsoleMaterialRejectUpdateList.Where(w => w.QuantityReject > 0).Select(s => new { ProductNo = s.ProductNo, OutsoleSupplierId = s.OutsoleSupplierId }).Distinct().ToList();

            foreach (var p in POAndSupplierHasRejectList)
            {
                var updateModel = new OutsoleRawMaterialModel()
                {
                    ProductNo         = p.ProductNo,
                    OutsoleSupplierId = p.OutsoleSupplierId,
                    ActualDate        = dtDefault
                };
                OutsoleRawMaterialController.UpdateActualDate(updateModel);
            }
        }
        private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            outsoleSupplierList = OutsoleSuppliersController.Select();
            sizeRunList         = SizeRunController.SelectByOutsoleRawMaterial();
            sewingMasterList    = SewingMasterController.Select();
            outsoleMaterialList = OutsoleMaterialController.Select().Where(w => productNoList.Contains(w.ProductNo) && w.OutsoleSupplierId == supplierID).ToList();

            DataTable dt = new DataTable();

            Dispatcher.Invoke(new Action(() =>
            {
                dt.Columns.Add("ProductNo", typeof(String));
                DataGridTextColumn columnProductNo = new DataGridTextColumn();
                columnProductNo.Header             = "PO No.";

                //Style
                Style styleColumnProductNo = new Style(typeof(DataGridCell));

                Setter setterColumnProductNoForeground   = new Setter();
                setterColumnProductNoForeground.Property = DataGridCell.ForegroundProperty;
                setterColumnProductNoForeground.Value    = Brushes.Black;
                styleColumnProductNo.Setters.Add(setterColumnProductNoForeground);

                Setter setterColumnProductNoBackground   = new Setter();
                setterColumnProductNoBackground.Property = DataGridCell.BackgroundProperty;
                setterColumnProductNoBackground.Value    = new Binding("ProductNoBackground");
                styleColumnProductNo.Setters.Add(setterColumnProductNoBackground);

                columnProductNo.CellStyle = styleColumnProductNo;

                columnProductNo.Binding    = new Binding("ProductNo");
                columnProductNo.FontWeight = FontWeights.Bold;

                DataColumn columnProductNoBackground   = new DataColumn("ProductNoBackground", typeof(SolidColorBrush));
                columnProductNoBackground.DefaultValue = Brushes.Transparent;
                dt.Columns.Add(columnProductNoBackground);

                dgInventory.Columns.Add(columnProductNo);

                Binding bindingWidth1 = new Binding();
                bindingWidth1.Source  = columnProductNo;
                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("OrderETD", typeof(DateTime));
                DataGridTextColumn column1_1 = new DataGridTextColumn();
                column1_1.Header             = "Order EFD";
                // Style
                Style styleOrderETD = new Style(typeof(DataGridCell));
                styleOrderETD.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center));
                column1_1.CellStyle = styleOrderETD;

                Binding binding      = new Binding();
                binding.Path         = new PropertyPath("OrderETD");
                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("DeliveryETD", typeof(DateTime));
                DataGridTextColumn column1_1_A = new DataGridTextColumn();
                column1_1_A.Header             = "Delivery EFD";
                Binding bindingEDTSupp         = new Binding();
                bindingEDTSupp.Path            = new PropertyPath("DeliveryETD");
                bindingEDTSupp.StringFormat    = "dd-MMM";
                column1_1_A.Binding            = bindingEDTSupp;
                column1_1_A.FontWeight         = FontWeights.Bold;

                // Style
                Style styleDeliveryETD = new Style(typeof(DataGridCell));
                styleDeliveryETD.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center));
                column1_1_A.CellStyle = styleDeliveryETD;

                dgInventory.Columns.Add(column1_1_A);
                Binding bindingWidth1_1_A = new Binding();
                bindingWidth1_1_A.Source  = column1_1_A;
                bindingWidth1_1_A.Path    = new PropertyPath("ActualWidth");
                ColumnDefinition cd1_1_A  = new ColumnDefinition();
                cd1_1_A.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_1_A);
                gridTotal.ColumnDefinitions.Add(cd1_1_A);


                dt.Columns.Add("SewingStartDate", typeof(DateTime));
                DataGridTextColumn column1_1_B  = new DataGridTextColumn();
                column1_1_B.Header              = "Sewing Start";
                Binding bindingSewingStart      = new Binding();
                bindingSewingStart.Path         = new PropertyPath("SewingStartDate");
                bindingSewingStart.StringFormat = "dd-MMM";
                column1_1_B.Binding             = bindingSewingStart;
                column1_1_B.FontWeight          = FontWeights.Bold;

                // Style
                Style styleSewingStart = new Style(typeof(DataGridCell));
                styleDeliveryETD.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center));
                column1_1_B.CellStyle = styleDeliveryETD;

                dgInventory.Columns.Add(column1_1_B);
                Binding bindingWidthSewingStart = new Binding();
                bindingWidthSewingStart.Source  = column1_1_B;
                bindingWidthSewingStart.Path    = new PropertyPath("ActualWidth");
                ColumnDefinition cdSewingStart  = new ColumnDefinition();
                cdSewingStart.SetBinding(ColumnDefinition.WidthProperty, bindingWidthSewingStart);
                gridTotal.ColumnDefinitions.Add(cdSewingStart);

                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");
                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);


                dt.Columns.Add("QuantityDelivery", typeof(Int32));
                DataGridTextColumn column1_4 = new DataGridTextColumn();
                column1_4.Header             = "Delivery Qty";
                // Style
                Style styleQtyDelivery = new Style(typeof(DataGridCell));
                styleQtyDelivery.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center));
                Setter setterBackgroundDelivery   = new Setter();
                setterBackgroundDelivery.Property = DataGridCell.ForegroundProperty;
                setterBackgroundDelivery.Value    = new Binding("QuantityDeliveryForeground");
                styleQtyDelivery.Setters.Add(setterBackgroundDelivery);
                column1_4.CellStyle = styleQtyDelivery;

                Binding bindingQtyDelivery = new Binding();
                bindingQtyDelivery.Path    = new PropertyPath("QuantityDelivery");
                column1_4.Binding          = bindingQtyDelivery;
                dgInventory.Columns.Add(column1_4);
                Binding bindingWidth1_4 = new Binding();
                bindingWidth1_4.Source  = column1_4;
                bindingWidth1_4.Path    = new PropertyPath("ActualWidth");
                ColumnDefinition cd1_4  = new ColumnDefinition();
                cd1_4.SetBinding(ColumnDefinition.WidthProperty, bindingWidth1_4);
                gridTotal.ColumnDefinitions.Add(cd1_4);

                DataColumn columnDeliveryForeground   = new DataColumn("QuantityDeliveryForeground", typeof(SolidColorBrush));
                columnDeliveryForeground.DefaultValue = Brushes.Black;
                dt.Columns.Add(columnDeliveryForeground);

                dgInventory.FrozenColumnCount = 8;

                var regex  = new Regex("[a-z]|[A-Z]");
                sizeNoList = outsoleMaterialList.Select(s => s.SizeNo).Distinct().OrderBy(s => regex.IsMatch(s) ? Double.Parse(regex.Replace(s, "")) : Double.Parse(s)).ToList();
                for (int i = 0; i <= sizeNoList.Count - 1; i++)
                {
                    //OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList[i];
                    string sizeNoBinding = sizeNoList[i].Contains(".") ? sizeNoList[i].Replace(".", "") : sizeNoList[i];
                    dt.Columns.Add(String.Format("Column{0}", sizeNoBinding), typeof(Int32));
                    DataGridTextColumn column = new DataGridTextColumn();
                    //column.SetValue(TagProperty, sizeRun.SizeNo);
                    column.Header  = sizeNoList[i];
                    column.Width   = 35;
                    column.Binding = new Binding(String.Format("Column{0}", sizeNoBinding));

                    Style style = new Style(typeof(DataGridCell));
                    style.Setters.Add(new Setter(TextBlock.TextAlignmentProperty, TextAlignment.Center));

                    Setter setterBackground   = new Setter();
                    setterBackground.Property = DataGridCell.BackgroundProperty;
                    setterBackground.Value    = new Binding(String.Format("Column{0}Background", sizeNoBinding));

                    Setter setterForeground   = new Setter();
                    setterForeground.Property = DataGridCell.ForegroundProperty;
                    setterForeground.Value    = new Binding(String.Format("Column{0}Foreground", sizeNoBinding));

                    Setter setterToolTip   = new Setter();
                    setterToolTip.Property = DataGridCell.ToolTipProperty;
                    setterToolTip.Value    = new Binding(String.Format("Column{0}ToolTip", sizeNoBinding));

                    style.Setters.Add(setterBackground);
                    style.Setters.Add(setterForeground);
                    style.Setters.Add(setterToolTip);

                    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", sizeNoBinding), typeof(SolidColorBrush));
                    columnBackground.DefaultValue = Brushes.Transparent;

                    DataColumn columnForeground   = new DataColumn(String.Format("Column{0}Foreground", sizeNoBinding), typeof(SolidColorBrush));
                    columnForeground.DefaultValue = Brushes.Black;

                    DataColumn columnToolTip = new DataColumn(String.Format("Column{0}ToolTip", sizeNoBinding), typeof(String));

                    dt.Columns.Add(columnBackground);
                    dt.Columns.Add(columnForeground);
                    dt.Columns.Add(columnToolTip);
                }

                dt.Columns.Add("TotalBalance", typeof(Int32));
                DataGridTextColumn columnTotalBalance = new DataGridTextColumn();
                columnTotalBalance.Header             = "Total";
                columnTotalBalance.Binding            = new Binding("TotalBalance");
                dgInventory.Columns.Add(columnTotalBalance);
                Binding bindingWidthTotalBalance = new Binding();
                bindingWidthTotalBalance.Source  = columnTotalBalance;
                bindingWidthTotalBalance.Path    = new PropertyPath("ActualWidth");
                ColumnDefinition cdTotalBalance  = new ColumnDefinition();
                cdTotalBalance.SetBinding(ColumnDefinition.WidthProperty, bindingWidthTotalBalance);
                gridTotal.ColumnDefinitions.Add(cdTotalBalance);
            }));

            foreach (string productNo in productNoList)
            {
                var outsoleMaterialDetailList = OutsoleMaterialDetailController.Select(productNo).Where(w => w.OutsoleSupplierId == supplierID).ToList();
                var order = orderList.FirstOrDefault(f => f.ProductNo == productNo);

                var dr = dt.NewRow();

                if (order == null)
                {
                    continue;
                }
                dr["ProductNo"] = productNo;

                //HighLightPO
                int qtyOutsoleMaterialDetail = outsoleMaterialDetailList.Sum(s => s.Quantity);
                if (qtyOutsoleMaterialDetail >= order.Quantity)
                {
                    dr["ProductNoBackground"] = Brushes.Green;
                }
                else if (qtyOutsoleMaterialDetail != 0 && qtyOutsoleMaterialDetail < order.Quantity)
                {
                    dr["ProductNoBackground"] = Brushes.Yellow;
                }

                dr["ArticleNo"] = order.ArticleNo;
                dr["Quantity"]  = order.Quantity;
                dr["OrderETD"]  = order.ETD;

                var sewingMasterModel = sewingMasterList.Where(w => w.ProductNo == productNo).FirstOrDefault();
                if (sewingMasterModel != null)
                {
                    dr["SewingStartDate"] = sewingMasterModel.SewingStartDate;
                }

                var outsoleRawMaterialModel = outsoleRawMaterialList.Where(w => w.ProductNo == productNo && w.OutsoleSupplierId == supplierID).FirstOrDefault();
                var dtTemp = new DateTime(2000, 01, 01);
                if (outsoleRawMaterialModel != null)
                {
                    dr["DeliveryETD"] = outsoleRawMaterialModel.ETD;
                    dtTemp            = outsoleRawMaterialModel.ETD;
                }

                int qtyDelivery = 0;
                foreach (string sizeNo in sizeNoList)
                {
                    string sizeNoBinding          = sizeNo.Contains(".") ? sizeNo.Replace(".", "") : sizeNo;
                    var    outsoleMaterialRecieve = outsoleMaterialList.Where(w => w.ProductNo == productNo && w.SizeNo == sizeNo).FirstOrDefault();

                    int qtyDeliveryPerSize = 0;
                    int qtyRejectPerSize   = 0;
                    if (outsoleMaterialRecieve != null)
                    {
                        qtyDeliveryPerSize = outsoleMaterialRecieve.Quantity;
                        qtyRejectPerSize   = outsoleMaterialRecieve.QuantityReject;
                    }
                    int qtyPerSize = 0;
                    if (sizeRunList.Where(w => w.ProductNo == productNo).Count() > 0)
                    {
                        qtyPerSize = sizeRunList.Where(w => w.ProductNo == productNo && w.SizeNo == sizeNo).Select(s => s.Quantity).FirstOrDefault();
                    }

                    if (qtyRejectPerSize > 0)
                    {
                        dr[String.Format("Column{0}", sizeNoBinding)]           = qtyRejectPerSize;
                        dr[String.Format("Column{0}Foreground", sizeNoBinding)] = Brushes.Red;
                    }

                    int qtyBalance = qtyPerSize - qtyDeliveryPerSize;
                    if (qtyBalance > 0 && dtTemp != dtDefault)
                    {
                        dr[String.Format("Column{0}", sizeNoBinding)] = qtyBalance + qtyRejectPerSize;
                        var dtNow = DateTime.Now;
                        if (outsoleMaterialRecieve != null)
                        {
                            if (outsoleMaterialRecieve.ModifiedTime.Date < dtNow.Date)
                            {
                                dr[String.Format("Column{0}Background", sizeNoBinding)] = Brushes.Tomato;
                            }
                            if (outsoleMaterialRecieve.ModifiedTime.Date == dtNow.Date)
                            {
                                dr[String.Format("Column{0}Background", sizeNoBinding)] = Brushes.Green;
                            }
                            dr[String.Format("Column{0}Foreground", sizeNoBinding)] = Brushes.Black;
                        }

                        if (qtyRejectPerSize > 0)
                        {
                            dr[String.Format("Column{0}Background", sizeNoBinding)] = Brushes.Yellow;
                            dr[String.Format("Column{0}ToolTip", sizeNoBinding)]    = String.Format("Balance: {0}\nReject: {1}", qtyBalance, qtyRejectPerSize);
                        }
                    }
                    qtyDelivery += qtyDeliveryPerSize;
                }
                int totalRelease = outsoleReleaseMaterialList.Where(w => w.ProductNo == productNo).Sum(s => s.Quantity);

                if (order.Quantity != qtyDelivery && qtyDelivery != 0)
                {
                    dr["QuantityDeliveryForeground"] = Brushes.Red;
                }

                dr["Release"]          = totalRelease;
                dr["QuantityDelivery"] = qtyDelivery;


                int totalQty    = outsoleMaterialList.Where(w => w.ProductNo == productNo).Sum(s => s.Quantity);
                int totalReject = outsoleMaterialList.Where(w => w.ProductNo == productNo).Sum(s => s.QuantityReject);

                if (order.Quantity - totalQty + totalReject > 0)
                {
                    dr["TotalBalance"] = order.Quantity - totalQty + totalReject;
                }

                dt.Rows.Add(dr);
            }

            Dispatcher.Invoke(new Action(() =>
            {
                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, 5);
                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;
                lblQuantityTotal.TextAlignment = TextAlignment.Center;

                Border bdrQuantityTotal = new Border();
                Grid.SetColumn(bdrQuantityTotal, 7);
                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;
                lblReleaseTotal.TextAlignment = TextAlignment.Center;

                Border bdrReleaseTotal = new Border();
                Grid.SetColumn(bdrReleaseTotal, 8);
                bdrReleaseTotal.BorderThickness = new Thickness(0, 0, 1, 1);
                bdrReleaseTotal.BorderBrush     = Brushes.Black;
                bdrReleaseTotal.Child           = lblReleaseTotal;
                gridTotal.Children.Add(bdrReleaseTotal);
                dgInventory.ItemsSource = dt.AsDataView();

                TextBlock lblQuantityDelivery     = new TextBlock();
                lblQuantityDelivery.Text          = dt.Compute("Sum(QuantityDelivery)", "").ToString();
                lblQuantityDelivery.Margin        = new Thickness(1, 0, 0, 0);
                lblQuantityDelivery.FontWeight    = FontWeights.Bold;
                lblQuantityDelivery.TextAlignment = TextAlignment.Center;

                Border bdrQuantityDeliveryTotal = new Border();
                Grid.SetColumn(bdrQuantityDeliveryTotal, 9);
                bdrQuantityDeliveryTotal.BorderThickness = new Thickness(0, 0, 1, 1);
                bdrQuantityDeliveryTotal.BorderBrush     = Brushes.Black;
                bdrQuantityDeliveryTotal.Child           = lblQuantityDelivery;
                gridTotal.Children.Add(bdrQuantityDeliveryTotal);
                dgInventory.ItemsSource = dt.AsDataView();

                for (int i = 0; i <= sizeNoList.Count - 1; i++)
                {
                    Border brTemp = new Border();
                    Grid.SetColumn(brTemp, 10 + i);
                    gridTotal.Children.Add(brTemp);
                }

                TextBlock txtTotalBalance     = new TextBlock();
                txtTotalBalance.Text          = dt.Compute("Sum(TotalBalance)", "").ToString();
                txtTotalBalance.Margin        = new Thickness(1, 0, 0, 0);
                txtTotalBalance.FontWeight    = FontWeights.Bold;
                txtTotalBalance.TextAlignment = TextAlignment.Center;

                Border brTotalBalance = new Border();
                Grid.SetColumn(brTotalBalance, 11 + sizeNoList.Count());
                brTotalBalance.BorderThickness = new Thickness(1, 0, 1, 1);
                brTotalBalance.BorderBrush     = Brushes.Black;
                brTotalBalance.Child           = txtTotalBalance;
                gridTotal.Children.Add(brTotalBalance);
                dgInventory.ItemsSource = dt.AsDataView();
            }));
            dtExportExcel = dt;
        }
Пример #6
0
 private void bwLoadDetail_DoWork(object sender, DoWorkEventArgs e)
 {
     outsoleMaterialReloadList = OutsoleMaterialDetailController.Select(productNo).Where(w => w.OutsoleSupplierId == supplierClicked.OutsoleSupplierId).ToList();
 }
        private void bwLoadReport_DoWork(object sender, DoWorkEventArgs e)
        {
            outsoleMaterialDetailList = OutsoleMaterialDetailController.SelectAll();

            outsoleMaterialDetailPerSupplierList = outsoleMaterialDetailList.Where(w => w.OutsoleSupplierId == outsoleSupplierSelected.OutsoleSupplierId).OrderBy(o => o.CreatedTime.Date).ToList();
            DataTable dt = new OutsoleMaterialDetailVarianceDataSet().Tables["OutsoleMaterialDetailVarianceTable"];

            var productNoList = outsoleMaterialDetailPerSupplierList.Select(s => s.ProductNo).Distinct().ToList();

            foreach (var productNo in productNoList)
            {
                var order = orderList.Where(w => w.ProductNo.Contains(productNo)).FirstOrDefault();
                var outsoleMaterialDetailPerSupplierPerPO = outsoleMaterialDetailPerSupplierList.Where(w => w.ProductNo.Contains(productNo)).ToList();
                var outsoleRawMaterial = outsoleRawMaterialList.FirstOrDefault(f => f.ProductNo.Contains(productNo) && f.OutsoleSupplierId == outsoleSupplierSelected.OutsoleSupplierId);

                if (order != null && outsoleMaterialDetailPerSupplierPerPO.Select(s => s.Quantity).Sum() > 0)
                {
                    DataRow dr = dt.NewRow();

                    dr["ProductNo"]   = productNo;
                    dr["OutsoleCode"] = order != null ? order.OutsoleCode : "";

                    DateTime startDelivery = outsoleMaterialDetailPerSupplierPerPO.FirstOrDefault().CreatedTime.Date;
                    if (startDelivery != dtDefault)
                    {
                        dr["StartDelivery"] = String.Format("{0:dd/MM}", startDelivery);
                    }

                    int balance = order.Quantity - outsoleMaterialDetailPerSupplierPerPO.Select(s => s.Quantity).Sum()
                                  + outsoleMaterialDetailPerSupplierPerPO.Select(s => s.Reject).Sum();

                    DateTime finishDelivery = dtDefault;
                    if (balance == 0)
                    {
                        finishDelivery       = outsoleMaterialDetailPerSupplierPerPO.LastOrDefault().CreatedTime.Date;
                        dr["FinishDelivery"] = String.Format("{0:dd/MM}", finishDelivery);
                    }

                    DateTime deliveryEFD = dtDefault;
                    if (outsoleRawMaterial != null)
                    {
                        deliveryEFD = outsoleRawMaterial.ETD;
                    }

                    if (deliveryEFD != dtDefault)
                    {
                        dr["DeliveryEFD"] = String.Format("{0:dd/MM}", deliveryEFD);
                    }

                    double leadTime = 0;
                    if (finishDelivery != dtDefault)
                    {
                        leadTime = (finishDelivery - startDelivery).TotalDays;
                    }
                    if (leadTime > 0)
                    {
                        dr["LeadTime"] = leadTime.ToString();
                    }

                    string deliveryPerformance = "";

                    if (deliveryEFD != dtDefault && finishDelivery != dtDefault && finishDelivery <= deliveryEFD)
                    {
                        deliveryPerformance = "OnTime";
                    }
                    double delayVariance = 0;
                    if (deliveryEFD != dtDefault && finishDelivery != dtDefault && finishDelivery > deliveryEFD)
                    {
                        deliveryPerformance = "DeLay";
                        delayVariance       = (finishDelivery - deliveryEFD).TotalDays;
                    }
                    dr["DeliveryPerformance"] = deliveryPerformance;
                    if (delayVariance > 0)
                    {
                        dr["DelayVariance"] = delayVariance;
                    }

                    dt.Rows.Add(dr);
                }
            }
            e.Result = dt;
        }
Пример #8
0
        private void bwPreview_DoWork(object sender, DoWorkEventArgs e)
        {
            var productNoAvailableList = orderList.Select(s => s.ProductNo).ToList();

            outsoleMaterialDetailList = OutsoleMaterialDetailController.SelectAll().Where(w => productNoAvailableList.Contains(w.ProductNo)).ToList();

            outsoleMaterialDetailFromToList = outsoleMaterialDetailList.Where(w => dateFrom.Date <= w.UpdatedTime.Date && w.UpdatedTime.Date <= dateTo.Date).ToList();

            DataTable dt = new OutsoleWHAccumulatingDataSet().Tables["OutsoleWHAccumulatingTable"];

            List <OutsoleWHAccumulatingModel> outsoleWHAccumulatingList = new List <OutsoleWHAccumulatingModel>();
            var productNoPerSupplierList = outsoleMaterialDetailFromToList.Select(s => new { ProductNo = s.ProductNo, OutsoleSupplierId = s.OutsoleSupplierId }).Distinct().ToList();

            foreach (var poPerSupp in productNoPerSupplierList)
            {
                var order = orderList.Where(w => w.ProductNo == poPerSupp.ProductNo).FirstOrDefault();
                if (order == null)
                {
                    continue;
                }
                string supplierName = supplierList.Where(w => w.OutsoleSupplierId == poPerSupp.OutsoleSupplierId).FirstOrDefault().Name;
                if (outsoleMaterialDetailFromToList.Where(w => w.OutsoleSupplierId == poPerSupp.OutsoleSupplierId && w.ProductNo == poPerSupp.ProductNo).Select(s => s.Reject).Sum() > 0)
                {
                    OutsoleWHAccumulatingModel outsoleWHAccumulating = new OutsoleWHAccumulatingModel()
                    {
                        OutsoleCode  = order.OutsoleCode,
                        SupplierName = supplierName,
                        SupplierId   = poPerSupp.OutsoleSupplierId,
                        ProductNo    = poPerSupp.ProductNo,
                        ArticleNo    = order.ArticleNo
                    };
                    outsoleWHAccumulatingList.Add(outsoleWHAccumulating);
                }
            }

            outsoleWHAccumulatingList = outsoleWHAccumulatingList.OrderBy(o => o.OutsoleCode)
                                        .ThenBy(t => t.SupplierName)
                                        .ThenBy(t => t.ProductNo)
                                        .ThenBy(t => t.ArticleNo)
                                        .ToList();

            foreach (var outsoleWHAccumulating in outsoleWHAccumulatingList)
            {
                var sizeRunList = SizeRunController.Select(outsoleWHAccumulating.ProductNo).ToList();
                if (outsoleMaterialDetailFromToList.Where(w => w.ProductNo == outsoleWHAccumulating.ProductNo).Select(s => s.Quantity).Sum() < sizeRunList.Select(s => s.Quantity).Sum() ||
                    outsoleMaterialDetailFromToList.Where(w => w.ProductNo == outsoleWHAccumulating.ProductNo).Select(s => s.Reject).Sum() <= 0)
                {
                    continue;
                }

                int indexColumn = 0;
                var regex       = new Regex(@"[A-Z]|[a-z]");
                foreach (var sizeRun in sizeRunList)
                {
                    var outsoleMaterialDetail = outsoleMaterialDetailFromToList.Where(w => w.ProductNo == outsoleWHAccumulating.ProductNo &&
                                                                                      w.OutsoleSupplierId == outsoleWHAccumulating.SupplierId &&
                                                                                      w.SizeNo == sizeRun.SizeNo).FirstOrDefault();
                    if (outsoleMaterialDetail == null)
                    {
                        continue;
                    }

                    DataRow dr = dt.NewRow();
                    dr["OutsoleCode"]  = outsoleWHAccumulating.OutsoleCode;
                    dr["SupplierName"] = outsoleWHAccumulating.SupplierName;
                    dr["ProductNo"]    = outsoleWHAccumulating.ProductNo;
                    dr["ArticleNo"]    = outsoleWHAccumulating.ArticleNo;
                    dr["SizeNo"]       = regex.IsMatch(sizeRun.SizeNo) ? regex.Replace(sizeRun.SizeNo, "") : sizeRun.SizeNo;
                    if (outsoleMaterialDetail.Reject > 0)
                    {
                        dr["QtyReject"] = outsoleMaterialDetail.Reject;
                    }

                    dt.Rows.Add(dr);
                    indexColumn++;
                }
            }
            e.Result = dt;
        }
Пример #9
0
        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();
            }));
        }