// 会员转账页面
        public ActionResult MemberTransfer(int RollMC_ID, string RollCardID, float RollMC_TotalMoney, int ShiftMC_ID, string ShiftCardID, decimal TL_TransferMoney, string TL_Remark, DateTime TL_CreateTime)
        {
            var jf = Convert.ToInt32(RollMC_TotalMoney);

            using (TransactionScope transaction = new TransactionScope())//使用事务
            {
                try
                {
                    //修改转出的会员信息
                    MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == RollMC_ID);
                    mc.MC_Point -= jf;
                    if (mc.MC_Point < 0)
                    {
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                    mc.MC_TotalMoney += RollMC_TotalMoney;
                    mc.MC_TotalCount += 1;

                    mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;


                    //在转账记录表插入一条记录
                    TransferLogs tr = new TransferLogs
                    {
                        S_ID             = (Session["Users"] as Users).S_ID,
                        U_ID             = (Session["Users"] as Users).U_ID,
                        TL_FromMC_ID     = RollMC_ID,
                        TL_FromMC_CardID = RollCardID,
                        TL_ToMC_ID       = ShiftMC_ID,
                        TL_ToMC_CardID   = ShiftCardID,
                        TL_TransferMoney = TL_TransferMoney,
                        TL_Remark        = TL_Remark,
                        TL_CreateTime    = TL_CreateTime
                    };
                    mpms.TransferLogs.Add(tr);

                    //修改转入的会员信息
                    MemCards zr = mpms.MemCards.FirstOrDefault(x => x.MC_ID == ShiftMC_ID);
                    zr.MC_Point += jf;

                    mpms.Entry <MemCards>(zr).State = System.Data.Entity.EntityState.Modified;

                    transaction.Complete();//放在catch上面,否则不能回滚
                }
                catch
                {
                }
            }

            return(Json(mpms.SaveChanges() > 2, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        // 添加修改方法
        public ActionResult MgAddOrUpdate(CardLevels sj)
        {
            if (sj.CL_ID == 0)
            {//添加
                if (mpms.CardLevels.FirstOrDefault(x => x.CL_LevelName == sj.CL_LevelName) != null)
                {
                    return(Json(-1, JsonRequestBehavior.AllowGet));
                }
                mpms.CardLevels.Add(sj);
                return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
            }
            //修改
            CardLevels qqq = mpms.CardLevels.FirstOrDefault(x => x.CL_ID == sj.CL_ID);

            if (sj.CL_LevelName != qqq.CL_LevelName && mpms.CardLevels.FirstOrDefault(x => x.CL_ID != sj.CL_ID && x.CL_LevelName == sj.CL_LevelName) != null)
            {
                return(Json(-1, JsonRequestBehavior.AllowGet));
            }
            qqq.CL_LevelName = sj.CL_LevelName;
            qqq.CL_NeedPoint = sj.CL_NeedPoint;
            qqq.CL_Point     = sj.CL_Point;
            qqq.CL_Percent   = sj.CL_Percent;
            mpms.Entry <CardLevels>(qqq).State = System.Data.Entity.EntityState.Modified;
            //修改
            return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        // 添加修改方法
        public ActionResult DoAddOrUpdate(ExchangGifts sj)
        {
            if (sj.EG_ID == 0)
            {//添加
                if (mpms.ExchangGifts.FirstOrDefault(x => x.EG_GiftName == sj.EG_GiftName) != null ||
                    mpms.ExchangGifts.FirstOrDefault(x => x.EG_GiftCode == sj.EG_GiftCode) != null)
                {
                    return(Json(-1, JsonRequestBehavior.AllowGet));
                }
                mpms.ExchangGifts.Add(sj);
                return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
            }

            ExchangGifts qqq = mpms.ExchangGifts.FirstOrDefault(x => x.EG_ID == sj.EG_ID);

            if ((sj.EG_GiftName != qqq.EG_GiftName && mpms.ExchangGifts.FirstOrDefault(x => x.EG_GiftName == sj.EG_GiftName) != null) ||
                (sj.EG_GiftCode != qqq.EG_GiftCode && mpms.ExchangGifts.FirstOrDefault(x => x.EG_GiftCode == sj.EG_GiftCode) != null))
            {
                return(Json(-1, JsonRequestBehavior.AllowGet));
            }

            qqq.EG_GiftCode = sj.EG_GiftCode;
            qqq.EG_GiftName = sj.EG_GiftName;
            qqq.EG_Number   = sj.EG_Number;
            qqq.EG_Point    = sj.EG_Point;
            qqq.EG_Remark   = sj.EG_Remark;
            qqq.EG_Photo    = sj.EG_Photo;
            mpms.Entry <ExchangGifts>(qqq).State = System.Data.Entity.EntityState.Modified;
            //修改
            return(Json(mpms.SaveChanges() > 0, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        //快速消费
        public ActionResult DoJffx(int MC_ID, string MC_CardID, float CO_Recash, int CO_GavePoint)
        {
            //修改消费的会员信息
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);

            mc.MC_Point -= CO_GavePoint;
            mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;


            //在转账记录表插入一条记录
            ConsumeOrders co = new ConsumeOrders
            {
                S_ID             = (Session["Users"] as Users).S_ID,
                U_ID             = (Session["Users"] as Users).U_ID,
                CO_OrderCode     = DateTime.Now.ToString("yyyyMMddHHmmss"),
                CO_OrderType     = 2,
                MC_ID            = MC_ID,
                MC_CardID        = MC_CardID,
                EG_ID            = 0,
                CO_TotalMoney    = 0,
                CO_DiscountMoney = 0,
                CO_GavePoint     = CO_GavePoint,
                CO_Recash        = CO_Recash,
                CO_Remark        = "积分返现",
                CO_CreateTime    = Convert.ToDateTime(Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"))
            };

            mpms.ConsumeOrders.Add(co);
            return(Json(mpms.SaveChanges() > 1, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        // 分配页面方法
        public ActionResult DoTancUpAdmin(string U_LoginName, int S_ID)
        {
            if (mpms.Users.FirstOrDefault(x => x.U_LoginName == U_LoginName) != null)
            {
                return(Json(-1, JsonRequestBehavior.AllowGet));
            }
            Users use = new Users
            {
                S_ID        = S_ID,
                U_LoginName = U_LoginName,
                U_Password  = "******",
                U_Role      = 2
            };

            mpms.Users.Add(use);
            mpms.SaveChanges();
            Shops sh = mpms.Shops.FirstOrDefault(x => x.S_ID == S_ID);

            sh.S_IsHasSetAdmin           = true;
            mpms.Entry <Shops>(sh).State = System.Data.Entity.EntityState.Modified;
            return(Json(mpms.SaveChanges() > 0?1:0, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        //修改用户信息
        public ActionResult UpdateUser(Users us)
        {
            var   uid  = (Session["Users"] as Users).U_ID;
            Users user = mpms.Users.FirstOrDefault(x => x.U_ID == uid);

            if (us.U_LoginName != user.U_LoginName && mpms.Users.FirstOrDefault(x => x.U_LoginName == us.U_LoginName) != null)
            {
                return(Json(new { pd = -1, U_RealNames = user.U_RealName }, JsonRequestBehavior.AllowGet));
            }
            user.U_LoginName = us.U_LoginName;
            user.U_RealName  = us.U_RealName;
            user.U_Sex       = us.U_Sex;
            user.U_Telephone = us.U_Telephone;

            mpms.Entry <Users>(user).State = System.Data.Entity.EntityState.Modified;

            if (mpms.SaveChanges() > 0)
            {
                Session["Users"] = user;
                return(Json(new { pd = true, U_RealNames = user.U_RealName }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { pd = false, U_RealNames = "" }, JsonRequestBehavior.AllowGet));
        }