Ejemplo n.º 1
0
 /// <summary>
 /// 向该角色添加一个已有的用户
 /// </summary>
 /// <param name="roleName"></param>
 /// <param name="userID"></param>
 /// <returns></returns>
 public int AddExitUser(string roleName,int userID)
 {
     using (CarSaleEntities context = new CarSaleEntities())
     {
         var role = context.Role.FirstOrDefault(r => r.RoleName == roleName);
         RoleUserInfo newitem = new RoleUserInfo();
         newitem.RoleID = role.ID;
         newitem.UserID = userID;
         context.AddToRoleUserInfo(newitem);
         context.SaveChanges();
         return 1;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 在角色分配页面向该角色添加一个用户,RoleUserInfo表,UserInfo表都要新增一条记录
 /// </summary>
 /// <returns></returns>
 public int AddUser(string roleName,string userName,string realName)
 {
     CarSaleEntities context=new CarSaleEntities();
     UserInfoBll bll=new UserInfoBll();
     bll.AddUserInfo(userName, realName, "123456", " ", " ", " ", " ", " ", 1, " ");
     var user = context.UserInfo.FirstOrDefault(u => u.UserName == userName);
     var role = context.Role.FirstOrDefault(r => r.RoleName == roleName);
     RoleUserInfo newitem=new RoleUserInfo();
     newitem.RoleID = role.ID;
     newitem.UserID = user.ID;
     context.AddToRoleUserInfo(newitem);
     context.SaveChanges();
     return 1;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 用于向 RoleUserInfo EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToRoleUserInfo(RoleUserInfo roleUserInfo)
 {
     base.AddObject("RoleUserInfo", roleUserInfo);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 创建新的 RoleUserInfo 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="roleID">RoleID 属性的初始值。</param>
 /// <param name="userID">UserID 属性的初始值。</param>
 public static RoleUserInfo CreateRoleUserInfo(global::System.Int32 id, global::System.Int32 roleID, global::System.Int32 userID)
 {
     RoleUserInfo roleUserInfo = new RoleUserInfo();
     roleUserInfo.ID = id;
     roleUserInfo.RoleID = roleID;
     roleUserInfo.UserID = userID;
     return roleUserInfo;
 }