예제 #1
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 <BusinessExpInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <BusinessExpInfo> list = new List <BusinessExpInfo>();

            Query q = BusinessExp.CreateQuery();

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

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (BusinessExp businessExp  in collection)
            {
                BusinessExpInfo businessExpInfo = new BusinessExpInfo();
                LoadFromDAL(businessExpInfo, businessExp);
                list.Add(businessExpInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
예제 #2
0
 //从后台获取数据
 internal static void  LoadFromDAL(BusinessExpInfo pBusinessExpInfo, BusinessExp pBusinessExp)
 {
     pBusinessExpInfo.businessExpId     = pBusinessExp.BusinessExpId;
     pBusinessExpInfo.mainBusinessExpId = pBusinessExp.MainBusinessExpId;
     pBusinessExpInfo.sheetNum          = pBusinessExp.SheetNum;
     pBusinessExpInfo.applyPeople       = pBusinessExp.ApplyPeople;
     pBusinessExpInfo.depart            = pBusinessExp.Depart;
     pBusinessExpInfo.memo              = pBusinessExp.Memo;
     pBusinessExpInfo.employee1Id       = pBusinessExp.Employee1Id;
     pBusinessExpInfo.employee2Id       = pBusinessExp.Employee2Id;
     pBusinessExpInfo.reasonExp         = pBusinessExp.ReasonExp;
     pBusinessExpInfo.applyDate         = pBusinessExp.ApplyDate;
     pBusinessExpInfo.preIsApply        = pBusinessExp.PreIsApply;
     pBusinessExpInfo.isApprove         = pBusinessExp.IsApprove;
     pBusinessExpInfo.isApply           = pBusinessExp.IsApply;
     pBusinessExpInfo.isApply1          = pBusinessExp.IsApply1;
     pBusinessExpInfo.isApply2          = pBusinessExp.IsApply2;
     pBusinessExpInfo.preIsOver         = pBusinessExp.PreIsOver;
     pBusinessExpInfo.isOver1           = pBusinessExp.IsOver1;
     pBusinessExpInfo.isOver2           = pBusinessExp.IsOver2;
     pBusinessExpInfo.preApplyTime      = pBusinessExp.PreApplyTime;
     pBusinessExpInfo.approveTime       = pBusinessExp.ApproveTime;
     pBusinessExpInfo.applyTime         = pBusinessExp.ApplyTime;
     pBusinessExpInfo.apply1Time        = pBusinessExp.Apply1Time;
     pBusinessExpInfo.apply2Time        = pBusinessExp.Apply2Time;
     pBusinessExpInfo.preEmployeeId     = pBusinessExp.PreEmployeeId;
     pBusinessExpInfo.sendEmployeeId    = pBusinessExp.SendEmployeeId;
     pBusinessExpInfo.recvEmployeeId    = pBusinessExp.RecvEmployeeId;
     pBusinessExpInfo.recv1EmployeeId   = pBusinessExp.Recv1EmployeeId;
     pBusinessExpInfo.recv2EmployeeId   = pBusinessExp.Recv2EmployeeId;
     pBusinessExpInfo.sendEmployeeName  = pBusinessExp.SendEmployeeName;
     pBusinessExpInfo.recv1EmployeeName = pBusinessExp.Recv1EmployeeName;
     pBusinessExpInfo.recv2EmployeeName = pBusinessExp.Recv2EmployeeName;
     pBusinessExpInfo.preEmployeeName   = pBusinessExp.PreEmployeeName;
     pBusinessExpInfo.recvEmployeeName  = pBusinessExp.RecvEmployeeName;
     pBusinessExpInfo.isNewCreate       = pBusinessExp.IsNewCreate;
     pBusinessExpInfo.isMain            = pBusinessExp.IsMain;
     pBusinessExpInfo.isMain1           = pBusinessExp.IsMain1;
     pBusinessExpInfo.isMain2           = pBusinessExp.IsMain2;
     pBusinessExpInfo.isMain3           = pBusinessExp.IsMain3;
     pBusinessExpInfo.moneySum          = pBusinessExp.MoneySum;
     pBusinessExpInfo.today             = pBusinessExp.Today;
     pBusinessExpInfo.signName          = pBusinessExp.SignName;
     pBusinessExpInfo.item1             = pBusinessExp.Item1;
     pBusinessExpInfo.item2             = pBusinessExp.Item2;
     pBusinessExpInfo.item3             = pBusinessExp.Item3;
     pBusinessExpInfo.item4             = pBusinessExp.Item4;
     pBusinessExpInfo.money1            = pBusinessExp.Money1;
     pBusinessExpInfo.money2            = pBusinessExp.Money2;
     pBusinessExpInfo.money3            = pBusinessExp.Money3;
     pBusinessExpInfo.money4            = pBusinessExp.Money4;
     pBusinessExpInfo.Loaded            = true;
 }
예제 #3
0
 /// <summary>
 /// 保存
 /// </summary>
 public override void Save()
 {
     if (!m_Loaded)           //新增
     {
         BusinessExp businessExp = new BusinessExp();
         SaveToDb(this, businessExp, true);
     }
     else            //修改
     {
         BusinessExp businessExp = new BusinessExp(businessExpId);
         if (businessExp.IsNew)
         {
             throw new AppException("该数据已经不存在了");
         }
         SaveToDb(this, businessExp, false);
     }
 }
예제 #4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns>是否成功</returns>
        public override void Delete()
        {
            if (!m_Loaded)
            {
                throw new AppException("尚未初始化");
            }
            bool result = (BusinessExp.Delete(BusinessExpId) == 1);

            //更新缓存
            if (result && CachedEntityCommander.IsTypeRegistered(typeof(BusinessExpInfo)))
            {
                ResetCache();
            }
            if (!result)
            {
                throw new AppException("删除失败,数据可能被删除");
            }
        }
예제 #5
0
 private void LoadFromId(int businessExpId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(BusinessExpInfo)))
     {
         BusinessExpInfo businessExpInfo = Find(GetList(), businessExpId);
         if (businessExpInfo == null)
         {
             throw new AppException("未能在缓存中找到相应的键值对象");
         }
         Copy(businessExpInfo, this);
     }
     else
     {
         BusinessExp businessExp = new BusinessExp(businessExpId);
         if (businessExp.IsNew)
         {
             throw new AppException("尚未初始化");
         }
         LoadFromDAL(this, businessExp);
     }
 }
예제 #6
0
 /// <summary>
 /// 保存
 /// </summary>
 public override void Save()
 {
     if(!m_Loaded)//新增
     {
         BusinessExp businessExp=new BusinessExp();
         SaveToDb(this, businessExp,true);
     }
     else//修改
     {
         BusinessExp businessExp=new BusinessExp(businessExpId);
         if(businessExp.IsNew)
             throw new AppException("该数据已经不存在了");
         SaveToDb(this, businessExp,false);
     }
 }
예제 #7
0
 private void LoadFromId(int businessExpId)
 {
     if (CachedEntityCommander.IsTypeRegistered(typeof(BusinessExpInfo)))
     {
         BusinessExpInfo businessExpInfo=Find(GetList(), businessExpId);
         if(businessExpInfo==null)
             throw new AppException("未能在缓存中找到相应的键值对象");
         Copy(businessExpInfo, this);
     }
     else
     {	BusinessExp businessExp=new BusinessExp( businessExpId);
         if(businessExp.IsNew)
         throw new AppException("尚未初始化");
        	LoadFromDAL(this, businessExp);
     }
 }
예제 #8
0
 //数据持久化
 internal static void SaveToDb(BusinessExpInfo pBusinessExpInfo, BusinessExp  pBusinessExp,bool pIsNew)
 {
     pBusinessExp.BusinessExpId = pBusinessExpInfo.businessExpId;
      		pBusinessExp.MainBusinessExpId = pBusinessExpInfo.mainBusinessExpId;
      		pBusinessExp.SheetNum = pBusinessExpInfo.sheetNum;
      		pBusinessExp.ApplyPeople = pBusinessExpInfo.applyPeople;
      		pBusinessExp.Depart = pBusinessExpInfo.depart;
      		pBusinessExp.Memo = pBusinessExpInfo.memo;
      		pBusinessExp.Employee1Id = pBusinessExpInfo.employee1Id;
      		pBusinessExp.Employee2Id = pBusinessExpInfo.employee2Id;
      		pBusinessExp.ReasonExp = pBusinessExpInfo.reasonExp;
      		pBusinessExp.ApplyDate = pBusinessExpInfo.applyDate;
      		pBusinessExp.PreIsApply = pBusinessExpInfo.preIsApply;
      		pBusinessExp.IsApprove = pBusinessExpInfo.isApprove;
      		pBusinessExp.IsApply = pBusinessExpInfo.isApply;
      		pBusinessExp.IsApply1 = pBusinessExpInfo.isApply1;
      		pBusinessExp.IsApply2 = pBusinessExpInfo.isApply2;
      		pBusinessExp.PreIsOver = pBusinessExpInfo.preIsOver;
      		pBusinessExp.IsOver1 = pBusinessExpInfo.isOver1;
      		pBusinessExp.IsOver2 = pBusinessExpInfo.isOver2;
      		pBusinessExp.PreApplyTime = pBusinessExpInfo.preApplyTime;
      		pBusinessExp.ApproveTime = pBusinessExpInfo.approveTime;
      		pBusinessExp.ApplyTime = pBusinessExpInfo.applyTime;
      		pBusinessExp.Apply1Time = pBusinessExpInfo.apply1Time;
      		pBusinessExp.Apply2Time = pBusinessExpInfo.apply2Time;
      		pBusinessExp.PreEmployeeId = pBusinessExpInfo.preEmployeeId;
      		pBusinessExp.SendEmployeeId = pBusinessExpInfo.sendEmployeeId;
      		pBusinessExp.RecvEmployeeId = pBusinessExpInfo.recvEmployeeId;
      		pBusinessExp.Recv1EmployeeId = pBusinessExpInfo.recv1EmployeeId;
      		pBusinessExp.Recv2EmployeeId = pBusinessExpInfo.recv2EmployeeId;
      		pBusinessExp.SendEmployeeName = pBusinessExpInfo.sendEmployeeName;
      		pBusinessExp.Recv1EmployeeName = pBusinessExpInfo.recv1EmployeeName;
      		pBusinessExp.Recv2EmployeeName = pBusinessExpInfo.recv2EmployeeName;
      		pBusinessExp.PreEmployeeName = pBusinessExpInfo.preEmployeeName;
      		pBusinessExp.RecvEmployeeName = pBusinessExpInfo.recvEmployeeName;
      		pBusinessExp.IsNewCreate = pBusinessExpInfo.isNewCreate;
      		pBusinessExp.IsMain = pBusinessExpInfo.isMain;
      		pBusinessExp.IsMain1 = pBusinessExpInfo.isMain1;
      		pBusinessExp.IsMain2 = pBusinessExpInfo.isMain2;
      		pBusinessExp.IsMain3 = pBusinessExpInfo.isMain3;
      		pBusinessExp.MoneySum = pBusinessExpInfo.moneySum;
      		pBusinessExp.Today = pBusinessExpInfo.today;
      		pBusinessExp.SignName = pBusinessExpInfo.signName;
      		pBusinessExp.Item1 = pBusinessExpInfo.item1;
      		pBusinessExp.Item2 = pBusinessExpInfo.item2;
      		pBusinessExp.Item3 = pBusinessExpInfo.item3;
      		pBusinessExp.Item4 = pBusinessExpInfo.item4;
      		pBusinessExp.Money1 = pBusinessExpInfo.money1;
      		pBusinessExp.Money2 = pBusinessExpInfo.money2;
      		pBusinessExp.Money3 = pBusinessExpInfo.money3;
      		pBusinessExp.Money4 = pBusinessExpInfo.money4;
     pBusinessExp.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pBusinessExp.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(BusinessExpInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pBusinessExpInfo.businessExpId = pBusinessExp.BusinessExpId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(BusinessExpInfo)))
     {
         ResetCache();
     }
 }
예제 #9
0
 //从后台获取数据
 internal static void LoadFromDAL(BusinessExpInfo pBusinessExpInfo, BusinessExp  pBusinessExp)
 {
     pBusinessExpInfo.businessExpId = pBusinessExp.BusinessExpId;
      		pBusinessExpInfo.mainBusinessExpId = pBusinessExp.MainBusinessExpId;
      		pBusinessExpInfo.sheetNum = pBusinessExp.SheetNum;
      		pBusinessExpInfo.applyPeople = pBusinessExp.ApplyPeople;
      		pBusinessExpInfo.depart = pBusinessExp.Depart;
      		pBusinessExpInfo.memo = pBusinessExp.Memo;
      		pBusinessExpInfo.employee1Id = pBusinessExp.Employee1Id;
      		pBusinessExpInfo.employee2Id = pBusinessExp.Employee2Id;
      		pBusinessExpInfo.reasonExp = pBusinessExp.ReasonExp;
      		pBusinessExpInfo.applyDate = pBusinessExp.ApplyDate;
      		pBusinessExpInfo.preIsApply = pBusinessExp.PreIsApply;
      		pBusinessExpInfo.isApprove = pBusinessExp.IsApprove;
      		pBusinessExpInfo.isApply = pBusinessExp.IsApply;
      		pBusinessExpInfo.isApply1 = pBusinessExp.IsApply1;
      		pBusinessExpInfo.isApply2 = pBusinessExp.IsApply2;
      		pBusinessExpInfo.preIsOver = pBusinessExp.PreIsOver;
      		pBusinessExpInfo.isOver1 = pBusinessExp.IsOver1;
      		pBusinessExpInfo.isOver2 = pBusinessExp.IsOver2;
      		pBusinessExpInfo.preApplyTime = pBusinessExp.PreApplyTime;
      		pBusinessExpInfo.approveTime = pBusinessExp.ApproveTime;
      		pBusinessExpInfo.applyTime = pBusinessExp.ApplyTime;
      		pBusinessExpInfo.apply1Time = pBusinessExp.Apply1Time;
      		pBusinessExpInfo.apply2Time = pBusinessExp.Apply2Time;
      		pBusinessExpInfo.preEmployeeId = pBusinessExp.PreEmployeeId;
      		pBusinessExpInfo.sendEmployeeId = pBusinessExp.SendEmployeeId;
      		pBusinessExpInfo.recvEmployeeId = pBusinessExp.RecvEmployeeId;
      		pBusinessExpInfo.recv1EmployeeId = pBusinessExp.Recv1EmployeeId;
      		pBusinessExpInfo.recv2EmployeeId = pBusinessExp.Recv2EmployeeId;
      		pBusinessExpInfo.sendEmployeeName = pBusinessExp.SendEmployeeName;
      		pBusinessExpInfo.recv1EmployeeName = pBusinessExp.Recv1EmployeeName;
      		pBusinessExpInfo.recv2EmployeeName = pBusinessExp.Recv2EmployeeName;
      		pBusinessExpInfo.preEmployeeName = pBusinessExp.PreEmployeeName;
      		pBusinessExpInfo.recvEmployeeName = pBusinessExp.RecvEmployeeName;
      		pBusinessExpInfo.isNewCreate = pBusinessExp.IsNewCreate;
      		pBusinessExpInfo.isMain = pBusinessExp.IsMain;
      		pBusinessExpInfo.isMain1 = pBusinessExp.IsMain1;
      		pBusinessExpInfo.isMain2 = pBusinessExp.IsMain2;
      		pBusinessExpInfo.isMain3 = pBusinessExp.IsMain3;
      		pBusinessExpInfo.moneySum = pBusinessExp.MoneySum;
      		pBusinessExpInfo.today = pBusinessExp.Today;
      		pBusinessExpInfo.signName = pBusinessExp.SignName;
      		pBusinessExpInfo.item1 = pBusinessExp.Item1;
      		pBusinessExpInfo.item2 = pBusinessExp.Item2;
      		pBusinessExpInfo.item3 = pBusinessExp.Item3;
      		pBusinessExpInfo.item4 = pBusinessExp.Item4;
      		pBusinessExpInfo.money1 = pBusinessExp.Money1;
      		pBusinessExpInfo.money2 = pBusinessExp.Money2;
      		pBusinessExpInfo.money3 = pBusinessExp.Money3;
      		pBusinessExpInfo.money4 = pBusinessExp.Money4;
     pBusinessExpInfo.Loaded=true;
 }
예제 #10
0
 public static void DelBExp(int businessid)
 {
     BusinessExp.Delete(businessid);
 }
예제 #11
0
        //数据持久化
        internal static void  SaveToDb(BusinessExpInfo pBusinessExpInfo, BusinessExp pBusinessExp, bool pIsNew)
        {
            pBusinessExp.BusinessExpId     = pBusinessExpInfo.businessExpId;
            pBusinessExp.MainBusinessExpId = pBusinessExpInfo.mainBusinessExpId;
            pBusinessExp.SheetNum          = pBusinessExpInfo.sheetNum;
            pBusinessExp.ApplyPeople       = pBusinessExpInfo.applyPeople;
            pBusinessExp.Depart            = pBusinessExpInfo.depart;
            pBusinessExp.Memo              = pBusinessExpInfo.memo;
            pBusinessExp.Employee1Id       = pBusinessExpInfo.employee1Id;
            pBusinessExp.Employee2Id       = pBusinessExpInfo.employee2Id;
            pBusinessExp.ReasonExp         = pBusinessExpInfo.reasonExp;
            pBusinessExp.ApplyDate         = pBusinessExpInfo.applyDate;
            pBusinessExp.PreIsApply        = pBusinessExpInfo.preIsApply;
            pBusinessExp.IsApprove         = pBusinessExpInfo.isApprove;
            pBusinessExp.IsApply           = pBusinessExpInfo.isApply;
            pBusinessExp.IsApply1          = pBusinessExpInfo.isApply1;
            pBusinessExp.IsApply2          = pBusinessExpInfo.isApply2;
            pBusinessExp.PreIsOver         = pBusinessExpInfo.preIsOver;
            pBusinessExp.IsOver1           = pBusinessExpInfo.isOver1;
            pBusinessExp.IsOver2           = pBusinessExpInfo.isOver2;
            pBusinessExp.PreApplyTime      = pBusinessExpInfo.preApplyTime;
            pBusinessExp.ApproveTime       = pBusinessExpInfo.approveTime;
            pBusinessExp.ApplyTime         = pBusinessExpInfo.applyTime;
            pBusinessExp.Apply1Time        = pBusinessExpInfo.apply1Time;
            pBusinessExp.Apply2Time        = pBusinessExpInfo.apply2Time;
            pBusinessExp.PreEmployeeId     = pBusinessExpInfo.preEmployeeId;
            pBusinessExp.SendEmployeeId    = pBusinessExpInfo.sendEmployeeId;
            pBusinessExp.RecvEmployeeId    = pBusinessExpInfo.recvEmployeeId;
            pBusinessExp.Recv1EmployeeId   = pBusinessExpInfo.recv1EmployeeId;
            pBusinessExp.Recv2EmployeeId   = pBusinessExpInfo.recv2EmployeeId;
            pBusinessExp.SendEmployeeName  = pBusinessExpInfo.sendEmployeeName;
            pBusinessExp.Recv1EmployeeName = pBusinessExpInfo.recv1EmployeeName;
            pBusinessExp.Recv2EmployeeName = pBusinessExpInfo.recv2EmployeeName;
            pBusinessExp.PreEmployeeName   = pBusinessExpInfo.preEmployeeName;
            pBusinessExp.RecvEmployeeName  = pBusinessExpInfo.recvEmployeeName;
            pBusinessExp.IsNewCreate       = pBusinessExpInfo.isNewCreate;
            pBusinessExp.IsMain            = pBusinessExpInfo.isMain;
            pBusinessExp.IsMain1           = pBusinessExpInfo.isMain1;
            pBusinessExp.IsMain2           = pBusinessExpInfo.isMain2;
            pBusinessExp.IsMain3           = pBusinessExpInfo.isMain3;
            pBusinessExp.MoneySum          = pBusinessExpInfo.moneySum;
            pBusinessExp.Today             = pBusinessExpInfo.today;
            pBusinessExp.SignName          = pBusinessExpInfo.signName;
            pBusinessExp.Item1             = pBusinessExpInfo.item1;
            pBusinessExp.Item2             = pBusinessExpInfo.item2;
            pBusinessExp.Item3             = pBusinessExpInfo.item3;
            pBusinessExp.Item4             = pBusinessExpInfo.item4;
            pBusinessExp.Money1            = pBusinessExpInfo.money1;
            pBusinessExp.Money2            = pBusinessExpInfo.money2;
            pBusinessExp.Money3            = pBusinessExpInfo.money3;
            pBusinessExp.Money4            = pBusinessExpInfo.money4;
            pBusinessExp.IsNew             = pIsNew;
            string UserName = SubsonicHelper.GetUserName();

            try
            {
                pBusinessExp.Save(UserName);
            }
            catch (Exception ex)
            {
                LogManager.getInstance().getLogger(typeof(BusinessExpInfo)).Error(ex);
                if (ex.Message.Contains("插入重复键"))               //违反了唯一键
                {
                    throw new AppException("此对象已经存在");          //此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
                }
                throw new AppException("保存失败");
            }
            pBusinessExpInfo.businessExpId = pBusinessExp.BusinessExpId;
            //如果缓存存在,更新缓存
            if (CachedEntityCommander.IsTypeRegistered(typeof(BusinessExpInfo)))
            {
                ResetCache();
            }
        }