Exemple #1
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(RelateBExpInfo pRelateBExpInfoFrom, RelateBExpInfo pRelateBExpInfoTo)
 {
     pRelateBExpInfoTo.RelateBExpId  = pRelateBExpInfoFrom.relateBExpId;
     pRelateBExpInfoTo.RelateId      = pRelateBExpInfoFrom.relateId;
     pRelateBExpInfoTo.BusinessExpId = pRelateBExpInfoFrom.businessExpId;
     pRelateBExpInfoTo.Loaded        = pRelateBExpInfoFrom.Loaded;
 }
Exemple #2
0
 //从后台获取数据
 internal static void  LoadFromDAL(RelateBExpInfo pRelateBExpInfo, RelateBExp pRelateBExp)
 {
     pRelateBExpInfo.relateBExpId  = pRelateBExp.RelateBExpId;
     pRelateBExpInfo.relateId      = pRelateBExp.RelateId;
     pRelateBExpInfo.businessExpId = pRelateBExp.BusinessExpId;
     pRelateBExpInfo.Loaded        = true;
 }
Exemple #3
0
        //数据持久化
        internal static void  SaveToDb(RelateBExpInfo pRelateBExpInfo, RelateBExp pRelateBExp, bool pIsNew)
        {
            pRelateBExp.RelateBExpId  = pRelateBExpInfo.relateBExpId;
            pRelateBExp.RelateId      = pRelateBExpInfo.relateId;
            pRelateBExp.BusinessExpId = pRelateBExpInfo.businessExpId;
            pRelateBExp.IsNew         = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pRelateBExp.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(RelateBExpInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pRelateBExpInfo.relateBExpId = pRelateBExp.RelateBExpId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)))
            {
                ResetCache();
            }
        }
Exemple #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 <RelateBExpInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <RelateBExpInfo> list = new List <RelateBExpInfo>();

            Query q = RelateBExp.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            RelateBExpCollection collection = new  RelateBExpCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (RelateBExp relateBExp  in collection)
            {
                RelateBExpInfo relateBExpInfo = new RelateBExpInfo();
                LoadFromDAL(relateBExpInfo, relateBExp);
                list.Add(relateBExpInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Exemple #5
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <RelateBExpInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <RelateBExpInfo>);
            }
            else
            {
                List <RelateBExpInfo> list       = new List <RelateBExpInfo>();
                RelateBExpCollection  collection = new  RelateBExpCollection();
                Query qry = new Query(RelateBExp.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (RelateBExp relateBExp in collection)
                {
                    RelateBExpInfo relateBExpInfo = new RelateBExpInfo();
                    LoadFromDAL(relateBExpInfo, relateBExp);
                    list.Add(relateBExpInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Exemple #6
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <RelateBExpInfo> pList, RelateBExpCollection pCollection)
 {
     foreach (RelateBExp relateBExp in pCollection)
     {
         RelateBExpInfo relateBExpInfo = new RelateBExpInfo();
         LoadFromDAL(relateBExpInfo, relateBExp);
         pList.Add(relateBExpInfo);
     }
 }
        public RelateBExpInfo GetRelateBExpInfoById(int RelateBExpId)
        {
            RelateBExpInfo relateBExpInfo  = null;//
            try
            {
                 relateBExpInfo = new RelateBExpInfo(RelateBExpId);

            }
            catch (AppException)
            {
                return null;
            }

            return  relateBExpInfo;
        }
        public RelateBExpInfo GetRelateBExpInfoById(int RelateBExpId)
        {
            RelateBExpInfo relateBExpInfo = null;             //

            try
            {
                relateBExpInfo = new RelateBExpInfo(RelateBExpId);
            }
            catch (AppException)
            {
                return(null);
            }

            return(relateBExpInfo);
        }
Exemple #9
0
 private void LoadFromId(int relateBExpId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)))
     {
         RelateBExpInfo relateBExpInfo = Find(GetList(), relateBExpId);
         if (relateBExpInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(relateBExpInfo, this);
     }
     else
     {
         RelateBExp relateBExp = new RelateBExp(relateBExpId);
         if (relateBExp.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, relateBExp);
     }
 }
Exemple #10
0
 protected void btnAddRelate_Click(object sender, EventArgs e)
 {
     if (ddlClient.SelectedValue.ToString() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ѡ��ͻ���');</script>");
     }
     if (ddlRelate.SelectedValue.ToString() == "")
     {
         Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('��ѡ����ϵ�ˣ�');</script>");
     }
     else
     {
         int bExpId = Convert.ToInt32(Request["BusinessExpId"].ToString());
         int RelateId = Convert.ToInt32(ddlRelate.SelectedValue);
         RelateBExpInfo rb = new RelateBExpInfo();
         rb.RelateId = RelateId;
         rb.BusinessExpId = bExpId;
         rb.Save();
         gvRelateDataBind();
         NumOfPeople();
     }
 }
Exemple #11
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(RelateBExpInfo pRelateBExpInfoTo)
 {
     Copy(this, pRelateBExpInfoTo);
 }
Exemple #12
0
 /// <summary>
 /// 复制一个对象,采用硬编码的方式,避免反射的低效
 /// </summary>
 /// <param name="pIndustryTypeInfoFrom"></param>
 /// <param name="pIndustryTypeInfoTo"></param>
 public static void Copy(RelateBExpInfo pRelateBExpInfoFrom, RelateBExpInfo pRelateBExpInfoTo)
 {
     pRelateBExpInfoTo.RelateBExpId = pRelateBExpInfoFrom.relateBExpId;
      		pRelateBExpInfoTo.RelateId = pRelateBExpInfoFrom.relateId;
      		pRelateBExpInfoTo.BusinessExpId = pRelateBExpInfoFrom.businessExpId;
     pRelateBExpInfoTo.Loaded=pRelateBExpInfoFrom.Loaded;
 }
 public object SaveRelateBExpInfo(RelateBExpInfo relateBExpInfo)
 {
     relateBExpInfo.Save();
     return relateBExpInfo . RelateBExpId;
 }
Exemple #14
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<RelateBExpInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< RelateBExpInfo> list = new List< RelateBExpInfo>();

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

            foreach (RelateBExp  relateBExp  in collection)
            {
                RelateBExpInfo relateBExpInfo = new RelateBExpInfo();
                LoadFromDAL(relateBExpInfo,   relateBExp);
                list.Add(relateBExpInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Exemple #15
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<RelateBExpInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< RelateBExpInfo>;
     }
     else
     {
         List< RelateBExpInfo>  list =new List< RelateBExpInfo>();
         RelateBExpCollection  collection=new  RelateBExpCollection();
         Query qry = new Query(RelateBExp.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(RelateBExp relateBExp in collection)
         {
             RelateBExpInfo relateBExpInfo= new RelateBExpInfo();
             LoadFromDAL(relateBExpInfo,relateBExp);
             list.Add(relateBExpInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }
Exemple #16
0
 //从后台获取数据
 internal static void LoadFromDAL(RelateBExpInfo pRelateBExpInfo, RelateBExp  pRelateBExp)
 {
     pRelateBExpInfo.relateBExpId = pRelateBExp.RelateBExpId;
      		pRelateBExpInfo.relateId = pRelateBExp.RelateId;
      		pRelateBExpInfo.businessExpId = pRelateBExp.BusinessExpId;
     pRelateBExpInfo.Loaded=true;
 }
Exemple #17
0
 /// <summary>
 /// 复制为另一个对象
 /// </summary>
 /// <param name="pIndustryTypeInfoTo"></param>
 public void CopyTo(RelateBExpInfo pRelateBExpInfoTo)
 {
     Copy(this,  pRelateBExpInfoTo);
 }
 public object  SaveRelateBExpInfo(RelateBExpInfo relateBExpInfo)
 {
     relateBExpInfo.Save();
     return(relateBExpInfo.RelateBExpId);
 }
 public List <RelateBExpInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(RelateBExpInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Exemple #20
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< RelateBExpInfo> pList, RelateBExpCollection pCollection)
 {
     foreach (RelateBExp relateBExp in pCollection)
     {
         RelateBExpInfo relateBExpInfo = new RelateBExpInfo();
         LoadFromDAL(relateBExpInfo, relateBExp );
         pList.Add(relateBExpInfo);
     }
 }
Exemple #21
0
 //数据持久化
 internal static void SaveToDb(RelateBExpInfo pRelateBExpInfo, RelateBExp  pRelateBExp,bool pIsNew)
 {
     pRelateBExp.RelateBExpId = pRelateBExpInfo.relateBExpId;
      		pRelateBExp.RelateId = pRelateBExpInfo.relateId;
      		pRelateBExp.BusinessExpId = pRelateBExpInfo.businessExpId;
     pRelateBExp.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pRelateBExp.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(RelateBExpInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pRelateBExpInfo.relateBExpId = pRelateBExp.RelateBExpId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(RelateBExpInfo)))
     {
         ResetCache();
     }
 }
        public void DeleteById(RelateBExpInfo pRelateBExpInfo)
        {
            RelateBExpInfo relateBExpInfo = new RelateBExpInfo(pRelateBExpInfo.RelateBExpId);

            relateBExpInfo.Delete();
        }
 public List <RelateBExpInfo> GetRelateBExpInfoList()
 {
     return(RelateBExpInfo.GetList());
 }
 public void DeleteById(RelateBExpInfo pRelateBExpInfo)
 {
     RelateBExpInfo relateBExpInfo = new RelateBExpInfo(pRelateBExpInfo.RelateBExpId);
     relateBExpInfo.Delete();
 }