Пример #1
0
        private TblUserJxsStockhis GetOutInitUserJxsStockhis()
        {
            TblUserJxsStockhis his = new TblUserJxsStockhis();

            //出货历史
            his.Batchnum    = this.BusinessId;
            his.Jsxid       = this.JsxParent != null ? this.JsxParent.Infoid : -1;
            his.Typeid      = this.JsxParent != null ? this.JsxParent.Typeid : -1;
            his.Amountdos   = this.RechargeCodeRuleInfo.DosPrice;
            his.Transferids = "无";
            his.Createtime  = DateTime.Now;
            his.Rate        = this.IsOpenCzs ? 1 : this.RechargeCodeRuleInfo.Rate;
            his.Pcnnodecode = this.IsPromotion ? this.Nodecode : "";
            his.Status      = this.IsPromotion ? 1 : 0;
            his.Amountdp    = 0;
            his.Remarks     = this.IsOpenCzs ? "代开充值商" : "";
            return(his);
        }
Пример #2
0
        /// <summary>
        /// 进出货
        /// </summary>
        /// <returns></returns>
        private bool StockExchangeCode()
        {
            this.BusinessId = db.GetPrimaryKeyValue <TblUserJxsStockhis>();
            TblUserJxsStockhis his = new TblUserJxsStockhis();

            //进货历史
            if (RechargeCodeRuleInfo.WholesaleCodeStock > 0)
            {
                his           = GetInInitUserJxsStockhis();
                his.Stocktype = 2;
                his.Num       = this.RechargeCodeRuleInfo.WholesaleCodeStock;
                his.Amountdos = this.RechargeCodeRuleInfo.DosPrice;
                db.TblUserJxsStockhisSet.Add(his);
                if (!(db.SaveChanges() > 0))
                {
                    Alert("写进货历史失败");
                    log.Info("写进货历史失败:");
                    return(false);
                }
            }
            if (this.RechargeCodeRuleInfo.RetailCodeStock > 0)
            {
                his           = GetInInitUserJxsStockhis();
                his.Stocktype = 1;
                his.Num       = this.RechargeCodeRuleInfo.RetailCodeStock;
                his.Amountdos = this.RechargeCodeRuleInfo.DosPrice;
                db.TblUserJxsStockhisSet.Add(his);
                if (!(db.SaveChanges() > 0))
                {
                    Alert("写进货历史失败");
                    log.Info("写进货历史失败");
                    return(false);
                }
            }
            //出货历史
            if (this.RechargeCodeRuleInfo.RetailCodeStock > 0)
            {
                //进货商加数量
                this.UserJxs.Stocknum2 += this.RechargeCodeRuleInfo.RetailCodeStock;
                his           = GetOutInitUserJxsStockhis();
                his.Stocktype = 4;
                his.Num       = this.RechargeCodeRuleInfo.RetailCodeStock;
                db.TblUserJxsStockhisSet.Add(his);
                if (!(db.SaveChanges() > 0))
                {
                    Alert("写出货历史失败");
                    log.Info("写出货历史失败:");
                    return(false);
                }
            }
            if (this.RechargeCodeRuleInfo.WholesaleCodeStock > 0)
            {
                //进货商加数量
                this.UserJxs.Stocknum += this.RechargeCodeRuleInfo.WholesaleCodeStock;
                //出货历史
                his           = GetOutInitUserJxsStockhis();
                his.Stocktype = 4;
                his.Num       = this.RechargeCodeRuleInfo.WholesaleCodeStock;

                db.TblUserJxsStockhisSet.Add(his);
                if (!(db.SaveChanges() > 0))
                {
                    Alert("写出货历史失败");
                    log.Info("写出货历史失败:");
                    return(false);
                }
            }

            if (this.JsxParent != null && this.JsxParent.Infoid > 0)
            {
                //扣充值商的货
                this.JsxParent.Stocknum -= this.RechargeCodeRuleInfo.RetailCodeStock;
                if (!(db.SaveChanges() > 0))
                {
                    Alert("更新出货充值商失败");
                    log.Info("更新出货充值商失败:");
                    return(false);
                }
            }
            this.UserJxs.Lastdate = DateTime.Now; //更新进货商最后进货时间
            this.UserJxs.Isfirst  = 0;            //非首次进货
            //更新进货商库存数量和最后进货时间
            if (!(db.SaveChanges() > 0))
            {
                Alert("更新进货商信息失败");
                log.Info("更新进货商信息失败");
                return(false);
            }
            return(true);
        }