コード例 #1
0
        public bool ValiActivePro(int aid, int pid, string attr, int qty, ref string msg)
        {
            DateTime now = DateTime.Now;

            DAO.Active a = db.Active.Where(m => m.ID == aid && m.StarDate <= now && now <= m.EndDate && m.Status == "1").FirstOrDefault();
            if (a != null)
            {
                DAO.ActivePros p = db.ActivePros.Where(m => m.ProID == pid && m.ActiveID == aid).FirstOrDefault();
                if (p != null)
                {
                    if (string.IsNullOrEmpty(attr))
                    {
                        if (p.Stock < qty)
                        {
                            msg = "活动产品:" + p.ProName + "库存数量不足!";
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        int            attrID = int.Parse(attr);
                        DAO.ActiveAttr at     = db.ActiveAttr.Where(m => m.ActiveID == aid && m.AProID == pid && m.AtrrID == attrID).FirstOrDefault();
                        if (at != null)
                        {
                            if (at.Stock < qty)
                            {
                                msg = "活动产品:" + p.ProName + "该款库存数量不足!";
                                return(false);
                            }
                            else
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            msg = "活动产品:" + p.ProName + "属性错误!";
                            return(false);
                        }
                    }
                }
                else
                {
                    msg = "活动产品不存在";
                    return(false);
                }
            }
            else
            {
                msg = "活动不存在或已过期";
                return(false);
            }
            //&&  m.StarDate<= now && now<=m.EndDate &&m.Status=="1"
        }
コード例 #2
0
        /// <summary>
        /// 修改一个活动
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool UpActive(DAO.Active m)
        {
            db.Entry(m).State = System.Data.EntityState.Modified;
            int r = db.SaveChanges();

            if (r > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public ActionResult Index(int aid = 0)
        {
            OutModel outmodel = new OutModel();

            ActiveModule.ActiveBus bll = new ActiveModule.ActiveBus();

            DAO.Active m = bll.GetActive(aid);

            if (m != null)
            {
                outmodel.active    = m;
                outmodel.parts     = bll.GetListByActive(aid);
                outmodel.activePro = bll.GetActiveListByActive(aid);
                outmodel.aimg      = bll.GetActiveImg();
            }
            return(View(outmodel));
        }
コード例 #4
0
 /// <summary>
 /// 获得一个活动
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public DAO.Active GetActive(int id)
 {
     DAO.Active r = db.Active.Where(m => m.ID == id).FirstOrDefault();
     return(r);
 }
コード例 #5
0
 /// <summary>
 /// 添加一个活动
 /// </summary>
 /// <param name="m"></param>
 /// <returns></returns>
 public DAO.Active AddActive(DAO.Active m)
 {
     DAO.Active r = db.Active.Add(m);
     db.SaveChanges();
     return(r);
 }