예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            MedicalExamination examinationToRemove = new MedicalExamination();

            examinationToRemove.IdMedicalExamination = int.Parse(dgvExamination.SelectedRows[0].Cells[8].Value.ToString());
            db.MedicalExaminations.Attach(examinationToRemove);
            db.MedicalExaminations.Remove(examinationToRemove);
            db.SaveChanges();
            if (tbSearchEmployeeExamination.Text.Trim() == "" || tbSearchEmployeeExaminationName.Text.Trim() == "")
            {
                display();
            }
            else
            {
                tbSearchEmployeeExamination_TextChanged(sender, e);
            }
            MessageBox.Show("Rekord został usunięty");
        }
예제 #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (cbEmployeeList.SelectedIndex == -1)
     {
         MessageBox.Show("Pole pracownik musi być wypełnione");
     }
     else
     {
         if (dtpExaminationDate.Value > DateTime.Today)
         {
             MessageBox.Show("Data badanie nie może być datą przyszłą");
         }
         else
         {
             MedicalExamination newMedicalExamination = new MedicalExamination();
             newMedicalExamination.IdEmployee = cbEmployeeList.SelectedIndex + 1;
             newMedicalExamination.Date       = dtpExaminationDate.Value;
             db.MedicalExaminations.Add(newMedicalExamination);
             db.SaveChanges();
             clear();
             MessageBox.Show("Prawidłowo wprowadzono badanie");
         }
     }
 }