Exemplo n.º 1
0
        public List <distributer> SelectDistributor()
        {
            string             query = "SELECT * FROM distributer";
            List <distributer> list  = new List <distributer>();

            if (this.OpenConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, connection);
                MySqlDataReader dataReader = cmd.ExecuteReader();
                while (dataReader.Read())
                {
                    var    distributer1 = new distributer();
                    string pret         = dataReader[0] + "";
                    distributer1.idDistributer = Int32.Parse(pret);
                    distributer1.naziv         = dataReader[1] + "";
                    distributer1.adresa        = dataReader[2] + "";
                    distributer1.telefon       = dataReader[3] + "";
                    distributer1.faks          = dataReader[4] + "";
                    distributer1.email         = dataReader[5] + "";
                    distributer1.oib           = dataReader[6] + "";
                    list.Add(distributer1);
                }
                dataReader.Close();
                this.CloseConnection();
                return(list);
            }
            else
            {
                return(list);
            }
        }
Exemplo n.º 2
0
        private void btnAddMovie_Click(object sender, RoutedEventArgs e)
        {
            distributer dbId = (distributer)listBoxDistributor.SelectedItem;

            name     = txtBoxNaziv.Text;
            year     = txtBoxYear.Text;
            duration = txtBoxDuration.Text;
            language = txtBoxLanguage.Text;
            country  = txtBoxCountry.Text;
            address  = dbId.idDistributer.ToString();
            path     = txtBoxPath.Text;
            string query = "insert into film(naziv, godina, trajanje, jezik, zemlja, putanja, distributer) values ( " + "'" + name + "'" + "," + "'" + year + "'" + "," + "'" + duration + "'" + "," + "'" + language + "'" + "," + "'" + country + "'" + "," + "'" + path + "'" + "," + "'" + address + "'" + ")";

            db.insert(query);
        }