Esempio n. 1
0
        public RoleInfo GetRoleInfoById(int RoleId)
        {
            RoleInfo roleInfo  = null;//
            try
            {
                 roleInfo = new RoleInfo(RoleId);

            }
            catch (AppException)
            {
                return null;
            }

            return  roleInfo;
        }
Esempio n. 2
0
 protected void btnAddUser_Click(object sender, EventArgs e)
 {
     if (IsPageValid())
     {
           try
             {
                 RoleInfo role = new RoleInfo();
                 role.RoleName = txtRoleName.Text.ToString();
                 role.Save();
                 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ӳɹ���');</script>");
             }
             catch (Exception Ex)
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('����ʧ�ܣ�" + Ex.Message + "');", true);
             }
     }
 }
Esempio n. 3
0
 protected void gvRole_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     int roleid = Convert.ToInt32(gvRole.DataKeys[e.RowIndex].Value);
     TextBox txtRoleName = gvRole.Rows[e.RowIndex].FindControl("txtRoleName") as TextBox;
     try
     {
         RoleInfo role = new RoleInfo(roleid);
         role.RoleName = txtRoleName.Text.ToString();
         role.Save();
         gvRole.EditIndex = -1;
         gvDataBind();
     }
     catch (Exception Ex)
     {
         ClientScript.RegisterStartupScript(this.GetType(), "Save", "alert('����ʧ�ܣ�" + Ex.Message + "');", true);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<RoleInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< RoleInfo> list = new List< RoleInfo>();

            Query q = Role .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            RoleCollection  collection=new  RoleCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Role  role  in collection)
            {
                RoleInfo roleInfo = new RoleInfo();
                LoadFromDAL(roleInfo,   role);
                list.Add(roleInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Esempio n. 5
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<RoleInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< RoleInfo>;
     }
     else
     {
         List< RoleInfo>  list =new List< RoleInfo>();
         RoleCollection  collection=new  RoleCollection();
         Query qry = new Query(Role.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Role role in collection)
         {
             RoleInfo roleInfo= new RoleInfo();
             LoadFromDAL(roleInfo,role);
             list.Add(roleInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(RoleInfo pRoleInfoFrom, RoleInfo pRoleInfoTo)
 {
     pRoleInfoTo.RoleId = pRoleInfoFrom.roleId;
      		pRoleInfoTo.RoleName = pRoleInfoFrom.roleName;
     pRoleInfoTo.Loaded=pRoleInfoFrom.Loaded;
 }
Esempio n. 7
0
 public object SaveRoleInfo(RoleInfo roleInfo)
 {
     roleInfo.Save();
     return roleInfo . RoleId;
 }
Esempio n. 8
0
 //从后台获取数据
 internal static void  LoadFromDAL(RoleInfo pRoleInfo, Role pRole)
 {
     pRoleInfo.roleId   = pRole.RoleId;
     pRoleInfo.roleName = pRole.RoleName;
     pRoleInfo.Loaded   = true;
 }
Esempio n. 9
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< RoleInfo> pList, RoleCollection pCollection)
 {
     foreach (Role role in pCollection)
     {
         RoleInfo roleInfo = new RoleInfo();
         LoadFromDAL(roleInfo, role );
         pList.Add(roleInfo);
     }
 }
Esempio n. 10
0
 public object  SaveRoleInfo(RoleInfo roleInfo)
 {
     roleInfo.Save();
     return(roleInfo.RoleId);
 }
Esempio n. 11
0
 public List <RoleInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(RoleInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Esempio n. 12
0
 public List <RoleInfo> GetRoleInfoList()
 {
     return(RoleInfo.GetList());
 }
Esempio n. 13
0
        public void DeleteById(RoleInfo pRoleInfo)
        {
            RoleInfo roleInfo = new RoleInfo(pRoleInfo.RoleId);

            roleInfo.Delete();
        }
Esempio n. 14
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(RoleInfo pRoleInfoTo)
 {
     Copy(this, pRoleInfoTo);
 }
Esempio n. 15
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(RoleInfo pRoleInfoTo)
 {
     Copy(this,  pRoleInfoTo);
 }
Esempio n. 16
0
 //从后台获取数据
 internal static void LoadFromDAL(RoleInfo pRoleInfo, Role  pRole)
 {
     pRoleInfo.roleId = pRole.RoleId;
      		pRoleInfo.roleName = pRole.RoleName;
     pRoleInfo.Loaded=true;
 }
Esempio n. 17
0
 public void DeleteById(RoleInfo pRoleInfo)
 {
     RoleInfo roleInfo = new RoleInfo(pRoleInfo.RoleId);
     roleInfo.Delete();
 }
Esempio n. 18
0
 //数据持久化
 internal static void SaveToDb(RoleInfo pRoleInfo, Role  pRole,bool pIsNew)
 {
     pRole.RoleId = pRoleInfo.roleId;
      		pRole.RoleName = pRoleInfo.roleName;
     pRole.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pRole.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(RoleInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pRoleInfo.roleId = pRole.RoleId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(RoleInfo)))
     {
         ResetCache();
     }
 }
Esempio n. 19
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(RoleInfo pRoleInfoFrom, RoleInfo pRoleInfoTo)
 {
     pRoleInfoTo.RoleId   = pRoleInfoFrom.roleId;
     pRoleInfoTo.RoleName = pRoleInfoFrom.roleName;
     pRoleInfoTo.Loaded   = pRoleInfoFrom.Loaded;
 }