Пример #1
0
        public IList<CY.GFive.Core.Business.RoomInfo> Search(string type, string keyword)
        {
            IList<Core.Business.RoomInfo> listRoomInfo = new List<Core.Business.RoomInfo>();
            SqlServerUtility sqlhelper = new SqlServerUtility();
            SqlDataReader reader;
            if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
            {
                sqlhelper.AddParameter("@KeyWord", SqlDbType.VarChar, keyword.Trim(), 50);
            }

            if (!string.IsNullOrEmpty(keyword) && (keyword.Trim() != ""))
            {
                if (type == "RoomCode")
                {
                    reader = sqlhelper.ExecuteSqlReader(SqlSelectByRoomCode);
                }
                else if (type == "BuildingCode")
                {
                    reader = sqlhelper.ExecuteSqlReader(SqlSelectByBuildingCode);
                }
                else if (type == "RoomNum")
                {
                    reader = sqlhelper.ExecuteSqlReader(SqlSelectByRoomNum);
                }
                else
                {
                    reader = sqlhelper.ExecuteSqlReader(SqlSelectByRoomState);
                }

            }
            else
            {
                reader = sqlhelper.ExecuteSqlReader(SqlGetAllRoomInfo);
            }

            if (reader != null && !reader.IsClosed)
            {
                while (reader.Read())
                {
                    RoomInfo ri = new RoomInfo();

                    if (!reader.IsDBNull(0)) ri.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) ri.RoomCode = reader.GetString(1);
                    if (!reader.IsDBNull(2)) ri.BuildingCode = reader.GetString(2);
                    if (!reader.IsDBNull(3)) ri.RoomNum = reader.GetString(3);
                    if (!reader.IsDBNull(4)) ri.TotalNum = reader.GetInt32(4);
                    //if (!reader.IsDBNull(5)) ri.ExistNum = reader.GetInt32(5);
                    //if (!reader.IsDBNull(6)) ri.AvailNum = reader.GetInt32(6);
                    if (!reader.IsDBNull(7)) ri.RoomState = reader.GetString(7);

                    ri.MarkOld();

                    listRoomInfo.Add(ri);
                }
                return listRoomInfo;
            }
            return null;
        }