protected void sub_click(object sender, EventArgs e) { wgiAdUnionSystem.BLL.wgi_notice bll = new wgiAdUnionSystem.BLL.wgi_notice(); wgiAdUnionSystem.Model.wgi_notice model = new wgiAdUnionSystem.Model.wgi_notice(); if (Request.QueryString["act"]=="edit") { model = bll.GetModel(int.Parse(hidnid.Value)); model.title = Server.HtmlEncode(txttitle.Text); model.notice = txtcontent.Value; model.objtype = int.Parse(ddlobjtype.Text); model.publisher = base.user.id; //model.pubdate = DateTime.Now;//真有重要更新应发新消息 bll.Update(model); ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('修改公告成功!');parent.closepop();parent.location=parent.location;", true); return; } model.notice = txtcontent.Value; model.objid = -1;//-1表示公告,私人消息会有用户id model.objtype = int.Parse(ddlobjtype.Text); model.pubdate = DateTime.Now; model.publisher = base.user.id; model.title = Server.HtmlEncode(txttitle.Text); model.unread = 0; bll.Add(model); ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('发布公告成功!');parent.closepop();parent.location=parent.location;", true); }
private void getmsgs() { Response.ContentType = "txt/html"; Response.Clear(); int id; if(!int.TryParse(Request["id"],out id)) { Response.Write("读取数据失败!"); Response.End(); } wgiAdUnionSystem.BLL.wgi_notice bll=new wgiAdUnionSystem.BLL.wgi_notice (); wgiAdUnionSystem.Model.wgi_notice model=bll.GetModel(id); //取出消息内容 string cont=model.notice; //更改阅读状态 try { string utype = Request.QueryString["utype"]; if (utype == "none") { bll.UpdateReadStatus(id.ToString(), 1); } else { int usertype = int.Parse(utype); int userid = int.Parse(Request.QueryString["uid"]); wgiAdUnionSystem.BLL.wgi_noticestat bllstat = new wgiAdUnionSystem.BLL.wgi_noticestat(); wgiAdUnionSystem.Model.wgi_noticestat modelstat = new wgiAdUnionSystem.Model.wgi_noticestat(); if (bllstat.GetList(" userid=" + userid + " and usertype=" + usertype + " and noticeid=" + id).Tables[0].Rows.Count == 0) { modelstat.deleted = 0; modelstat.noticeid = id; modelstat.unread = 1; modelstat.userid = userid; modelstat.usertype = usertype; bllstat.Add(modelstat); } else { bllstat.UpdateRead(id, 1, userid, 0); } } } catch (Exception) { Response.Write("读取数据失败!"); Response.End(); } Response.Write(cont); Response.End(); }