public addFeedback(Accomodation currentAccomondation, Customer currentCust)
 {
     // TODO: Complete member initialization
     InitializeComponent();
     CurrentFacility = null;
     CurrentAccomondation = currentAccomondation;
     rtb_feedback.Text = CurrentAccomondation.Feedback;
     CurrentCustomer = currentCust;
     Db = new Database();
 }
 public Details(Customer c, Accomodation a, DateTime start, DateTime end, string roomID)
 {
     InitializeComponent();
     CurrentCustomer = c;
     CurrentAccomodation = a;
     StartD = start;
     EndD = end;
     RoomID = roomID;
     Database = new Database();
     populateDetails();
 }
 public Bookings(Customer c, Accomodation a, int book_id, int acc_id, int room_id, int room_number, string start_date, string end_date)
 {
     C = c;
     A = a;
     Book_id = book_id;
     Acc_id = acc_id;
     Room_id = room_id;
     Room_number = room_number;
     Start_date = start_date;
     End_date = end_date;
 }
        public accomodationInfo(Customer c, Accomodation a)
        {
            InitializeComponent();
            CurrentCustomer = c;
            CurrentAccomondation = a;
            CurrentFacility = null;
            db = new Database();
            try
            {
                CurrentAccomondation = db.searchAccomodation(CurrentAccomondation.ID);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            showAccommodationData();
        }
        public bookingDetails(Accomodation a, Customer c)
        {
            InitializeComponent();
            startDateRoom = new List<DateTime>();
            endDateRoom = new List<DateTime>();
            roomId = new List<int>();
            rooms = new Dictionary<int, int>();
            CurrentCustomer = c;
            CurrentAccomodation = a;

            accommodation_id = a.ID;
            user_id = c.Custi_id;
            Database = new Database();
            dgv_bookings.ColumnCount = 2;
            dgv_bookings.Columns[0].Name = "Room ID";
            dgv_bookings.Columns[1].Name = "Room Number";
            dgv_bookings.Columns[0].Width = dgv_bookings.Width / 2 - 22;
            dgv_bookings.Columns[1].Width = dgv_bookings.Width / 2 - 21;
            l_hotelName_bd.Text = Database.getHotelNameDb(accommodation_id);
            dbDateCheck();
        }
        public void updateAccFeedback(Accomodation a, Customer c)
        {
            try
            {
                SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db");
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                string myEditQuery =
                    "UPDATE accommodations SET acco_feedback='" + a.Feedback + "' WHERE acc_id=" + a.ID;

                command.CommandText = myEditQuery;
                command.ExecuteNonQuery();
                connection.Close();

                // 1 = Account created +
                // 2 = Account updated +
                // 3 = Account deleted +
                // 4 = Aquired accommodation information
                // 5 = Aquired facility information +
                // 6 = Booked an accommodation +
                // 7 = Deleted a booking +
                // 8 = Gave feedback about accommodation +
                // 9 = Gave feedback about facility +
                // 10 = Start of session
                // 11 = End of session

                //log(string custname, int custId, int action)
                logger.log(c.Custi_id, 8);

            }
            catch (Exception et)
            {
                Console.WriteLine(et.ToString());
            }
        }
        public Accomodation searchAccomodation(string acc_id)
        {
            try
            {
                string accommodation_id = acc_id;
                Accomodation ac = null;
                SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db");
                connection.Open();

                SQLiteCommand cmd = new SQLiteCommand("select * from accommodations where acc_id =  " + accommodation_id, connection);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string name = reader.GetString(reader.GetOrdinal("acc_name"));
                        string adress_city = reader.GetString(reader.GetOrdinal("acc_adress_city"));
                        string adress_county = reader.GetString(reader.GetOrdinal("acc_adress_county"));
                        string adress_postcode = reader.GetString(reader.GetOrdinal("acc_adress_postcode"));
                        string adress_street = reader.GetString(reader.GetOrdinal("acc_adress_street"));
                        string adress_number = reader.GetString(reader.GetOrdinal("acc_adress_number"));
                        string description = reader.GetString(reader.GetOrdinal("acc_description"));
                        string picture_url = reader.GetString(reader.GetOrdinal("acc_picture_url"));
                        string feedback = reader.GetString(reader.GetOrdinal("acco_feedback"));
                        ac = new Accomodation(""+acc_id,name, adress_city, adress_county, adress_postcode, adress_street, adress_number, description,picture_url, feedback);
                    }

                }
                connection.Close();
                return ac;

            }
            catch (Exception et)
            {
                Console.WriteLine(et.ToString());
            }
            return null;
        }
        //returning all accommodations in a list
        public List<Accomodation> getAllAccommodations()
        {
            List<Accomodation> allAccommodationList = new List<Accomodation>();
            try
            {
                SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db");
                connection.Open();

                Accomodation ac = null;
                SQLiteCommand cmd = new SQLiteCommand("select * from accommodations", connection);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int acc_id = reader.GetInt32(reader.GetOrdinal("acc_id"));
                        string name = reader.GetString(reader.GetOrdinal("acc_name"));
                        string adress_city = reader.GetString(reader.GetOrdinal("acc_adress_city"));
                        string adress_county = reader.GetString(reader.GetOrdinal("acc_adress_county"));
                        string adress_postcode = reader.GetString(reader.GetOrdinal("acc_adress_postcode"));
                        string adress_street = reader.GetString(reader.GetOrdinal("acc_adress_street"));
                        string adress_number = reader.GetString(reader.GetOrdinal("acc_adress_number"));
                        string description = reader.GetString(reader.GetOrdinal("acc_description"));
                        string picture_url = reader.GetString(reader.GetOrdinal("acc_picture_url"));
                        string feedback = reader.GetString(reader.GetOrdinal("acco_feedback"));
                        ac = new Accomodation("" + acc_id, name, adress_city, adress_county, adress_postcode, adress_street, adress_number, description, picture_url,feedback);
                        allAccommodationList.Add(ac);
                    }

                }
                connection.Close();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
            return allAccommodationList;
        }