Пример #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_PromotionDetail model)
 {
     return(dal.Add(model));
 }
Пример #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.BD_PromotionDetail model)
 {
     return(dal.Update(model));
 }
Пример #3
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);
        }
    }