Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id  = RequestTool.RequestInt("id", 0);
            int tid = RequestTool.RequestInt("tid", 0);

            if (id == 0)
            {
                if (!EX_Admin.Power("promotion_add", "添加促销活动"))
                {
                    PageReturnMsg = PageNoPowerMsg();
                }
            }
            else
            {
                if (!EX_Admin.Power("promotion_edit", "编辑促销活动"))
                {
                    PageReturnMsg = PageNoPowerMsg();
                }
            }

            model = B_Lebi_Promotion.GetModel(id);
            if (model == null)
            {
                model = new Lebi_Promotion();
                model.Type_id_PromotionStatus = 240;
            }
            else
            {
                tid = model.Promotion_Type_id;
                if (model.Case805 != "")
                {
                    string codes             = "";
                    List <Lebi_Product> pros = B_Lebi_Product.GetList("id in (" + model.Case805 + ")", "");
                    foreach (Lebi_Product pro in pros)
                    {
                        if (codes == "")
                        {
                            codes = pro.Number;
                        }
                        else
                        {
                            if (codes.Contains(pro.Number))
                            {
                                continue;
                            }
                            else
                            {
                                codes = codes + "," + pro.Number;
                            }
                        }
                    }
                    model.Case805 = codes;
                }
            }
            pt = B_Lebi_Promotion_Type.GetModel(tid);
            if (pt == null)
            {
                PageError();
                return;
            }
        }
Exemple #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Promotion model)
 {
     D_Lebi_Promotion.Instance.Update(model);
 }
Exemple #3
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Promotion SafeBindForm(Lebi_Promotion model)
 {
     return(D_Lebi_Promotion.Instance.SafeBindForm(model));
 }
Exemple #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Promotion model)
 {
     return(D_Lebi_Promotion.Instance.Add(model));
 }
Exemple #5
0
        /// <summary>
        /// 编辑保存促销
        /// </summary>
        public void Promotion_Edit()
        {
            int                 id    = RequestTool.RequestInt("id", 0);
            int                 tid   = RequestTool.RequestInt("tid", 0);
            Lebi_Promotion      model = B_Lebi_Promotion.GetModel(id);
            Lebi_Promotion_Type pt;
            bool                addflag = false;

            if (model == null)
            {
                if (!EX_Admin.Power("promotion_add", "添加促销活动"))
                {
                    AjaxNoPower();
                    return;
                }
                pt      = B_Lebi_Promotion_Type.GetModel(tid);
                model   = new Lebi_Promotion();
                addflag = true;
            }
            else
            {
                if (!EX_Admin.Power("promotion_edit", "编辑促销活动"))
                {
                    AjaxNoPower();
                    return;
                }
                pt = B_Lebi_Promotion_Type.GetModel(model.Promotion_Type_id);
            }
            if (pt == null)
            {
                Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                return;
            }
            B_Lebi_Promotion.BindForm(model);
            model.IsCase801 = RequestTool.RequestInt("IsCase801", 0);
            model.IsCase802 = RequestTool.RequestInt("IsCase802", 0);
            model.IsCase803 = RequestTool.RequestInt("IsCase803", 0);
            model.IsCase804 = RequestTool.RequestInt("IsCase804", 0);
            model.IsCase805 = RequestTool.RequestInt("IsCase805", 0);
            model.IsCase806 = RequestTool.RequestInt("IsCase806", 0);
            model.IsRule901 = RequestTool.RequestInt("IsRule901", 0);
            model.IsRule902 = RequestTool.RequestInt("IsRule902", 0);
            model.IsRule903 = RequestTool.RequestInt("IsRule903", 0);
            model.IsRule904 = RequestTool.RequestInt("IsRule904", 0);
            model.IsRule905 = RequestTool.RequestInt("IsRule905", 0);
            model.IsRule906 = RequestTool.RequestInt("IsRule906", 0);
            model.IsRule907 = RequestTool.RequestInt("IsRule907", 0);
            model.IsRule908 = RequestTool.RequestInt("IsRule908", 0);
            model.IsRule909 = RequestTool.RequestInt("IsRule909", 0);
            model.IsRule910 = RequestTool.RequestInt("IsRule910", 0);
            model.IsRule911 = RequestTool.RequestInt("IsRule911", 0);
            model.IsRule912 = RequestTool.RequestInt("IsRule912", 0);
            model.Case804   = RequestTool.RequestString("Case804");;
            //处理包含商品
            string Case805 = RequestTool.RequestString("Case805");

            Case805 = Case805.Replace(",", "','");
            Case805 = "'" + Case805 + "'";
            List <Lebi_Product> pros = B_Lebi_Product.GetList("Number in (" + Case805 + ")", "");
            string ids = "";

            foreach (Lebi_Product pro in pros)
            {
                if (ids == "")
                {
                    ids = pro.id.ToString();
                }
                else
                {
                    ids = ids + "," + pro.id.ToString();
                }
            }
            model.Case805                 = ids;
            model.Admin_id                = CurrentAdmin.id;
            model.Admin_UserName          = CurrentAdmin.UserName;
            model.Time_Start              = pt.Time_Start;
            model.Time_End                = pt.Time_End;
            model.Type_id_PromotionStatus = pt.Type_id_PromotionStatus;
            model.Remark            = RequestTool.RequestString("Remark");
            model.Sort              = RequestTool.RequestInt("Sort", 0);
            model.Promotion_Type_id = pt.id;
            if (model.IsCase801 > 0 || model.IsCase802 > 0 || model.IsCase803 > 0 || model.IsCase804 > 0 || model.IsCase805 > 0)
            {
                model.IsSetCase = 1;
            }
            else
            {
                model.IsSetCase = 0;
            }
            if (addflag)
            {
                B_Lebi_Promotion.Add(model);
                model.id = B_Lebi_Promotion.GetMaxId();
            }
            else
            {
                B_Lebi_Promotion.Update(model);
            }
            Response.Write("{\"msg\":\"OK\",\"id\":\"" + model.id + "\"}");
        }