private void buttonInregistreaza_Click(object sender, EventArgs e) { DataRowView drvacvariu = comboBoxAcvariu.SelectedItem as DataRowView; DataRowView drvsubstanta = comboBoxSubstanta.SelectedItem as DataRowView; string mesaj = "Ati adaugat " + textBoxCantitate.Text + " lingurite\n" + drvsubstanta["substanta"] + "\nin acvariul" + drvacvariu["numeac"] + "?"; Confirmare c = new Confirmare(mesaj); DialogResult dr = c.ShowDialog(); if (dr == DialogResult.Yes) { try { int ida = Convert.ToInt32(comboBoxAcvariu.SelectedValue); int ids = Convert.ToInt32(comboBoxSubstanta.SelectedValue); string cantitate = Convert.ToString(textBoxCantitate.Text); Dozare.Inregistrez_Dozare(ids, ida, dateTimePicker1.Value.Date, cantitate); substanteT.Clear(); comboBoxSubstanta.DataSource = null; Completez_Combo_Substante(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (dr == DialogResult.No) { MessageBox.Show("Nu s-a inregistrat nici o dozare"); } }
private void buttonSterge_Click(object sender, EventArgs e) { if (checkedListBoxDozare.CheckedIndices.Count > 0) { Confirmare c = new Confirmare("Confirmati stergerea datelor?"); DialogResult dr = c.ShowDialog(); ArrayList DozariInutile = new ArrayList(); if (dr == DialogResult.Yes) { int id_doza; try { foreach (int i in checkedListBoxDozare.CheckedIndices) { checkedListBoxDozare.SelectedIndex = i; id_doza = Convert.ToInt32(checkedListBoxDozare.SelectedValue); DozariInutile.Add(id_doza); } Istoric_Sterge.Sterge_Inregistrari(DozariInutile, d, idacvariu); MessageBox.Show("Stergere s-a efectuat cu succes"); dozariT.Clear(); checkedListBoxDozare.DataSource = null; Completez_CheckedListBox_Dozari(idacvariu, d); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (dr == DialogResult.No) { MessageBox.Show("Restituirea NU a fost inregistrata"); Goleste_checkedListBoxDozare(); } } else { MessageBox.Show("NU ati selectat nici o inregistrare"); } }
public void Sterge_acvarii() { if (checkedListBox1.CheckedIndices.Count > 0) { Confirmare c = new Confirmare("Stergeti acvariul?"); DialogResult dr = c.ShowDialog(); ArrayList Acvariisterse = new ArrayList(); if (dr == DialogResult.Yes) { int id_acvariu; try { foreach (int i in checkedListBox1.CheckedIndices) { checkedListBox1.SelectedIndex = i; id_acvariu = Convert.ToInt32(checkedListBox1.SelectedValue); Acvariisterse.Add(id_acvariu); } Adau_Sterg_date.Sterge_Acvarii(Acvariisterse); MessageBox.Show("Acvariul a fost sters din Baza de date"); acvariuT.Clear(); checkedListBox1.DataSource = null; Completez_CheckedBox_Acvarii(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (dr == DialogResult.No) { MessageBox.Show("Stergerea nu a fost efectuata"); Goleste_checkedListBox(); } } else { MessageBox.Show("Nu ati selectat nici un acvariu"); } }