Beispiel #1
0
        private void UpdateHourlyReservation()
        {
            reservation_hourly = new List <Reservation_Hourly>();

            OleDbConnection cn  = new OleDbConnection();   //Connection
            OleDbCommand    cmd = new OleDbCommand();      //Command
            OleDbDataReader dr;

            String path = Assembly.GetExecutingAssembly().Location;

            path = path.Replace("bin\\Debug\\ICTProjectPOS.exe", "RestaurantDB.accdb");
            String connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", path);

            cn.ConnectionString = @connectionString;
            cmd.Connection      = cn;

            try
            {
                cmd.CommandText = "SELECT * FROM Reservation WHERE ResDate = @date AND ResTime = @time";

                cmd.Parameters.AddWithValue("@date", _date);
                cmd.Parameters.AddWithValue("@time", _time);

                cn.Open();
                dr = cmd.ExecuteReader();


                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Reservation_Hourly res = new Reservation_Hourly(Int32.Parse(dr[0].ToString()), Int32.Parse(dr[6].ToString()));
                        reservation_hourly.Add(res);
                    }
                }

                cn.Close();
            }
            catch
            {
                // empty
            }
        }
        private void UpdateHourlyReservation()
        {
            reservation_hourly = new List<Reservation_Hourly>();

            OleDbConnection cn = new OleDbConnection();    //Connection
            OleDbCommand cmd = new OleDbCommand();         //Command
            OleDbDataReader dr;

            String path = Assembly.GetExecutingAssembly().Location;
            path = path.Replace("bin\\Debug\\ICTProjectPOS.exe", "RestaurantDB.accdb");
            String connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}", path);

            cn.ConnectionString = @connectionString;
            cmd.Connection = cn;

            try
            {
                cmd.CommandText = "SELECT * FROM Reservation WHERE ResDate = @date AND ResTime = @time";

                cmd.Parameters.AddWithValue("@date", _date);
                cmd.Parameters.AddWithValue("@time", _time);

                cn.Open();
                dr = cmd.ExecuteReader();


                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Reservation_Hourly res = new Reservation_Hourly(Int32.Parse(dr[0].ToString()), Int32.Parse(dr[6].ToString()));
                        reservation_hourly.Add(res);
                    }
                }

                cn.Close();

            }
            catch
            {
                // empty
            }

        }