AddRole.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:2k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using com.etong.DAL;
- using com.etong.Model;
- public partial class SysManage_AddRole : System.Web.UI.Page
- {
- RoleManage rm = new RoleManage();
- protected void Page_Load(object sender, EventArgs e)
- {
- IB_Cancel.Attributes.Add("onclick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
- if (!this.Page.IsPostBack)
- {
- this.DDL_CreateRole.DataSource = rm.GetAllRoles();
- this.DDL_CreateRole.DataValueField = "RoleID";
- this.DDL_CreateRole.DataTextField = "RoleName";
- this.DDL_CreateRole.DataBind();
- this.DDL_UserRole.DataSource = rm.GetAllRoles();
- this.DDL_UserRole.DataValueField = "RoleID";
- this.DDL_UserRole.DataTextField = "RoleName";
- this.DDL_UserRole.DataBind();
-
- this.DDL_UserRole.Items.Insert(0, new ListItem("未选择", "-1"));
- }
- }
- protected void IB_Confirm_Click(object sender, EventArgs e)
- {
- RoleInfo roleInfo = new RoleInfo();
- roleInfo.RoleName = TB_RoleName.Text.ToString();
- roleInfo.RoleDesc = TB_RoleDesc.Text.ToString();
- if (DDL_CreateRole.Items.Count > 0)
- {
- roleInfo.CreateRole = Convert.ToInt32(DDL_CreateRole.SelectedValue.ToString());
- }
- if (DDL_UserRole.Items.Count > 0)
- {
- roleInfo.UserRole = Convert.ToInt32(DDL_UserRole.SelectedValue.ToString());
- }
- if (rm.AddRole(roleInfo) == true)
- {
- this.Page.ClientScript.RegisterStartupScript(this.GetType(), "0", "<script>alert('系统提示:角色记录添加成功!');window.returnValue='btok';window.close()</script>");
- }
- else
- {
- this.Page.ClientScript.RegisterStartupScript(this.GetType(), "0", "<script>alert('系统提示:角色记录添加失败!');window.close();</script>");
- }
- }
- }