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

.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.         Notice notice = new Notice();
  19.         EtongZwf zwf = new EtongZwf();
  20.         DataView dv = new DataView();
  21.         CheckUserInfo checkuserinfo = (CheckUserInfo)Session["checkuserinfo"];
  22.         int userid = checkuserinfo.UserID;
  23.         dv = zwf.RoleGetAll();
  24.         DDL_Role.DataSource = dv;
  25.         DDL_Role.DataTextField = "RoleName";
  26.         DDL_Role.DataValueField = "RoleID";
  27.         DDL_Role.DataBind();
  28.         DDL_Role.Items.Insert(0, new ListItem("---请选择---", "-1"));
  29.         DDL_User.Items.Insert(0, new ListItem("---请选择---", "-1"));
  30.         string noticeid = Request.QueryString["NoticeID"].Trim();
  31.         if (!IsPostBack)
  32.         {
  33.             if (noticeid == "")
  34.                 return;
  35.             dv = notice.NoticeSearch(userid, Convert.ToInt32(noticeid));
  36.             this.TB_Content.Text = dv[0]["NoticeContent"].ToString().Trim();
  37.             this.TB_CreateUserID.Text = dv[0]["EmpName"].ToString().Trim();
  38.             this.TB_InvaidDate.Text = dv[0]["InvaidDate"].ToString().Trim();
  39.             this.TB_NoticeDate.Text = dv[0]["NoticeDate"].ToString();
  40.             this.TB_Title.Text = dv[0]["NoticeTitle"].ToString();
  41.             string roleid = dv[0]["AssRoleID"].ToString();
  42.             string assuserid = dv[0]["AssUserID"].ToString();
  43.             if (dv[0]["AssRoleID"].ToString() != "-1")
  44.             {
  45.                 DDL_Role.Items.FindByValue(roleid).Selected = true;
  46.                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert("+roleid+");</script>");
  47.                 //return;
  48.                 dv = notice.GetUser(Convert.ToInt32(roleid));
  49.                 DDL_User.DataSource = dv;
  50.                 DDL_User.DataTextField = "EmpName";
  51.                 DDL_User.DataValueField = "UserID";
  52.                 DDL_User.DataBind();
  53.                 if (assuserid != "-1")
  54.                 {
  55.                     DDL_User.Items.FindByValue(assuserid).Selected = true;
  56.                 }
  57.             }
  58.         }
  59.         BT_Cancel.Attributes.Add("onclick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
  60.     }
  61.     protected void BT_Confirm_Click(object sender, ImageClickEventArgs e)
  62.     {
  63.         string noticeid = Request.QueryString["NoticeID"].Trim();
  64.         string title = TB_Title.Text.ToString();
  65.         string content = this.TB_Content.Text.ToString();
  66.         DateTime invaiddate = Convert.ToDateTime(this.TB_InvaidDate.Text);
  67.         int roleid = Convert.ToInt32(DDL_Role.SelectedValue.ToString());
  68.         int userid = Convert.ToInt32(DDL_User.SelectedValue.ToString());      
  69.         Notice notice = new Notice();
  70.         bool returnvalue = false;
  71.         returnvalue = notice.NoticeUpdate(Convert.ToInt32(noticeid), title, content, invaiddate, roleid, userid);
  72.         if (returnvalue)
  73.             ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert('系统提示:修改记录成功!');</script>");
  74.         else
  75.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:修改记录不成功!');window.close();</script>");        
  76.     }
  77.     protected void DDL_Role_SelectedIndexChanged(object sender, EventArgs e)
  78.     {
  79.         Notice notice = new Notice();
  80.         int roleid = Convert.ToInt32(DDL_Role.SelectedValue.ToString());
  81.         DataView dv = new DataView();
  82.         dv = notice.GetUser(roleid);
  83.         DDL_User.DataSource = dv;
  84.         DDL_User.DataTextField = "EmpName";
  85.         DDL_User.DataValueField = "UserID";
  86.         DDL_User.DataBind();
  87.         DDL_User.Items.Insert(0, new ListItem("---请选择---", "-1"));
  88.     }
  89. }