NoticeAdd.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:3k
源码类别:

.net编程

开发平台:

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. using com.etong.user;
  12. using com.etong.BusinessRule.Zwf;
  13. using com.etong.Inform;
  14. public partial class SysManage_Notice : System.Web.UI.Page
  15. {
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         if (!IsPostBack)
  19.         {
  20.             Notice notice = new Notice();
  21.             CheckUserInfo checkuserinfo = (CheckUserInfo)Session["checkuserinfo"];   
  22.             int userid = checkuserinfo.UserID;
  23.             //int userid = 0;
  24.             EtongZwf zwf = new EtongZwf();
  25.             DataView dv = new DataView();            
  26.             dv = zwf.RoleGetAll();
  27.             DDL_Role.DataSource = dv;
  28.             DDL_Role.DataTextField = "RoleName";
  29.             DDL_Role.DataValueField = "RoleID";
  30.             DDL_Role.DataBind();
  31.             DDL_Role.Items.Insert(0, new ListItem("---请选择---", "-1"));
  32.             DDL_User.Items.Insert(0, new ListItem("---请选择---", "-1"));
  33.             if (checkuserinfo.EmpName != null)
  34.             {
  35.                 TB_CreateUserID.Text = checkuserinfo.EmpName;
  36.             }
  37.             else
  38.                 TB_CreateUserID.Text = "系统管理员";
  39.             TB_NoticeDate.Text = DateTime.Now.ToString();
  40.             BT_Cancel.Attributes.Add("onclick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
  41.         }
  42.     }
  43.     protected void BT_Confirm_Click(object sender, ImageClickEventArgs e)
  44.     {
  45.         string noticetitle = this.TB_Title.Text;
  46.         string content = this.TB_Content.Text;
  47.         CheckUserInfo checkuserinfo = (CheckUserInfo)Session["checkuserinfo"];    
  48.         int userid = checkuserinfo.UserID;
  49.         //int userid = 0;
  50.         DateTime invaiddate =Convert.ToDateTime(this.TB_InvaidDate.Text);
  51.         int roleid = Convert.ToInt32( DDL_Role.SelectedValue);
  52.         int assuserid =Convert.ToInt32( DDL_User.SelectedValue);
  53.         Notice notice = new Notice();        
  54.         bool returnvalue = false;
  55.         returnvalue = notice.NoticeAdd(noticetitle, content, invaiddate, DateTime.Now,userid, roleid, assuserid);
  56.         if (returnvalue)        
  57.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:添加记录成功!');</script>");
  58.         
  59.         else
  60.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:添加记录不成功!');window.close();</script>");
  61.         this.TB_Content.Text = "";
  62.         this.TB_CreateUserID.Text= "";
  63.         this.TB_InvaidDate.Text = "";
  64.         this.TB_NoticeDate.Text = DateTime.Now.ToString();
  65.         this.TB_Title.Text = "";
  66.     }
  67.     protected void DDL_Role_SelectedIndexChanged(object sender, EventArgs e)
  68.     {
  69.         Notice notice = new Notice();
  70.         int roleid =Convert.ToInt32(DDL_Role.SelectedValue.ToString());
  71.         DataView dv = new DataView();
  72.         dv = notice.GetUser(roleid);
  73.         DDL_User.DataSource = dv;
  74.         DDL_User.DataTextField = "EmpName";
  75.         DDL_User.DataValueField = "UserID";
  76.         DDL_User.DataBind();
  77.         DDL_User.Items.Insert(0, new ListItem("---请选择---", "-1"));
  78.     }
  79. }