/// <summary>
        /// 中止变价单
        /// </summary>
        /// <param name="IsJobRun">true:自动中止;false:人工中止</param>
        public void AbortedPriceChange(PriceChangeMaster mst, bool IsJobRun)
        {
            if (mst != null)
            {
                PreCheckAborted(mst);

                if ((DateTime.Now > mst.EndDate && IsJobRun) || !IsJobRun)
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        if (mst.PriceType == RequestPriceType.PurchasePrice)
                        {
                            UpdatePriceWhenPurchaseType(mst, false);
                        }
                        else if (mst.PriceType == RequestPriceType.SalePrice)
                        {
                            UpdatePriceWhenSaleType(mst, false);
                        }

                        // update status = aborted;
                        UpdatePriceChangeAborted(mst);

                        CreateOperationLog(mst, "终止", BizLogType.PriceChange_Run);

                        ts.Complete();
                    }
                }
            }
        }
        public int ClonePriceChange(PriceChangeMaster item)
        {
            PreCheckSaveOrUpdate(item);

            using (TransactionScope ts = new TransactionScope())
            {
                int masterSysNo = ObjectFactory <IPriceChangeDA> .Instance.SavePriceChangeMaster(item);

                if (item.ItemList != null && item.ItemList.Count > 0)
                {
                    item.ItemList.ForEach(p =>
                    {
                        p.MasterSysNo = masterSysNo;
                        SavePriceChangeItem(p);
                    }
                                          );
                }

                #region write log

                item.SysNo = masterSysNo;
                CreateOperationLog(item, "复制", BizLogType.PriceChange_Clone);

                #endregion

                ts.Complete();

                return(masterSysNo);
            }
        }
        private void PreCheckAudit(PriceChangeMaster item)
        {
            PriceChangeMaster info = GetPriceChangeBySysNo(item.SysNo);

            if (string.IsNullOrEmpty(item.AuditMemo))
            {
                //throw new BizException(string.Format("审核时需要输入审核备注"));
                ThrowBizException("PriceChange_AuditMemoNotNullWhenAudit");
            }

            if (info.Status != RequestPriceStatus.Auditting)
            {
                //throw new BizException("只有待审核状态才能进行审核操作!");
                ThrowBizException("PriceChange_JustWaitAuditCanAudit");
            }

            //审核的时候,去除校验新单中商品存在有效变价单据的逻辑,执行新单据的变价规则
            //string expMsg = string.Empty;

            //if (info.ItemList != null && info.ItemList.Count > 0)
            //{
            //    info.ItemList.ForEach(p =>
            //    {
            //        if (IsExistsAuditedOrRuningProduct(p))
            //        {
            //            expMsg += string.Format("状态为待启动或运行中的变价单存在商品【{0}】!\r\n", p.ProductID);
            //        }
            //    });
            //}

            //if (!string.IsNullOrEmpty(expMsg))
            //{
            //    throw new BizException(expMsg);
            //}
        }
Exemple #4
0
        public string ClonePriceChange(List <int> sysNos)
        {
            List <BatchActionItem <int> > items = sysNos.Select(p => new BatchActionItem <int>
            {
                ID   = p.ToString(),
                Data = p
            }).ToList();

            var bp = ObjectFactory <PriceChangeProcessor> .Instance;

            BatchActionResult <int> resutl = BatchActionManager.DoBatchAction <int>(items, (sysno) =>
            {
                PriceChangeMaster item = GetPriceChangeBySysNo(sysno);

                if (item == null)
                {
                    //throw new BizException(string.Format("没有找到记录编号为{0}的记录", sysno));
                    throw new BizException(string.Format(ResouceManager.GetMessageString("Invoice.PriceChange", "PriceChange_NotFounTheRecord"), sysno));
                }

                if (item.Status != RequestPriceStatus.Finished && item.Status != RequestPriceStatus.Aborted)
                {
                    //throw new BizException(string.Format("记录编号为{0}的记录的状态不是终止状态或已完成状态", sysno));
                    throw new BizException(string.Format(ResouceManager.GetMessageString("Invoice.PriceChange", "PriceChange_NotStopOrFinshedStatus"), sysno));
                }

                item.Status = RequestPriceStatus.Auditting;
                bp.ClonePriceChange(item);
            });

            return(resutl.PromptMessage);
        }
        public void UpdatePriceChange(PriceChangeMaster item)
        {
            PreCheckSaveOrUpdate(item);

            using (TransactionScope ts = new TransactionScope())
            {
                ObjectFactory <IPriceChangeDA> .Instance.UpdatePriceChangeMaster(item);

                ObjectFactory <IPriceChangeDA> .Instance.DeletePriceChangeItemByMasterSysNo(item.SysNo);

                if (item.ItemList != null && item.ItemList.Count > 0)
                {
                    item.ItemList.ForEach(p =>
                    {
                        p.MasterSysNo = item.SysNo;
                        SavePriceChangeItem(p);
                    }
                                          );
                }

                #region write log

                CreateOperationLog(item, "更新", BizLogType.PriceChange_Update);

                #endregion

                ts.Complete();
            }
        }
 private void PreCheckAborted(PriceChangeMaster mst)
 {
     if (mst.Status != RequestPriceStatus.Running)
     {
         //throw new BizException(string.Format("单据编号:【{0}】的变价单为{1}状态,只有运行中的状态才可以中止!", mst.SysNo, mst.Status.ToDisplayText()));
         ThrowBizException("PriceChange_JustWaitStartCanStop", mst.SysNo, mst.Status.ToDisplayText());
     }
 }
Exemple #7
0
        public void UpdatePriceChangeStatus(PriceChangeMaster item)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("PriceChange_ChangePriceChangeStatus");

            cmd.SetParameterValue <PriceChangeMaster>(item);

            cmd.ExecuteNonQuery();
        }
Exemple #8
0
        public int SavePriceChangeMaster(PriceChangeMaster item)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("PriceChange_SavePriceChangeMaster");

            cmd.SetParameterValue <PriceChangeMaster>(item);

            return(cmd.ExecuteScalar <int>());
        }
 private void PrecheckRun(PriceChangeMaster mst)
 {
     if (mst.Status != RequestPriceStatus.Audited)
     {
         //throw new BizException(string.Format("单据编号:【{0}】的变价单为{1}状态,只有待启动状态才允许启动!", mst.SysNo, mst.Status.ToDisplayText()));
         ThrowBizException("PriceChange_JustWaitStartCanStart", mst.SysNo, mst.Status.ToDisplayText());
     }
 }
Exemple #10
0
        public PriceChangeMaster UpdatePriceChangeMaster(PriceChangeMaster item)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("PriceChange_UpdatePriceChangeMaster");

            cmd.SetParameterValue <PriceChangeMaster>(item);

            cmd.ExecuteNonQuery();

            return(item);
        }
        public void AuditPriceChange(PriceChangeMaster item)
        {
            PreCheckAudit(item);

            item.Status = RequestPriceStatus.Audited;

            UpdatePriceChangeStatus(item);

            #region write log

            CreateOperationLog(item, item.Status.ToDisplayText(), BizLogType.PriceChange_Audit);

            #endregion
        }
Exemple #12
0
        public void SavePriceChange(PriceChangeVM vm, Action<int> callback)
        {
            PriceChangeMaster entity = vm.ConvertVM<PriceChangeVM, PriceChangeMaster>();

            string relativeUrl = "/InvoiceService/Invoice/SavePriceChange";

            restClient.Create<int>(relativeUrl, entity, (obj, args) => 
            {
                if (args.FaultsHandle())
                    return;

                callback(args.Result);
            });
        }
Exemple #13
0
        public void UpdatePriceChange(PriceChangeVM vm, Action<PriceChangeVM> callback)
        {
            PriceChangeMaster entity = vm.ConvertVM<PriceChangeVM, PriceChangeMaster>();
   
            string relativeUrl = "/InvoiceService/Invoice/UpdatePriceChange";

            restClient.Create<PriceChangeMaster>(relativeUrl, entity, (obj, args) =>
            {
                if (args.FaultsHandle())
                    return;

                PriceChangeVM temp = args.Result.Convert<PriceChangeMaster, PriceChangeVM>();

                callback(temp);
            });
        }
 private void PreCheckSaveOrUpdate(PriceChangeMaster item)
 {
     item.ItemList.ForEach(p =>
     {
         if (item.PriceType == RequestPriceType.PurchasePrice && p.NewInstockPrice <= 0)
         {
             //throw new BizException(string.Format("变价类型为采购价时,采购新价必填且不为0!"));
             ThrowBizException("PriceChange_PurchasePriceNotNullWhenPurchase");
         }
         else if (item.PriceType == RequestPriceType.SalePrice && (p.NewShowPrice <= 0 && p.NewPrice <= 0))
         {
             //throw new BizException("变价类型为销售价时,市场价或销售价其中之一必填且不为0!");
             ThrowBizException("PriceChange_MarketPriceOrCurrentPriceNotNullWhenCurrent");
         }
     });
 }
        public void VoidPriceChange(PriceChangeMaster item)
        {
            if (item.Status != RequestPriceStatus.Auditting)
            {
                //throw new BizException("只有待审核状态才能进行作废操作!");
                ThrowBizException("PriceChange_JustWaitAuditCanVoid");
            }

            item.Status = RequestPriceStatus.Void;

            UpdatePriceChangeStatus(item);

            #region write log

            CreateOperationLog(item, item.Status.ToDisplayText(), BizLogType.PriceChange_Void);

            #endregion
        }
 /// <summary>
 /// 销售变价时更新价格
 /// </summary>
 /// <param name="mst">变价单</param>
 /// <param name="IsRun">true:启动操作;false:中止操作</param>
 private void UpdatePriceWhenSaleType(PriceChangeMaster mst, bool IsRun)
 {
     if (mst.ItemList != null && mst.ItemList.Count > 0)
     {
         mst.ItemList.ForEach(p =>
         {
             // 更新了市场价格
             if (p.NewShowPrice != decimal.Zero)
             {
                 if (IsRun)
                 {
                     // 启动操作更新市场价格
                     UpdateProductBasicPrice(p.ProductsysNo, p.NewShowPrice);
                 }
                 else
                 {
                     if (p.Status == PriceChangeItemStatus.Enable)
                     {
                         // 中止操作还原市场价格
                         UpdateProductBasicPrice(p.ProductsysNo, p.OldShowPrice);
                     }
                 }
             }
             // 更新了销售价格
             if (p.NewPrice != decimal.Zero)
             {
                 if (IsRun)
                 {
                     // 启动操作更新销售价格
                     UpdateProductCurrentPrice(p.ProductsysNo, p.NewPrice);
                 }
                 else
                 {
                     if (p.Status == PriceChangeItemStatus.Enable)
                     {
                         // 中止操作还原销售价格
                         UpdateProductCurrentPrice(p.ProductsysNo, p.OldPrice);
                     }
                 }
             }
         });
     }
 }
Exemple #17
0
        public PriceChangeMaster GetPriceChangeBySysNo(int sysno)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("PriceChange_GetByPriceChangeBySysNo");

            cmd.SetParameterValue("@SysNo", sysno);

            DataSet           ds     = cmd.ExecuteDataSet();
            PriceChangeMaster master = new PriceChangeMaster();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                master = DataMapper.GetEntity <PriceChangeMaster>(row);

                master.ItemList = new List <PriceChangeItem>();

                master.ItemList = DataMapper.GetEntityList <PriceChangeItem, List <PriceChangeItem> >(ds.Tables[1].Rows);
            }

            return(master);
        }
 /// <summary>
 /// 采购变价时更新价格
 /// </summary>
 /// <param name="mst">变价单</param>
 /// <param name="IsRun">true:启动操作;false:中止操作</param>
 private void UpdatePriceWhenPurchaseType(PriceChangeMaster mst, bool IsRun)
 {
     if (mst.ItemList != null && mst.ItemList.Count > 0)
     {
         mst.ItemList.ForEach(p =>
         {
             if (IsRun)
             {
                 // 启动操作更新采购价格
                 UpdateProductVirtualPrice(p.ProductsysNo, p.OldInstockPrice, p.NewInstockPrice);
             }
             else
             {
                 if (p.Status == PriceChangeItemStatus.Enable)
                 {
                     // 中止操作还原采购价格
                     UpdateProductVirtualPrice(p.ProductsysNo, p.NewInstockPrice, p.OldInstockPrice);
                 }
             }
         });
     }
 }
        /// <summary>
        /// 启动变价单
        /// </summary>
        /// <param name="IsJobRun">true:自动中止;false:人工中止</param>
        public void RunPriceChange(PriceChangeMaster mst, bool IsJobRun)
        {
            if (mst != null)
            {
                PrecheckRun(mst);

                using (TransactionScope ts = new TransactionScope())
                {
                    if ((DateTime.Now > mst.BeginDate && DateTime.Now < mst.EndDate && IsJobRun) ||
                        !IsJobRun)
                    {
                        if (mst.PriceType == RequestPriceType.PurchasePrice)
                        {
                            UpdatePriceWhenPurchaseType(mst, true);
                        }
                        else if (mst.PriceType == RequestPriceType.SalePrice)
                        {
                            UpdatePriceWhenSaleType(mst, true);
                        }


                        //新单压就单,使旧单的状态为不可用状态
                        foreach (var sub in mst.ItemList)
                        {
                            ObjectFactory <IPriceChangeDA> .Instance.DisableOldChangeItemStatusByNewItemSysNo(sub.SysNo);
                        }

                        // update realbegindate;
                        UpdateRealBeginDate(mst.SysNo);
                        CreateOperationLog(mst, "启动", BizLogType.PriceChange_Run);

                        ts.Complete();
                    }
                }
            }
        }
 public void UpdatePriceChangeStatus(PriceChangeMaster item)
 {
     ObjectFactory <IPriceChangeDA> .Instance.UpdatePriceChangeStatus(item);
 }
 private void CreateOperationLog(PriceChangeMaster item, string action, BizLogType logType)
 {
     ExternalDomainBroker.CreateOperationLog(string.Format("用户:\"{0}\"{1}了编号为\"{2}\"类型为\"{3}\"的变价单", (string.IsNullOrEmpty(ServiceContext.Current.UserDisplayName) ? "Job" : ServiceContext.Current.UserDisplayName), action, item.SysNo, item.PriceType.ToDisplayText())
                                             , logType, item.SysNo, "8601");
 }
 public PriceChangeMaster UpdatePriceChange(PriceChangeMaster item)
 {
     return(ObjectFactory <PriceChangeAppService> .Instance.UpdatePriceChange(item));
 }
 public int SavePriceChange(PriceChangeMaster items)
 {
     return(ObjectFactory <PriceChangeAppService> .Instance.SavePriceChange(items));
 }
        public void BuildData(System.Collections.Specialized.NameValueCollection requestPostData, out KeyValueVariables variables, out KeyTableVariables tableVariables)
        {
            variables      = new KeyValueVariables();
            tableVariables = new KeyTableVariables();
            string sysNo = requestPostData["SysNo"];

            if (sysNo != null && sysNo.Trim() != String.Empty)
            {
                sysNo = System.Web.HttpUtility.UrlDecode(sysNo);
                int requestSysNo = int.TryParse(sysNo, out requestSysNo) ? requestSysNo : int.MinValue;

                if (requestSysNo > int.MinValue)
                {
                    PriceChangeMaster requestInfo = ObjectFactory <PriceChangeAppService> .Instance.GetPriceChangeBySysNo(requestSysNo);

                    if (requestInfo.PriceType == BizEntity.Invoice.RequestPriceType.SalePrice)
                    {
                        variables.Add("PrintTitle", "销售变价单");
                    }
                    else if (requestInfo.PriceType == BizEntity.Invoice.RequestPriceType.PurchasePrice)
                    {
                        variables.Add("PrintTitle", "采购变价单");
                    }
                    variables.Add("SysNo", requestInfo.SysNo.ToString().Trim().PadLeft(8, '0'));
                    variables.Add("RealBeginDate", requestInfo.RealBeginDate.HasValue ? requestInfo.RealBeginDate.Value.ToLongDateString().Trim() : string.Empty);
                    variables.Add("BeginDate", requestInfo.BeginDate.HasValue ? requestInfo.BeginDate.Value.ToLongDateString().Trim() : string.Empty);
                    variables.Add("EndDate", requestInfo.EndDate.HasValue ? requestInfo.EndDate.Value.ToLongDateString().Trim() : string.Empty);
                    variables.Add("BillInDate", DateTime.Now.ToLongDateString());
                    variables.Add("IsPurchasePrice", requestInfo.PriceType == BizEntity.Invoice.RequestPriceType.PurchasePrice);
                    variables.Add("IsSalePrice", requestInfo.PriceType == BizEntity.Invoice.RequestPriceType.SalePrice);

                    DataTable dtProduct = new DataTable();
                    dtProduct.Columns.AddRange(new System.Data.DataColumn[]
                    {
                        new DataColumn("ProductID"),
                        new DataColumn("ProductName"),
                        new DataColumn("OldPrice"),
                        new DataColumn("NewPrice"),
                        new DataColumn("DiffPrice"),

                        new DataColumn("OldShowPrice"),
                        new DataColumn("NewShowPrice"),

                        new DataColumn("OldInstockPrice"),
                        new DataColumn("NewInstockPrice"),
                        new DataColumn("DiffInstockPrice"),

                        new DataColumn("IsPurchasePrice"),
                        new DataColumn("IsSalePrice")
                    });

                    if (requestInfo.ItemList != null)
                    {
                        requestInfo.ItemList.ForEach(p =>
                        {
                            DataRow drProduct        = dtProduct.NewRow();
                            drProduct["ProductID"]   = p.ProductID;
                            drProduct["ProductName"] = p.ProductName.Trim();
                            drProduct["OldPrice"]    = p.OldPrice.ToString("N2");
                            drProduct["NewPrice"]    = p.NewPrice == 0 ? "---" : p.NewPrice.ToString("N2");
                            drProduct["DiffPrice"]   = (p.NewPrice - p.OldPrice).ToString("N2");

                            drProduct["OldShowPrice"]     = p.OldShowPrice.ToString("N2");
                            drProduct["NewShowPrice"]     = p.NewShowPrice == 0 ? "---" : p.NewShowPrice.ToString("N2");
                            drProduct["OldInstockPrice"]  = p.OldInstockPrice.ToString("N2");
                            drProduct["NewInstockPrice"]  = p.NewInstockPrice == 0 ? "---" : p.NewInstockPrice.ToString("N2");
                            drProduct["DiffInstockPrice"] = (p.NewInstockPrice - p.OldInstockPrice).ToString("N2");

                            drProduct["IsPurchasePrice"] = requestInfo.PriceType == BizEntity.Invoice.RequestPriceType.PurchasePrice;
                            drProduct["IsSalePrice"]     = requestInfo.PriceType == BizEntity.Invoice.RequestPriceType.SalePrice;

                            dtProduct.Rows.Add(drProduct);
                        });
                    }

                    tableVariables.Add("ProductList", dtProduct);
                }
            }
        }
Exemple #25
0
        public PriceChangeMaster UpdatePriceChange(PriceChangeMaster newItem)
        {
            ObjectFactory <PriceChangeProcessor> .Instance.UpdatePriceChange(newItem);

            return(GetPriceChangeBySysNo(newItem.SysNo));
        }
Exemple #26
0
 public int SavePriceChange(PriceChangeMaster item)
 {
     return(ObjectFactory <PriceChangeProcessor> .Instance.SavePriceChange(item));
 }
        /// <summary>
        /// 中止变价单
        /// </summary>
        /// <param name="master"></param>
        public virtual void UpdatePriceChangeAborted(PriceChangeMaster master)
        {
            master.Status = RequestPriceStatus.Aborted;

            UpdatePriceChangeStatus(master);
        }