Exemple #1
0
        /// <summary>
        /// Get ParkingList from Parking Table With specific Building Number and Level
        /// </summary>
        /// <param name="connStr"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public List <Parking> getParkingList(string connStr, Object obj)
        {
            ShowParking sp = (ShowParking)obj;

            List <Parking> parkingList = new List <Parking>();
            SqlConnection  conn        = new SqlConnection(connStr);

            using (conn)
            {
                conn.Open();
                string     queryStr = "Select * From Parking  Where (BuildingNumber=@BuildingNumber And ParkingLevel=@ParkingLevel) Order By AsielNo";
                SqlCommand comm     = new SqlCommand(queryStr, conn);
                comm.Parameters.AddWithValue("@BuildingNumber", sp.Selectedbuilding);
                comm.Parameters.AddWithValue("@ParkingLevel", sp.Selectedlevel);
                using (SqlDataReader reader = comm.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Parking p = new Parking();
                        p.ParkingNumber  = reader.GetString(0);
                        p.Level          = reader.GetInt32(reader.GetOrdinal("ParkingLevel")).ToString();
                        p.BuildingNumber = reader.GetInt32(reader.GetOrdinal("BuildingNumber")).ToString();
                        p.Asiel          = reader.GetString(3);
                        p.Price          = reader.GetInt32(4);
                        parkingList.Add(p);
                    }
                }
                conn.Close();
            }
            return(parkingList);
        }
Exemple #2
0
        /// <summary>
        /// Get the resrved Parkings From reservation Table which are not Expired
        /// </summary>
        /// <param name="conStr"></param>
        /// <param name="sp"></param>
        /// <returns></returns>
        public List <ShowParking> getParkingFromReservation(string conStr, ShowParking sp)
        {
            List <ShowParking> ListOfReservedParking = new List <ShowParking>();
            SqlConnection      con = new SqlConnection(conStr);

            using (con)
            {
                con.Open();
                Boolean    expired   = true;
                string     querryStr = "Select DateIn,DateOut,TimeIn,TimeOut,ParkingID from Reservations Where IsExpired!=@expired And(BuildingNumber=@BuildingNumber And LevelNumber=@LevelNumber)";
                SqlCommand comm      = new SqlCommand(querryStr, con);
                comm.Parameters.AddWithValue("@expired", expired);
                comm.Parameters.AddWithValue("@BuildingNumber", sp.Selectedbuilding);
                comm.Parameters.AddWithValue("@LevelNumber", sp.Selectedlevel);
                using (SqlDataReader reader = comm.ExecuteReader()) {
                    while (reader.Read())
                    {
                        ShowParking p = new ShowParking();
                        p.DateIn    = reader.GetDateTime(0);
                        p.DateOut   = reader.GetDateTime(1);
                        p.TimeIn    = reader.GetDateTime(2);
                        p.TimeOut   = reader.GetDateTime(3);
                        p.ParkingID = reader.GetString(9);
                        ListOfReservedParking.Add(p);
                    }
                }
            }
            return(ListOfReservedParking);
        }