Esempio n. 1
0
        public bool CancelPurchaseNotice(ORD_PurchaseNoticeParam param)
        {
            bool flag = true;

            try
            {
                ORD_PurchaseNoticeResult noticeResult = this.GetInfo(param);
                if (noticeResult != null)
                {
                    if (noticeResult.PurchaseQty > 0)
                    {
                        flag = false;
                        throw new WarnException("当前采购通知已存在关联的采购信息,不允许取消通知!");
                    }
                    this.DelInfo(param);//删除当前采购通知
                    //汇总采购通知所关联的销售明细下所有关联的有效的采购通知的数量
                    List <ORD_PurchaseNoticeResult> noticeList = this.GetList(new ORD_PurchaseNoticeParam()
                    {
                        SOLineGuid = noticeResult.SOLineGuid
                    });
                    int?noticeQty = 0;
                    if (noticeList != null && noticeList.Count > 0)
                    {
                        noticeQty = noticeList.Sum(a => a.NoticeQty);
                    }
                    ORD_SalesOrderLineBLL orderLineBLL = new ORD_SalesOrderLineBLL();
                    orderLineBLL.SessionInfo = this.SessionInfo;
                    ORD_SalesOrderLineResult orderLineResult = orderLineBLL.GetInfo(new ORD_SalesOrderLineParam()
                    {
                        SOLineGuid = noticeResult.SOLineGuid
                    });
                    orderLineResult.NotifyQty = noticeQty;
                    orderLineBLL.AddOrUpdate(orderLineResult);
                    ORD_SalesOrderBLL orderBLL = new ORD_SalesOrderBLL();
                    orderBLL.SessionInfo = this.SessionInfo;
                    orderBLL.UpdateStatus(new ORD_SalesOrderParam()
                    {
                        SOGuid = noticeResult.SOGuid
                    });                                                                              //更新销售明细的通知状态
                }
                else
                {
                    flag = false;
                    throw new WarnException("当前采购通知记录在系统中不存在!");
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }

            return(flag);
        }
Esempio n. 2
0
        public bool SubmitSalesReturnBill(ORD_SalesReturnParam param)
        {
            this.CheckSession();
            bool submitFlag = true;

            try
            {
                ORD_SalesReturnResult returnResult = this.GetInfo(param);

                if (returnResult != null)
                {
                    #region 判断是否可以提交

                    bool isAllowSubmit = true;

                    if (returnResult.ApproveStatus == "待审核")
                    {
                        isAllowSubmit = false;
                        throw new WarnException("销售退货单当前状态为:【已提交,待审核】,禁止重复提交!");
                    }
                    else if (returnResult.ApproveStatus == "审核完成")
                    {
                        isAllowSubmit = false;
                        throw new WarnException("销售退货单当前状态为:【审核完成】,撤单后才可以再次提交!");
                    }
                    if (isAllowSubmit)
                    {
                        returnResult.Status        = "Approve";
                        returnResult.ApproveStatus = "待审核";
                        WCFAddUpdateResult ret = this.AddOrUpdate(returnResult);
                        if (ret.KeyGuid.ToGuid() == Guid.Empty)
                        {
                            submitFlag = false;
                        }
                        else
                        {
                            #region 定义相关变量
                            ORD_SalesOrderBLL saleOrderBLL = new ORD_SalesOrderBLL();
                            saleOrderBLL.SessionInfo = this.SessionInfo;
                            ORD_SalesOrderLineBLL saleOrderLineBLL = new ORD_SalesOrderLineBLL();
                            saleOrderLineBLL.SessionInfo = this.SessionInfo;
                            STK_OutBLL outBLL = new STK_OutBLL();
                            outBLL.SessionInfo = this.SessionInfo;
                            STK_OutLineBLL outLineBLL = new STK_OutLineBLL();
                            outLineBLL.SessionInfo = this.SessionInfo;
                            ORD_SalesReturnLineBLL returnLineBLL = new ORD_SalesReturnLineBLL();
                            returnLineBLL.SessionInfo = this.SessionInfo;
                            Guid?[] SOLineGuids     = null;
                            Guid?[] StkOutLineGuids = null;
                            Guid?[] SRGuids         = null;
                            Guid?[] effSRGuids      = null;
                            Guid?[] SOGuids         = null;
                            List <STK_OutLineResult>         linkOutLineList       = new List <STK_OutLineResult>();
                            List <ORD_SalesOrderLineResult>  linkSaleOrderLineList = new List <ORD_SalesOrderLineResult>();
                            List <ORD_SalesReturnResult>     linkReturnList        = new List <ORD_SalesReturnResult>();
                            List <ORD_SalesReturnLineResult> linkReturnLineList    = new List <ORD_SalesReturnLineResult>();
                            List <ORD_SalesReturnLineResult> effReturnLineList     = new List <ORD_SalesReturnLineResult>();
                            #endregion
                            List <ORD_SalesReturnLineResult> salesReturnLineList = returnLineBLL.GetList(new ORD_SalesReturnLineParam()
                            {
                                SRGuid = returnResult.SRGuid
                            });

                            #region 更新出库明细的数量
                            //获取退货明细关联的出库明细ID集合
                            StkOutLineGuids = salesReturnLineList.Select(a => a.StkOutLineGuid).Distinct().ToArray();
                            if (StkOutLineGuids != null && StkOutLineGuids.Length > 0)
                            {
                                //退货明细关联的出库明细
                                linkOutLineList = outLineBLL.GetList(new STK_OutLineParam()
                                {
                                    StkOutLineGuids = StkOutLineGuids
                                });
                                //关联的出库明细所关联的退货明细
                                linkReturnLineList = returnLineBLL.GetList(new ORD_SalesReturnLineParam()
                                {
                                    StkOutLineGuids = StkOutLineGuids
                                });
                                SRGuids = linkReturnLineList.Select(a => a.SRGuid).Distinct().ToArray();
                                if (SRGuids != null && SRGuids.Length > 0)
                                {
                                    //关联的出库明细所关联的退货明细对应的退货主单
                                    linkReturnList = this.GetList(new ORD_SalesReturnParam()
                                    {
                                        SRGuids = SRGuids, StatusArr = new string[] { "Complete", "Approve" }
                                    });
                                    if (linkReturnList != null && linkReturnList.Count > 0)
                                    {
                                        effSRGuids        = linkReturnList.Select(a => (Guid?)a.SRGuid).Distinct().ToArray();
                                        effReturnLineList = linkReturnLineList.Where(a => effSRGuids.Contains(a.SRGuid)).ToList();
                                        foreach (STK_OutLineResult outLineResult in linkOutLineList)
                                        {
                                            int?qty = effReturnLineList.Where(a => a.StkOutLineGuid == outLineResult.StkOutLineGuid).Sum(a => a.Qty.ToInt32());
                                            outLineResult.ReturnOccQty = qty;
                                        }
                                    }
                                }
                                //更新退货明细关联的出库明细的退货数量
                                outLineBLL.UpdateOrInsertList(linkOutLineList);
                            }
                            #endregion

                            #region 更新销售明细的退货占有数量和销售主单的退货占有状态
                            //获取关联的销售明细ID集合
                            SOLineGuids           = salesReturnLineList.Select(a => a.SOLineGuid).Distinct().ToArray();
                            linkSaleOrderLineList = saleOrderLineBLL.GetList(new ORD_SalesOrderLineParam()
                            {
                                SOLineGuids = SOLineGuids, IsCancel = false
                            });
                            //获取关联的销售明细所关联的退货明细
                            linkReturnLineList = returnLineBLL.GetList(new ORD_SalesReturnLineParam()
                            {
                                SOLineGuids = SOLineGuids
                            });
                            SRGuids = linkReturnLineList.Select(a => a.SRGuid).Distinct().ToArray();
                            if (SRGuids != null && SRGuids.Length > 0)
                            {
                                //销售明细所关联的退货明细对应的退货主单
                                linkReturnList = this.GetList(new ORD_SalesReturnParam()
                                {
                                    SRGuids = SRGuids, StatusArr = new string[] { "Complete", "Approve" }
                                });
                                if (linkReturnList != null && linkReturnList.Count > 0)
                                {
                                    effSRGuids        = linkReturnList.Select(a => (Guid?)a.SRGuid).Distinct().ToArray();
                                    effReturnLineList = linkReturnLineList.Where(a => effSRGuids.Contains(a.SRGuid)).ToList();
                                    foreach (ORD_SalesOrderLineResult saleLineResult in linkSaleOrderLineList)
                                    {
                                        int?qty = effReturnLineList.Where(a => a.SOLineGuid == saleLineResult.SOLineGuid).Sum(a => a.Qty.ToInt32());
                                        saleLineResult.ReturnOccQty = qty;
                                    }
                                }
                            }
                            saleOrderLineBLL.UpdateOrInsertList(linkSaleOrderLineList);
                            SOGuids = linkSaleOrderLineList.Select(a => a.SOGuid).Distinct().ToArray();
                            foreach (Guid soguid in SOGuids)
                            {
                                saleOrderBLL.UpdateStatus(new ORD_SalesOrderParam()
                                {
                                    SOGuid = soguid
                                });
                            }

                            #endregion
                        }
                    }


                    #endregion
                }
                else
                {
                    throw new WarnException("要提交的销售退货单在系统中不存在!");
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(submitFlag);
        }
Esempio n. 3
0
        public PageList <ORD_PurchaseNoticeResult> GetPageList(ORD_PurchaseNoticeParam param)
        {
            PageList <ORD_PurchaseNoticeResult> ret = new PageList <ORD_PurchaseNoticeResult>();

            try
            {
                ORD_SalesOrderBLL orderBLL = new ORD_SalesOrderBLL();
                orderBLL.SessionInfo = this.SessionInfo;
                ORD_SalesOrderParam orderParam = new ORD_SalesOrderParam()
                {
                    BillNo    = param.SOBillNo,
                    SalerName = param.SalerName,
                    PageIndex = 1,
                    PageSize  = 5000
                };

                PageList <ORD_SalesOrderResult> orderList = orderBLL.GetPageList(orderParam);
                if (orderList.ResultList != null && orderList.ResultList.Count > 0)
                {
                    Guid?[] SOGuids = orderList.ResultList.Select(a => a.SOGuid).Distinct().ToArray();
                    ORD_SalesOrderLineBLL lineBLL = new ORD_SalesOrderLineBLL();
                    lineBLL.SessionInfo = this.SessionInfo;
                    ORD_SalesOrderLineParam lineParam = new ORD_SalesOrderLineParam()
                    {
                        Model      = param.Model,
                        SOLineCode = param.SOLineCode,
                        SOGuids    = SOGuids,
                        PageIndex  = 1,
                        PageSize   = 5000,
                        IsCancel   = false
                    };
                    PageList <ORD_SalesOrderLineResult> lineList = lineBLL.GetPageList(lineParam);
                    if (lineList.ResultList != null && lineList.ResultList.Count > 0)
                    {
                        Guid?[] SOLineGuIds = lineList.ResultList.Select(a => (Guid?)a.SOLineGuid).Distinct().ToArray();
                        param.SOLineGuids = SOLineGuIds;
                        ret = this.SelectList <ORD_PurchaseNoticeResult>(param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(50), new List <Field>()
                        {
                            Field.All
                        }, GetWhereClip(param), ORD_PurchaseNotice._.CreatedTime.Desc);
                        foreach (ORD_PurchaseNoticeResult noticeResult in ret.ResultList)
                        {
                            ORD_SalesOrderResult orderResult = orderList.ResultList.FirstOrDefault(a => a.SOGuid == noticeResult.SOGuid);
                            if (orderResult != null)
                            {
                                noticeResult.SOBillNo     = orderResult.BillNo;
                                noticeResult.SalerName    = orderResult.SalerName;
                                noticeResult.SaleCurrency = orderResult.Currency;
                            }
                            ORD_SalesOrderLineResult lineResult = lineList.ResultList.FirstOrDefault(a => a.SOLineGuid == noticeResult.SOLineGuid);
                            if (lineResult != null)
                            {
                                noticeResult.SOLineCode       = lineResult.SOLineCode;
                                noticeResult.SalePrice        = lineResult.UnitPrice;
                                noticeResult.Unit             = lineResult.Unit;
                                noticeResult.Model            = lineResult.Model;
                                noticeResult.Brand            = lineResult.Brand;
                                noticeResult.Batch            = lineResult.Batch;
                                noticeResult.Package          = lineResult.Package;
                                noticeResult.InvType          = lineResult.InvType;
                                noticeResult.NeedDeliveryDate = lineResult.NeedDeliveryDate;
                                noticeResult.SaleQty          = lineResult.Qty;
                            }
                            if (noticeResult.PurchaseQty.ToInt32() == 0)
                            {
                                noticeResult.PurStatus = "未采购";
                            }
                            else if (noticeResult.NoticeQty.ToInt32() <= noticeResult.PurchaseQty.ToInt32())
                            {
                                noticeResult.PurStatus = "采购完成";
                            }
                            else
                            {
                                noticeResult.PurStatus = "部分采购";
                            }
                        }
                    }
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        /// 批量修改和插入
        /// </summary>
        /// <param name="paramList"></param>
        /// <returns></returns>
        public WCFAddUpdateResult UpdateOrInsertList(List <ORD_PurchaseNoticeResult> list)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                #region 判断
                if (list.Count <= 0)
                {
                    throw new WarnException("没有需要操作的对象!");
                }
                #endregion
                foreach (ORD_PurchaseNoticeResult noticeResult in list)
                {
                    if (noticeResult.NoticeGuid.ToGuid() != Guid.Empty)
                    {
                        noticeResult.UpdatedEmpID   = this.SessionInfo.UserID;
                        noticeResult.UpdatedEmpName = this.SessionInfo.UserName;
                        noticeResult.UpdatedTime    = DateTime.Now;
                    }
                    else
                    {
                        noticeResult.NoticeGuid     = Guid.NewGuid();
                        noticeResult.CreatedEmpID   = this.SessionInfo.UserID;
                        noticeResult.CreatedEmpName = this.SessionInfo.UserName;
                        noticeResult.CreatedTime    = DateTime.Now;
                        noticeResult.IsDeleted      = false;
                    }
                }
                int affect = 0;
                this.BatchInsertOrUpdate <ORD_PurchaseNoticeResult>(list);
                affect = this.BatchExecute();

                #region 设置返回值
                ret.Key = affect;
                #endregion
                if (affect > 0)
                {
                    Guid?[] SOLineGuids = list.Where(a => a.SOLineGuid.ToGuid() != Guid.Empty).Select(a => a.SOLineGuid).Distinct().ToArray();
                    if (SOLineGuids.Length > 0)
                    {
                        List <ORD_PurchaseNoticeResult> noticeList = this.GetList(new ORD_PurchaseNoticeParam()
                        {
                            SOLineGuids = SOLineGuids
                        });

                        List <ORD_SalesOrderLineResult> lineResultList = new List <ORD_SalesOrderLineResult>();
                        ORD_SalesOrderLineResult        lineResult     = null;
                        foreach (Guid soLineGuid in SOLineGuids)
                        {
                            lineResult            = new ORD_SalesOrderLineResult();
                            lineResult.SOLineGuid = soLineGuid;
                            int Qty = noticeList.Where(a => a.SOLineGuid == soLineGuid).Sum(a => a.NoticeQty.ToInt32());
                            lineResult.NotifyQty = Qty;
                            lineResultList.Add(lineResult);
                        }
                        ORD_SalesOrderLineBLL lineBLL = new ORD_SalesOrderLineBLL();
                        lineBLL.SessionInfo = this.SessionInfo;
                        lineBLL.UpdateOrInsertList(lineResultList);//更新销售明细的通知数量
                        ORD_SalesOrderBLL orderBLL = new ORD_SalesOrderBLL();
                        orderBLL.UpdateStatus(new ORD_SalesOrderParam()
                        {
                            SOGuid = list[0].SOGuid
                        });                                                                        //更新销售明细的通知状态
                    }
                }
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }