コード例 #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);
     }
 }
コード例 #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);
     }
 }
コード例 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBox1.Text != "")
         {
             urejanjeDodajanjeSestavin tempForm = new urejanjeDodajanjeSestavin();
             SQLiteConnection          conn     = new SQLiteConnection("data source = database.db");
             conn.Open();
             SQLiteCommand com = new SQLiteCommand(conn);
             com.CommandText = "SELECT s.skupna_kolicina, e.ime FROM sestavine s INNER JOIN enote e ON e.id=s.enota_id WHERE s.ime = '" + comboBox1.Text + "' LIMIT 1;";
             SQLiteDataReader reader = com.ExecuteReader();
             while (reader.Read())
             {
                 tempForm.textBoxKolicina.Text   = reader.GetValue(0).ToString();
                 tempForm.comboBoxEnota.Text     = reader.GetString(1);
                 tempForm.comboBoxSestavina.Text = comboBox1.Text;
             }
             reader.Close();
             tempForm.ShowDialog();
             if (tempForm.DialogResult == DialogResult.OK)
             {
                 com.CommandText = "UPDATE sestavine SET skupna_kolicina = " + tempForm.textBoxKolicina.Text + ", ime = '" + tempForm.comboBoxSestavina.Text + "', enota_id = (SELECT id FROM enote WHERE ime = '" + tempForm.comboBoxEnota.Text + "') WHERE ime = '" + comboBox1.Text + "';";
                 com.ExecuteNonQuery();
             }
             com.Dispose();
             conn.Close();
             fresh();
         }
         else
         {
             MessageBox.Show("Izberite sestavino!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }