示例#1
0
    public void DataAdd()
    {
        Cms.BLL.sc_Coupon   bll = new Cms.BLL.sc_Coupon();
        Cms.Model.sc_Coupon bml = new Cms.Model.sc_Coupon();
        string urlhot           = Request.Url.Host.ToString();

        bml.type_id    = int.Parse(ddpid.SelectedValue.ToString());
        bml.cname      = tbtilte.Text.Trim();
        bml.cmoney     = Convert.ToInt32(tbPrice.Text.Trim());
        bml.number     = Convert.ToInt32(tbnumber.Text.Trim());
        bml.stime      = DateTime.Parse(tbstime.Text);
        bml.etime      = DateTime.Parse(tbetime.Text);
        bml.picurl     = photoUrl.Text.Trim();
        bml.updatetime = DateTime.Now;
        bml.peson      = Convert.ToInt32(cbluserDegree.SelectedValue);
        bml.content    = txtusedContent.InnerText;
        int result = bll.Add(bml);

        if (result > 0)
        {
            if (bml.peson == 0)
            {
                DataTable               dt           = new Cms.BLL.C_user().GetList("").Tables[0];
                Cms.BLL.C_user_coupon   bll_coupon   = new Cms.BLL.C_user_coupon();
                Cms.Model.C_user_coupon model_coupon = new Cms.Model.C_user_coupon();
                if (dt != null && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        for (int j = 0; j < bml.number; j++)
                        {
                            model_coupon.user_id    = Convert.ToInt32(dt.Rows[i]["id"]);
                            model_coupon.article_id = bml.article_id;
                            model_coupon.coupon_id  = Convert.ToInt32(result);
                            model_coupon.title      = bml.cname;
                            model_coupon.picUrl     = bml.picurl;
                            model_coupon.price      = Convert.ToDecimal(bml.cmoney);
                            model_coupon.stime      = bml.stime;
                            model_coupon.etime      = bml.etime;
                            model_coupon.number     = 1;
                            model_coupon.content    = bml.content;
                            model_coupon.status     = 0;
                            model_coupon.type_id    = bml.type_id;
                            model_coupon.updatetime = DateTime.Now;
                            bll_coupon.Add(model_coupon);
                        }
                    }
                }
            }
            adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加优惠卷" + tbtilte.Text); //记录日志
            ShowConfirm("是否继续添加?", "couponedit.aspx?action=add", "couponlist.aspx");
        }
    }
示例#2
0
 public void DataUpdate(int id)
 {
     Cms.BLL.sc_Coupon   bll = new Cms.BLL.sc_Coupon();
     Cms.Model.sc_Coupon bml = bll.GetModel(id);
     bml.type_id = int.Parse(ddpid.SelectedValue.ToString());
     bml.cname   = tbtilte.Text.Trim();
     bml.cmoney  = Convert.ToInt32(tbPrice.Text.Trim());
     bml.number  = Convert.ToInt32(tbnumber.Text.Trim());
     bml.stime   = DateTime.Parse(tbstime.Text);
     bml.etime   = DateTime.Parse(tbetime.Text);
     bml.picurl  = photoUrl.Text.Trim();
     bml.peson   = Convert.ToInt32(cbluserDegree.SelectedValue);
     bml.content = txtusedContent.InnerText;
     //bml.updatetime = DateTime.Now;
     if (bll.Update(bml))
     {
         adminUser.AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "修改优惠卷" + tbtilte.Text); //记录日志
         if (bml.peson == 0)
         {
             DataTable               dt           = new Cms.BLL.C_user().GetList("").Tables[0];
             Cms.BLL.C_user_coupon   bll_coupon   = new Cms.BLL.C_user_coupon();
             Cms.Model.C_user_coupon model_coupon = new Cms.Model.C_user_coupon();
             if (dt != null && dt.Rows.Count > 0)
             {
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     for (int j = 0; j < bml.number; j++)
                     {
                         model_coupon.user_id    = Convert.ToInt32(dt.Rows[i]["id"]);
                         model_coupon.article_id = bml.article_id;
                         model_coupon.coupon_id  = id;
                         model_coupon.title      = bml.cname;
                         model_coupon.picUrl     = bml.picurl;
                         model_coupon.price      = Convert.ToDecimal(bml.cmoney);
                         model_coupon.stime      = bml.stime;
                         model_coupon.etime      = bml.etime;
                         model_coupon.number     = 1;
                         model_coupon.content    = bml.content;
                         model_coupon.status     = 0;
                         model_coupon.updatetime = DateTime.Now;
                         bll_coupon.Add(model_coupon);
                     }
                 }
             }
         }
         JscriptMsg("提交成功!", "couponlist.aspx", "Success");
     }
 }