/// <summary> /// 保存用户角色信息 /// </summary> private void SaveRoles(int UserID) { UserData.Move_UserPermissionCache(UserID); ArrayList lst = BusinessFacade.sys_UserRolesDisp(UserID); foreach (sys_UserRolesTable var in lst) { if (BusinessFacade.sys_Roles_CheckUser(var.R_RoleID)) { var.DB_Option_Action_ = "Delete"; BusinessFacade.sys_UserRolesInsertUpdate(var); } } sys_UserRolesTable urt = new sys_UserRolesTable(); urt.DB_Option_Action_ = "Insert"; urt.R_UserID = UserID; foreach (ListItem var in MultiListBox1.SecondListBox.Items) { urt.R_RoleID = Convert.ToInt32(var.Value); if (BusinessFacade.sys_Roles_CheckUser(urt.R_RoleID)) { BusinessFacade.sys_UserRolesInsertUpdate(urt); } } }
protected void AddUserToRole() { string userIDs = (string)Common.sink("UserIDs", MethodType.Get, 2000, 1, DataType.Str); int UserID = 0; string[] userIDsArray = userIDs.Split(','); foreach (string item in userIDsArray) { if (!string.IsNullOrEmpty(item)) { UserID = Convert.ToInt32(item); //判断是否已经增加过当前角色用户 if (BusinessFacade.sys_UserRolesDisp(UserID, RoleID).R_RoleID == 0) { sys_UserRolesTable su = new sys_UserRolesTable(); su.DB_Option_Action_ = "Insert"; su.R_RoleID = RoleID; su.R_UserID = UserID; BusinessFacade.sys_UserRolesInsertUpdate(su); UserData.Move_UserPermissionCache(UserID); } } } EventMessage.MessageBox(1, "操作成功", string.Format("从角色ID:{0}中增加用户ID:{1}成功!", RoleID, userIDs), Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("RoleManager.aspx?RoleID={0}&CMD=Look", RoleID))); }
protected void Button3_Click(object sender, EventArgs e) { int UserID = (int)Common.sink(DropDownList1.UniqueID, MethodType.Post, 255, 1, DataType.Int); UserData.Move_UserPermissionCache(UserID); sys_UserRolesTable su = new sys_UserRolesTable(); su.DB_Option_Action_ = "Insert"; su.R_RoleID = RoleID; su.R_UserID = UserID; BusinessFacade.sys_UserRolesInsertUpdate(su); EventMessage.MessageBox(1, "操作成功", string.Format("从角色ID:{0}中增加用户ID:{1}成功!", RoleID, UserID), Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("RoleManager.aspx?RoleID={0}&CMD=Look", RoleID))); }
/// <summary> /// 将记录集转为sys_UserRolesTable实体类 /// </summary> /// <param name="dr">记录集</param> /// <returns>sys_UserRolesTable</returns> protected object Populatesys_UserRoles(IDataReader dr) { sys_UserRolesTable nc = new sys_UserRolesTable(); if (!Convert.IsDBNull(dr["R_UserID"])) { nc.R_UserID = Convert.ToInt32(dr["R_UserID"]); // 用户ID与sys_User表中UserID相关 } if (!Convert.IsDBNull(dr["R_RoleID"])) { nc.R_RoleID = Convert.ToInt32(dr["R_RoleID"]); // 用户所属角色ID与Sys_Roles关联 } return(nc); }
/// <summary> /// 新增/删除/修改 sys_UserRoles /// </summary> /// <param name="fam">sys_UserRolesTable实体类</param> /// <returns>返回0操正常</returns> public override int sys_UserRolesInsertUpdate(sys_UserRolesTable fam) { int rInt = 0; using (SqlConnection Conn = GetSqlConnection()) { SqlCommand cmd = new SqlCommand("sys_UserRolesInsertUpdateDelete", Conn); cmd.CommandType = CommandType.StoredProcedure; //设置参数 cmd.Parameters.Add("@DB_Option_Action_", SqlDbType.NVarChar).Value = fam.DB_Option_Action_; //操作方法 Insert:增加 Update:修改 Delete:删除 Disp:显示单笔记录 cmd.Parameters.Add("@R_UserID", SqlDbType.Int).Value = fam.R_UserID; //用户ID与sys_User表中UserID相关 cmd.Parameters.Add("@R_RoleID", SqlDbType.Int).Value = fam.R_RoleID; //用户所属角色ID与Sys_Roles关联 Conn.Open(); rInt = Convert.ToInt32(cmd.ExecuteScalar()); cmd.Dispose(); Conn.Dispose(); Conn.Close(); } return(rInt); }
/// <summary> /// 绑定按钮 /// </summary> private void BindButton() { switch (CMD) { case "New": CMD_Txt = "增加"; HiddenDisp(); TopTr.Visible = false; break; case "Edit": CMD_Txt = "修改"; HiddenDisp(); HeadMenuButtonItem Bm0 = new HeadMenuButtonItem(); Bm0.ButtonPopedom = PopedomType.List; Bm0.ButtonUrl = string.Format("?CMD=Look&RoleID={0}", RoleID); Bm0.ButtonIcon = "back.gif"; Bm0.ButtonName = "返回"; HeadMenuWebControls1.ButtonList.Add(Bm0); HeadMenuButtonItem Bm1 = new HeadMenuButtonItem(); Bm1.ButtonPopedom = PopedomType.Delete; Bm1.ButtonUrlType = UrlType.JavaScript; Bm1.ButtonUrl = string.Format("DelData('?CMD=Delete&RoleID={0}')", RoleID); HeadMenuWebControls1.ButtonList.Add(Bm1); break; case "Look": HiddenInput(); HeadMenuButtonItem Bm2 = new HeadMenuButtonItem(); Bm2.ButtonPopedom = PopedomType.Edit; Bm2.ButtonUrl = string.Format("?CMD=Edit&RoleID={0}", RoleID); HeadMenuWebControls1.ButtonList.Add(Bm2); break; case "Delete": CMD_Txt = "删除"; sys_RolesTable sat = new sys_RolesTable(); sat.RoleID = RoleID; sat.DB_Option_Action_ = CMD; BusinessFacade.sys_RolesInsertUpdate(sat); BusinessFacade.sys_RoleApplication_Move(RoleID); BusinessFacade.sys_RolePermission_Move(RoleID); UserData.Move_RoleUserPermissionCache(RoleID); EventMessage.MessageBox(1, "操作成功", "删除记录ID:(" + RoleID + ")成功!", Icon_Type.OK, Common.GetHomeBaseUrl("RoleList.aspx")); break; case "Move": sys_RoleApplicationTable rt = new sys_RoleApplicationTable(); rt.A_ApplicationID = (int)Common.sink("ApplicationID", MethodType.Get, 255, 1, DataType.Int); rt.A_RoleID = RoleID; rt.DB_Option_Action_ = "Delete"; BusinessFacade.sys_RoleApplicationInsertUpdate(rt); BusinessFacade.sys_RolePermission_Move(rt.A_RoleID, rt.A_ApplicationID); UserData.Move_RoleUserPermissionCache(RoleID); EventMessage.MessageBox(1, "操作成功", "移除应用ID:(" + rt.A_ApplicationID + ")成功!", Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("RoleManager.aspx?RoleID={0}&CMD=Look", RoleID))); break; case "MoveUser": //检测删除权限 FrameWorkPermission.CheckPermissionVoid(PopedomType.Delete); int UserID = (int)Common.sink("UserID", MethodType.Get, 255, 1, DataType.Int); UserData.Move_UserPermissionCache(UserID); sys_UserRolesTable su = new sys_UserRolesTable(); su.DB_Option_Action_ = "Delete"; su.R_RoleID = RoleID; su.R_UserID = UserID; BusinessFacade.sys_UserRolesInsertUpdate(su); EventMessage.MessageBox(1, "操作成功", string.Format("从角色ID:{0}中移除用户ID:{1}成功!", RoleID, UserID), Icon_Type.OK, Common.GetHomeBaseUrl(string.Format("RoleManager.aspx?RoleID={0}&CMD=Look", RoleID))); break; } All_Title_Txt = CMD_Txt + App_Txt; HeadMenuWebControls1.HeadOPTxt = TabOptionItem1.Tab_Name = All_Title_Txt; }
/// <summary> /// 新增/删除/修改 sys_UserRoles /// </summary> /// <param name="fam">sys_UserRolesTable实体类</param> /// <returns>返回0操正常</returns> public abstract int sys_UserRolesInsertUpdate(sys_UserRolesTable fam);