private void hlbtnEdit_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton      btn      = sender as HyperlinkButton;
            ConvertRequestItemVM selected = this.dgProductList.SelectedItem as ConvertRequestItemVM;
            ConvertRequestItemVM seleced  = RequestItemList.Where(p => p.ProductSysNo == selected.ProductSysNo).FirstOrDefault();

            #region Dialog

            UCProductBatch batch = new UCProductBatch(seleced.ProductSysNo.Value.ToString(), seleced.ProductID, seleced.HasBatchInfo, seleced.BatchDetailsInfoList);
            batch.IsCreateMode      = false;
            batch.PType             = Models.Request.PageType.Convert;
            batch.IsNotLend_Return  = true;
            batch.StockSysNo        = RequestVM.StockSysNo;
            batch.ProductSysNo      = selected.ProductSysNo.Value.ToString();
            batch.ProductID         = selected.ProductID;
            batch.OperationQuantity = seleced.ConvertQuantity;
            batch.ConverterCost     = seleced.ConvertUnitCost;
            batch.ConvertType       = this.ConvertType;

            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;

            #endregion

            SetTotalCost();
        }
Esempio n. 2
0
        private void ShowEditModeDialog(object sender, RoutedEventArgs e, string title, bool isNotReturn)
        {
            HyperlinkButton         btn        = sender as HyperlinkButton;
            List <ExperienceItemVM> itemSource = this.dgProductList.ItemsSource as List <ExperienceItemVM>;
            ExperienceItemVM        selected   = this.dgProductList.SelectedItem as ExperienceItemVM;

            ExperienceVM     RequestVM = this.DataContext as ExperienceVM;
            ExperienceItemVM seleced   = RequestVM.ExperienceItemInfoList.Where(p => p.ProductSysNo == selected.ProductSysNo).FirstOrDefault();

            UCProductBatch batch = new UCProductBatch(seleced.ProductSysNo.Value.ToString(), seleced.ProductID, false, null);


            //batch.StockSysNo = RequestVM.StockSysNo;
            //if (seleced.ReturnDateETA.HasValue)
            //batch.ReturnDate = seleced.ReturnDateETA;
            //batch.OperationQuantity =  seleced.LendQuantity.HasValue ? seleced.LendQuantity.Value : 0;
            //batch.PType = Models.Request.PageType.Lend;
            //batch.IsCreateMode = false;
            //batch.IsNotLend_Return = isNotReturn;

            IDialog dialog = CurrentWindow.ShowDialog("添加明细", batch, (obj, args) =>
            {
                ProductVMAndBillInfo productList = args.Data as ProductVMAndBillInfo;
                if (productList != null)
                {
                    productList.ProductVM.ForEach(p =>
                    {
                        ExperienceItemVM vm = null;

                        #region 只允许添加自己权限范围内可以访问商品
                        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;

                        int?returnQuantity = null;
                        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 (!batch.IsNotLend_Return)
                        {
                            returnQuantity = (from s in p.ProductBatchLst select s.ReturnQuantity).Sum();
                        }


                        if (!AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_SeniorPM_Query))
                        {
                            new InventoryQueryFacade(CurrentPage).CheckOperateRightForCurrentUser(queryFilter, (Innerogj, innerArgs) =>
                            {
                                if (!innerArgs.FaultsHandle())
                                {
                                    if (!innerArgs.Result)
                                    {
                                        CurrentWindow.Alert(string.Format(errorMessage, p.ProductID));
                                        return;
                                    }
                                    else
                                    {
                                        vm = new ExperienceItemVM
                                        {
                                            //ProductSysNo = p.SysNo,
                                            //LendQuantity = quantity,
                                            //ProductName = p.ProductName,
                                            //ProductID = p.ProductID,
                                            //PMUserName = p.PMUserName,
                                            //ReturnDateETA = productList.ReturnDate,
                                            //BatchDetailsInfoList = EntityConverter<BatchInfoVM, ProductBatchInfoVM>.Convert(p.ProductBatchLst),
                                            //IsHasBatch = p.IsHasBatch
                                        };

                                        RequestVM.ExperienceItemInfoList.Remove((ExperienceItemVM)this.dgProductList.SelectedItem);
                                        RequestVM.ExperienceItemInfoList.Add(vm);
                                        this.dgProductList.ItemsSource = RequestVM.ExperienceItemInfoList;
                                    }
                                }
                            });
                        }
                        else
                        {
                            vm = new ExperienceItemVM
                            {
                                //ProductSysNo = p.SysNo,
                                //LendQuantity = quantity,
                                //ProductName = p.ProductName,
                                //ProductID = p.ProductID,
                                //PMUserName = p.PMUserName,
                                //ReturnDateETA = productList.ReturnDate,
                                //BatchDetailsInfoList = EntityConverter<BatchInfoVM, ProductBatchInfoVM>.Convert(p.ProductBatchLst),
                                //IsHasBatch = p.IsHasBatch
                            };

                            RequestVM.ExperienceItemInfoList.Remove((ExperienceItemVM)this.dgProductList.SelectedItem);
                            RequestVM.ExperienceItemInfoList.Add(vm);
                            this.dgProductList.ItemsSource = RequestVM.ExperienceItemInfoList;
                        }

                        #endregion
                    });
                }
            });

            batch.DialogHandler = dialog;
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, RoutedEventArgs e)
        {
            bool IsOk = true;

            if (null == this.CurrentWidnow)
            {
                return;
            }

            // UI Check
            if (!ValidationManager.Validate(this.basicInfo))
            {
                return;
            }

            // 已选择的批次
            this.selectedLst = new List <ProductBatchInfoVM>();
            if (this.IsNotLend_Return)
            {
                batches.ToList <ProductBatchInfoVM>().ForEach((p) =>
                {
                    if (p.Quantity != 0)
                    {
                        selectedLst.Add(p);
                    }
                });
            }
            else
            {
                batchVM.ToList <ProductBatchInfoVM>().ForEach((p) =>
                {
                    if (p.ReturnQuantity.HasValue && p.ReturnQuantity != 0)
                    {
                        selectedLst.Add(p);
                    }
                });
            }

            // 根据商品编号获取商品信息
            ProductQueryFacade facade = new ProductQueryFacade(CPApplication.Current.CurrentPage);
            PagingInfo         paging = new PagingInfo
            {
                PageIndex = 0,
                PageSize  = 1,
            };
            List <ProductVM> productLst = new List <ProductVM>();

            facade.QueryProduct(new ProductSimpleQueryVM {
                ProductSysNo = filterVM.ProductSysNo
            }, paging
                                , (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }

                productLst = DynamicConverter <ProductVM> .ConvertToVMList <List <ProductVM> >(args.Result.Rows);

                // 附加批次信息
                List <BatchInfoVM> batchList = EntityConverter <ProductBatchInfoVM, BatchInfoVM> .Convert(selectedLst);

                ProductVMAndBillInfo paramVM = new ProductVMAndBillInfo();
                paramVM.ProductVM            = productLst;

                if (paramVM.ProductVM.FirstOrDefault().IsHasBatch == 1)
                {
                    paramVM.ProductVM.FirstOrDefault().ProductBatchLst = batchList;
                    if (filterVM.ReturnDate.HasValue)
                    {
                        paramVM.ReturnDate = filterVM.ReturnDate;
                    }
                    // check batch info
                    IsOk = PreCheckHasBatch();
                }
                else if (paramVM.ProductVM.FirstOrDefault().IsHasBatch == 0)
                {
                    switch (this.PType)
                    {
                    case PageType.Lend:
                        paramVM.Quantity       = Convert.ToInt32(filterVM.LendNum);
                        paramVM.ReturnQuantity = Convert.ToInt32(filterVM.ReturnNum);
                        break;

                    case PageType.Adjust:
                        paramVM.Quantity = Convert.ToInt32(filterVM.AdjustNum);
                        break;

                    case PageType.Convert:
                        paramVM.Quantity = Convert.ToInt32(filterVM.ConvertNum);
                        break;
                    }
                    if (filterVM.ReturnDate.HasValue)
                    {
                        paramVM.ReturnDate = filterVM.ReturnDate;
                    }
                }

                if (!IsOk)
                {
                    return;
                }

                this.DialogHandler.ResultArgs.Data = paramVM;

                this.DialogHandler.ResultArgs.DialogResult = DialogResultType.OK;
                this.DialogHandler.Close();
            });
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (!PreCheckAddProduct(RequestVM))
            {
                return;
            }

            UCProductBatch batch = new UCProductBatch();

            batch.IsCreateMode     = true;
            batch.StockSysNo       = RequestVM.StockSysNo;
            batch.PType            = Models.Request.PageType.Lend;
            batch.IsNotLend_Return = true;

            IDialog dialog = Window.ShowDialog("添加明细", batch, (obj, args) =>
            {
                ProductVMAndBillInfo productList = args.Data as ProductVMAndBillInfo;
                if (productList != null)
                {
                    productList.ProductVM.ForEach(p =>
                    {
                        LendRequestItemVM vm = RequestItemList.FirstOrDefault(item =>
                        {
                            return(item.ProductSysNo == p.SysNo);
                        });
                        if (vm == null)
                        {
                            #region 只允许添加自己权限范围内可以访问商品
                            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;

                            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))
                            {
                                new InventoryQueryFacade(this).CheckOperateRightForCurrentUser(queryFilter, (Innerogj, innerArgs) =>
                                {
                                    if (!innerArgs.FaultsHandle())
                                    {
                                        if (!innerArgs.Result)
                                        {
                                            Window.Alert(string.Format(errorMessage, p.ProductID));
                                            return;
                                        }
                                        else
                                        {
                                            vm = new LendRequestItemVM
                                            {
                                                ProductSysNo         = p.SysNo,
                                                LendQuantity         = quantity,
                                                ProductName          = p.ProductName,
                                                ProductID            = p.ProductID,
                                                PMUserName           = p.PMUserName,
                                                ReturnDateETA        = productList.ReturnDate,
                                                BatchDetailsInfoList = EntityConverter <BatchInfoVM, ProductBatchInfoVM> .Convert(p.ProductBatchLst),
                                                IsHasBatch           = p.IsHasBatch
                                            };
                                            RequestItemList.Add(vm);
                                            ucLendProductList.dgProductList.ItemsSource = RequestItemList;
                                        }
                                    }
                                });
                            }
                            else
                            {
                                vm = new LendRequestItemVM
                                {
                                    ProductSysNo         = p.SysNo,
                                    LendQuantity         = quantity,
                                    ProductName          = p.ProductName,
                                    ProductID            = p.ProductID,
                                    PMUserName           = p.PMUserName,
                                    ReturnDateETA        = productList.ReturnDate,
                                    BatchDetailsInfoList = EntityConverter <BatchInfoVM, ProductBatchInfoVM> .Convert(p.ProductBatchLst),
                                    IsHasBatch           = p.IsHasBatch
                                };
                                RequestItemList.Add(vm);
                                ucLendProductList.dgProductList.ItemsSource = RequestItemList;
                            }

                            #endregion
                        }
                        else
                        {
                            Window.Alert(string.Format("已存在编号为{0}的商品.", p.SysNo));
                        }
                    });
                }
            });

            batch.DialogHandler = dialog;
        }
        private void hlbtnEdit_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton     btn      = sender as HyperlinkButton;
            AdjustRequestItemVM selected = btn.DataContext as AdjustRequestItemVM;
            AdjustRequestItemVM seleced  = RequestVM.AdjustItemInfoList.Where(p => p.ProductSysNo == selected.ProductSysNo).FirstOrDefault();

            UCProductBatch batch = new UCProductBatch(seleced.ProductSysNo.Value.ToString(), seleced.ProductID, seleced.HasBatchInfo, seleced.BatchDetailsInfoList);

            batch.IsCreateMode      = false;
            batch.StockSysNo        = RequestVM.StockSysNo;
            batch.ProductSysNo      = selected.ProductSysNo.Value.ToString();
            batch.ProductID         = selected.ProductID;
            batch.OperationQuantity = selected.AdjustQuantity;
            batch.IsNotLend_Return  = true;
            batch.PType             = Models.Request.PageType.Adjust;

            IDialog dialog = Window.ShowDialog("更新明细", batch, (obj, args) =>
            {
                ProductVMAndBillInfo productList = args.Data as ProductVMAndBillInfo;
                if (productList != null && productList.ProductVM != null)
                {
                    productList.ProductVM.ForEach(p =>
                    {
                        AdjustRequestItemVM vm = null;

                        #region 只允许添加自己权限范围内可以访问商品
                        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;

                        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))
                        {
                            new InventoryQueryFacade(this).CheckOperateRightForCurrentUser(queryFilter, (Innerogj, innerArgs) =>
                            {
                                if (!innerArgs.FaultsHandle())
                                {
                                    if (!innerArgs.Result)
                                    {
                                        Window.Alert(string.Format(errorMessage, p.ProductID));
                                        return;
                                    }
                                    else
                                    {
                                        vm = new AdjustRequestItemVM
                                        {
                                            ProductSysNo         = p.SysNo,
                                            AdjustQuantity       = quantity,
                                            AdjustCost           = p.UnitCost,
                                            ProductName          = p.ProductName,
                                            ProductID            = p.ProductID,
                                            BatchDetailsInfoList = EntityConverter <BatchInfoVM, ProductBatchInfoVM> .Convert(p.ProductBatchLst),
                                            IsHasBatch           = p.IsHasBatch,
                                            RequestStatus        = AdjustRequestStatus.Origin
                                        };

                                        RequestVM.AdjustItemInfoList.Remove((AdjustRequestItemVM)this.dgAdjustProduct.SelectedItem);
                                        RequestVM.AdjustItemInfoList.Add(vm);
                                        this.dgAdjustProduct.ItemsSource = RequestVM.AdjustItemInfoList;
                                    }
                                }
                            });
                        }
                        else
                        {
                            vm = new AdjustRequestItemVM
                            {
                                ProductSysNo         = p.SysNo,
                                AdjustQuantity       = quantity,
                                AdjustCost           = p.UnitCost,
                                ProductName          = p.ProductName,
                                ProductID            = p.ProductID,
                                BatchDetailsInfoList = EntityConverter <BatchInfoVM, ProductBatchInfoVM> .Convert(p.ProductBatchLst),
                                IsHasBatch           = p.IsHasBatch,
                                RequestStatus        = AdjustRequestStatus.Origin
                            };
                            RequestVM.AdjustItemInfoList.Remove((AdjustRequestItemVM)this.dgAdjustProduct.SelectedItem);
                            RequestVM.AdjustItemInfoList.Add(vm);
                            this.dgAdjustProduct.ItemsSource = RequestVM.AdjustItemInfoList;
                        }

                        #endregion
                    });
                }
            });

            batch.DialogHandler = dialog;
        }
Esempio n. 6
0
        private void hlbtnReturn_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton          btn        = sender as HyperlinkButton;
            List <LendRequestItemVM> itemSource = this.dgProductList.ItemsSource as List <LendRequestItemVM>;
            LendRequestItemVM        selected   = this.dgProductList.SelectedItem as LendRequestItemVM;

            LendRequestVM     RequestVM = this.DataContext as LendRequestVM;
            LendRequestItemVM seleced   = RequestVM.LendItemInfoList.Where(p => p.ProductSysNo == selected.ProductSysNo).FirstOrDefault();

            UCProductBatch batch = new UCProductBatch(seleced.ProductSysNo.Value.ToString(), seleced.ProductID, selected.HasBatchInfo, seleced.BatchDetailsInfoList);


            batch.StockSysNo = RequestVM.StockSysNo;
            if (seleced.ReturnDateETA.HasValue)
            {
                batch.ReturnDate = seleced.ReturnDateETA;
            }
            batch.PType            = Models.Request.PageType.Lend;
            batch.IsCreateMode     = false;
            batch.IsNotLend_Return = false;

            IDialog dialog = CurrentWindow.ShowDialog("添加明细", batch, (obj, args) =>
            {
                ProductVMAndBillInfo productList = args.Data as ProductVMAndBillInfo;
                if (productList != null)
                {
                    productList.ProductVM.ForEach(p =>
                    {
                        #region 只允许添加自己权限范围内可以访问商品
                        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;

                        int?returnQuantity = null;
                        Dictionary <string, int> batchReturns = new Dictionary <string, int>();
                        if (p.IsHasBatch == 1)
                        {
                            returnQuantity = (from s in p.ProductBatchLst select s.ReturnQuantity).Sum();
                            foreach (var item in p.ProductBatchLst)
                            {
                                if (item.ReturnQuantity > 0)
                                {
                                    batchReturns.Add(item.BatchNumber, item.ReturnQuantity);
                                }
                            }
                        }
                        else if (p.IsHasBatch == 0)
                        {
                            returnQuantity = productList.ReturnQuantity;
                        }

                        if (!AuthMgr.HasFunctionAbsolute(AuthKeyConst.IM_SeniorPM_Query))
                        {
                            new InventoryQueryFacade(CurrentPage).CheckOperateRightForCurrentUser(queryFilter, (Innerogj, innerArgs) =>
                            {
                                if (!innerArgs.FaultsHandle())
                                {
                                    if (!innerArgs.Result)
                                    {
                                        CurrentWindow.Alert(string.Format(errorMessage, p.ProductID));
                                        return;
                                    }
                                    else
                                    {
                                        RequestVM.LendItemInfoList.ForEach(t =>
                                        {
                                            if (t.ProductSysNo == selected.ProductSysNo)
                                            {
                                                if (p.IsHasBatch == 0)
                                                {
                                                    t.ToReturnQuantity = returnQuantity;
                                                }
                                                else if (p.IsHasBatch == 1)
                                                {
                                                    foreach (var item in batchReturns)
                                                    {
                                                        t.BatchDetailsInfoList.ForEach(b =>
                                                        {
                                                            if (b.BatchNumber.Equals(item.Key))
                                                            {
                                                                b.ReturnQuantity = item.Value;
                                                                // UI
                                                                if (t.ToReturnQuantity.HasValue)
                                                                {
                                                                    t.ToReturnQuantity = t.ToReturnQuantity.Value + item.Value;
                                                                }
                                                                else
                                                                {
                                                                    t.ToReturnQuantity = item.Value;
                                                                }
                                                            }
                                                        });
                                                    }
                                                }
                                            }
                                        });

                                        this.dgProductList.ItemsSource = RequestVM.LendItemInfoList;
                                    }
                                }
                            });
                        }
                        else
                        {
                            RequestVM.LendItemInfoList.ForEach(t =>
                            {
                                // clear toReturnQuantity
                                t.ToReturnQuantity = null;

                                if (t.ProductSysNo == selected.ProductSysNo)
                                {
                                    if (p.IsHasBatch == 0)
                                    {
                                        t.ToReturnQuantity = returnQuantity;
                                    }
                                    else if (p.IsHasBatch == 1)
                                    {
                                        foreach (var item in batchReturns)
                                        {
                                            t.BatchDetailsInfoList.ForEach(b =>
                                            {
                                                if (b.BatchNumber.Equals(item.Key))
                                                {
                                                    b.ReturnQuantity = item.Value;
                                                    // UI
                                                    if (t.ToReturnQuantity.HasValue)
                                                    {
                                                        t.ToReturnQuantity = t.ToReturnQuantity.Value + item.Value;
                                                    }
                                                    else
                                                    {
                                                        t.ToReturnQuantity = item.Value;
                                                    }
                                                }
                                            });
                                        }
                                    }
                                }
                            });

                            this.dgProductList.ItemsSource = RequestVM.LendItemInfoList;
                        }

                        #endregion
                    });
                }
            });

            batch.DialogHandler = dialog;
        }