private void BindData()
        {
            #region 组装查询条件
            string whereStr  = " 1 = 1 ";
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (Title like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", ""));
                    return;
                }
            }
            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.common_message bll = new BLL.common_message();
            this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("Manage.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_message", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
            BLL.common_message   bll   = new BLL.common_message();
            Model.common_message model = bll.GetModel(this.id);

            model.group_id    = Convert.ToInt32(txtgroup_id.Text);
            model.cover       = Convert.ToString(txtcover.Text);
            model.title       = Convert.ToString(txttitle.Text);
            model.subtitle    = Convert.ToString(txtsubtitle.Text);
            model.contents    = Convert.ToString(txtcontents.Text);
            model.sender_id   = Convert.ToInt32(txtsender_id.Text);
            model.receiver_id = Convert.ToInt32(txtreceiver_id.Text);
            model.add_time    = Convert.ToDateTime(txtadd_time.Text);
            model.is_read     = Convert.ToInt32(txtis_read.Text);
            model.is_send     = Convert.ToInt32(txtis_send.Text);
            model.send_time   = Convert.ToDateTime(txtsend_time.Text);

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改全局消息信息,主键:" + id); //记录日志
                JscriptMsg("修改全局消息信息成功!", "Manage.aspx");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_message", EnumCollection.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.common_message bll = new BLL.common_message();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除全局消息" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", this.keywords));
        }
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_message_list", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txttitle.Text.Trim() == "" || txttitle.Text.Trim().Length > 50)
            {
                strError += "标题为空或超出长度!<br />";
            }
            if (txtsubtitle.Text.Trim() == "" || txtsubtitle.Text.Trim().Length > 200)
            {
                strError += "摘要为空或超出长度!<br />";
            }
            if (txtcontents.Text.Trim() == "" || txtcontents.Text.Trim().Length > 4000)
            {
                strError += "内容为空或超出长度!<br />";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.common_message model = new Model.common_message();
            BLL.common_message   bll   = new BLL.common_message();

            model.group_id    = (int)EnumCollection.message_group.系统消息;
            model.cover       = "";
            model.title       = Convert.ToString(txttitle.Text);
            model.subtitle    = Convert.ToString(txtsubtitle.Text);
            model.contents    = Convert.ToString(txtcontents.Text);
            model.sender_id   = 0;
            model.receiver_id = 0;
            model.add_time    = System.DateTime.Now;
            model.is_read     = (int)EnumCollection.YesOrNot.否;
            model.is_send     = (int)EnumCollection.YesOrNot.否;
            model.send_time   = System.DateTime.Now;

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加消息信息,主键:" + id); //记录日志
                JscriptMsg("添加消息信息成功!", "message_list.aspx");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int id = RequestHelper.GetQueryInt("id");
         Model.common_message model = new BLL.common_message().GetModel(id);
         if (model == null)
         {
             contents = "";
         }
         else
         {
             contents = model.contents;
         }
     }
 }
 private void BindInfo()
 {
     BLL.common_message   bll   = new BLL.common_message();
     Model.common_message model = bll.GetModel(this.id);
     if (model == null)
     {
         JscriptMsg("信息不存在或已被删除!", "back");
         return;
     }
     txtgroup_id.Text    = model.group_id + "";
     txtcover.Text       = model.cover + "";
     txttitle.Text       = model.title + "";
     txtsubtitle.Text    = model.subtitle + "";
     txtcontents.Text    = model.contents + "";
     txtsender_id.Text   = model.sender_id + "";
     txtreceiver_id.Text = model.receiver_id + "";
     txtadd_time.Text    = model.add_time + "";
     txtis_read.Text     = model.is_read + "";
     txtis_send.Text     = model.is_send + "";
     txtsend_time.Text   = model.send_time + "";
 }
示例#7
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_common_message", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4)
            {
                strError += "分组ID为空或超出长度![br]";
            }
            if (txtcover.Text.Trim() == "" || txtcover.Text.Trim().Length > 255)
            {
                strError += "封面图为空或超出长度![br]";
            }
            if (txttitle.Text.Trim() == "" || txttitle.Text.Trim().Length > 50)
            {
                strError += "标题为空或超出长度![br]";
            }
            if (txtsubtitle.Text.Trim() == "" || txtsubtitle.Text.Trim().Length > 200)
            {
                strError += "副标题为空或超出长度![br]";
            }
            if (txtcontents.Text.Trim() == "" || txtcontents.Text.Trim().Length > 4000)
            {
                strError += "内容为空或超出长度![br]";
            }
            if (txtsender_id.Text.Trim() == "" || txtsender_id.Text.Trim().Length > 4)
            {
                strError += "发送者ID为空或超出长度![br]";
            }
            if (txtreceiver_id.Text.Trim() == "" || txtreceiver_id.Text.Trim().Length > 4)
            {
                strError += "接收者ID为空或超出长度![br]";
            }
            if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8)
            {
                strError += "添加时间为空或超出长度![br]";
            }
            if (txtis_read.Text.Trim() == "" || txtis_read.Text.Trim().Length > 4)
            {
                strError += "是否读取为空或超出长度![br]";
            }
            if (txtis_send.Text.Trim() == "" || txtis_send.Text.Trim().Length > 4)
            {
                strError += "是否已推送为空或超出长度![br]";
            }
            if (txtsend_time.Text.Trim() == "" || txtsend_time.Text.Trim().Length > 8)
            {
                strError += "推送时间为空或超出长度![br]";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.common_message model = new Model.common_message();
            BLL.common_message   bll   = new BLL.common_message();

            model.group_id    = Convert.ToInt32(txtgroup_id.Text);
            model.cover       = Convert.ToString(txtcover.Text);
            model.title       = Convert.ToString(txttitle.Text);
            model.subtitle    = Convert.ToString(txtsubtitle.Text);
            model.contents    = Convert.ToString(txtcontents.Text);
            model.sender_id   = Convert.ToInt32(txtsender_id.Text);
            model.receiver_id = Convert.ToInt32(txtreceiver_id.Text);
            model.add_time    = Convert.ToDateTime(txtadd_time.Text);
            model.is_read     = Convert.ToInt32(txtis_read.Text);
            model.is_send     = Convert.ToInt32(txtis_send.Text);
            model.send_time   = Convert.ToDateTime(txtsend_time.Text);

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加全局消息信息,主键:" + id); //记录日志
                JscriptMsg("添加全局消息信息成功!", "Manage.aspx", "");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }