Ejemplo n.º 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 = new Hi.BLL.BD_Promotion().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 (new Hi.BLL.BD_Promotion().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='PromotionList.aspx?type=" + Request["type"] + "';</script>");
                }
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 禁用
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnNo_Click(object sender, EventArgs e)
    {
        if (KeyID != 0)
        {
            Hi.Model.BD_Promotion proModel = new Hi.BLL.BD_Promotion().GetModel(KeyID);

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

            if (proModel != null)
            {
                proModel.IsEnabled = 0;

                if (new Hi.BLL.BD_Promotion().Update(proModel))
                {
                    Hi.Model.BD_CompNews newsModel = new Hi.Model.BD_CompNews();
                    if (newsl != null && newsl.Count > 0)
                    {
                        foreach (Hi.Model.BD_CompNews item in newsl)
                        {
                            item.IsEnabled = 0;
                            newsModel      = item;
                        }
                        new Hi.BLL.BD_CompNews().Update(newsModel);
                    }

                    Response.Write("<script>window.location.href='PromotionInfo2.aspx?KeyId=" + Common.DesEncrypt(this.KeyID.ToString(), Common.EncryptKey) + "&type=" + Request["type"] + "';</script>");
                }
            }
        }
    }
Ejemplo n.º 3
0
    public void DataBinds()
    {
        List <Hi.Model.BD_CompNews> CompNewS = new Hi.BLL.BD_CompNews().GetList("", " isnull(dr,0)=0 and CompID=" + CompID + " and ID='" + KeyID + "'", "");

        if (CompNewS.Count > 0)
        {
            Hi.Model.BD_CompNews CompNew = CompNewS[0];
            lblNewTitle.InnerHtml   = CompNew.NewsTitle + IsEnd(CompNew.PmID);
            lblNewContent.InnerHtml = CompNew.NewsContents;
            lblCreateDate.InnerText = CompNew.CreateDate.ToString("yyy-MM-dd HH:mm") + " 【" + Common.GetCPNewStateName(CompNew.NewsType) + "】" + (CompNew.IsTop == 1 ? "【置顶】" : "");
        }
        else
        {
            Response.Write("数据不存在");
            Response.End();
        }
    }
Ejemplo n.º 4
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();
        }
    }
Ejemplo n.º 5
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(txtNewsTitle.Value.Trim()))
        {
            JScript.AlertMsgOne(this, "消息标题不能为空!", JScript.IconOption.错误);
            return;
        }

        Hi.Model.BD_CompNews NewsNotice = null;

        if (KeyID != 0)
        {
            NewsNotice              = new Hi.BLL.BD_CompNews().GetModel(KeyID);
            NewsNotice.NewsTitle    = Common.NoHTML(txtNewsTitle.Value.Trim());
            NewsNotice.NewsContents = content7.Text.Trim();
            //是否启用
            if (this.RdIsbled1.Checked)
            {
                NewsNotice.IsEnabled = 1;
            }
            else
            {
                NewsNotice.IsEnabled = 0;
            }
            //是否置顶
            if (this.RdTop3.Checked)
            {
                NewsNotice.IsTop = 1;
            }
            else
            {
                NewsNotice.IsTop = 0;
            }
            //类别
            if (this.RdType1.Checked)
            {
                NewsNotice.NewsType = 1;
            }
            else if (this.RdType2.Checked)
            {
                NewsNotice.NewsType = 2;
            }
            else if (this.RdType3.Checked)
            {
                NewsNotice.NewsType = 3;
            }
            else if (this.RdType4.Checked)
            {
                NewsNotice.NewsType = 4;
            }
            else if (this.RdType5.Checked)
            {
                NewsNotice.NewsType = 5;
            }
            string ShowType = "";
            if (CkShowType1.Checked)
            {
                ShowType = "1";
            }
            if (CkShowType2.Checked)
            {
                if (ShowType == "")
                {
                    ShowType = "2";
                }
                else
                {
                    ShowType += "," + "2";
                }
            }
            NewsNotice.ShowType   = ShowType;
            NewsNotice.ts         = DateTime.Now;
            NewsNotice.modifyuser = UserID;
            if (new Hi.BLL.BD_CompNews().Update(NewsNotice))
            {
                if (this.RdTop3.Checked)
                {
                    List <Hi.Model.BD_CompNews> CompNew = new Hi.BLL.BD_CompNews().GetList("", " isnull(dr,0)=0 and Compid=" + CompID + " and IsEnabled=1 and istop=1", " CreateDate desc");
                    if (CompNew.Count > 3)
                    {
                        for (int i = 0; i < CompNew.Count; i++)
                        {
                            if (i > 1 && CompNew[i].ID != NewsNotice.ID)
                            {
                                CompNew[i].IsTop = 0;
                                new Hi.BLL.BD_CompNews().Update(CompNew[i]);
                            }
                        }
                    }
                }
                //JScript.AlertMsgMo(this, "操作成功", "function(){ window.location.href='NewsInfo.aspx?KeyID=" + KeyID + "'; }");
                Response.Redirect("NewsInfo.aspx?KeyID=" + KeyID);
            }
        }
        else
        {
            NewsNotice              = new Hi.Model.BD_CompNews();
            NewsNotice.CompID       = CompID;
            NewsNotice.NewsTitle    = Common.NoHTML(txtNewsTitle.Value.Trim());
            NewsNotice.NewsContents = content7.Text.Trim();
            //是否启用
            if (this.RdIsbled1.Checked)
            {
                NewsNotice.IsEnabled = 1;
            }
            else
            {
                NewsNotice.IsEnabled = 0;
            }
            //是否置顶
            if (this.RdTop3.Checked)
            {
                NewsNotice.IsTop = 1;
            }
            else
            {
                NewsNotice.IsTop = 0;
            }
            //类别
            if (this.RdType1.Checked)
            {
                NewsNotice.NewsType = 1;
            }
            else if (this.RdType2.Checked)
            {
                NewsNotice.NewsType = 2;
            }
            else if (this.RdType3.Checked)
            {
                NewsNotice.NewsType = 3;
            }
            else if (this.RdType4.Checked)
            {
                NewsNotice.NewsType = 4;
            }
            else if (this.RdType5.Checked)
            {
                NewsNotice.NewsType = 5;
            }
            string ShowType = "";
            if (CkShowType1.Checked)
            {
                ShowType = "1";
            }
            if (CkShowType2.Checked)
            {
                if (ShowType == "")
                {
                    ShowType = "2";
                }
                else
                {
                    ShowType += "," + "2";
                }
            }
            NewsNotice.ShowType = ShowType;
            //标准参数
            NewsNotice.CreateDate   = DateTime.Now;
            NewsNotice.CreateUserID = UserID;
            NewsNotice.ts           = DateTime.Now;
            NewsNotice.modifyuser   = UserID;
            int newsrid = 0;
            newsrid = new Hi.BLL.BD_CompNews().Add(NewsNotice);
            if (newsrid > 0)
            {
                WebReference.AppService app = new AppService();
                try
                {
                    app.MsgPush(newsrid.ToString(), "1");
                }
                catch
                {
                    app.Abort();
                }

                if (this.RdTop3.Checked)
                {
                    List <Hi.Model.BD_CompNews> CompNew = new Hi.BLL.BD_CompNews().GetList("", " isnull(dr,0)=0 and Compid=" + CompID + " and IsEnabled=1 and istop=1 and PMID=0", " createdate desc");
                    if (CompNew.Count > 3)
                    {
                        for (int i = 0; i < CompNew.Count; i++)
                        {
                            if (i > 1 && CompNew[i].ID != newsrid)
                            {
                                CompNew[i].IsTop = 0;
                                new Hi.BLL.BD_CompNews().Update(CompNew[i]);
                            }
                        }
                    }
                }
                Response.Redirect("NewsInfo.aspx?KeyID=" + newsrid);
            }
        }
    }
Ejemplo n.º 6
0
    public ResultNewsAdd CompNewsAdd(string JSon)
    {
        try
        {
            #region JSon取值

            string userID    = string.Empty;
            string compID    = string.Empty;
            string title     = string.Empty;
            string contents  = string.Empty;
            string IsEnabled = string.Empty;
            string IsTop     = string.Empty;
            string NewsType  = string.Empty;
            string ShowType  = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompanyID"].ToString() != "" &&
                JInfo["Title"].ToString() != "" &&
                JInfo["IsEnable"].ToString() != "" && JInfo["IsTop"].ToString() != "" &&
                JInfo["NewsType"].ToString() != "")
            {
                userID = JInfo["UserID"].ToString();

                compID    = JInfo["CompanyID"].ToString();
                title     = Common.NoHTML(JInfo["Title"].ToString());
                contents  = Common.NoHTML(JInfo["Contents"].ToString());
                IsEnabled = JInfo["IsEnable"].ToString();
                IsTop     = JInfo["IsTop"].ToString();
                NewsType  = JInfo["NewsType"].ToString();
                ShowType  = JInfo["ShowType"].ToString();
            }
            else
            {
                return(new ResultNewsAdd()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(userID), out user, int.Parse(compID)))
            {
                return new ResultNewsAdd()
                       {
                           Result = "F", Description = "登录信息异常"
                       }
            }
            ;

            #endregion

            Hi.Model.BD_CompNews NewsNotice = new Hi.Model.BD_CompNews();
            NewsNotice.CompID       = Convert.ToInt32(compID);
            NewsNotice.NewsTitle    = title;
            NewsNotice.NewsContents = contents;
            NewsNotice.IsEnabled    = IsEnabled == "1" ? 1 : 0; //是否启用
            NewsNotice.IsTop        = IsTop == "1" ? 1 : 0;     //是否置顶
            if (NewsType.Trim() != "1" && NewsType.Trim() != "2" && NewsType.Trim() != "3" &&
                NewsType.Trim() != "4" && NewsType.Trim() != "5")
            {
                return new ResultNewsAdd()
                       {
                           Result = "F", Description = "类别异常"
                       }
            }
            ;
            NewsNotice.NewsType = Convert.ToInt32(NewsType);//类别
            if (ShowType.Trim() != "1" && ShowType.Trim() != "2" && ShowType.Trim() != "3" && ShowType.Trim() != "-1")
            {
                return new ResultNewsAdd()
                       {
                           Result = "F", Description = "展示效果异常"
                       }
            }
            ;
            if (ShowType != "-1")
            {
                NewsNotice.ShowType = ShowType == "3"?"1,2":ShowType;//标红、加new
            }
            //标准参数
            NewsNotice.CreateDate   = DateTime.Now;
            NewsNotice.CreateUserID = Convert.ToInt32(userID);
            NewsNotice.ts           = DateTime.Now;
            NewsNotice.modifyuser   = Convert.ToInt32(userID);
            int newsrid = 0;
            newsrid = new Hi.BLL.BD_CompNews().Add(NewsNotice);

            if (newsrid <= 0)
            {
                return new ResultNewsAdd()
                       {
                           Result = "F", Description = "添加失败", NewsID = newsrid.ToString()
                       }
            }
            ;
            if (IsTop == "1")//置顶数量不能超过3个
            {
                List <Hi.Model.BD_CompNews> CompNew = new Hi.BLL.BD_CompNews().GetList("", " isnull(dr,0)=0 and Compid=" + compID + " and IsEnabled=1 and istop=1 and PMID=0", " createdate desc");

                if (CompNew.Count > 3)
                {
                    for (int i = 0; i < CompNew.Count; i++)
                    {
                        if (i > 1 && CompNew[i].ID != newsrid)
                        {
                            CompNew[i].IsTop      = 0;
                            NewsNotice.ts         = DateTime.Now;
                            NewsNotice.modifyuser = Convert.ToInt32(userID);
                            new Hi.BLL.BD_CompNews().Update(CompNew[i]);
                        }
                    }
                }
            }

            new MsgSend().GetMsgService(newsrid.ToString(), "1");
            return(new ResultNewsAdd()
            {
                Result = "T", Description = "添加成功", NewsID = newsrid.ToString()
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "CompNewsAdd :" + JSon);
            return(new ResultNewsAdd()
            {
                Result = "F", Description = "异常"
            });
        }
    }
Ejemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Hi.Model.BD_CompNews model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Hi.Model.BD_CompNews model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 9
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (KeyID > 0)
        {
            bool Audit = false;
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(KeyID);
            if (comp != null)
            {
                if (comp.dr == 1)
                {
                    JScript.AlertMsg(this, "厂商不存在!。");
                    return;
                }
                string         str  = string.Empty;
                SqlTransaction Tran = null;
                try
                {
                    if (comp.AuditState == 2)
                    {
                        Audit = true;
                    }
                    if (Common.CompExistsAttribute("CompName", txtCompName.Value.Trim(), KeyID.ToString()))
                    {
                        JScript.AlertMsg(this, "该厂商名称已存在。");
                        return;
                    }
                    string CompAddr = hidProvince.Value.Trim();
                    if (!string.IsNullOrWhiteSpace(hidCity.Value.Trim()) && hidCity.Value.Trim() != "选择市")
                    {
                        CompAddr += "-" + hidCity.Value.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(hidArea.Value.Trim()) && hidArea.Value.Trim() != "选择区")
                    {
                        CompAddr += "-" + hidArea.Value.Trim();
                    }
                    comp.CompAddr = CompAddr;
                    comp.CompName = Common.NoHTML(txtCompName.Value.Trim());
                    comp.Capital  = Capital.Value.Trim();
                    comp.CompType = Convert.ToInt32(CompType.SelectedValue);
                    comp.Tel      = Common.NoHTML(txtTel.Value.Trim());
                    if (txtPrincipal.Value.Trim() != "")
                    {
                        comp.Principal = Common.NoHTML(txtPrincipal.Value.Trim());
                    }
                    else
                    {
                        comp.Principal = Common.NoHTML(txtUserTrueName.Value.Trim());
                    }
                    comp.Legal = Common.NoHTML(txtLegal.Value.Trim());
                    if (txtPhone.Value.Trim() != "")
                    {
                        comp.Phone = Common.NoHTML(txtPhone.Value.Trim());
                    }
                    else
                    {
                        comp.Phone = Common.NoHTML(txtUserPhone.Value.Trim());
                    }
                    comp.ShortName  = Common.NoHTML(txtShotName.Value.Trim());
                    comp.Zip        = Common.NoHTML(txtZip.Value.Trim());
                    comp.Identitys  = Common.NoHTML(txtIdentitys.Value.Trim());
                    comp.Licence    = Common.NoHTML(txtLicence.Value.Trim());
                    comp.LegalTel   = Common.NoHTML(txtLegalTel.Value.Trim());
                    comp.ManageInfo = Common.NoHTML(txtInfo.Value.Trim());
                    comp.Fax        = Common.NoHTML(txtFax.Value.Trim());
                    comp.Account    = Common.NoHTML(txtAccount.Value.Trim());
                    comp.Address    = Common.NoHTML(txtAddress.Value.Trim());
                    comp.IndID      = txtIndusName.SelectedValue.ToInt(0);
                    comp.Trade      = txtIndusName.Items[txtIndusName.SelectedIndex].Text;
                    comp.AuditState = 2;
                    comp.AuditDate  = DateTime.Now;//add by hgh 审核日期
                    comp.AuditUser  = UserID.ToString();

                    comp.ts               = DateTime.Now;
                    comp.modifyuser       = UserID;
                    comp.OrganizationCode = Common.NoHTML(txtOrcode.Value.Trim());
                    comp.IsEnabled        = rdEbleYes.Checked ? 1 : 0;
                    comp.HotShow          = rdHotShowYes.Checked ? 1 : 0;
                    comp.FirstShow        = Convert.ToInt32(ddlChkShow.SelectedValue);// rdFirstShowYes.Checked ? 1 : 0;
                    comp.Remark           = Common.NoHTML(txtRemark.Value.Trim());
                    comp.Erptype          = ddlErptype.SelectedValue.ToInt(0);
                    //企业编号  add by hgh
                    comp.CompCode = Common.CreateCode(KeyID);
                    if (HidFfileName.Value != "")
                    {
                        if (string.IsNullOrEmpty(comp.Attachment))
                        {
                            comp.Attachment = HidFfileName.Value;
                        }
                        else
                        {
                            comp.Attachment += "," + HidFfileName.Value;
                        }
                    }
                    List <Hi.Model.SYS_CompUser> ListComp = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and Ctype=1 and Utype=4 and CompID=" + KeyID + "", "");
                    if (ListComp.Count > 0)
                    {
                        Tran  = DBUtility.SqlHelper.CreateStoreTranSaction();
                        Audit = ListComp[0].IsAudit == 2;
                        if (Audit)
                        {
                            List <Hi.Model.BD_Distributor> dis = new Hi.BLL.BD_Distributor().GetList("", " isnull(dr,0)=0 and compid=" + KeyID + "", "");
                            foreach (Hi.Model.BD_Distributor model2 in dis)
                            {
                                model2.IsEnabled  = comp.IsEnabled;
                                model2.ts         = DateTime.Now;
                                model2.modifyuser = UserID;
                                new Hi.BLL.BD_Distributor().Update(model2, Tran);
                            }
                            new Hi.BLL.BD_Company().Update(comp, Tran);
                            List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                            if (user.Count > 0)
                            {
                                user[0].TrueName   = Common.NoHTML(txtUserTrueName.Value.Trim());
                                user[0].ts         = DateTime.Now;
                                user[0].modifyuser = UserID;
                                new Hi.BLL.SYS_Users().Update(user[0], Tran);
                            }
                            Tran.Commit();
                            Response.Redirect("CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5", false);
                        }
                        else
                        {
                            if (UserType == 3 || UserType == 4)
                            {
                                comp.OrgID      = OrgID;
                                comp.SalesManID = SalesManID;
                            }
                            if ((new Hi.BLL.BD_Company().Update(comp, Tran)))
                            {
                                //新增数据字典
                                Hi.Model.BD_DefDoc doc = new Hi.Model.BD_DefDoc();
                                doc.CompID     = KeyID;
                                doc.AtCode     = "";
                                doc.AtName     = "计量单位";
                                doc.ts         = DateTime.Now;
                                doc.modifyuser = UserID;
                                doc.dr         = 0;
                                List <Hi.Model.BD_DefDoc> ll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='计量单位'", "", Tran);
                                if (ll.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc, Tran);
                                }

                                //代理商加盟是否需要审核
                                Hi.Model.SYS_SysName sysname = new Hi.Model.SYS_SysName();
                                sysname.CompID     = KeyID;
                                sysname.Code       = "";
                                sysname.Name       = "代理商加盟是否需要审核";
                                sysname.Value      = "0";
                                sysname.ts         = DateTime.Now;
                                sysname.modifyuser = UserID;
                                List <Hi.Model.SYS_SysName> sysl = new Hi.BLL.SYS_SysName().GetList("", "Name='代理商加盟是否需要审核' and CompID=" + KeyID, "", Tran);
                                if (sysl != null && sysl.Count == 0)
                                {
                                    new Hi.BLL.SYS_SysName().Add(sysname, Tran);
                                }

                                //费用科目
                                Hi.Model.BD_DefDoc doc1 = new Hi.Model.BD_DefDoc();
                                doc1.CompID     = KeyID;
                                doc1.AtCode     = "";
                                doc1.AtName     = "费用科目";
                                doc1.ts         = DateTime.Now;
                                doc1.modifyuser = UserID;
                                doc1.dr         = 0;
                                List <Hi.Model.BD_DefDoc> ll1 = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='费用科目'", "", Tran);
                                if (ll1.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc1, Tran);
                                }


                                doc.CompID     = KeyID;
                                doc.AtCode     = "";
                                doc.AtName     = "代理商等级";
                                doc.ts         = DateTime.Now;
                                doc.modifyuser = UserID;
                                doc.dr         = 0;
                                List <Hi.Model.BD_DefDoc> lll = new Hi.BLL.BD_DefDoc().GetList("", "isnull(dr,0)=0 and compid=" + KeyID + " and atname='代理商等级'", "", Tran);
                                if (lll.Count == 0)
                                {
                                    new Hi.BLL.BD_DefDoc().Add(doc, Tran);
                                }
                                List <Hi.Model.SYS_Role> l = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and compid=" + KeyID + " and RoleName='企业管理员'", "");
                                if (l.Count == 0)
                                {
                                    //新增角色(企业管理员)
                                    Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                                    role.CompID       = KeyID;
                                    role.RoleName     = "企业管理员";
                                    role.IsEnabled    = 1;
                                    role.SortIndex    = "1";
                                    role.CreateDate   = DateTime.Now;
                                    role.CreateUserID = UserID;
                                    role.ts           = DateTime.Now;
                                    role.modifyuser   = UserID;
                                    role.dr           = 0;
                                    int Roid = new Hi.BLL.SYS_Role().Add(role, Tran);

                                    //新增角色用户
                                    Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser();
                                    RoleUser.FunType    = 1;
                                    RoleUser.UserID     = ListComp[0].UserID;
                                    RoleUser.RoleID     = Roid;
                                    RoleUser.IsEnabled  = true;
                                    RoleUser.CreateUser = this.UserID.ToString();
                                    RoleUser.CreateDate = DateTime.Now;
                                    RoleUser.ts         = DateTime.Now;
                                    RoleUser.dr         = 0;
                                    new Hi.BLL.SYS_RoleUser().Add(RoleUser, Tran);

                                    //修改用户对应的角色
                                    List <Hi.Model.SYS_Users> ListUser = new Hi.BLL.SYS_Users().GetList("", " isnull(dr,0)=0 and id=" + ListComp[0].UserID + " ", "");
                                    if (ListUser.Count > 0)
                                    {
                                        ListUser[0].TrueName   = Common.NoHTML(txtUserTrueName.Value.Trim());
                                        ListUser[0].ts         = DateTime.Now;
                                        ListUser[0].modifyuser = UserID;
                                        ListUser[0].AuditState = 2;
                                        new Hi.BLL.SYS_Users().Update(ListUser[0], Tran);
                                    }
                                    ListComp[0].IsAudit    = 2;
                                    ListComp[0].modifyuser = UserID;
                                    ListComp[0].ts         = DateTime.Now;
                                    ListComp[0].RoleID     = Roid;
                                    new Hi.BLL.SYS_CompUser().Update(ListComp[0], Tran);

                                    Hi.Model.BD_CompNews CNew = new Hi.Model.BD_CompNews();
                                    CNew.NewsTitle    = "欢迎登录" + ConfigurationManager.AppSettings["PhoneSendName"].ToString() + "平台";
                                    CNew.NewsContents = "”" + ConfigurationManager.AppSettings["PhoneSendName"].ToString() + "”平台为企业和代理商之间搭建了电子商务平台,通过企业入驻及代理商的加盟,形成覆盖全行业的线上销售网络。同时,充分利用平台信息化整合优势,帮助入驻企业销售模式电商化改造,以及为代理商信息化建设提供有力支持。另外,还将为供应链上的相关各方提供全渠道的结算服务以及授信融资等多项互联网金融服务。";
                                    CNew.IsEnabled    = 1;
                                    CNew.IsTop        = 0;
                                    CNew.NewsType     = 2;
                                    CNew.ShowType     = "1,2";
                                    CNew.CompID       = KeyID;
                                    CNew.CreateDate   = DateTime.Now;
                                    CNew.CreateUserID = UserID;
                                    CNew.ts           = DateTime.Now;
                                    CNew.modifyuser   = UserID;
                                    new Hi.BLL.BD_CompNews().Add(CNew, Tran);

                                    //新增角色权限表
                                    Hi.Model.SYS_RoleSysFun rolesys = null;
                                    //add by hgh   增加了:and funcode<>'1030'
                                    List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=1 and funcode<>'1030'", "");
                                    foreach (Hi.Model.SYS_SysFun sys in funList)
                                    {
                                        rolesys              = new Hi.Model.SYS_RoleSysFun();
                                        rolesys.CompID       = KeyID;
                                        rolesys.RoleID       = Roid;
                                        rolesys.FunCode      = sys.FunCode;
                                        rolesys.FunName      = sys.FunName;
                                        rolesys.IsEnabled    = 1;
                                        rolesys.CreateUserID = UserID;
                                        rolesys.CreateDate   = DateTime.Now;
                                        rolesys.ts           = DateTime.Now;
                                        rolesys.modifyuser   = UserID;
                                        new Hi.BLL.SYS_RoleSysFun().Add(rolesys, Tran);
                                    }

                                    //新增代理商分类
                                    Hi.Model.BD_DisType distype = new Hi.Model.BD_DisType();
                                    distype.CompID       = KeyID;
                                    distype.TypeName     = "全部";
                                    distype.ParentId     = 0;
                                    distype.TypeCode     = "1001";
                                    distype.SortIndex    = "1000";
                                    distype.IsEnabled    = 0;
                                    distype.CreateUserID = UserID;
                                    distype.CreateDate   = DateTime.Now;
                                    distype.ts           = DateTime.Now;
                                    distype.modifyuser   = UserID;
                                    distype.dr           = 0;
                                    new Hi.BLL.BD_DisType().Add(distype, Tran);
                                    Tran.Commit();

                                    //审核成功   添加一条默认的商品分类 -开始

                                    string Typecode = "";//商品大类
                                    //Hi.Model.SYS_GType gtype = new Hi.BLL.SYS_GType().GetList(" top 1 *", " Deep=3  and FullCode like '"+ Typecode + "-%' and IsEnabled=1 and dr=0 ", " parentid,ID")[0];
                                    //Hi.Model.BD_GoodsCategory DisType = new Hi.Model.BD_GoodsCategory();

                                    //DisType.Code = NewCategoryCode("1");
                                    //DisType.Deep = 1;
                                    //DisType.ParCode = "";
                                    //DisType.ParentId = 0;
                                    //DisType.CompID = KeyID;
                                    //DisType.CategoryName = "默认";
                                    //DisType.GoodsTypeID = gtype.ID;
                                    //DisType.SortIndex = "1000";
                                    //DisType.CreateDate = DateTime.Now;
                                    //DisType.CreateUserID = 0;
                                    //DisType.IsEnabled = 1;
                                    //DisType.ts = DateTime.Now;
                                    //DisType.modifyuser = 0;
                                    //SqlTransaction trans = SqlHelper.CreateStoreTranSaction();
                                    //try
                                    //{
                                    //    int countID = 0;
                                    //    if ((countID = new Hi.BLL.BD_GoodsCategory().Add(DisType, trans)) > 0)
                                    //    {
                                    //        List<Hi.Model.BD_Goods> gList = new Hi.BLL.BD_Goods().GetList("", " CategoryID=''", "");
                                    //        if (gList != null && gList.Count > 0)
                                    //        {
                                    //            foreach (var bdGoodse in gList)
                                    //            {
                                    //                bdGoodse.CategoryID = countID;
                                    //                new Hi.BLL.BD_Goods().Update(bdGoodse, trans);
                                    //            }
                                    //        }
                                    //        trans.Commit();

                                    //    }

                                    //}
                                    //catch (Exception ex)
                                    //{
                                    //    Tiannuo.LogHelper.LogHelper.Error("Error", ex);
                                    //    if (trans != null)
                                    //    {
                                    //        if (trans.Connection != null)
                                    //        {
                                    //            trans.Rollback();
                                    //        }
                                    //    }
                                    //    return;
                                    //}
                                    //finally
                                    //{
                                    //    SqlHelper.ConnectionClose();
                                    //    if (trans != null)
                                    //    {
                                    //        if (trans.Connection != null)
                                    //        {
                                    //            trans.Connection.Close();
                                    //        }
                                    //    }
                                    //}
                                    //审核成功   添加一条默认的商品分类 -结束



                                    DBUtility.GetPhoneCode getphonecode = new DBUtility.GetPhoneCode();
                                    str = getphonecode.ReturnSTRS(ListUser[0].Phone, comp.CompName, ListUser[0].UserName);
                                    if (str != "Success")
                                    {
                                        JScript.AlertMsgMo(this, "审核通过的通知短信发送失败!请自行发送短信通知企业。", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=" + Request.QueryString["type"] + "" + "'; }");
                                    }
                                    else
                                    {
                                        JScript.AlertMsgMo(this, "审核成功", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5'; }");
                                    }
                                }
                                else
                                {
                                    ListComp[0].IsAudit    = 2;
                                    ListComp[0].modifyuser = UserID;
                                    ListComp[0].ts         = DateTime.Now;
                                    new Hi.BLL.SYS_CompUser().Update(ListComp[0], Tran);
                                    Hi.Model.SYS_Users           user  = null;
                                    List <Hi.Model.SYS_CompUser> User2 = new Hi.BLL.SYS_CompUser().GetList("", " dr=0 and utype=4 and CompID=" + KeyID + "", "");
                                    if (User2.Count > 0)
                                    {
                                        user = new Hi.BLL.SYS_Users().GetModel(User2[0].UserID);
                                    }
                                    Tran.Commit();

                                    // 发短信通知
                                    DBUtility.GetPhoneCode getphonecode = new DBUtility.GetPhoneCode();
                                    getphonecode.GetUser(ConfigurationManager.AppSettings["PhoneCodeAccount"].ToString(), ConfigurationManager.AppSettings["PhoneCodePwd"].ToString());
                                    str = getphonecode.ReturnSTRS(user.Phone, comp.CompName, user.UserName);
                                    if (str != "Success")
                                    {
                                        JScript.AlertMsgMo(this, "审核通过的通知短信发送失败!请自行发送短信通知企业。", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=" + Request.QueryString["type"] + "" + "'; }");
                                    }
                                    else
                                    {
                                        JScript.AlertMsgMo(this, "审核成功", "function(){ window.location.href='CompInfo.aspx?go=1&KeyID=" + KeyID + "&type=5'; }");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        JScript.AlertMsg(this, "用户明细数据异常!。");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Tiannuo.LogHelper.LogHelper.Error("Error", ex);
                    if (Tran != null)
                    {
                        if (Tran.Connection != null)
                        {
                            Tran.Rollback();
                        }
                    }
                    JScript.AlertMsgMo(this, "审核失败", "function(){ window.location.href=window.location.href; }");
                }
                finally
                {
                    DBUtility.SqlHelper.ConnectionClose();
                }
            }
            else
            {
                JScript.AlertMsg(this, "厂商不存在!。");
                return;
            }


            //cust by ggh 20180327 begin  审核通过时,默认给核心企业设置手续费

            Settings(KeyID);

            //cust by ggh 20180327  end  审核通过时,默认给核心企业设置手续费
        }
        else
        {
            if (Common.GetUserExists(txtUsername.Value.Trim()))
            {
                JScript.AlertMsg(this, "该登录帐号已存在。");
                return;
            }
            if (Common.CompExistsAttribute("CompName", txtCompName.Value.Trim()))
            {
                JScript.AlertMsg(this, "该厂商名称已存在。");
                return;
            }
            Regex Phonereg = new Regex("^0?1[0-9]{10}$");
            if (!Phonereg.IsMatch(txtUserPhone.Value.Trim()))
            {
                JScript.AlertMsg(this, "手机号码格式错误!");
                return;
            }
            if (Common.GetUserExists("Phone", txtUserPhone.Value.Trim()))
            {
                JScript.AlertMsg(this, "手机号码已被注册!");
                return;
            }
            Hi.Model.BD_Company comp = new Hi.Model.BD_Company();
            if (UserType == 3 || UserType == 4)
            {
                comp.OrgID      = OrgID;
                comp.SalesManID = SalesManID;
            }
            comp.CompName = Common.NoHTML(txtCompName.Value.Trim());
            comp.Capital  = Capital.Value.Trim();
            comp.CompType = Convert.ToInt32(CompType.SelectedValue);
            comp.Tel      = Common.NoHTML(txtTel.Value.Trim());
            if (txtPrincipal.Value.Trim() != "")
            {
                comp.Principal = Common.NoHTML(txtPrincipal.Value.Trim());
            }
            else
            {
                comp.Principal = Common.NoHTML(txtUserTrueName.Value.Trim());
            }
            comp.Legal    = Common.NoHTML(txtLegal.Value.Trim());
            comp.LegalTel = Common.NoHTML(txtLegalTel.Value.Trim());
            if (txtPhone.Value.Trim() != "")
            {
                comp.Phone = Common.NoHTML(txtPhone.Value.Trim());
            }
            else
            {
                comp.Phone = Common.NoHTML(txtUserPhone.Value.Trim());
            }
            comp.ShortName        = Common.NoHTML(txtShotName.Value.Trim());
            comp.Zip              = Common.NoHTML(txtZip.Value.Trim());
            comp.Identitys        = Common.NoHTML(txtIdentitys.Value.Trim());
            comp.Licence          = Common.NoHTML(txtLicence.Value.Trim());
            comp.ManageInfo       = Common.NoHTML(txtInfo.Value.Trim());
            comp.Fax              = Common.NoHTML(txtFax.Value.Trim());
            comp.OrganizationCode = Common.NoHTML(txtOrcode.Value.Trim());
            comp.Trade            = txtIndusName.Items[txtIndusName.SelectedIndex].Text;
            comp.Account          = Common.NoHTML(txtAccount.Value.Trim());
            comp.Attachment       = HidFfileName.Value;
            comp.Address          = Common.NoHTML(txtAddress.Value.Trim());
            comp.CustomCompinfo   = "本公司产品种类丰富、质量优良、价格公道、服务周到。感谢您长期的支持与厚爱,您的满意是我们最高的追求,我们将竭诚为您提供优质、贴心的服务!";

            string CompAddr = hidProvince.Value.Trim();
            if (!string.IsNullOrWhiteSpace(hidCity.Value.Trim()) && hidCity.Value.Trim() != "选择市")
            {
                CompAddr += "-" + hidCity.Value.Trim();
            }
            if (!string.IsNullOrWhiteSpace(hidArea.Value.Trim()) && hidArea.Value.Trim() != "选择区")
            {
                CompAddr += "-" + hidArea.Value.Trim();
            }
            comp.CompAddr = CompAddr;

            comp.IndID        = txtIndusName.SelectedValue.ToInt(0);
            comp.CreateDate   = DateTime.Now;
            comp.CreateUserID = UserID;
            comp.ts           = DateTime.Now;
            comp.modifyuser   = UserID;
            comp.IsEnabled    = rdEbleYes.Checked ? 1 : 0;
            comp.HotShow      = rdHotShowYes.Checked ? 1 : 0;
            comp.FirstShow    = Convert.ToInt32(ddlChkShow.SelectedValue);// rdFirstShowYes.Checked ? 1 : 0;
            comp.SortIndex    = "001";
            comp.Remark       = Common.NoHTML(txtRemark.Value.Trim());
            comp.Erptype      = ddlErptype.SelectedValue.ToInt(0);
            comp.AuditState   = 0;
            int            comid = 0;
            SqlTransaction Tran  = DBUtility.SqlHelper.CreateStoreTranSaction();
            comid         = new Hi.BLL.BD_Company().Add(comp, Tran);
            comp.CompCode = Common.CreateCode(comid);
            comp.ID       = comid;
            new Hi.BLL.BD_Company().Update(comp, Tran);
            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            user.UserName     = Common.NoHTML(txtUsername.Value.Trim());
            user.TrueName     = Common.NoHTML(txtUserTrueName.Value.Trim());
            user.UserPwd      = Util.md5(txtUpwd.Text.Trim());
            user.Phone        = Common.NoHTML(txtUserPhone.Value.Trim());
            user.AuditState   = 2;
            user.IsEnabled    = 1;
            user.AuditUser    = UserID.ToString();
            user.CreateUserID = UserID;
            user.CreateDate   = DateTime.Now;
            user.ts           = DateTime.Now;
            user.modifyuser   = UserID;
            int userid = 0;
            userid = new Hi.BLL.SYS_Users().Add(user, Tran);
            Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
            CompUser.CompID       = comid;
            CompUser.DisID        = 0;
            CompUser.CreateDate   = DateTime.Now;
            CompUser.CreateUserID = UserID;
            CompUser.modifyuser   = UserID;
            CompUser.CType        = 1;
            CompUser.UType        = 4;
            CompUser.IsEnabled    = 1;
            CompUser.IsAudit      = 0;
            CompUser.ts           = DateTime.Now;
            CompUser.dr           = 0;
            CompUser.UserID       = userid;
            new Hi.BLL.SYS_CompUser().Add(CompUser, Tran);
            Tran.Commit();
            Response.Redirect("CompInfo.aspx?go=1&KeyID=" + comid, false);
        }
    }
Ejemplo n.º 10
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);
        }
    }