Esempio n. 1
0
 public void VsaviSestavine()
 {
     try
     {
         SQLiteConnection conn = new SQLiteConnection("data source = database.db");
         conn.Open();
         SQLiteCommand com = new SQLiteCommand(conn);
         com.CommandText = "SELECT ns.kolicina, s.ime AS sIme, e.ime AS eIme FROM norme n " +
                           "INNER JOIN sestavine_norme ns ON ns.norma_id=n.id " +
                           "INNER JOIN sestavine s ON s.id=ns.sestavina_id " +
                           "INNER JOIN enote e ON e.id=s.enota_id " +
                           "WHERE n.ime = '" + Ime + "';";
         SQLiteDataReader reader = com.ExecuteReader();
         while (reader.Read())
         {
             Sestavina temSestavina = new Sestavina(reader.GetString(1), reader.GetFloat(0).ToString(), reader.GetString(2));
             AddIng(temSestavina);
         }
         com.Dispose();
         conn.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
 private void buttonIzbrisiPolje_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex > 0)
     {
         string    currentSelectedItem = listBox1.SelectedItem.ToString();
         string[]  seperateStrings1    = currentSelectedItem.Split(',');
         string[]  seperateStrings2    = seperateStrings1[1].Split(' ');
         Sestavina ses = new Sestavina("", "", "");
         foreach (Sestavina s in trenutniIzdelek.Sestavine)
         {
             if (s.Ime == seperateStrings1[0] && s.Kolicina == seperateStrings2[0] && s.Enota == seperateStrings2[1])
             {
                 ses = s;
                 break;
             }
         }
         trenutniIzdelek.Sestavine.Remove(ses);
         listBox1.Items.Remove(listBox1.SelectedItem);
     }
 }
Esempio n. 3
0
 private void addFieldbutton_Click(object sender, EventArgs e)
 {
     try
     {
         if (sestavina)
         {
             urejanjeDodajanjeSestavin tempForm = new urejanjeDodajanjeSestavin();
             tempForm.ShowDialog();
             if (tempForm.DialogResult == DialogResult.OK)
             {
                 Sestavina tempsestavina = new Sestavina(tempForm.comboBoxSestavina.Text, tempForm.textBoxKolicina.Text, tempForm.comboBoxEnota.Text);
                 trenutniIzdelek.AddIng(tempsestavina);
                 listBox1.Items.Add(tempsestavina.izpis());
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 4
0
 private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     try
     {
         int index = this.listBox1.IndexFromPoint(e.Location);
         if (index != System.Windows.Forms.ListBox.NoMatches)
         {
             string   currentSelectedItem       = listBox1.Items[index].ToString();
             string[] seperateStrings1          = currentSelectedItem.Split(',');
             string[] seperateStrings2          = seperateStrings1[1].Split(' ');
             urejanjeDodajanjeSestavin tempForm = new urejanjeDodajanjeSestavin();
             tempForm.comboBoxSestavina.Text = seperateStrings1[0];
             tempForm.textBoxKolicina.Text   = seperateStrings2[0];
             tempForm.comboBoxEnota.Text     = seperateStrings2[1];
             tempForm.ShowDialog();
             if (tempForm.DialogResult == DialogResult.OK)
             {
                 Sestavina ses = new Sestavina("", "", "");
                 foreach (Sestavina s in trenutniIzdelek.Sestavine)
                 {
                     if (s.Ime == seperateStrings1[0] && s.Kolicina == seperateStrings2[0] && s.Enota == seperateStrings2[1])
                     {
                         ses = s;
                         break;
                     }
                 }
                 trenutniIzdelek.Sestavine.Remove(ses);
                 listBox1.Items.Remove(listBox1.SelectedItem);
                 Sestavina tempsestavina = new Sestavina(tempForm.comboBoxSestavina.Text, tempForm.textBoxKolicina.Text, tempForm.comboBoxEnota.Text);
                 trenutniIzdelek.AddIng(tempsestavina);
                 listBox1.Items.Add(tempsestavina.izpis());
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 5
0
 public void AddIng(Sestavina tempSestavina)
 {
     Sestavine.Add(tempSestavina);
 }