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

.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.DAL;
  12. using com.etong.Model;
  13. public partial class SysManage_AddRole : System.Web.UI.Page
  14. {
  15.     RoleManage rm = new RoleManage();
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         IB_Cancel.Attributes.Add("onclick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
  19.         if (!this.Page.IsPostBack)
  20.         {
  21.             this.DDL_CreateRole.DataSource = rm.GetAllRoles();
  22.             this.DDL_CreateRole.DataValueField = "RoleID";
  23.             this.DDL_CreateRole.DataTextField = "RoleName";
  24.             this.DDL_CreateRole.DataBind();
  25.             this.DDL_UserRole.DataSource = rm.GetAllRoles();
  26.             this.DDL_UserRole.DataValueField = "RoleID";
  27.             this.DDL_UserRole.DataTextField = "RoleName";
  28.             this.DDL_UserRole.DataBind();
  29.             
  30.             this.DDL_UserRole.Items.Insert(0, new ListItem("未选择", "-1"));
  31.         }
  32.     }
  33.     protected void IB_Confirm_Click(object sender, EventArgs e)
  34.     {
  35.         RoleInfo roleInfo = new RoleInfo();
  36.         roleInfo.RoleName = TB_RoleName.Text.ToString();
  37.         roleInfo.RoleDesc = TB_RoleDesc.Text.ToString();
  38.         if (DDL_CreateRole.Items.Count > 0)
  39.         {
  40.             roleInfo.CreateRole = Convert.ToInt32(DDL_CreateRole.SelectedValue.ToString());
  41.         }
  42.         if (DDL_UserRole.Items.Count > 0)
  43.         {
  44.             roleInfo.UserRole = Convert.ToInt32(DDL_UserRole.SelectedValue.ToString());
  45.         }
  46.         if (rm.AddRole(roleInfo) == true)
  47.         {
  48.             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "0", "<script>alert('系统提示:角色记录添加成功!');window.returnValue='btok';window.close()</script>");
  49.         }
  50.         else
  51.         {
  52.             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "0", "<script>alert('系统提示:角色记录添加失败!');window.close();</script>");
  53.         }
  54.     }
  55. }