示例#1
0
文件: MsgBll.cs 项目: liuyim93/yohome
        /// <summary>
        /// 根据条件查询留言
        /// </summary>
        /// <param name="author">留言人</param>
        /// <param name="phone">电话</param>
        /// <param name="email">邮箱</param>
        /// <param name="adr">店址</param>
        /// <param name="time1">留言时间(小)</param>
        /// <param name="time2">留言时间(大)</param>
        /// <param name="read">留言状态</param>
        /// <returns></returns>
        public static DataTable getMsg(string author, string phone, string email, string adr, string time1, string time2, int read)
        {
            string sql = "select * from Msg where Author like '%" + author + "%' and Phone like '%" + phone + "%' and Email like '%" + email + "%' and Adress like '%" + adr + "%'";

            if (time1 != "" && time2 != "")
            {
                sql += " and CreateTime>'" + time1 + "' and CreateTime<'" + time2 + "'";
            }
            else
            {
                if (time1 == "" && time2 != "")
                {
                    sql += " and  CreateTime<'" + time2 + "'";
                }
                else if (time1 != "" && time2 == "")
                {
                    sql += " and CreateTime>'" + time1 + "'";
                }
            }
            if (read != 2)
            {
                sql += "and IsRead=" + read;
            }
            sql += " order by CreateTime desc";
            return(MsgDal.getMsg(sql));
        }
示例#2
0
文件: MsgBll.cs 项目: liuyim93/yohome
 /// <summary>
 /// 修改留言状态
 /// </summary>
 /// <param name="msgId"></param>
 /// <param name="read"></param>
 /// <returns></returns>
 public static int UpdateRead(int msgId, int read)
 {
     return(MsgDal.UpdateRead(msgId, read));
 }
示例#3
0
文件: MsgBll.cs 项目: liuyim93/yohome
 /// <summary>
 /// 删除留言
 /// </summary>
 /// <param name="msgId"></param>
 /// <returns></returns>
 public static int DeleteMsg(int msgId)
 {
     return(MsgDal.DeleteMsg(msgId));
 }
示例#4
0
文件: MsgBll.cs 项目: liuyim93/yohome
        /// <summary>
        /// 查询所有的留言
        /// </summary>
        /// <returns></returns>
        public static DataTable getAllMsg()
        {
            string sql = "select * from Msg order by CreateTime desc";

            return(MsgDal.getMsg(sql));
        }
示例#5
0
文件: MsgBll.cs 项目: liuyim93/yohome
        /// <summary>
        /// 查询留言详情
        /// </summary>
        /// <param name="msgId"></param>
        /// <returns></returns>
        public static List <Msg> GetMsgbyId(int msgId)
        {
            string sql = "select * from Msg where MsgId=" + msgId;

            return(MsgDal.GetMsg(sql));
        }
示例#6
0
文件: MsgBll.cs 项目: liuyim93/yohome
 /// <summary>
 /// 添加留言
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static int AddMsg(Msg msg)
 {
     return(MsgDal.AddMsg(msg));
 }
示例#7
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MsgDal   dal   = new MsgDal();
        Bill_Msg model = new Bill_Msg();

        if (Request["type"] == "add")
        {
            model.Title    = txt_title.Text;
            model.Contents = txt_content.Text;
            model.Writer   = Session["userCode"].ToString();
            //beg发布时间
            if (this.txt_addTime.Text.Trim() != "")
            {
                DateTime date = DateTime.MinValue;
                bool     flag = DateTime.TryParse(this.txt_addTime.Text.ToString(), out date);
                if (flag)
                {
                    model.Date = date;
                }
                else
                {
                    Response.Write("<script>alert('日期格式错误!');</script>");
                    return;
                }
            }
            else
            {
                Response.Write("<script>alert('请填写发布日期!');</script>");
                txt_addTime.Focus();
                return;
            }
            //end发布时间

            //beg截止时间
            if (this.txt_endTime.Text.Trim() != "")
            {
                DateTime date = DateTime.MinValue;
                bool     flag = DateTime.TryParse(this.txt_endTime.Text.ToString(), out date);
                if (flag)
                {
                    model.Endtime = date.ToString();
                }
                else
                {
                    Response.Write("<script>alert('日期格式错误!');</script>");;
                    return;
                }
            }
            else
            {
                Response.Write("<script>alert('请填写有效期限!');</script>");
                txt_endTime.Focus();
                return;
            }
            //end截止时间



            model.ReadTimes    = "0";
            model.Mstype       = lbType.Text.Trim();//ddlType.SelectedValue;
            model.Accessories  = "";
            model.Notifierid   = "";
            model.Notifiername = "";

            int row = dal.InsertModel(model);
            if (row > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('保存成功!');window.location.href='messageList.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('保存失败!');", true);
            }
        }
        else
        {
            model.Title    = txt_title.Text;
            model.Contents = txt_content.Text;
            model.Mstype   = lbType.Text.Trim();//ddlType.SelectedValue;
            //beg截止时间
            if (this.txt_endTime.Text.Trim() != "")
            {
                DateTime date = DateTime.MinValue;
                bool     flag = DateTime.TryParse(this.txt_endTime.Text.ToString(), out date);
                if (flag)
                {
                    model.Endtime = date.ToString();
                }
                else
                {
                    Response.Write("<script>alert('日期格式错误!');</script>");
                    return;
                }
            }
            else
            {
                Response.Write("<script>alert('请填写有效期限!');</script>");
                txt_endTime.Focus();
                return;
            }
            //end截止时间

            model.Notifiername = hftzr.Value;
            model.Accessories  = hffj.Value;
            int row = dal.updateModel(model, Session["userCode"].ToString(), Request["id"]);
            if (row > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('保存成功!');window.location.href='messageList.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('保存失败!');", true);
            }
        }
    }