Notice.aspx.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:4k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class Module_Admin_SysInfo_AddNotice : System.Web.UI.Page
  12. {
  13.     protected void Page_Load(object sender, EventArgs e)
  14.     {
  15.         if (Session["UserName"] != null)
  16.         {
  17.             this.lnkbtnAdd.Visible = true;
  18.         }
  19.         else
  20.         {
  21.             Response.Write("<script language=javascript>top.location.href='../../Index.aspx'</script>");
  22.         }
  23.         SqlData da = new SqlData();
  24.         string cmdtxt1 = "select * from tb_Notice";
  25.         this.GridView1.DataSource = da.ExceDS(cmdtxt1, "tb_Notice");
  26.         this.GridView1.DataKeyNames = new string[] { "ID" };
  27.         this.GridView1.DataBind();
  28.     }
  29.     protected void btnOK_Click(object sender, EventArgs e)
  30.     {
  31.         string cmdtxt = "INSERT INTO tb_Notice(NoticeTitle,NoticeContent,NoticeTime,NoticePerson) values('"+this.txtSubject.Text+"'";
  32.         cmdtxt += ",'"+CommonClass.HtmlEncode(this.txtContent.Text)+"','"+DateTime.Now+"','"+Session["UserName"].ToString()+"')";
  33.         SqlData da = new SqlData();
  34.         if (da.ExceSQL(cmdtxt))
  35.         {
  36.             Response.Write("<script language=javascript>alert('操作成功!');location='Notice.aspx'</script>");
  37.         }
  38.         else
  39.         {
  40.             Response.Write("<script language=javascript>alert('操作失败!');location='javascript:history.go(-1)'</script>");
  41.         }
  42.     }
  43.     protected void lnkbtnAdd_Click1(object sender, EventArgs e)
  44.     {
  45.         this.Panel2.Visible = false;
  46.         this.Panel1.Visible = true;
  47.     }
  48.     protected void btnFind_Click(object sender, EventArgs e)
  49.     {
  50.         SqlData da = new SqlData();
  51.         string search = this.dropClass.SelectedValue;
  52.         switch (search)
  53.         {
  54.             case "公告ID":
  55.                 da.BindData(this.GridView1, "Select * From tb_Notice Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Notice");
  56.                 break;
  57.             case "公告主题":
  58.                 da.BindData(this.GridView1, "Select * From tb_Notice Where NoticeTitle  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Notice");
  59.                 break;
  60.             case "发表人":
  61.                 da.BindData(this.GridView1, "Select * From tb_Notice Where NoticePerson  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Notice");
  62.                 break;
  63.             default:
  64.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  65.                 break;
  66.         }
  67.     }
  68.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  69.     {
  70.         this.GridView1.PageIndex = e.NewPageIndex;
  71.         SqlData da = new SqlData();
  72.         string search = this.dropClass.SelectedValue;
  73.         switch (search)
  74.         {
  75.             case "公告ID":
  76.                 da.BindData(this.GridView1, "Select * From tb_Notice Where ID  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Notice");
  77.                 break;
  78.             case "公告主题":
  79.                 da.BindData(this.GridView1, "Select * From tb_Notice Where NoticeTitle  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Notice");
  80.                 break;
  81.             case "发表人":
  82.                 da.BindData(this.GridView1, "Select * From tb_Notice Where NoticePerson  Like  '%" + this.txtKeyWord.Text + "%'", "tb_Notice");
  83.                 break;
  84.             default:
  85.                 Response.Write("<script lanuage=javascript>alert('出错拉!');location='javascript:history.go(-1)'</script>");
  86.                 break;
  87.         }
  88.     }
  89. }