Example #1
0
        /// <summary>
        /// 取得查詢結果資料
        /// </summary>
        /// <param name="vCreate_Date_From">入庫日期(起)</param>
        /// <param name="vCreate_Date_To">入庫日期(迄)</param>
        /// <param name="vTrea_Register_Id">金庫登記簿單號</param>
        /// <returns></returns>
        public List <TreasuryRegisterSearch> GetSearchList(string vCreate_Date_From, string vCreate_Date_To, string vTrea_Register_Id)
        {
            var      result = new List <TreasuryRegisterSearch>();
            DateTime DateFrom, DateTo;

            DateTime.TryParse(vCreate_Date_From, out DateFrom);
            if (DateTime.TryParse(vCreate_Date_To, out DateTo))
            {
                DateTo = DateTo.DateToLatestTime();
            }
            using (TreasuryDBEntities db = new TreasuryDBEntities())
            {
                var _Open_Trea_Type = db.SYS_CODE.AsNoTracking().Where(x => x.CODE_TYPE == "OPEN_TREA_TYPE").ToList();
                var _Regi_Status    = db.SYS_CODE.AsNoTracking().Where(x => x.CODE_TYPE == "FORM_STATUS").ToList();

                result = GetSearchModel(db.TREA_OPEN_REC.AsNoTracking()
                                        .Where(x => x.CREATE_DT >= DateFrom, !vCreate_Date_From.IsNullOrWhiteSpace())
                                        .Where(x => x.CREATE_DT <= DateTo, !vCreate_Date_To.IsNullOrWhiteSpace())
                                        .Where(x => x.TREA_REGISTER_ID == vTrea_Register_Id, !vTrea_Register_Id.IsNullOrWhiteSpace())
                                        .AsEnumerable()
                                        , _Open_Trea_Type, _Regi_Status).ToList();
            }

            return(result);
        }