Exemple #1
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        if (KeyID != 0)
        {
            Hi.Model.BD_Promotion proModel = ProBll.GetModel(KeyID);
            //促销公告
            List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID, "");

            if (proModel != null)
            {
                proModel.IsEnabled = 1;
                proModel.dr        = 1;
                if (ProBll.Update(proModel))
                {
                    if (newsl != null && newsl.Count > 0)
                    {
                        Hi.Model.BD_CompNews newsModel = new Hi.Model.BD_CompNews();
                        foreach (Hi.Model.BD_CompNews item in newsl)
                        {
                            item.IsEnabled = 0;
                            item.dr        = 1;
                            newsModel      = item;
                        }
                        new Hi.BLL.BD_CompNews().Update(newsModel);
                    }
                    Response.Write("<script>window.location.href='../PmtManager/PromotionList.aspx?type=" + Request["type"] + "';</script>");
                }
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// 绑定数据
    /// </summary>
    public void Bind()
    {
        if (KeyID != 0)
        {
            string Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", CompID);
            Hi.Model.BD_Promotion ProModel = ProBll.GetModel(KeyID);

            if (ProModel != null)
            {
                this.lblProTitle.InnerText = ProModel.ProTitle;
                this.lblProType.InnerText  = Common.GetProType(ProModel.ProType.ToString());
                pro = ProModel.ProType.ToString();

                this.lblProIsEnabled.InnerText = Common.GetIsEnabled(ProModel.IsEnabled.ToString());
                this.lblProStartDate.InnerText = ProModel.ProStartTime == DateTime.MinValue ? "" : ProModel.ProStartTime.ToString("yyyy-MM-dd");
                this.lblProEndDate.InnerText   = ProModel.ProEndTime == DateTime.MinValue ? "" : ProModel.ProEndTime.ToString("yyyy-MM-dd");
                this.lblProInfos.InnerText     = ProModel.ProInfos;

                if (ProModel.ProStartTime <= DateTime.Now && ProModel.ProEndTime.AddDays(1) > DateTime.Now)
                {
                    //促销活动中
                    //判断是否禁用
                    if (ProModel.IsEnabled == 0)
                    {
                        //未禁用
                        this.liEdit.Visible = true;  //编辑
                        this.liDel.Visible  = true;  //删除
                        this.liNo.Visible   = false; //禁用
                        this.liOk.Visible   = true;  //启用
                    }
                    else
                    {
                        //已禁用
                        this.liEdit.Visible = false; //编辑
                        this.liDel.Visible  = false; //删除
                        this.liNo.Visible   = true;  //禁用
                        this.liOk.Visible   = false; //启用
                    }
                }
                else if (ProModel.ProStartTime > DateTime.Now)
                {
                    //判断是否禁用
                    if (ProModel.IsEnabled == 0)
                    {
                        //未禁用
                        this.liEdit.Visible = true;  //编辑
                        this.liDel.Visible  = true;  //删除
                        this.liNo.Visible   = false; //禁用
                        this.liOk.Visible   = true;  //启用
                    }
                    else
                    {
                        //已禁用
                        this.liEdit.Visible = false; //编辑
                        this.liDel.Visible  = false; //删除
                        this.liNo.Visible   = true;  //禁用
                        this.liOk.Visible   = false; //启用
                    }
                }
                else
                {
                    this.liEdit.Visible = true;  //编辑
                    this.liDel.Visible  = true;  //删除
                    this.liNo.Visible   = false; //禁用
                    this.liOk.Visible   = false; //启用
                }

                //促销活动商品明细
                List <Hi.Model.BD_PromotionDetail> gl = ProDBll.GetList("", " CompId=" + this.CompID + " and ProID=" + KeyID, "");
                if (gl != null && gl.Count > 0)
                {
                    if (ProModel.ProType == 3)
                    {
                        lblDisCount.InnerText = "订购数量每满(" + (int)ProModel.Discount + "),获赠品(" + gl[0].GoodsPrice.ToString("#,####" + Digits) + ")个";
                    }
                    else if (ProModel.ProType == 4)
                    {
                        lblDisCount.InnerText = "在原订货价基础上再打折(" + (int)ProModel.Discount + ")%";
                    }

                    this.rpDtl.DataSource = gl;
                    this.rpDtl.DataBind();
                }
            }
        }
    }
Exemple #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.BD_Promotion model)
 {
     return(dal.Update(model));
 }
Exemple #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_Promotion model)
 {
     return(dal.Add(model));
 }
Exemple #5
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string str              = string.Empty;
        string ProType          = string.Empty; //促销方式
        string ProIsEnabled     = string.Empty; //是否启用
        string ProInfos         = string.Empty; //促销描述
        string ProIsJieTi       = string.Empty; //是否启用阶梯
        string PromotionDate    = string.Empty; //促销开始日期
        string PromotionEndDate = string.Empty; //促销结束日期
        int    isComNew         = 0;            //是否发布促销公告

        #region 判断值是否为空,取值
        //促销方式
        ProType = Request["promotionType"].ToString();
        //是否启用
        ProIsEnabled = Request["IsEnabled"].ToString();
        //是否启用阶梯
        ProIsJieTi = Request["IsEnabled2"].ToString();
        //促销开始日期
        if (this.txtPromotionDate.Value.Trim() == "")
        {
            str += " -- 促销开始日期不能为空。</br>";
        }
        else
        {
            PromotionDate = this.txtPromotionDate.Value.Trim();
        }
        //促销结束日期
        if (this.txtPromotionDate1.Value.Trim() == "")
        {
            str += " -- 促销结束日期不能为空。</br>";
        }
        else
        {
            PromotionEndDate = this.txtPromotionDate1.Value.Trim();
        }
        ProInfos = Common.NoHTML(this.txtProInfos.Value.Trim().ToString());
        if (str != "")
        {
            JScript.AlertMsgOne(this, str, JScript.IconOption.错误, 2500);
            return;
        }

        #endregion

        //是否发布促销公告
        isComNew = this.isOkComNews.Checked ? 1 : 0;
        string NewsContents = string.Empty;
        NewsContents = "<font size=\"3\" style=\"line-height:30px;\">";
        SqlTransaction Tran = null;
        try
        {
            Hi.Model.BD_Promotion proModel = null;
            int ProId = 0;
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            if (KeyID != 0)//修改
            {
                ProId = KeyID;
                List <Hi.Model.BD_PromotionDetail2> l = new Hi.BLL.BD_PromotionDetail2().GetList("", "isnull(dr,0)=0 and proId=" + KeyID + " and compId=" + this.CompID, "", Tran);
                if (l.Count > 0)
                {
                    foreach (Hi.Model.BD_PromotionDetail2 item in l)
                    {
                        new Hi.BLL.BD_PromotionDetail2().Delete(item.ID, Tran);
                    }
                }
                proModel = new Hi.BLL.BD_Promotion().GetModel(KeyID, Tran);
            }
            else
            {
                proModel = new Hi.Model.BD_Promotion();
            }
            //else
            //{
            proModel.Type    = Type.ToInt(0);
            proModel.CompID  = this.CompID;
            proModel.ProType = ProType.ToInt(0);
            if (ProType == "5")
            {
                proModel.ProTitle = "订单满减促销";
            }
            else if (ProType == "6")
            {
                proModel.ProTitle = "订单满折促销";
            }
            proModel.IsEnabled    = ProIsEnabled.ToInt(0);
            proModel.Discount     = 0;
            proModel.ProStartTime = PromotionDate.ToDateTime();
            proModel.ProEndTime   = PromotionEndDate.ToDateTime();
            proModel.ProInfos     = ProInfos;
            proModel.CreateUserID = this.UserID;
            proModel.CreateDate   = DateTime.Now;
            proModel.modifyuser   = this.UserID;
            proModel.ts           = DateTime.Now.ToString();
            if (KeyID != 0)//修改
            {
                ProId       = KeyID;
                proModel.ID = KeyID;
                new Hi.BLL.BD_Promotion().Update(proModel, Tran);
            }
            else
            {
                ProId = new Hi.BLL.BD_Promotion().Add(proModel, Tran);
            }
            if (ProType == "5")
            {
                string[] price  = Request["txtPrice"].ToString().Split(',');    //需要满金额
                string[] price2 = Request["txtSendFull"].ToString().Split(','); //满后需要减得金额
                for (int i = 0; i < price.Length; i++)
                {
                    if (price[i] != "")
                    {
                        Hi.Model.BD_PromotionDetail2 modelDeta = new Hi.Model.BD_PromotionDetail2();
                        modelDeta.CompID       = this.CompID;
                        modelDeta.ProID        = ProId;
                        modelDeta.OrderPrice   = Convert.ToDecimal(price[i]);
                        modelDeta.Discount     = Convert.ToDecimal(price2[i]);
                        modelDeta.modifyuser   = this.UserID;
                        modelDeta.ts           = DateTime.Now;
                        modelDeta.CreateUserID = this.UserID;
                        modelDeta.CreateDate   = DateTime.Now;
                        new Hi.BLL.BD_PromotionDetail2().Add(modelDeta, Tran);
                        NewsContents += "订单金额满¥" + price[i] + ",立减¥" + price2[i] + "<br>";
                    }
                }
            }
            else if (ProType == "6")
            {
                string[] prices  = Request["txtPrices"].ToString().Split(',');   //需要满金额
                string[] prices2 = Request["txtDiscount"].ToString().Split(','); //满后折扣
                for (int i = 0; i < prices.Length; i++)
                {
                    if (prices[i] != "")
                    {
                        Hi.Model.BD_PromotionDetail2 modelDeta = new Hi.Model.BD_PromotionDetail2();
                        modelDeta.CompID       = this.CompID;
                        modelDeta.ProID        = ProId;
                        modelDeta.OrderPrice   = Convert.ToDecimal(prices[i]);
                        modelDeta.Discount     = Convert.ToDecimal(prices2[i]);
                        modelDeta.modifyuser   = this.UserID;
                        modelDeta.ts           = DateTime.Now;
                        modelDeta.CreateUserID = this.UserID;
                        modelDeta.CreateDate   = DateTime.Now;
                        new Hi.BLL.BD_PromotionDetail2().Add(modelDeta, Tran);
                        NewsContents += "订单金额满¥" + prices[i] + ",打折(" + prices2[i] + ")%<br>";
                    }
                }
            }
            //}
            Hi.Model.BD_CompNews news = new Hi.Model.BD_CompNews();

            news.CompID       = CompID;
            news.CreateDate   = DateTime.Now;
            news.CreateUserID = UserID;
            news.dr           = 0;
            news.ts           = DateTime.Now;
            news.IsTop        = 1;
            news.IsEnabled    = 0;
            news.NewsType     = 4;
            news.ShowType     = "2";
            if (ProType == "5")
            {
                news.NewsTitle = "订单满减促销";
            }
            else if (ProType == "6")
            {
                news.NewsTitle = "订单满折促销";
            }

            NewsContents += "先到先得!";
            ProInfos      = ProInfos == "" ? "" : "(" + ProInfos + ")";
            NewsContents += ProInfos;

            NewsContents += " </br> 活动时间:" + PromotionDate.ToDateTime().ToString("yyyy-MM-dd") + "至" + PromotionEndDate.ToDateTime().ToString("yyyy-MM-dd");

            NewsContents     += "</font>";
            news.NewsContents = NewsContents;
            news.modifyuser   = UserID;
            news.PmID         = ProId;
            if (isComNew == 1)
            {
                new Hi.BLL.BD_CompNews().Add(news, Tran);
            }
            Tran.Commit();
            Response.Write("<script>window.location.href='PromotionInfo2.aspx?KeyId=" + Common.DesEncrypt(ProId.ToString(), Common.EncryptKey) + "&type=" + Type + "';</script>");
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMsgOne(this, "保存失败了", JScript.IconOption.错误, 2500);
            return;
        }
        finally
        {
            DBUtility.SqlHelper.ConnectionClose();
        }
    }
Exemple #6
0
    public void Bind()
    {
        //首次进行页面清除Session
        Session.Remove("GoodsPrice");
        if (KeyID != 0)
        {
            string Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", CompID);
            Hi.Model.BD_Promotion ProModel = ProBll.GetModel(KeyID);

            //促销公告
            List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID + "and isnull(IsEnabled,0)=1", "");

            if (ProModel != null)
            {
                this.txtPromotiontitle.Value = ProModel.ProTitle;
                this.txtPromotionDate.Value  = ProModel.ProStartTime == DateTime.MinValue ? "" : ProModel.ProStartTime.ToString("yyyy-MM-dd");
                this.txtPromotionDate1.Value = ProModel.ProEndTime == DateTime.MinValue ? "" : ProModel.ProEndTime.ToString("yyyy-MM-dd");
                this.txtProInfos.Value       = ProModel.ProInfos;

                if (newsl != null && newsl.Count > 0)
                {
                    this.isOkComNews.Checked = true;
                    this.isNoComNews.Checked = false;
                }
                else
                {
                    this.isOkComNews.Checked = false;
                    this.isNoComNews.Checked = true;
                }

                //促销方式
                if (ProModel.ProType == 3)
                {
                    this.promotionType3.Checked = true;
                    this.txtSendFull.Value      = string.Format("{0:N4}", ProModel.Discount.ToString("#,####" + Digits));
                }
                else
                {
                    this.promotionType4.Checked = true;
                    this.txtDiscount.Value      = string.Format("{0:N4}", ProModel.Discount.ToString("#,####" + Digits));
                }
                //促销禁用
                if (ProModel.IsEnabled == 0)
                {
                    this.IsEnabled0.Checked = true;
                }
                else
                {
                    this.IsEnabled1.Checked = true;
                }

                decimal count = 0;
                //促销活动商品明细
                List <Hi.Model.BD_PromotionDetail> gl = ProDBll.GetList("", " CompId=" + this.CompID + " and ProID=" + KeyID, "");
                if (gl != null && gl.Count > 0)
                {
                    List <Hi.Model.BD_GoodsInfo> ll = new List <Hi.Model.BD_GoodsInfo>();

                    Hi.Model.BD_GoodsInfo model = null;
                    foreach (var item in gl)
                    {
                        model              = new Hi.Model.BD_GoodsInfo();
                        model.CompID       = this.CompID;
                        model.IsEnabled    = true;
                        model.CreateUserID = this.UserID;
                        model.CreateDate   = DateTime.Now;
                        model.ts           = DateTime.Now;
                        model.modifyuser   = this.UserID;
                        model.ID           = item.GoodInfoID;
                        model.GoodsID      = item.GoodsID;
                        model.SalePrice    = GoodsPrice(item.GoodInfoID.ToString());
                        model.TinkerPrice  = item.GoodsPrice; //促销价
                        count              = item.GoodsPrice;
                        ll.Add(model);
                    }
                    if (ProModel.ProType == 3)
                    {
                        //满送
                        this.txtSendNum.Value = string.Format("{0:N4}", count.ToString("#,####" + Digits));
                    }
                    Session["GoodsPrice"] = ll;
                    this.rpDtl.DataSource = ll;
                    this.rpDtl.DataBind();
                }
            }
        }
        else
        {
            this.rpDtl.DataSource = "";
            this.rpDtl.DataBind();
        }
    }
Exemple #7
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string  str              = string.Empty;
        string  ProTitle         = string.Empty;
        string  ProType          = string.Empty;
        string  ProIsEnabled     = string.Empty;
        string  ProInfos         = string.Empty;
        string  PromotionDate    = string.Empty;
        string  PromotionEndDate = string.Empty;
        decimal disCount         = 0; //折扣率
        decimal SendNum          = 0; //满送数量
        int     isComNew         = 0;

        #region 判断值是否为空,取值
        //促销标题
        if (this.txtPromotiontitle.Value == "")
        {
            str += " -- 促销标题不能为空。</br>";
        }
        else
        {
            ProTitle = Common.NoHTML(this.txtPromotiontitle.Value.Trim());
        }
        //促销方式
        ProType = Request["promotionType"].ToString();
        //是否启用
        ProIsEnabled = Request["IsEnabled"].ToString();

        //促销开始日期
        if (this.txtPromotionDate.Value.Trim() == "")
        {
            str += " -- 促销开始日期不能为空。</br>";
        }
        else
        {
            PromotionDate = this.txtPromotionDate.Value.Trim();
        }
        //促销结束日期
        if (this.txtPromotionDate1.Value.Trim() == "")
        {
            str += " -- 促销结束日期不能为空。</br>";
        }
        else
        {
            PromotionEndDate = this.txtPromotionDate1.Value.Trim();
        }
        ProInfos = Common.NoHTML(this.txtProInfos.Value.Trim().ToString());

        List <Hi.Model.BD_GoodsInfo> gl = Session["GoodsPrice"] as List <Hi.Model.BD_GoodsInfo>;

        if (gl == null || gl.Count <= 0)
        {
            str += " -- 促销商品信息不能为空。</br>";
        }
        // 促销类型判断取值
        if (Type == "1")
        {
            if (ProType == "3")
            {
                //满送
                disCount = this.txtSendFull.Value.Trim().ToString().ToDecimal(0);
                SendNum  = this.txtSendNum.Value.Trim().ToString().ToDecimal(0);

                if (disCount.ToString() == "" || SendNum.ToString() == "")
                {
                    if (disCount.ToString() == "")
                    {
                        str += " -- 满送订购数量不能为空。</br>";
                    }
                    else
                    {
                        str += " -- 获赠商品数量不能为空。</br>";
                    }
                }
            }
            else
            {
                //打折
                disCount = this.txtDiscount.Value.Trim().ToString().ToDecimal(0);
                if (disCount.ToString() != "")
                {
                    if ((int)disCount < 0 || (int)disCount > 100)
                    {
                        str += " -- 打折请输入0—100的数。</br>";
                    }
                }
                else
                {
                    str += " -- 打折不能为空。</br>";
                }
            }
        }

        if (str != "")
        {
            JScript.AlertMsgOne(this, str, JScript.IconOption.错误, 2500);
            ClientScript.RegisterStartupScript(this.GetType(), "Protype", "<script>Protype('" + ProType + "');</script>");
            return;
        }

        #endregion

        int ProId = 0;

        //是否发布促销公告
        isComNew = this.isOkComNews.Checked ? 1 : 0;

        string NewsContents = string.Empty;


        NewsContents = "<font size=\"3\" style=\"line-height:30px;\">";
        try
        {
            if (KeyID != 0)
            {
                #region 修改促销
                Hi.Model.BD_Promotion proModel = ProBll.GetModel(KeyID);

                if (proModel != null)
                {
                    proModel.Type         = Type.ToInt(0);
                    proModel.ProType      = ProType.ToInt(0);
                    proModel.ProTitle     = ProTitle;
                    proModel.IsEnabled    = ProIsEnabled.ToInt(0);
                    proModel.Discount     = disCount;
                    proModel.ProStartTime = PromotionDate.ToDateTime();
                    proModel.ProEndTime   = PromotionEndDate.ToDateTime();
                    proModel.ProInfos     = ProInfos;
                    proModel.modifyuser   = this.UserID;
                    proModel.ts           = DateTime.Now.ToString();

                    List <Hi.Model.BD_PromotionDetail> l = new List <Hi.Model.BD_PromotionDetail>();

                    Hi.Model.BD_PromotionDetail proDmodel = null;
                    foreach (var item in gl)
                    {
                        proDmodel            = new Hi.Model.BD_PromotionDetail();
                        proDmodel.CompID     = this.CompID;
                        proDmodel.GoodInfoID = item.ID;
                        proDmodel.GoodsID    = item.GoodsID;

                        if (ProType == "3")
                        {
                            //满送
                            proDmodel.SendGoodsinfoID = item.ID;
                            proDmodel.GoodsPrice      = SendNum;
                        }
                        else
                        {
                            proDmodel.SendGoodsinfoID = 0;

                            if (ProType == "4")
                            {
                                //打折
                                proDmodel.GoodsPrice = (item.SalePrice * (disCount / 100));
                            }
                            else
                            {
                                proDmodel.GoodsPrice = item.TinkerPrice;
                            }
                        }

                        proDmodel.GoodsName    = GoodsName(item.ID.ToString());
                        proDmodel.GoodsUnit    = GoodsUnit(item.ID.ToString());
                        proDmodel.Goodsmemo    = Goodsmemo(item.ID.ToString());
                        proDmodel.ts           = DateTime.Now.ToString();
                        proDmodel.modifyuser   = this.UserID;
                        proDmodel.CreateUserID = this.UserID;
                        proDmodel.CreateDate   = DateTime.Now;

                        string memo = proDmodel.Goodsmemo == "" ? "" : proDmodel.Goodsmemo.Substring(0, proDmodel.Goodsmemo.Length - 1);

                        NewsContents += proDmodel.GoodsName + "  " + memo + " /" + proDmodel.GoodsUnit + "  原价 " + item.SalePrice.ToString("N") + "   促销价  " + proDmodel.GoodsPrice.ToString("N") + "! </br>";

                        l.Add(proDmodel);
                    }
                    int Id = ProBll.ProUpdate(proModel, l);

                    NewsContents += "先到先得!";
                    ProInfos      = ProInfos == "" ? "" : "(" + ProInfos + ")";
                    NewsContents += ProInfos;

                    NewsContents += "</br> 活动时间:" + PromotionDate.ToDateTime().ToString("yyyy-MM-dd") + "至" + PromotionEndDate.ToDateTime().ToString("yyyy-MM-dd");

                    NewsContents += "</font>";

                    //促销公告
                    List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID, "");
                    Hi.Model.BD_CompNews        news  = null;
                    if (newsl != null && newsl.Count > 0)
                    {
                        foreach (Hi.Model.BD_CompNews item in newsl)
                        {
                            news              = new Hi.Model.BD_CompNews();
                            news.ID           = item.ID;
                            news.PmID         = KeyID;
                            news.CompID       = item.CompID;
                            news.CreateDate   = DateTime.Now;
                            news.CreateUserID = UserID;
                            news.dr           = item.dr;
                            news.ts           = DateTime.Now;
                            if (ProIsEnabled.ToInt(0) == 1)
                            {
                                news.IsTop     = 1;
                                news.IsEnabled = 0;
                                news.NewsType  = 4;
                                news.ShowType  = "2";
                            }
                            else
                            {
                                news.IsTop     = item.IsTop;
                                news.IsEnabled = 0;
                                news.NewsType  = item.NewsType;
                                news.ShowType  = item.ShowType;
                            }
                            news.NewsTitle    = ProTitle;
                            news.NewsContents = NewsContents;
                            news.modifyuser   = UserID;
                        }
                    }
                    else
                    {
                        news              = new Hi.Model.BD_CompNews();
                        news.PmID         = KeyID;
                        news.CompID       = CompID;
                        news.CreateDate   = DateTime.Now;
                        news.CreateUserID = UserID;
                        news.dr           = 0;
                        news.ts           = DateTime.Now;
                        news.IsTop        = 1;
                        news.IsEnabled    = 1;
                        news.NewsType     = 4;
                        news.ShowType     = "2";
                        news.NewsTitle    = ProTitle;
                        news.NewsContents = NewsContents;
                        news.modifyuser   = UserID;
                    }

                    if (Id != 0)
                    {
                        if (isComNew == 1)
                        {
                            if (newsl != null && newsl.Count > 0)
                            {
                                //存在促销公告
                                new Hi.BLL.BD_CompNews().Update(news);
                            }
                            else
                            {
                                //不存在促销公告
                                new Hi.BLL.BD_CompNews().Add(news);
                            }
                        }
                        else
                        {
                            if (newsl != null && newsl.Count > 0)
                            {
                                news.IsEnabled = 0;
                                //存在促销公告
                                new Hi.BLL.BD_CompNews().Update(news);
                            }
                            else
                            {
                                news.IsEnabled = 0;
                                //不存在促销公告
                                new Hi.BLL.BD_CompNews().Add(news);
                            }
                        }

                        Response.Write("<script>window.location.href='../PmtManager/PromotionInfo.aspx?KeyId=" + Common.DesEncrypt(this.KeyID.ToString(), Common.EncryptKey) + "&type=" + Type + "';</script>");
                    }
                }
                #endregion
            }
            else
            {
                #region 新增促销
                Hi.Model.BD_Promotion proModel = new Hi.Model.BD_Promotion();

                proModel.Type         = Type.ToInt(0);
                proModel.CompID       = this.CompID;
                proModel.ProType      = ProType.ToInt(0);
                proModel.ProTitle     = ProTitle;
                proModel.IsEnabled    = ProIsEnabled.ToInt(0);
                proModel.Discount     = disCount;
                proModel.ProStartTime = PromotionDate.ToDateTime();
                proModel.ProEndTime   = PromotionEndDate.ToDateTime();
                proModel.ProInfos     = ProInfos;
                proModel.CreateUserID = this.UserID;
                proModel.CreateDate   = DateTime.Now;
                proModel.modifyuser   = this.UserID;
                proModel.ts           = DateTime.Now.ToString();

                List <Hi.Model.BD_PromotionDetail> l = new List <Hi.Model.BD_PromotionDetail>();

                Hi.Model.BD_PromotionDetail proDmodel = null;
                foreach (var item in gl)
                {
                    proDmodel            = new Hi.Model.BD_PromotionDetail();
                    proDmodel.CompID     = this.CompID;
                    proDmodel.GoodInfoID = item.ID;
                    proDmodel.GoodsID    = item.GoodsID;

                    if (ProType == "3")
                    {
                        //满送
                        proDmodel.SendGoodsinfoID = item.ID;
                        proDmodel.GoodsPrice      = SendNum;
                    }
                    else
                    {
                        proDmodel.SendGoodsinfoID = 0;
                        if (ProType == "4")
                        {
                            //打折
                            proDmodel.GoodsPrice = (item.SalePrice * (disCount / 100));
                        }
                        else
                        {
                            proDmodel.GoodsPrice = item.TinkerPrice;
                        }
                    }

                    proDmodel.GoodsName    = GoodsName(item.ID.ToString());
                    proDmodel.GoodsUnit    = GoodsUnit(item.ID.ToString());
                    proDmodel.Goodsmemo    = Goodsmemo(item.ID.ToString());
                    proDmodel.ts           = DateTime.Now.ToString();
                    proDmodel.modifyuser   = this.UserID;
                    proDmodel.CreateUserID = this.UserID;
                    proDmodel.CreateDate   = DateTime.Now;

                    string memo = proDmodel.Goodsmemo == "" ? "" : proDmodel.Goodsmemo.Substring(0, proDmodel.Goodsmemo.Length - 1);

                    NewsContents += proDmodel.GoodsName + "  " + memo + " /" + proDmodel.GoodsUnit + "  原价 " + item.SalePrice.ToString("N") + "   促销价  " + proDmodel.GoodsPrice.ToString("N") + "! </br>";
                    l.Add(proDmodel);
                }

                NewsContents += "先到先得!";
                ProInfos      = ProInfos == "" ? "" : "(" + ProInfos + ")";
                NewsContents += ProInfos;

                NewsContents += " </br> 活动时间:" + PromotionDate.ToDateTime().ToString("yyyy-MM-dd") + "至" + PromotionEndDate.ToDateTime().ToString("yyyy-MM-dd");

                NewsContents += "</font>";

                Hi.Model.BD_CompNews news = new Hi.Model.BD_CompNews();

                news.CompID       = CompID;
                news.CreateDate   = DateTime.Now;
                news.CreateUserID = UserID;
                news.dr           = 0;
                news.ts           = DateTime.Now;
                news.IsTop        = 1;
                news.IsEnabled    = 1;
                news.NewsType     = 4;
                news.ShowType     = "2";
                news.NewsTitle    = ProTitle;
                news.NewsContents = NewsContents;
                news.modifyuser   = UserID;

                int Id = ProBll.AddPro(proModel, l);

                if (Id != 0)
                {
                    news.PmID = Id;

                    if (isComNew == 1)
                    {
                        int count = new Hi.BLL.BD_CompNews().Add(news);

                        WebReference.AppService app = new AppService();
                        try
                        {
                            app.MsgPush(count.ToString(), "1");
                        }
                        catch
                        {
                            app.Abort();
                        }
                    }
                    Response.Write("<script>window.location.href='../PmtManager/PromotionInfo.aspx?KeyId=" + Common.DesEncrypt(Id.ToString(), Common.EncryptKey) + "&type=" + Type + "';</script>");
                }

                #endregion
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }