private void check(int idFilmCheck)
        {
            bazaDanych bd = new bazaDanych();

            bd.openConn();
            MySqlDataAdapter adapterRezerwacja = new MySqlDataAdapter();
            DataTable        tableRezerwacja   = new DataTable();
            MySqlCommand     commandRezerwacja = new MySqlCommand("SELECT * FROM `Wypozyczone_filmy` WHERE `id_filmu`= @idFilm", bd.getConnection());

            commandRezerwacja.Parameters.Add("@idFilm", MySqlDbType.VarChar).Value = idFilmCheck;
            adapterRezerwacja.SelectCommand = commandRezerwacja;
            adapterRezerwacja.Fill(tableRezerwacja);



            if (tableRezerwacja.Rows.Count > 0)
            {
                button1.Visible         = false;
                labelZarezerwowane.Text = "Ten film jest zarezerwowany";
            }
            else
            {
                button1.Visible         = true;
                labelZarezerwowane.Text = "";
            }
            bd.closeConn();
        }
        private void buttonDodajWytwornie_Click(object sender, EventArgs e)
        {
            bazaDanych   bd      = new bazaDanych();
            MySqlCommand command = new MySqlCommand("INSERT INTO `Wytwornia`( `nazwa`, `kraj`) VALUES (@nazwa,@kraj)", bd.getConnection());

            command.Parameters.Add("@nazwa", MySqlDbType.VarChar).Value = wytworniaTextBox.Text;
            command.Parameters.Add("@kraj", MySqlDbType.VarChar).Value  = krajTextBox.Text;

            bd.openConn();
            if (!fieldsIsEmpty())
            {
                if (!wytworniaExist())
                {
                    if (command.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Udało się dodać wytwórnie filmową!");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
                else
                {
                    MessageBox.Show("Taka wytwórnia już istnieje");
                }
            }
            else
            {
                MessageBox.Show("Najpierw podaj wszystkie dane!");
            }
            bd.closeConn();
        }
Esempio n. 3
0
        public Boolean actorExist()
        {
            bazaDanych       bd        = new bazaDanych();
            String           nazwisko  = textBoxNazwisko.Text;
            String           imie      = imieTextBox.Text;
            String           wiek      = textBoxWiek.Text;
            DataTable        dataTable = new DataTable();
            MySqlDataAdapter adapter   = new MySqlDataAdapter();
            MySqlCommand     command   = new MySqlCommand("SELECT * FROM `Aktor` WHERE `imie` = @imie and `nazwisko` = @nazwisko and `wiek` = @wiek", bd.getConnection());

            command.Parameters.Add("@imie", MySqlDbType.VarChar).Value     = imie;
            command.Parameters.Add("@nazwisko", MySqlDbType.VarChar).Value = nazwisko;
            command.Parameters.Add("@wiek", MySqlDbType.VarChar).Value     = wiek;
            adapter.SelectCommand = command;
            adapter.Fill(dataTable);

            if (dataTable.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        private void buttonDodajAktora_Click(object sender, EventArgs e)
        {
            bazaDanych   bd      = new bazaDanych();
            MySqlCommand command = new MySqlCommand("INSERT INTO `Gatunek_filmu`( `gatunek`) VALUES (@gatunek)", bd.getConnection());

            command.Parameters.Add("@gatunek", MySqlDbType.VarChar).Value = textBoxGatunek.Text;


            bd.openConn();
            if (!fieldsIsEmpty())
            {
                if (!gatunekExist())
                {
                    if (command.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Udało się dodać gatunek filmu!");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
                else
                {
                    MessageBox.Show("Taki gatunek istnieje");
                }
            }
            else
            {
                MessageBox.Show("Najpierw podaj wszystkie dane!");
            }

            bd.closeConn();
        }
Esempio n. 5
0
        private void buttonDodajAktora_Click(object sender, EventArgs e)
        {
            String     film = comboBox1.Text.ToString();
            String     xxx;
            bazaDanych bd = new bazaDanych();

            bd.openConn();
            try
            {
                if (film != "")
                {
                    DataTable filmTable = new DataTable();

                    MySqlDataAdapter adapterFilm = new MySqlDataAdapter();
                    MySqlCommand     commandFilm = new MySqlCommand("SELECT * FROM `Film` WHERE `tytul` = @film", bd.getConnection());
                    commandFilm.Parameters.Add("@film", MySqlDbType.VarChar).Value = film;
                    adapterFilm.SelectCommand = commandFilm;
                    adapterFilm.Fill(filmTable);
                    var filmId = filmTable.Rows[0]["id_filmu"].ToString();



                    if (filmTable.Rows.Count > 0)
                    {
                        if (checkedListBox1.CheckedItems.Count > 0)
                        {
                            for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++)
                            {
                                xxx = checkedListBox1.CheckedItems[i].ToString();
                                MySqlCommand command = new MySqlCommand("INSERT INTO `Obsada` (`Id_obsady`,`id_aktor`,`id_film` ) VALUES (NULL,@id_aktor,@id_film)", bd.getConnection());
                                command.Parameters.Add("@id_aktor", MySqlDbType.VarChar).Value = xxx;
                                command.Parameters.Add("@id_film", MySqlDbType.VarChar).Value  = filmId;

                                if (command.ExecuteNonQuery() == 1)
                                {
                                }
                            }
                        }
                        MessageBox.Show("Dodano aktorów");
                        bd.closeConn();
                    }
                }
                else
                {
                    MessageBox.Show("Wybierz film");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 6
0
        public void buttonZaloguj_Click(object sender, EventArgs e)
        {
            bazaDanych bd    = new bazaDanych();
            String     login = textBoxLogin.Text;
            String     haslo = textBoxHaslo.Text;

            DataTable        dataTable = new DataTable();
            MySqlDataAdapter adapter   = new MySqlDataAdapter();
            MySqlCommand     command   = new MySqlCommand("SELECT * FROM `Login` WHERE `login` = @log and `haslo` = @haslo", bd.getConnection());

            command.Parameters.Add("@log", MySqlDbType.VarChar).Value   = login;
            command.Parameters.Add("@haslo", MySqlDbType.VarChar).Value = haslo;
            adapter.SelectCommand = command;
            adapter.Fill(dataTable);



            if (dataTable.Rows.Count > 0)
            {
                var upra     = dataTable.Rows[0]["uprawnienia"].ToString();
                var upraBool = bool.Parse(upra);
                var id       = dataTable.Rows[0]["id_uzytkownika"].ToString();


                if (upraBool == false)
                {
                    this.Hide();
                    zalogowanoUserForm user = new zalogowanoUserForm(id);
                    user.Show();
                }
                else if (upraBool == true)
                {
                    this.Hide();
                    zalogowanoAdminForm admin = new zalogowanoAdminForm();
                    admin.Show();
                }
            }
            else
            if (login.Trim().Equals(""))
            {
                MessageBox.Show("Podaj login");
            }
            else if (haslo.Trim().Equals(""))
            {
                MessageBox.Show("Podaj haslo");
            }
            else
            {
                MessageBox.Show("Błędny login lub hasło");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bazaDanych   bd      = new bazaDanych();
            MySqlCommand command = new MySqlCommand("INSERT INTO `Wypozyczone_filmy`( `id_uzytkownika`, `id_filmu`) VALUES (@id_uzytkownika,@id_filmu)", bd.getConnection());

            command.Parameters.Add("@id_uzytkownika", MySqlDbType.VarChar).Value = id;
            command.Parameters.Add("@id_filmu", MySqlDbType.VarChar).Value       = idFilmu;
            bd.openConn();
            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Film został zarezerwowany");
                ReloadForm();
            }
            bd.closeConn();
        }
        public void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                bazaDanych bd = new bazaDanych();
                bd.openConn();
                DataTable        filmTable   = new DataTable();
                MySqlDataAdapter adapter     = new MySqlDataAdapter();
                DataTable        table       = new DataTable();
                MySqlDataAdapter adapterFilm = new MySqlDataAdapter();
                MySqlCommand     commandFilm = new MySqlCommand("SELECT * FROM `Dodawanie_filmu` WHERE `tytul`= @tytul", bd.getConnection());
                commandFilm.Parameters.Add("@tytul", MySqlDbType.VarChar).Value = listBox1.SelectedItem.ToString();
                adapterFilm.SelectCommand = commandFilm;
                adapterFilm.Fill(filmTable);
                labelGatunek.Text  = filmTable.Rows[0]["gatunek"].ToString();
                labelOpis.Text     = filmTable.Rows[0]["opis_filmu"].ToString();
                labelTytuł.Text    = filmTable.Rows[0]["tytul"].ToString();
                labelPremiera.Text = filmTable.Rows[0]["premiera"].ToString();
                MySqlCommand command = new MySqlCommand("SELECT * FROM `Obsada_filmu` WHERE `id_film`= @id", bd.getConnection());
                command.Parameters.Add("@id", MySqlDbType.VarChar).Value = filmTable.Rows[0]["id_filmu"].ToString();
                adapter.SelectCommand = command;
                adapter.Fill(table);
                String aktorzy = "";
                this.idFilmu = filmTable.Rows[0]["id_filmu"].ToString();

                for (int i = 0; i < table.Rows.Count; i++)

                {
                    if (aktorzy == "")
                    {
                        aktorzy += table.Rows[i]["imie"].ToString() + " " + table.Rows[i]["nazwisko"].ToString();
                    }
                    else
                    {
                        aktorzy += ", " + table.Rows[i]["imie"].ToString() + " " + table.Rows[i]["nazwisko"].ToString();
                    }
                }
                labelObsada.Text = aktorzy;


                check(int.Parse(filmTable.Rows[0]["id_filmu"].ToString()));

                bd.closeConn();
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 9
0
        private void buttonZarejestruj_Click(object sender, EventArgs e)
        {
            bazaDanych   bd      = new bazaDanych();
            MySqlCommand command = new MySqlCommand("INSERT INTO `Uzytkownik`( `imie`, `nazwisko`, `login`, `haslo`, `email`) VALUES (@imie,@nazwisko,@login,@haslo,@email)", bd.getConnection());

            command.Parameters.Add("@imie", MySqlDbType.VarChar).Value     = textBoxImie.Text;
            command.Parameters.Add("@nazwisko", MySqlDbType.VarChar).Value = textBoxNazwisko.Text;
            command.Parameters.Add("@login", MySqlDbType.VarChar).Value    = textBoxLogin.Text;
            command.Parameters.Add("@haslo", MySqlDbType.VarChar).Value    = textBoxHaslo.Text;
            command.Parameters.Add("@email", MySqlDbType.VarChar).Value    = textBoxMail.Text;


            bd.openConn();
            if (!fieldsIsEmpty())
            {
                if (textBoxHaslo.Text.Equals(textBoxPowHaslo.Text))
                {
                    if (loginIsBusy())
                    {
                        MessageBox.Show("Login jest już zajęty");
                    }
                    else
                    {
                        if (command.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Udało się założyć konto!");
                        }
                        else
                        {
                            MessageBox.Show("Error");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Podane hasła nie są takie same");
                }
            }
            else
            {
                MessageBox.Show("Najpierw podaj wszystkie dane!");
            }
            bd.closeConn();
        }
Esempio n. 10
0
        public Boolean wytworniaExist()
        {
            bazaDanych       bd        = new bazaDanych();
            String           wytwornia = wytworniaTextBox.Text;
            DataTable        dataTable = new DataTable();
            MySqlDataAdapter adapter   = new MySqlDataAdapter();
            MySqlCommand     command   = new MySqlCommand("SELECT * FROM `Wytwornia` WHERE `nazwa` = @wytwornia", bd.getConnection());

            command.Parameters.Add("@wytwornia", MySqlDbType.VarChar).Value = wytwornia;
            adapter.SelectCommand = command;
            adapter.Fill(dataTable);

            if (dataTable.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 11
0
        public Boolean loginIsBusy()
        {
            bazaDanych       bd        = new bazaDanych();
            String           login     = textBoxLogin.Text;
            DataTable        dataTable = new DataTable();
            MySqlDataAdapter adapter   = new MySqlDataAdapter();
            MySqlCommand     command   = new MySqlCommand("SELECT * FROM `Uzytkownik` WHERE `login` = @log", bd.getConnection());

            command.Parameters.Add("@log", MySqlDbType.VarChar).Value = login;
            adapter.SelectCommand = command;
            adapter.Fill(dataTable);

            if (dataTable.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
        public Boolean gatunekExist()
        {
            bazaDanych       bd        = new bazaDanych();
            String           gatunek   = textBoxGatunek.Text;
            DataTable        dataTable = new DataTable();
            MySqlDataAdapter adapter   = new MySqlDataAdapter();
            MySqlCommand     command   = new MySqlCommand("SELECT * FROM `Gatunek_filmu` WHERE `gatunek` = @gatunek", bd.getConnection());

            command.Parameters.Add("@gatunek", MySqlDbType.VarChar).Value = gatunek;
            adapter.SelectCommand = command;
            adapter.Fill(dataTable);

            if (dataTable.Rows.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 13
0
        private void buttonDodajAktora_Click(object sender, EventArgs e)
        {
            bazaDanych   bd      = new bazaDanych();
            MySqlCommand command = new MySqlCommand("INSERT INTO `Aktor`( `imie`, `nazwisko`, `wiek`, `data_urodzenia`, `miejsce_urodzenia`) VALUES (@imie,@nazwisko,@wiek,@data,@miejsce)", bd.getConnection());

            command.Parameters.Add("@imie", MySqlDbType.VarChar).Value     = imieTextBox.Text;
            command.Parameters.Add("@nazwisko", MySqlDbType.VarChar).Value = textBoxNazwisko.Text;
            command.Parameters.Add("@wiek", MySqlDbType.VarChar).Value     = textBoxWiek.Text;
            command.Parameters.Add("@data", MySqlDbType.VarChar).Value     = textBoxDataUro.Text;
            command.Parameters.Add("@miejsce", MySqlDbType.VarChar).Value  = textBoxMiejsceUr.Text;


            bd.openConn();
            if (!fieldsIsEmpty())
            {
                if (!actorExist())
                {
                    if (command.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Udało się dodać aktora!");
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
                else
                {
                    MessageBox.Show("Aktor istnieje");
                }
            }
            else
            {
                MessageBox.Show("Najpierw podaj wszystkie dane!");
            }

            bd.closeConn();
        }
Esempio n. 14
0
        public dodajFilmForm()
        {
            bazaDanych bd = new bazaDanych();

            InitializeComponent();
            string connectionString = "datasource=hosting2043243.online.pro;port=3306;username=00344320_wypozyczalnia;password=ramziuch12;database=00344320_wypozyczalnia";
            string query            = "SELECT * FROM Film";
            string gatunki          = "SELECT * FROM Gatunek_filmu";
            string wytwornia        = "SELECT * FROM Wytwornia";



            try
            {
                MySqlConnection databaseConnection = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);
                commandDatabase.CommandTimeout = 60;
                MySqlDataReader reader;
                databaseConnection.Open();

                reader = commandDatabase.ExecuteReader();



                while (reader.Read())
                {
                    string[] row = { reader.GetString(0), reader.GetString(1) };

                    ListViewItem item = new ListViewItem(row);
                    listView1.Items.Add(item);
                }


                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            try
            {
                MySqlConnection databaseConnection = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase    = new MySqlCommand(gatunki, databaseConnection);
                commandDatabase.CommandTimeout = 60;
                MySqlDataReader reader; databaseConnection.Open();

                reader = commandDatabase.ExecuteReader();



                while (reader.Read())
                {
                    comboBox1.Items.Add(reader.GetString("gatunek"));
                }


                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            try
            {
                MySqlConnection databaseConnection = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase    = new MySqlCommand(wytwornia, databaseConnection);
                commandDatabase.CommandTimeout = 60;
                MySqlDataReader reader; databaseConnection.Open();

                reader = commandDatabase.ExecuteReader();



                while (reader.Read())
                {
                    comboBox2.Items.Add(reader.GetString("nazwa"));
                }


                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 15
0
        private void buttonDodajAktora_Click(object sender, EventArgs e)
        {
            String gatunek1   = comboBox1.Text.ToString();
            String wytwornia1 = comboBox2.Text.ToString();

            if ((gatunek1 != "") && (wytwornia1 != "") && (!fieldsIsEmpty()))
            {
                try
                {
                    bazaDanych bd = new bazaDanych();
                    bd.openConn();
                    DataTable        gatunekTable   = new DataTable();
                    MySqlDataAdapter adapterGatunek = new MySqlDataAdapter();
                    MySqlCommand     commandGatunek = new MySqlCommand("SELECT * FROM `Gatunek_filmu` WHERE `gatunek` = @gatunek", bd.getConnection());
                    commandGatunek.Parameters.Add("@gatunek", MySqlDbType.VarChar).Value = gatunek1;
                    adapterGatunek.SelectCommand = commandGatunek;
                    adapterGatunek.Fill(gatunekTable);
                    var gat = gatunekTable.Rows[0]["Id_gatunku"].ToString();

                    if (gatunekTable.Rows.Count > 0)
                    {
                        DataTable        wytworniaTable   = new DataTable();
                        MySqlDataAdapter adapterWytwornia = new MySqlDataAdapter();
                        MySqlCommand     commandWytwornia = new MySqlCommand("SELECT `id_wytworni` FROM `Wytwornia` WHERE `nazwa` = @wytwornia", bd.getConnection());
                        commandWytwornia.Parameters.Add("@wytwornia", MySqlDbType.VarChar).Value = wytwornia1;
                        adapterWytwornia.SelectCommand = commandWytwornia;
                        adapterWytwornia.Fill(wytworniaTable);
                        var wytw = wytworniaTable.Rows[0]["id_wytworni"].ToString();
                        if (wytworniaTable.Rows.Count > 0)
                        {
                            MySqlCommand command = new MySqlCommand("INSERT INTO `Film`( `tytul`, `premiera`, `Id_gatunek`, `id_wytwornia`, `opis_filmu`) VALUES (@tytul,@premiera,@gat,@wyt,@opis_filmu)", bd.getConnection());
                            command.Parameters.Add("@tytul", MySqlDbType.VarChar).Value    = tytulTextBox.Text;
                            command.Parameters.Add("@premiera", MySqlDbType.VarChar).Value = premieraTextBox.Text;
                            command.Parameters.Add("@opis_filmu", MySqlDbType.Text).Value  = opisTextBox.Text;
                            command.Parameters.Add("@gat", MySqlDbType.VarChar).Value      = gat;
                            command.Parameters.Add("@wyt", MySqlDbType.VarChar).Value      = wytw;



                            if (command.ExecuteNonQuery() == 1)
                            {
                                MessageBox.Show("Filmu został dodany");
                            }
                        }
                        bd.closeConn();
                    }
                    else
                    {
                        MessageBox.Show("xxx");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Wypełnij wszystkie pola");
            }
        }