Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
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);
     }
 }