Exemple #1
0
        /// <summary>
        /// Sends a movie struct into the database.
        /// </summary>
        public static void pushToDb(movie mt)
        {
            LocationsHandler loc = new LocationsHandler();

            int currWeek = loc.weekOfTheYear(),
                cinemaId = 0;

            bool isRightWeek = false;


            using (SQLiteCommand command = connection.CreateCommand()) {
                command.CommandText = "SELECT 'Mozi'.'Letrehozasi_het' FROM 'Mozi' WHERE 'Mozi'.'Nev'='" + mt.selectedCinemaName + "'";
                command.CommandType = CommandType.Text;
                SQLiteDataReader r = command.ExecuteReader();
                if (r.Read())
                {
                    if (currWeek >= int.Parse(r.GetValue(0).ToString()))
                    {
                        isRightWeek = true;
                    }
                }
                else
                {
                    MessageBox.Show("Anyukad");
                }
            }
            using (SQLiteCommand command = connection.CreateCommand()) {
                command.CommandText = "SELECT 'Mozi'.'ID' FROM 'Mozi' WHERE 'Mozi'.'Nev'='" + mt.selectedCinemaName + "'";
                command.CommandType = CommandType.Text;
                SQLiteDataReader r = command.ExecuteReader();
                if (r.Read())
                {
                    cinemaId = int.Parse(r.GetValue(0).ToString());
                }
                else
                {
                    MessageBox.Show("anyukad2");
                }
            }


            //ha a megfelelő hétbe jönnek az adatok, akkor mentsük el az adatbázisba az adatokat
            if (isRightWeek)
            {
                string        commandString = "insert into 'Filmek' ('F_Cim', 'Mufaj', 'Hossz', 'Korhatar', 'Vetitesi_het', 'Mozi_ID', 'Vetitesi_Nap', 'Vetitesi_Ido', 'Rendezo', 'Foszereplo') values ('" + mt.title + "', '" + mt.genres + "', '" + mt.playtime + "', '" + mt.ageRestriction + "', '" + currWeek + "', '" + cinemaId + "', '" + mt.ScreeningDate + "', '" + mt.ScreeningTime + "', '" + mt.producer + "', '" + mt.starring + "')";
                SQLiteCommand command       = new SQLiteCommand(commandString, connection);
                command.ExecuteNonQuery();


                MessageBox.Show("Sikeres feltöltés!");
            }
            else
            {
                MessageBox.Show("Nem a megfelelő hétre töltötte fel az adatokat.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a cinema based on the arguments. It checks if the name already exists.
        /// </summary>
        public static void createCinema(string county, string city, string street, string cinemaName, string maintainerName, string houseNumber, DateTime creationTime)
        {
            //mozit menti el, ha nem létezik még
            int count = 0;

            using (SQLiteCommand command = connection.CreateCommand()) {
                command.CommandText = "SELECT NEV FROM 'Mozi' WHERE 'Mozi'.'Nev'='" + cinemaName + "'";
                command.CommandType = CommandType.Text;
                SQLiteDataReader r = command.ExecuteReader();
                while (r.Read())
                {
                    count++;
                }
            }

            LocationsHandler locH = new LocationsHandler();

            if (count == 0)
            {
                string        command = "insert into 'Mozi' ('Megye', 'IrszVarKer', 'Utca', 'H_szam', 'Nev', 'Tulaj_Nev', 'Letrehozasi_het') values ('" + county + "', '" + city + "','" + street + "', '" + houseNumber + "', '" + cinemaName + "', '" + maintainerName + "', '" + locH.weekOfTheYear(creationTime) + "')";
                SQLiteCommand insert  = new SQLiteCommand(command, connection);
                insert.ExecuteNonQuery();
            }
            else
            {
                MessageBox.Show("Már létezik " + cinemaName + " nevű mozi az adatbázisban!");
            }
        }
Exemple #3
0
        /// <summary>
        /// Populate the database with default entries if it doesn't exist yet.
        /// </summary>
        static DB()
        {
            connection = new SQLiteConnection("Data Source=" + DatabasePath + "; version=3;");
            if (!File.Exists(DatabasePath))
            {
                SQLiteConnection.CreateFile(DatabasePath);
                connection.Open();

                string[] createTablesCommand =
                {
                    "create table 'Mozi' ( 'ID' INTEGER PRIMARY KEY, 'Megye' VARCHAR, 'IrszVarKer' VARCHAR, 'Utca' VARCHAR, 'H_szam' VARCHAR, 'Nev' VARCHAR, 'Tulaj_Nev' VARCHAR, 'Letrehozasi_het' INT )",
                    "create table 'Tulaj' ( 'Felhasznalo' VARCHAR, 'Jelszo' VARCHAR )",
                    "create table 'Filmek' ( 'F_Cim' VARCHAR, 'Mufaj' VARCHAR, 'Hossz' INTEGER, 'Korhatar' INTEGER, 'Vetitesi_het' INTEGER, 'Mozi_ID' INTEGER, 'Vetitesi_Nap' VARCHAR, 'Vetitesi_Ido' VARCHAR, 'Rendezo' VARCHAR, 'Foszereplo' VARCHAR)",

                    "insert into 'Tulaj' ('Felhasznalo', 'Jelszo') values ('Zoli', 'jelszo')",
                    "insert into 'Mozi' ('ID', 'Megye', 'IrszVarKer', 'Utca', 'H_szam', 'Nev', 'Tulaj_Nev', 'Letrehozasi_het') values ('0', 'Bács-Kiskun', '6000 Kecskemét', 'Szent János', '11/a', 'Zoli mozija', 'Zoli', '" + loc.weekOfTheYear() + "')",
                    "insert into 'Filmek' ('F_Cim', 'Mufaj', 'Hossz', 'Korhatar', 'Vetitesi_het', 'Mozi_ID', 'Vetitesi_Nap', 'Vetitesi_Ido', 'Rendezo', 'Foszereplo') values ('Suttogó', 'akció', '120', '12', '8', '0', '2020-08-20', '13:30', 'Nagy Zsiga', 'Brad Pitt')",
                };

                foreach (string item in createTablesCommand)
                {
                    SQLiteCommand prepDb = new SQLiteCommand(item, connection);
                    prepDb.ExecuteNonQuery();
                }
            }
            else
            {
                connection.Open();
            }
        }