예제 #1
0
    protected void Save(string strRoleID)
    {
        if (strRoleID != string.Empty)
        {
            using (MWDatabaseEntities MWDB = new MWDatabaseEntities())
            {
                System.Guid gu      = new Guid(strRoleID);
                tblRole     objRole = MWDB.tblRole.First(r => r.RoleID == gu);
                if (objRole != null)
                {
                    MenuPermissionRoleBLL Menu_Permission_RoleBLLs = new MenuPermissionRoleBLL();
                    Menu_Permission_RoleBLLs.DeleteT(strRoleID);

                    IList <RadTreeNode> nodeCollection = RadTreeView_Rigth.CheckedNodes;
                    //删除
                    //循环选中的节点并获取值
                    foreach (RadTreeNode node in nodeCollection)
                    {
                        if (node.Value != string.Empty)
                        {
                            tblMenu_Permission_Role tblp     = new tblMenu_Permission_Role();
                            System.Guid             guMenuID = new Guid(node.Value);
                            tblp.MenuID = guMenuID;
                            tblp.RoleID = gu;
                            Menu_Permission_RoleBLLs.Add(tblp);
                        }
                    }
                }
            }
        }
    }
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="RoleObj"></param>
        /// <returns></returns>
        public bool Add(tblMenu_Permission_Role tblMenu_Permission_RoleObj)
        {
            tblMenu_Permission_RoleObj.ID = System.Guid.NewGuid();
            string userHostAddress = HttpContext.Current.Request.UserHostAddress;
            int    counts          = 0;

            //插入数据
            try
            {
                using (MWDatabaseEntities MWDB = new MWDatabaseEntities())
                {
                    MWDB.tblMenu_Permission_Role.AddObject(tblMenu_Permission_RoleObj);
                    counts = MWDB.SaveChanges();
                    if (counts > 0)
                    {
                        DbLoggerBLL.SysLogger.Info("Increase menu and the role relationship successfully! ID: '"
                                                   + tblMenu_Permission_RoleObj.ID + "'. User host address: '" + userHostAddress + "'");
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                DbLoggerBLL.SysLogger.Error("Increase menu and the role relationship failed! ID: '"
                                            + tblMenu_Permission_RoleObj.ID + "'. User host address: '" + userHostAddress + "' . Exception info"
                                            + ex.Message);
                return(false);
            }
            return(false);
        }