Exemplo n.º 1
0
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     upperComponentList         = UpperComponentController.Select();
     upperComponentMaterialList = UpperComponentMaterialController.Select(productNo);
     sizeRunList = SizeRunController.Select(productNo);
     upperComponentRawMaterialList = UpperComponentRawMaterialController.Select(productNo);
 }
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     insockSupplierList    = InsockSuppliersController.Select();
     insockMaterialList    = InsockMaterialController.Select(productNo);
     sizeRunList           = SizeRunController.Select(productNo);
     insockRawMaterialList = InsockRawMaterialController.SelectPerPO(productNo);
 }
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     outsoleSupplierList             = OutsoleSuppliersController.Select();
     outsoleMaterialList             = OutsoleMaterialController.Select(productNo);
     sizeRunList                     = SizeRunController.Select(productNo);
     outsoleRawMaterialList          = OutsoleRawMaterialController.Select(productNo);
     outsoleMaterialRackPositionList = OutsoleMaterialRackPositionController.Select(productNo);
 }
Exemplo n.º 4
0
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     orderList     = OrderController.Select();
     supplierList  = SupplierController.Select();
     componentList = ComponentController.Select();
     sizeRunList   = SizeRunController.Select();
     offDayList    = OffDayController.Select();
     offDayMapList = OffDayMapController.Select();
 }
Exemplo n.º 5
0
 private void BwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     materialPlanList = MaterialPlanController.GetMaterialPlanByPO(productNo);
     materialPlanList.ForEach(t => t.ActualDateString = t.ActualDate != dtDefault ? String.Format("{0:MM/dd}", t.ActualDate) : "");
     supplierAccessoriesList = SupplierController.GetSuppliersAccessories();
     sizeRunList             = SizeRunController.Select(productNo);
     matsInspectionList      = MaterialInspectController.GetMaterialInspectByPO(productNo);
     matsDeliveryList        = MaterialDeliveryController.GetMaterialDeliveryByPO(productNo);
 }
Exemplo n.º 6
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();
 }
Exemplo n.º 7
0
        private void cbOutsoleCode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cbSelect = cbOutsoleCode.SelectedItem as Order;

            sizeRunList = SizeRunController.Select();

            sizeRunList_OutsoleCode = sizeRunList.Where(w => w.OutsoleCode == cbSelect.OutsoleCode).ToList();
            var regex = new Regex(@"[a-z]|[A-Z]");

            sizeRunList_OutsoleCode = sizeRunList_OutsoleCode.OrderBy(o => regex.IsMatch(o.SizeNo) ? Double.Parse(regex.Replace(o.SizeNo, "100")) : Double.Parse(o.SizeNo)).ToList();
            LoadSizeRun(sizeRunList_OutsoleCode);
        }
Exemplo n.º 8
0
        private void bwAddMore_DoWork(object sender, DoWorkEventArgs e)
        {
            string productNo = "";

            txtProductNo.Dispatcher.Invoke((Action)(() =>
            {
                productNo = txtProductNo.Text;
            }));
            orderSearch       = OrdersController.SelectTop1(productNo);
            sizeRunSearchList = SizeRunController.Select(productNo);
            outsoleReleaseMaterialSearchList = OutsoleReleaseMaterialController.Select(productNo);
            outsoleMaterialSearchList        = OutsoleMaterialController.Select(productNo);
        }
        private void BwSearch_DoWork(object sender, DoWorkEventArgs e)
        {
            var searchWhat = e.Argument as String;

            try
            {
                if (doMode == DoMode.Confirm)
                {
                    osmConfirmList = OutsoleMaterialController.GetOSConfirmByIndexNo(int.Parse(searchWhat));
                }
                else if (doMode == DoMode.Release)
                {
                    osmConfirmList = OutsoleMaterialController.GetOSConfirmByPO(searchWhat);
                    sizeRunList    = SizeRunController.Select(searchWhat);
                }
            }
            catch (Exception ex)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                }));
            }
        }
Exemplo n.º 10
0
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     sizeRunList     = SizeRunController.Select(productNo);
     outsoleWHFGList = OutsoleWHFGController.Select(productNo).OrderBy(o => o.CreatedDate).ToList();
 }
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     sizeRunList         = SizeRunController.Select(productNo);
     sockliningInputList = SockliningInputController.SelectByPO(productNo);
     offDayList          = OffDayController.Select();
 }
Exemplo n.º 12
0
        private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            DataTable     dt         = new DataTable();
            var           regex      = new Regex("[a-z]|[A-Z]");
            List <String> sizeNoList = upperComponentMaterialList.Select(s => s.SizeNo).Distinct().OrderBy(s => regex.IsMatch(s) ? Double.Parse(regex.Replace(s, "")) : Double.Parse(s)).ToList();

            DateTime dtDefault        = new DateTime(2000, 01, 01);
            var      sewingMasterList = SewingMasterController.Select().ToList();

            Dispatcher.Invoke(new Action(() =>
            {
                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("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);



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

                dgInventory.FrozenColumnCount = 8;
                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));
                    style.Setters.Add(setterBackground);
                    column.CellStyle = style;

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

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

                    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.White;

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

            foreach (string productNo in productNoList)
            {
                sizeRunList = SizeRunController.Select(productNo);
                var     upperComponentMaterialList_D1 = upperComponentMaterialList.Where(w => w.ProductNo == productNo).ToList();
                DataRow dr = dt.NewRow();
                dr["ProductNo"] = productNo;
                OrdersModel order = orderList.Where(w => w.ProductNo == productNo).FirstOrDefault();
                if (order != null)
                {
                    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;
                }

                UpperComponentRawMaterialModel upperComponentRawMaterialModel = upperComponentRawMaterialList.Where(w => w.ProductNo == productNo && w.UpperComponentID == upperComponentID).FirstOrDefault();
                DateTime dtTemp = new DateTime(2000, 01, 01);
                if (upperComponentRawMaterialModel != null)
                {
                    dr["DeliveryETD"] = upperComponentRawMaterialModel.ETD;
                    dtTemp            = upperComponentRawMaterialModel.ETD;
                }

                int qtyDelivery = 0;
                //int qtyMatchTotal = 0;
                foreach (string sizeNo in sizeNoList)
                {
                    string sizeNoBinding = sizeNo.Contains(".") ? sizeNo.Replace(".", "") : sizeNo;
                    int    qtyPerSize    = 0;
                    if (sizeRunList.Count > 0)
                    {
                        qtyPerSize = sizeRunList.Where(w => w.SizeNo == sizeNo).Select(s => s.Quantity).FirstOrDefault();
                    }

                    var upperComponentRecieve = upperComponentMaterialList.Where(w => w.ProductNo == productNo && w.SizeNo == sizeNo).FirstOrDefault();
                    int qtyRejectPerSize      = 0;
                    int qtyDeliveryPerSize    = 0;
                    if (upperComponentRecieve != null)
                    {
                        qtyDeliveryPerSize = upperComponentRecieve.Quantity;
                        qtyRejectPerSize   = upperComponentRecieve.QuantityReject;
                    }

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

                    //int qtyDeliveryPerSize = upperComponentMaterialList.Where(w => w.ProductNo == productNo && w.SizeNo == sizeNo).Select(s => s.Quantity).FirstOrDefault();
                    int qtyBalance = qtyPerSize - qtyDeliveryPerSize;
                    if (qtyBalance > 0 && dtTemp != dtDefault)
                    {
                        dr[String.Format("Column{0}", sizeNoBinding)] = qtyBalance + qtyRejectPerSize;
                        DateTime dtNow = DateTime.Now;
                        UpperComponentMaterialModel upperComponentMaterialRecieve = upperComponentMaterialList.Where(w => w.ProductNo == productNo && w.SizeNo == sizeNo).FirstOrDefault();
                        if (upperComponentMaterialRecieve != null)
                        {
                            if (upperComponentMaterialRecieve.ModifiedTime.Date < dtNow.Date)
                            {
                                dr[String.Format("Column{0}Background", sizeNoBinding)] = Brushes.Tomato;
                            }
                            if (upperComponentMaterialRecieve.ModifiedTime.Date == dtNow.Date)
                            {
                                dr[String.Format("Column{0}Background", sizeNoBinding)] = Brushes.Green;
                            }
                        }
                        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;

                    // Matching
                    //if (upperComponentMaterialList_D1.Count > 0)
                    //{
                    //    int qtyMin = upperComponentMaterialList_D1.Where(o => o.SizeNo == sizeNo).Select(o => o.Quantity - o.QuantityReject).Min();
                    //    //int qtyRelease = outsoleReleaseMaterialList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity);
                    //    //int qtyMatch = qtyMin - qtyRelease;
                    //    int qtyMatch = qtyMin;
                    //    if (qtyMatch < 0)
                    //    {
                    //        qtyMatch = 0;
                    //    }
                    //    qtyMatchTotal += qtyMatch;
                    //}
                }
                int totalQty = upperComponentMaterialList.Where(w => w.ProductNo == productNo).Sum(s => s.Quantity - s.QuantityReject);
                //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;
                //dr["Matching"] = qtyMatchTotal;
                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;
                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;
                //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;
                Border bdrQuantityDeliveryTotal = new Border();
                Grid.SetColumn(bdrQuantityDeliveryTotal, 8);
                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 <= 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);
                //}
            }));
        }
Exemplo n.º 13
0
 private void bwSearch_DoWork(object sender, DoWorkEventArgs e)
 {
     orders      = OrdersController.SelectTop1(productNo);
     sizeRunList = SizeRunController.Select(productNo);
 }
Exemplo n.º 14
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;
        }
Exemplo n.º 15
0
 private void bwLoad_DoWork(object sender, DoWorkEventArgs e)
 {
     orderCurrentList = OrderController.Select();
     sizeRunList      = SizeRunController.Select();
 }
Exemplo n.º 16
0
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     outsoleOutputList = OutsoleOutputController.Select(productNo);
     sizeRunList       = SizeRunController.Select(productNo);
     offDayList        = OffDayController.SelectDate();
 }
        private void BwLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                sizeRunList          = SizeRunController.Select(productNo);
                matsDeliveryByPOList = MaterialDeliveryController.GetMaterialDeliveryByPO(productNo);
                matsPlanByPOList     = MaterialPlanController.GetMaterialPlanByPO(productNo);
                supplierList         = SupplierController.GetSuppliersAccessories();
                Dispatcher.Invoke(new Action(() =>
                {
                    // Create Column Datagrid
                    dgDeliveryInfo.Columns.Clear();
                    dtDelivery = new DataTable();

                    dtDelivery.Columns.Add("Status", typeof(String));
                    dtDelivery.Columns.Add("Name", typeof(String));
                    dtDelivery.Columns.Add("SupplierId", typeof(String));
                    DataGridTemplateColumn colSuppName = new DataGridTemplateColumn();
                    colSuppName.Header                  = String.Format("Supplier");
                    DataTemplate templateSuppName       = new DataTemplate();
                    FrameworkElementFactory tblSuppName = new FrameworkElementFactory(typeof(TextBlock));
                    templateSuppName.VisualTree         = tblSuppName;
                    tblSuppName.SetBinding(TextBlock.TextProperty, new Binding(String.Format("Name")));
                    tblSuppName.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
                    tblSuppName.SetValue(TextBlock.PaddingProperty, new Thickness(3, 0, 3, 0));
                    colSuppName.CellTemplate            = templateSuppName;
                    colSuppName.ClipboardContentBinding = new Binding(String.Format("Name"));
                    dgDeliveryInfo.Columns.Add(colSuppName);

                    //Column ETD
                    dtDelivery.Columns.Add("ETD", typeof(String));
                    dtDelivery.Columns.Add("ETDDate", typeof(DateTime));
                    DataGridTemplateColumn colETD = new DataGridTemplateColumn();
                    colETD.Header                  = String.Format("EFD");
                    colETD.MinWidth                = 60;
                    DataTemplate templateETD       = new DataTemplate();
                    FrameworkElementFactory tblETD = new FrameworkElementFactory(typeof(TextBlock));
                    templateETD.VisualTree         = tblETD;
                    tblETD.SetBinding(TextBlock.TextProperty, new Binding(String.Format("ETD")));
                    tblETD.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
                    tblETD.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
                    tblETD.SetValue(TextBlock.PaddingProperty, new Thickness(3, 0, 3, 0));
                    colETD.CellTemplate            = templateETD;
                    colETD.ClipboardContentBinding = new Binding(String.Format("ETD"));
                    dgDeliveryInfo.Columns.Add(colETD);

                    //Column Actual Date
                    dtDelivery.Columns.Add("ActualDate", typeof(String));
                    dtDelivery.Columns.Add("ActualDateDate", typeof(DateTime));
                    DataGridTemplateColumn colActualDate = new DataGridTemplateColumn();
                    colActualDate.Header                  = String.Format("{0}\n{1}\n{2}", "Order Size", "Qty", "Actual Date");
                    DataTemplate templateActualDate       = new DataTemplate();
                    FrameworkElementFactory tblActualDate = new FrameworkElementFactory(typeof(TextBlock));
                    templateActualDate.VisualTree         = tblActualDate;
                    tblActualDate.SetBinding(TextBlock.TextProperty, new Binding(String.Format("ActualDate")));
                    tblActualDate.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
                    tblActualDate.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
                    tblActualDate.SetValue(TextBlock.PaddingProperty, new Thickness(3, 0, 3, 0));
                    colActualDate.CellTemplate            = templateActualDate;
                    colActualDate.ClipboardContentBinding = new Binding(String.Format("ActualDate"));
                    dgDeliveryInfo.Columns.Add(colActualDate);

                    var regex = new Regex("[a-z]|[A-Z]");
                    if (sizeRunList.Count() > 0)
                    {
                        sizeRunList = sizeRunList.OrderBy(s => regex.IsMatch(s.SizeNo) ? Double.Parse(regex.Replace(s.SizeNo, "100")) : Double.Parse(s.SizeNo)).ToList();
                    }
                    foreach (var sizeRun in sizeRunList)
                    {
                        string sizeBinding = sizeRun.SizeNo.Contains(".") ? sizeRun.SizeNo.Replace(".", "@") : sizeRun.SizeNo;

                        dtDelivery.Columns.Add(String.Format("Column{0}", sizeBinding), typeof(String));
                        dtDelivery.Columns.Add(String.Format("Column{0}Foreground", sizeBinding), typeof(SolidColorBrush));
                        //dtDelDetail.Columns.Add(String.Format("Column{0}ToolTip", sizeBinding), typeof(String));
                        DataGridTextColumn column = new DataGridTextColumn();
                        column.SetValue(TagProperty, sizeRun.SizeNo);
                        column.Header   = string.Format("{0}\n\n{1}", sizeRun.SizeNo, sizeRun.Quantity);
                        column.MinWidth = 40;
                        column.MaxWidth = 200;
                        column.Binding  = new Binding(String.Format("Column{0}", sizeBinding));

                        Style styleColumn              = new Style();
                        Setter setterColumnForecolor   = new Setter();
                        setterColumnForecolor.Property = DataGridCell.ForegroundProperty;
                        setterColumnForecolor.Value    = new Binding(String.Format("Column{0}Foreground", sizeBinding));

                        styleColumn.Setters.Add(setterColumnForecolor);
                        column.CellStyle = styleColumn;

                        dgDeliveryInfo.Columns.Add(column);
                    }

                    //Column Total
                    dtDelivery.Columns.Add("Balance", typeof(String));
                    DataGridTemplateColumn colBalance = new DataGridTemplateColumn();
                    colBalance.Header                  = String.Format("Total\n\n{0}", sizeRunList.Sum(s => s.Quantity));
                    colBalance.MinWidth                = 80;
                    colBalance.MaxWidth                = 80;
                    DataTemplate templateBalance       = new DataTemplate();
                    FrameworkElementFactory tblBalance = new FrameworkElementFactory(typeof(TextBlock));
                    templateBalance.VisualTree         = tblBalance;
                    tblBalance.SetBinding(TextBlock.TextProperty, new Binding(String.Format("Balance")));
                    tblBalance.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
                    tblBalance.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
                    tblBalance.SetValue(TextBlock.PaddingProperty, new Thickness(3, 0, 3, 0));
                    colBalance.CellTemplate            = templateBalance;
                    colBalance.ClipboardContentBinding = new Binding(String.Format("Balance"));
                    dgDeliveryInfo.Columns.Add(colBalance);

                    DataGridTemplateColumn colButtonOK = new DataGridTemplateColumn();
                    colButtonOK.MinWidth                = 40;
                    colButtonOK.MaxWidth                = 40;
                    DataTemplate templateButtonOK       = new DataTemplate();
                    FrameworkElementFactory fefButtonOK = new FrameworkElementFactory(typeof(Button));
                    templateButtonOK.VisualTree         = fefButtonOK;
                    fefButtonOK.SetValue(Button.ContentProperty, "Ok");
                    fefButtonOK.AddHandler(Button.ClickEvent, new RoutedEventHandler(BtnOK_Click));
                    colButtonOK.CellTemplate = templateButtonOK;
                    dgDeliveryInfo.Columns.Add(colButtonOK);

                    // Binding Data
                    if (matsDeliveryByPOList.Count() == 0)
                    {
                        foreach (var matsPlan in matsPlanByPOList)
                        {
                            var supplierByPlan = supplierList.FirstOrDefault(f => f.SupplierId == matsPlan.SupplierId);
                            foreach (var sizeRun in sizeRunList)
                            {
                                matsDeliveryByPOList.Add(new MaterialDeliveryModel
                                {
                                    SupplierId          = matsPlan.SupplierId,
                                    SupplierNameDisplay = supplierByPlan != null ? String.Format("{0} - {1}", supplierByPlan.Name, supplierByPlan.ProvideAccessories) : "",
                                    ProductNo           = matsPlan.ProductNo,
                                    ETD = matsPlan.ETD,
                                    ActualDeliveryDate = dtDefault,
                                    SizeNo             = sizeRun.SizeNo,
                                    Quantity           = 0,
                                    Reject             = 0,
                                    RejectSewing       = 0
                                });
                            }
                        }
                    }
                    else
                    {
                        // Put Supplier Name - Accessories Name
                        matsDeliveryByPOList.ForEach(f => f.SupplierNameDisplay = String.Format("{0} - {1}",
                                                                                                supplierList.FirstOrDefault(w => w.SupplierId == f.SupplierId).Name,
                                                                                                supplierList.FirstOrDefault(w => w.SupplierId == f.SupplierId).ProvideAccessories));
                    }

                    var supplierIdList = matsDeliveryByPOList.Select(s => s.SupplierId).Distinct().ToList();
                    foreach (var supplierId in supplierIdList)
                    {
                        var deliveryListBySupp = matsDeliveryByPOList.Where(w => w.SupplierId == supplierId).ToList();
                        var materialInfoBySupp = deliveryListBySupp.FirstOrDefault();

                        // Row Quantity, Reject, RejectSewing
                        DataRow drQuantity     = dtDelivery.NewRow();
                        DataRow drReject       = dtDelivery.NewRow();
                        DataRow drRejectSewing = dtDelivery.NewRow();

                        drQuantity["Status"]     = RowQuantity;
                        drReject["Status"]       = RowReject;
                        drRejectSewing["Status"] = RowRejectSewing;

                        drQuantity["Name"]     = materialInfoBySupp.SupplierNameDisplay;
                        drReject["Name"]       = RowReject;
                        drRejectSewing["Name"] = RowRejectSewing;

                        drQuantity["SupplierId"]     = materialInfoBySupp.SupplierId;
                        drReject["SupplierId"]       = materialInfoBySupp.SupplierId;
                        drRejectSewing["SupplierId"] = materialInfoBySupp.SupplierId;

                        drQuantity["ETD"] = string.Format("{0:MM/dd}", materialInfoBySupp.ETD);
                        if (materialInfoBySupp.ActualDeliveryDate != dtDefault)
                        {
                            drQuantity["ActualDate"] = string.Format("{0:MM/dd}", materialInfoBySupp.ActualDeliveryDate);
                        }

                        drQuantity["ActualDateDate"] = materialInfoBySupp.ActualDeliveryDate;
                        drQuantity["ETDDate"]        = materialInfoBySupp.ETD;

                        foreach (var sizeRun in sizeRunList)
                        {
                            string sizeBinding = sizeRun.SizeNo.Contains(".") ? sizeRun.SizeNo.Replace(".", "@") : sizeRun.SizeNo;

                            var deliveryBySizeNo = deliveryListBySupp.FirstOrDefault(f => f.SizeNo == sizeRun.SizeNo);
                            if (deliveryBySizeNo != null)
                            {
                                if (deliveryBySizeNo.Quantity > 0)
                                {
                                    drQuantity[String.Format("Column{0}", sizeBinding)] = deliveryBySizeNo.Quantity;
                                    if (deliveryBySizeNo.Quantity == sizeRun.Quantity)
                                    {
                                        drQuantity[String.Format("Column{0}Foreground", sizeBinding)] = Brushes.Blue;
                                    }
                                }
                                if (deliveryBySizeNo.Reject > 0)
                                {
                                    drReject[String.Format("Column{0}", sizeBinding)]           = deliveryBySizeNo.Reject;
                                    drReject[String.Format("Column{0}Foreground", sizeBinding)] = Brushes.Red;
                                }
                                if (deliveryBySizeNo.RejectSewing > 0)
                                {
                                    drRejectSewing[String.Format("Column{0}", sizeBinding)]           = deliveryBySizeNo.RejectSewing;
                                    drRejectSewing[String.Format("Column{0}Foreground", sizeBinding)] = Brushes.Red;
                                }
                            }
                        }

                        int totalBalanceBySupp = sizeRunList.Sum(s => s.Quantity) - deliveryListBySupp.Sum(s => s.Quantity);
                        int totalReject        = deliveryListBySupp.Sum(s => s.Reject);
                        int totalRejectSewing  = deliveryListBySupp.Sum(s => s.RejectSewing);

                        drQuantity["Balance"]     = totalBalanceBySupp > 0 ? totalBalanceBySupp.ToString() : "";
                        drReject["Balance"]       = totalReject > 0 ? totalReject.ToString() : "";
                        drRejectSewing["Balance"] = totalRejectSewing > 0 ? totalRejectSewing.ToString() : "";

                        dtDelivery.Rows.Add(drQuantity);
                        dtDelivery.Rows.Add(drReject);
                        dtDelivery.Rows.Add(drRejectSewing);
                    }

                    dgDeliveryInfo.ItemsSource = dtDelivery.AsDataView();
                }));
            }
            catch (Exception ex)
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    MessageBox.Show(ex.InnerException.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                }));
            }
        }