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