Example #1
0
        /// <summary>
        /// 根据条件获取在场来访
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public List <VisitorInfo> QueryPageIn(Entities.Condition.VisitorInfoCondition condition, int pagesize, int pageindex, out int total)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select a.*,c.UserName,b.EntranceTime,d.GateName,b.EntranceImage,b.EntranceCertificateImage from VisitorInfo a left join ParkIORecord  b on a.RecordID=b.VisitorID  ");
            strSql.Append(" left join SysUser c on b.EntranceOperatorID=c.RecordID  ");
            strSql.Append(" left join ParkGate d on b.EntranceGateID=d.GateID  ");
            strSql.Append(" where a.DataStatus!=2 and b.EntranceTime>=@StartTime and b.EntranceTime<=@EndTime and b.IsExit=0 ");
            if (!string.IsNullOrWhiteSpace(condition.PlateNumber))
            {
                strSql.Append(" and PlateNumber like @PlateNumber ");
            }

            if (!string.IsNullOrWhiteSpace(condition.VisitorName))
            {
                strSql.Append(" and VisitorName like @VisitorName ");
            }
            if (condition.VisitorState != 0)
            {
                strSql.Append(" and VisitorState = @VisitorState ");
            }

            if (!string.IsNullOrWhiteSpace(condition.VisitorMobilePhone))
            {
                strSql.Append(" and VisitorMobilePhone like @VisitorMobilePhone ");
            }

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                dbOperator.ClearParameters();
                dbOperator.AddParameter("StartTime", condition.StartTime);
                dbOperator.AddParameter("EndTime", condition.EndTime);
                if (!string.IsNullOrWhiteSpace(condition.PlateNumber))
                {
                    dbOperator.AddParameter("PlateNumber", "%" + condition.PlateNumber + "%");
                }
                if (!string.IsNullOrWhiteSpace(condition.VisitorName))
                {
                    dbOperator.AddParameter("VisitorName", "%" + condition.VisitorName + "%");
                }

                if (!string.IsNullOrWhiteSpace(condition.VisitorMobilePhone))
                {
                    dbOperator.AddParameter("VisitorMobilePhone", "%" + condition.VisitorMobilePhone + "%");
                }
                if (condition.VisitorState != -1)
                {
                    dbOperator.AddParameter("VisitorState", condition.VisitorState);
                }
                using (DbDataReader reader = dbOperator.Paging(strSql.ToString(), "CreateTime DESC", pageindex, pagesize, out total))
                {
                    List <VisitorInfo> models = new List <VisitorInfo>();
                    while (reader.Read())
                    {
                        models.Add(DataReaderToModel <VisitorInfo> .ToModel(reader));
                    }
                    return(models);
                }
            }
        }
Example #2
0
        public static List <VisitorInfo> QueryPageInOut(Entities.Condition.VisitorInfoCondition condition, int pagesize, int pageindex, out int total)
        {
            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }

            IParkVisitor factory = ParkVisitorFactory.GetFactory();

            return(factory.QueryPageInOut(condition, pagesize, pageindex, out total));
        }