Пример #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (pizzeBindingSource.Current != null)
     {
         if (MessageBox.Show("Czy na pewno chcesz to usunąć?", "Wiadomość", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             db.Pizze.Remove(pizzeBindingSource.Current as Pizze);
             pizzeBindingSource.RemoveCurrent();
             db.SaveChanges();
         }
     }
 }
Пример #2
0
 private void frmAddEditPizza_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         if (string.IsNullOrEmpty(txtNazwaPizzy.Text))
         {
             MessageBox.Show("Proszę wprowadzić nazwę Pizzy!", "Wiadomość", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtNazwaPizzy.Focus();
             e.Cancel = true;
             return;
         }
         db.SaveChanges();
         e.Cancel = false;
     }
     e.Cancel = false;
 }