private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (!RequestVM.StockSysNo.HasValue)
            {
                CurrentWindow.Alert("请选择转换商品所在仓库。");
                return;
            }

            UCProductBatch batch = new UCProductBatch();

            batch.IsCreateMode = true;
            batch.PType        = Models.Request.PageType.Convert;
            batch.ConvertType  = this.ConvertType;
            if (RequestVM.StockSysNo.HasValue)
            {
                batch.StockSysNo = RequestVM.StockSysNo.Value;
            }
            batch.IsNotLend_Return = true;

            IDialog dialog = CurrentWindow.ShowDialog("批次信息", batch, (obj, args) =>
            {
                ProductVMAndBillInfo productList = args.Data as ProductVMAndBillInfo;

                if (null != productList && productList.ProductVM != null)
                {
                    productList.ProductVM.ForEach(p =>
                    {
                        ConvertRequestItemVM vm = RequestItemList.FirstOrDefault(item =>
                        {
                            return(item.ProductSysNo == p.SysNo);
                        });
                        if (vm == null)
                        {
                            string errorMessage = "对不起,您没有权限访问{0}商品!";
                            InventoryQueryFilter queryFilter = new InventoryQueryFilter();
                            queryFilter.ProductSysNo         = p.SysNo;
                            queryFilter.UserName             = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.LoginUser.LoginName;
                            queryFilter.CompanyCode          = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.CompanyCode;
                            queryFilter.UserSysNo            = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.LoginUser.UserSysNo;
                            //判断改商品是否属于当前PM

                            int quantity = 1;
                            if (p.IsHasBatch == 1)
                            {
                                quantity = (from s in p.ProductBatchLst select s.Quantity).Sum();
                            }
                            else if (p.IsHasBatch == 0)
                            {
                                quantity = productList.Quantity;
                            }

                            if (!AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_SeniorPM_Query))
                            {
                                InventoryQueryFacade.CheckOperateRightForCurrentUser(queryFilter, (Innerogj, innerArgs) =>
                                {
                                    if (!innerArgs.FaultsHandle())
                                    {
                                        if (!innerArgs.Result)
                                        {
                                            Page.Context.Window.Alert(string.Format(errorMessage, p.ProductID));
                                            return;
                                        }
                                        else
                                        {
                                            vm = new ConvertRequestItemVM
                                            {
                                                ProductSysNo              = p.SysNo,
                                                ConvertQuantity           = quantity,
                                                ConvertType               = ConvertType,
                                                ConvertUnitCost           = p.UnitCost,
                                                ConvertUnitCostWithoutTax = p.UnitCostWithoutTax,
                                                ProductName               = p.ProductName,
                                                ProductID            = p.ProductID,
                                                BatchDetailsInfoList = EntityConverter <BatchInfoVM, ProductBatchInfoVM> .Convert(p.ProductBatchLst),
                                                IsHasBatch           = p.IsHasBatch,
                                                RequestStatus        = ConvertRequestStatus.Origin
                                            };
                                            vm.QuantityOrCostChanged = SetTotalCost;
                                            ItemList.Add(vm);
                                            RequestItemList.Add(vm);
                                            dgProductList.ItemsSource = ItemList;
                                            SetTotalCost();
                                        }
                                    }
                                });
                            }
                            else
                            {
                                vm = new ConvertRequestItemVM
                                {
                                    ProductSysNo              = p.SysNo,
                                    ConvertQuantity           = quantity,
                                    ConvertType               = ConvertType,
                                    ConvertUnitCost           = p.UnitCost,
                                    ConvertUnitCostWithoutTax = p.UnitCostWithoutTax,
                                    ProductName               = p.ProductName,
                                    ProductID            = p.ProductID,
                                    BatchDetailsInfoList = EntityConverter <BatchInfoVM, ProductBatchInfoVM> .Convert(p.ProductBatchLst),
                                    IsHasBatch           = p.IsHasBatch,
                                    RequestStatus        = ConvertRequestStatus.Origin
                                };
                                vm.QuantityOrCostChanged = SetTotalCost;
                                ItemList.Add(vm);
                                RequestItemList.Add(vm);
                                dgProductList.ItemsSource = ItemList;
                                SetTotalCost();
                            }
                        }
                        else
                        {
                            Page.Context.Window.Alert(String.Format(vm.ConvertType == ConvertProductType.Source ? "商品:{0},已经存在于源商品中" : "商品:{0},已经存在于目标商品中", vm.ProductID));
                        }
                    });
                }
            });

            batch.DialogHandler = dialog;
        }
示例#2
0
        private void dgInventoryQueryResult_LoadingDataSource(object sender, Newegg.Oversea.Silverlight.Controls.Data.LoadingDataEventArgs e)
        {
            queryFilter = EntityConverter <InventoryQueryVM, InventoryQueryFilter> .Convert(queryVM);

            this.queryFilter.PagingInfo = new QueryFilter.Common.PagingInfo();

            this.queryFilter.PagingInfo.PageIndex = e.PageIndex;
            this.queryFilter.PagingInfo.PageSize  = e.PageSize;
            this.queryFilter.PagingInfo.SortBy    = e.SortField;
            //如果查询总库存,则调用QueryInventory的service,否则调用QueryInventoryStock:
            //if (this.queryFilter.IsShowTotalInventory != null && this.queryFilter.IsShowTotalInventory.Value)
            //{

            #region 获取自己能访问到的PM

            queryFilter.UserSysNo   = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.LoginUser.UserSysNo;
            queryFilter.CompanyCode = Newegg.Oversea.Silverlight.ControlPanel.Core.CPApplication.Current.CompanyCode;

            if (!AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_SeniorPM_Query))
            {
                if (queryFilter == null || !queryFilter.ProductSysNo.HasValue)
                {
                    Window.Alert("请先选择商品!");
                    return;
                }
                serviceFacade.CheckOperateRightForCurrentUser(queryFilter, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    if (args.Result)
                    {
                        serviceFacade.QueryInventoryList(queryFilter, (innerObj, innerArgs) =>
                        {
                            if (innerArgs.FaultsHandle())
                            {
                                return;
                            }
                            var getList = innerArgs.Result.Rows;

                            foreach (var x in getList)
                            {
                                x["ActivedQty"]  = x["ActivedQty"] == null || x["ActivedQty"].ToString() == "" ? "--" : x["ActivedQty"];
                                x["InactiveQty"] = x["InactiveQty"] == null || x["InactiveQty"].ToString() == "" ? "--" : x["InactiveQty"];
                                x["InvalidQty"]  = x["InvalidQty"] == null || x["InvalidQty"].ToString() == "" ? "--" : x["InvalidQty"];
                            }

                            int totalCount = innerArgs.Result.TotalCount;
                            this.dgInventoryQueryResult.ItemsSource = getList;
                            this.dgInventoryQueryResult.TotalCount  = totalCount;
                        });
                        //}
                        //else
                        //{
                        //    serviceFacade.QueryInventoryStockList(queryFilter, (obj, args) =>
                        //    {
                        //        if (args.FaultsHandle())
                        //        {
                        //            return;
                        //        }
                        //        var getList = args.Result.Rows;
                        //        int totalCount = args.Result.TotalCount;
                        //        this.dgInventoryQueryResult.ItemsSource = getList;
                        //        this.dgInventoryQueryResult.TotalCount = totalCount;
                        //    });
                        //}
                        this.UnPayOrderQtyColumn.Visibility = queryVM.IsUnPayShow ? Visibility.Visible : Visibility.Collapsed;
                        this.StockNameColumn.Visibility     =
                            queryVM.IsShowTotalInventory ? Visibility.Collapsed : Visibility.Visible;
                    }
                    else
                    {
                        Window.Alert(string.Format("你没有权限查询该商品库存"));
                    }
                });
            }
            else
            {
                serviceFacade.QueryInventoryList(queryFilter, (innerObj, innerArgs) =>
                {
                    if (innerArgs.FaultsHandle())
                    {
                        return;
                    }
                    var getList = innerArgs.Result.Rows;

                    foreach (var x in getList)
                    {
                        x["ActivedQty"]  = x["ActivedQty"] == null || x["ActivedQty"].ToString() == "" ? "--" : x["ActivedQty"];
                        x["InactiveQty"] = x["InactiveQty"] == null || x["InactiveQty"].ToString() == "" ? "--" : x["InactiveQty"];
                        x["InvalidQty"]  = x["InvalidQty"] == null || x["InvalidQty"].ToString() == "" ? "--" : x["InvalidQty"];
                    }

                    int totalCount = innerArgs.Result.TotalCount;
                    this.dgInventoryQueryResult.ItemsSource = getList;
                    this.dgInventoryQueryResult.TotalCount  = totalCount;

                    this.UnPayOrderQtyColumn.Visibility = queryVM.IsUnPayShow ? Visibility.Visible : Visibility.Collapsed;
                    this.StockNameColumn.Visibility     = queryVM.IsShowTotalInventory ? Visibility.Collapsed : Visibility.Visible;
                });
            }
            #endregion
        }