Exemplo n.º 1
0
        private bool procitajOdredjeneKomponenteIzMagacina(string query)
        {
            bool uspjesno = false;

            try
            {
                connection.Open();
                wpPanelMagacin.Children.Clear();
                MySqlCommand    command = new MySqlCommand(query, connection);
                MySqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    Kutija kutija = new Kutija(Convert.ToInt32(reader["LadicaBroj"].ToString()), reader["Sadrzaj"].ToString(), reader["Slika"].ToString(), Convert.ToInt32(reader["Kolicina"].ToString()), Convert.ToInt32(reader["ID"].ToString()), () => inicijalizujKutije());
                    wpPanelMagacin.Children.Add(kutija);
                }
                uspjesno = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(uspjesno);
        }
Exemplo n.º 2
0
 private void inicijalizujKutije()
 {
     connection = new MySqlConnection(Properties.Settings.Default.connectionString);
     try
     {
         connection.Open();
         wpPanelMagacin.Children.Clear();
         string          query   = "SELECT * FROM magacin;";
         MySqlCommand    command = new MySqlCommand(query, connection);
         MySqlDataReader reader  = command.ExecuteReader();
         while (reader.Read())
         {                                                                                                                                                                                                                                                //Metode sa Action delegatom se prosljedjuju na ovaj nacin                                                                                                                                                                                                                                              // s tim da su po potrebi u zagradama mogli biti argumenti npr: ()=>NekaMetoda(nekiBroj,nekiString)
             Kutija kutija = new Kutija(Convert.ToInt32(reader["LadicaBroj"].ToString()), reader["Sadrzaj"].ToString(), reader["Slika"].ToString(), Convert.ToInt32(reader["Kolicina"].ToString()), Convert.ToInt32(reader["ID"].ToString()), () => inicijalizujKutije());
             wpPanelMagacin.Children.Add(kutija);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         if (connection != null)
         {
             connection.Close();
         }
     }
 }
 public PodizanjeKomponenti(Kutija kutija)
 {
     InitializeComponent();
     imgSadrzaj.Source = new ImageSourceConverter().ConvertFromString(@kutija.Slika) as ImageSource;
     lbSadrzaj.Content = kutija.Sadrzaj;
     for (int i = 0; i < kutija.Kolicina; i++)
     {
         cbKolicinaSadrzaja.Items.Add((i + 1));
     }
     cbKolicinaSadrzaja.SelectedIndex = kutija.Kolicina - 1;
     kutijaZaPodizanje = kutija;
 }