public accomodationInfo(Facility f)
 {
     CurrentAccomondation = null;
     InitializeComponent();
     db = new Database();
     CurrentFacility = f;
     showFacilityData();
 }
 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 void updateFacFeedback(Facility f, Customer c)
        {
            try
            {
                SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db");
                connection.Open();
                SQLiteCommand command = new SQLiteCommand(connection);

                string myEditQuery =
                    "UPDATE facility SET feedback='" + f.Feedback + "' WHERE fac_id=" + f.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, 9);

            }
            catch (Exception et)
            {
                Console.WriteLine(et.ToString());
            }
        }
        public Facility selectFacility(string fac_id, Customer c)
        {
            Facility ftemp = null;
            try
            {
                SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db");
                connection.Open();
                SQLiteCommand cmd = new SQLiteCommand("select * from facility where fac_id="+fac_id, connection);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                    while (reader.Read())
                    {
                        ftemp = new Facility(System.Convert.ToString(reader.GetInt32(reader.GetOrdinal("fac_id"))),
                            reader.GetString(reader.GetOrdinal("type")), reader.GetString(reader.GetOrdinal("name")),
                            reader.GetString(reader.GetOrdinal("adress_city")), reader.GetString(reader.GetOrdinal("adress_country")),
                            reader.GetString(reader.GetOrdinal("adress_postcode")), reader.GetString(reader.GetOrdinal("adress_street")),
                            reader.GetString(reader.GetOrdinal("adress_number")),
                            reader.GetString(reader.GetOrdinal("information")),
                            reader.GetString(reader.GetOrdinal("feedback")),
                            reader.GetString(reader.GetOrdinal("picture_url")));
                    }

                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, 5);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
            return ftemp;
        }
        //get the data about one facility out of the db and returns an Facility object
        public List<Facility> getFacility()
        {
            List<Facility> list = new List<Facility>();
            try
            {
                SQLiteConnection connection = new SQLiteConnection("Data Source=tourismus.db");
                connection.Open();
                SQLiteCommand cmd = new SQLiteCommand("select * from facility",connection);
                SQLiteDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                    while (reader.Read())
                    {
                        Facility ftemp = new Facility(System.Convert.ToString(reader.GetInt32(reader.GetOrdinal("fac_id"))),
                            reader.GetString(reader.GetOrdinal("type")), reader.GetString(reader.GetOrdinal("name")),
                            reader.GetString(reader.GetOrdinal("adress_city")), reader.GetString(reader.GetOrdinal("adress_country")),
                            reader.GetString(reader.GetOrdinal("adress_postcode")), reader.GetString(reader.GetOrdinal("adress_street")),
                            reader.GetString(reader.GetOrdinal("adress_number")),
                            reader.GetString(reader.GetOrdinal("information")),
                            reader.GetString(reader.GetOrdinal("feedback")),
                            reader.GetString(reader.GetOrdinal("picture_url")));
                        list.Add(ftemp);
                    }

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