예제 #1
0
        private void Image_Add(object sender, MouseButtonEventArgs e)
        {
            var oldrow = DGridRouteCardDetails.SelectedItem as RouteCardViewModel;
            var row    = new RouteCardViewModel()
            {
                ColorPerRow            = oldrow.ColorPerRow,
                TblColor               = oldrow.TblColor,
                Direction              = oldrow.Direction,
                Notes                  = oldrow.Notes,
                Price                  = oldrow.Price,
                RouteCardHeaderIserial = oldrow.RouteCardHeaderIserial,
                SalesOrderPerRow       = oldrow.SalesOrderPerRow,
                TblSalesOrder          = oldrow.TblSalesOrder,
                Size         = oldrow.Size,
                SizeQuantity = oldrow.SizeQuantity,
                TblWarehouse = oldrow.TblWarehouse,
                RouteGroupID = oldrow.RouteGroupID,
            };

            row.WareHouseDegreeList = new ObservableCollection <TblAuthWarehouse1>();

            foreach (var item in oldrow.WareHouseDegreeList)
            {
                row.WareHouseDegreeList.Add(item);
            }
            row.Degrees       = oldrow.Degrees;
            row.Degree        = oldrow.Degree;
            row.ObjectIndex   = Guid.NewGuid().ToString("D");
            row.RoutCardSizes = new ObservableCollection <RoutCardSizeInfo>();
            row.RoutCardSizes.CollectionChanged += row.RoutCardSizes_CollectionChanged;
            if (oldrow != null)
            {
                foreach (var variable in oldrow.RoutCardSizes)
                {
                    row.RoutCardSizes.Add(new RoutCardSizeInfo
                    {
                        SizeCode         = variable.SizeCode,
                        IsTextBoxEnabled = variable.IsTextBoxEnabled,
                        SizeConsumption  = variable.SizeConsumption,
                    });
                }
            }
            MyViewModel.RouteCardDetails.Add(row);
        }
예제 #2
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dGridStyles.SelectedItems.Count > 0)
                {
                    if (SubmitAction != null)
                    {
                        foreach (_Proxy.TblSalesOrderColor item in dGridStyles.SelectedItems)
                        {
                            if (RouteCardDetailOperationList != null && RouteCardDetailOperationList.Any(x => x.TblColor == item.TblColor))
                            {
                                foreach (
                                    var variable in
                                    RouteCardDetailOperationList.Where(x => x.TblColor == item.TblColor)
                                    .GroupBy(x => x.Degree))
                                {
                                    var temp = new RouteCardViewModel
                                    {
                                        WareHouseDegreeList = ViewModel.WareHouseDegreeList,
                                        TblSalesOrder       = item.TblSalesOrder,
                                        TblColor            = item.TblColor,
                                        ObjectIndex         = Guid.NewGuid().ToString("D"),
                                        Price            = CostPerOperation,
                                        ColorPerRow      = item.TblColor1,
                                        SalesOrderPerRow = item.TblSalesOrder1,
                                        Degree           = variable.Key,
                                    };

                                    foreach (var sizeItem in item.TblSalesOrderSizeRatios)
                                    {
                                        var routeCardSize = new RoutCardSizeInfo
                                        {
                                            SizeCode         = sizeItem.Size,
                                            SizeConsumption  = (int)sizeItem.Ratio,
                                            IsTextBoxEnabled = true
                                        };
                                        temp.RoutCardSizes.Add(routeCardSize);
                                    }

                                    foreach (var newVariable in temp.RoutCardSizes)
                                    {
                                        if (RouteCardDetailOperationList != null)
                                        {
                                            var row =
                                                RouteCardDetailOperationList.FirstOrDefault(
                                                    x =>
                                                    x.Size == newVariable.SizeCode && x.TblColor == item.TblColor &&
                                                    x.Degree == variable.Key);
                                            if (row != null)
                                            {
                                                if (row.SizeQuantity != null)
                                                {
                                                    newVariable.SizeConsumption = (int)row.SizeQuantity;
                                                }
                                            }
                                            else
                                            {
                                                newVariable.SizeConsumption = 0;
                                            }
                                        }
                                        else
                                        {
                                            newVariable.SizeConsumption = 0;
                                        }
                                    }
                                    ReturnResult.Add(temp);
                                }
                            }
                            else
                            {
                                var temp = new RouteCardViewModel
                                {
                                    WareHouseDegreeList = ViewModel.WareHouseDegreeList,
                                    TblSalesOrder       = item.TblSalesOrder,
                                    TblColor            = item.TblColor,
                                    ObjectIndex         = Guid.NewGuid().ToString("D"),

                                    ColorPerRow      = item.TblColor1,
                                    SalesOrderPerRow = item.TblSalesOrder1,
                                    Degree           = "1st",
                                    Price            = CostPerOperation,
                                };

                                foreach (var sizeItem in item.TblSalesOrderSizeRatios)
                                {
                                    var routeCardSize = new RoutCardSizeInfo
                                    {
                                        SizeCode         = sizeItem.Size,
                                        SizeConsumption  = (int)sizeItem.Ratio,
                                        IsTextBoxEnabled = true
                                    };
                                    temp.RoutCardSizes.Add(routeCardSize);
                                }
                                ReturnResult.Add(temp);
                            }
                        }
                        ViewModel.RouteCardDetailOperationList = RouteCardDetailOperationList;
                        SubmitAction(this, new EventArgs());
                    }
                }
                DialogResult = true;
            }
            catch (Exception ex)
            {
                var errw = new ErrorWindow(ex);
                errw.Show();
            }
        }