Exemplo n.º 1
0
 private void btnSterge_Click(object sender, EventArgs e)
 {
     if (studentiBindingSource.Current != null)
     {
         if (MessageBox.Show("Esti sigur ca vrei sa stergi inregistrarea?", "Mesaj", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             db.Studentis.Remove(studentiBindingSource.Current as Studenti);
             studentiBindingSource.RemoveCurrent();
             db.SaveChanges();
         }
     }
 }
 private void frmAdaugaModificaStudent_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         if (string.IsNullOrEmpty(txtCNPStudent.Text))
         {
             MessageBox.Show("Scrieti CNP-ul studentului.", "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtCNPStudent.Focus();
             e.Cancel = true;
             return;
         }
         if (txtCNPStudent.TextLength != 13)
         {
             MessageBox.Show("CNP-ul trebuie sa aiba 13 cifre!", "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtCNPStudent.Focus();
             e.Cancel = true;
             return;
         }
         db.SaveChanges();
         e.Cancel = false;
     }
     e.Cancel = false;
 }