Exemplo n.º 1
0
        public void CancelVerifyRequest(LendRequestVM requestVM, Action <LendRequestVM> callback)
        {
            string relativeUrl = "/InventoryService/LendRequest/CancelVerifyRequest";

            SetRequestUserInfo(requestVM, InventoryAdjustSourceAction.CancelAudit);
            UpdateRequestStatus(relativeUrl, requestVM, callback);
        }
Exemplo n.º 2
0
        public void CreateRequest(LendRequestVM requestVM, Action <LendRequestVM> callback)
        {
            string relativeUrl = "/InventoryService/LendRequest/CreateRequest";

            requestVM.CompanyCode = CPApplication.Current.CompanyCode;
            SetRequestUserInfo(requestVM, InventoryAdjustSourceAction.Create);

            LendRequestInfo msg = ConvertRequestVMToInfo(requestVM);

            restClient.Create <LendRequestInfo>(relativeUrl, msg, (obj, args) =>
            {
                if (!args.FaultsHandle())
                {
                    LendRequestVM vm = null;
                    if (args.Result != null)
                    {
                        vm = ConvertRequestInfoToVM(args.Result);
                    }
                    if (callback != null)
                    {
                        callback(vm);
                    }
                }
            });
        }
Exemplo n.º 3
0
        private LendRequestVM ConvertRequestInfoToVM(LendRequestInfo info)
        {
            LendRequestVM vm = info.Convert <LendRequestInfo, LendRequestVM>((i, v) =>
            {
                v.StockSysNo        = i.Stock == null ? null : i.Stock.SysNo;
                v.AuditUserSysNo    = i.AuditUser == null ? null : i.AuditUser.SysNo;
                v.CreateUserSysNo   = i.CreateUser == null ? null : i.CreateUser.SysNo;
                v.EditUserSysNo     = i.EditUser == null ? null : i.EditUser.SysNo;
                v.OutStockUserSysNo = i.OutStockUser == null ? null : i.OutStockUser.SysNo;
                v.LendUserSysNo     = i.LendUser == null ? null : i.LendUser.SysNo;
                v.ProductLineSysno  = i.ProductLineSysno == null ? null : i.ProductLineSysno;
            });

            if (info.LendItemInfoList != null)
            {
                info.LendItemInfoList.ForEach(p =>
                {
                    LendRequestItemVM item = vm.LendItemInfoList.FirstOrDefault(i => i.SysNo == p.SysNo);
                    if (p.LendProduct != null)
                    {
                        item.ProductSysNo   = p.LendProduct.SysNo;
                        item.ProductName    = p.LendProduct.ProductBasicInfo.ProductTitle.Content;
                        item.ProductID      = p.LendProduct.ProductID;
                        item.PMUserSysNo    = p.LendProduct.ProductBasicInfo.ProductManager.UserInfo.SysNo;
                        item.PMUserName     = p.LendProduct.ProductBasicInfo.ProductManager.UserInfo.UserDisplayName;
                        item.ReturnDateETA  = p.ExpectReturnDate;
                        item.ReturnQuantity = p.ReturnQuantity;
                    }
                });
            }
            return(vm);
        }
Exemplo n.º 4
0
        public void OutStockRequest(LendRequestVM requestVM, Action <LendRequestVM> callback)
        {
            string relativeUrl = "/InventoryService/LendRequest/OutStockRequest";

            SetRequestUserInfo(requestVM, InventoryAdjustSourceAction.OutStock);
            UpdateRequestStatus(relativeUrl, requestVM, callback);
        }
Exemplo n.º 5
0
        private void hlbtnViewReturnLog_Click(object sender, RoutedEventArgs e)
        {
            LendRequestVM     requestVM  = this.DataContext as LendRequestVM;
            LendRequestItemVM returnItem = this.dgProductList.SelectedItem as LendRequestItemVM;
            int productSysNo             = (int)returnItem.ProductSysNo;

            LendRequestItemVM         seleced       = requestVM.LendItemInfoList.Where(p => p.ProductSysNo == returnItem.ProductSysNo).FirstOrDefault();
            List <ProductBatchInfoVM> bathcInfoList = seleced.BatchDetailsInfoList;

            List <LendRequestReturnItemInfo> returnItemLog = new List <LendRequestReturnItemInfo>();

            requestVM.ReturnItemInfoList.ForEach(i =>
            {
                if (i.ReturnProduct.SysNo == productSysNo)
                {
                    LendRequestReturnItemInfo ri = new LendRequestReturnItemInfo
                    {
                        ReturnDate     = i.ReturnDate,
                        ReturnQuantity = i.ReturnQuantity
                    };
                    returnItemLog.Add(ri);
                }
            });
            LendRequestReturnItem ucReturnItemLog = new LendRequestReturnItem {
                ReturnItemList = returnItemLog
            };

            CurrentWindow.ShowDialog("归还", ucReturnItemLog);
        }
Exemplo n.º 6
0
        private void hlbtnDelete_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton   btn       = sender as HyperlinkButton;
            LendRequestItemVM vm        = btn.DataContext as LendRequestItemVM;
            LendRequestVM     RequestVM = this.DataContext as LendRequestVM;

            RequestVM.LendItemInfoList.Remove(vm);
            this.dgProductList.ItemsSource = RequestVM.LendItemInfoList;
        }
Exemplo n.º 7
0
 private void btnReset_Click(object sender, RoutedEventArgs e)
 {
     if (RequestVM.SysNo != null)
     {
         OnPageLoad(sender, e);
     }
     else
     {
         RequestVM = new LendRequestVM();
     }
 }
Exemplo n.º 8
0
        private bool PreCheckAddProduct(LendRequestVM request)
        {
            bool result = true;

            if (!request.StockSysNo.HasValue)
            {
                result = false;
                Window.Alert("请选择先仓库!");
            }

            return(result);
        }
Exemplo n.º 9
0
        private LendRequestInfo ConvertRequestVMToInfo(LendRequestVM vm)
        {
            LendRequestInfo info = vm.ConvertVM <LendRequestVM, LendRequestInfo>((v, i) =>
            {
                i.Stock = new StockInfo {
                    SysNo = v.StockSysNo
                };
                i.CreateUser = new BizEntity.Common.UserInfo {
                    SysNo = v.CreateUserSysNo
                };
                i.EditUser = new BizEntity.Common.UserInfo {
                    SysNo = v.EditUserSysNo
                };
                i.AuditUser = new BizEntity.Common.UserInfo {
                    SysNo = v.AuditUserSysNo
                };
                i.OutStockUser = new BizEntity.Common.UserInfo {
                    SysNo = v.OutStockUserSysNo
                };
                i.LendUser = new BizEntity.Common.UserInfo {
                    SysNo = v.LendUserSysNo
                };
                i.ProductLineSysno = v.ProductLineSysno;
            });

            info.LendItemInfoList = new List <LendRequestItemInfo>();
            vm.LendItemInfoList.ForEach(item =>
            {
                LendRequestItemInfo itemInfo = item.ConvertVM <LendRequestItemVM, LendRequestItemInfo>();
                if (itemInfo.BatchDetailsInfoList != null)
                {
                    itemInfo.BatchDetailsInfoList.ForEach(p =>
                    {
                        var re = item.BatchDetailsInfoList.FirstOrDefault(k => k.ProductSysNo == p.ProductSysNo && k.BatchNumber.Equals(p.BatchNumber));
                        if (re != null)
                        {
                            p.ReturnQty = re.ReturnQuantity ?? 0;
                        }
                    });
                }
                itemInfo.LendProduct = new BizEntity.IM.ProductInfo {
                    SysNo = item.ProductSysNo.Value
                };
                if (item.ReturnDateETA.HasValue)
                {
                    itemInfo.ExpectReturnDate = (DateTime)item.ReturnDateETA;
                }
                info.LendItemInfoList.Add(itemInfo);
            });
            return(info);
        }
Exemplo n.º 10
0
 public override void OnPageLoad(object sender, EventArgs e)
 {
     MaintainFacade = new LendRequestMaintainFacade(this);
     base.OnPageLoad(sender, e); if (RequestSysNo.HasValue)
     {
         MaintainFacade.GetLendRequestInfoBySysNo(RequestSysNo.Value, (vm) =>
         {
             if (vm == null || vm.CompanyCode == null || vm.CompanyCode.Trim() != CPApplication.Current.CompanyCode)
             {
                 vm = null;
                 Window.Alert("单据不存在,此单据可能已经被删除或请传入其它的单据编号重试。");
             }
             RequestVM = vm;
         });
     }
     else
     {
         RequestVM = new LendRequestVM();
     }
 }
Exemplo n.º 11
0
        public void GetLendRequestInfoBySysNo(int sysNo, Action <LendRequestVM> callback)
        {
            string relativeUrl = string.Format("/InventoryService/LendRequest/Load/{0}", sysNo);

            restClient.Query <LendRequestInfo>(relativeUrl, (obj, args) =>
            {
                if (!args.FaultsHandle())
                {
                    LendRequestVM vm = null;
                    if (args.Result != null)
                    {
                        vm = ConvertRequestInfoToVM(args.Result);
                    }
                    if (callback != null)
                    {
                        callback(vm);
                    }
                }
            });
        }
Exemplo n.º 12
0
        private void UpdateRequestStatus(string relativeUrl, LendRequestVM requestVM, Action <LendRequestVM> callback)
        {
            LendRequestInfo msg = ConvertRequestVMToInfo(requestVM);

            restClient.Update <LendRequestInfo>(relativeUrl, msg, (obj, args) =>
            {
                if (!args.FaultsHandle())
                {
                    LendRequestVM vm = null;
                    if (args.Result != null)
                    {
                        vm = ConvertRequestInfoToVM(args.Result);
                    }
                    if (callback != null)
                    {
                        callback(vm);
                    }
                }
            });
        }
Exemplo n.º 13
0
        private void SetRequestUserInfo(LendRequestVM requestVM, InventoryAdjustSourceAction action)
        {
            int?currentUserSysNo = CPApplication.Current.LoginUser.UserSysNo;

            if (action == InventoryAdjustSourceAction.Create)
            {
                requestVM.CreateUserSysNo = currentUserSysNo;
            }
            else if (action == InventoryAdjustSourceAction.Audit || action == InventoryAdjustSourceAction.CancelAudit)
            {
                requestVM.AuditUserSysNo = currentUserSysNo;
            }
            else if (action == InventoryAdjustSourceAction.OutStock)
            {
                requestVM.OutStockUserSysNo = currentUserSysNo;
            }
            else
            {
                requestVM.EditUserSysNo = currentUserSysNo;
            }
        }
Exemplo n.º 14
0
        public void ReturnRequest(LendRequestVM requestVM, Action <LendRequestVM> callback)
        {
            string relativeUrl = "/InventoryService/LendRequest/ReturnLendItem";

            SetRequestUserInfo(requestVM, InventoryAdjustSourceAction.Return);
            LendRequestInfo msg = ConvertRequestVMToInfo(requestVM);

            restClient.Update <LendRequestInfo>(relativeUrl, msg, (obj, args) =>
            {
                if (!args.FaultsHandle())
                {
                    LendRequestVM vm = null;
                    if (args.Result != null)
                    {
                        vm = ConvertRequestInfoToVM(args.Result);
                    }
                    if (callback != null)
                    {
                        callback(vm);
                    }
                }
            });
        }
Exemplo n.º 15
0
        private void ShowEditModeDialog(object sender, RoutedEventArgs e, string title, bool isNotReturn)
        {
            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.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 =>
                    {
                        LendRequestItemVM 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 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
                                        };

                                        RequestVM.LendItemInfoList.Remove((LendRequestItemVM)this.dgProductList.SelectedItem);
                                        RequestVM.LendItemInfoList.Add(vm);
                                        this.dgProductList.ItemsSource = RequestVM.LendItemInfoList;
                                    }
                                }
                            });
                        }
                        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
                            };

                            RequestVM.LendItemInfoList.Remove((LendRequestItemVM)this.dgProductList.SelectedItem);
                            RequestVM.LendItemInfoList.Add(vm);
                            this.dgProductList.ItemsSource = RequestVM.LendItemInfoList;
                        }

                        #endregion
                    });
                }
            });

            batch.DialogHandler = dialog;
        }
Exemplo n.º 16
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;
        }