Esempio n. 1
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     if (txtName.Text != string .Empty )
     {
         ACPatient _SelectedPatient = new ACPatient();
         _SelectedPatient.PatientID = txtNo.Text != string.Empty ? Convert.ToInt32(txtNo.Text) : 0;
         _SelectedPatient.PatientName = txtName.Text;
         _SelectedPatient.Address = txtAddress.Text;
         _SelectedPatient.Phone = txtPhone.Text;
         _SelectedPatient.Mobile = txtMobile.Text;
         _SelectedPatient.DOB = DtpDOB.Value;
         // txtAge.Text = (DateTime.Now - _SelectedPatient.DOB).ToString();
         _SelectedPatient.Notes = txtNotes.Text;
         string ret=patient.addACPatient(_SelectedPatient);
         MessageBox.Show(ret, @"إضافه\تعديل مريض", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ResetFields();
         DGVPatient.DataSource = patient.SelectAllBDPatient(); 
 }
 }
Esempio n. 2
0
 public string addACPatient(ACPatient patient)
 {
     try
     {
         var Query = _contextDatabase.ACPatients.Where(a => a.PatientID == patient.PatientID).FirstOrDefault();
         if (Query != null)
         {
             Query.PatientName = patient.PatientName;
             Query.DOB = patient.DOB;
             Query.Phone = patient.Phone;
             Query.Mobile = patient.Mobile;
             Query.Address = patient.Address;
             Query.Notes = patient.Notes;
             _contextDatabase.SaveChanges();
             return "تم الحفظ بنجاح";
         }
         else
         {
             ACPatient _bDPatient = new ACPatient();
             _bDPatient.PatientName = patient.PatientName;
             _bDPatient.DOB = patient.DOB;
             _bDPatient.Phone = patient.Phone;
             _bDPatient.Mobile = patient.Mobile;
             _bDPatient.Address = patient.Address;
             _bDPatient.Notes = patient.Notes;
             _contextDatabase.ACPatients.Add(_bDPatient);
             _contextDatabase.SaveChanges();
             return "تم الحفظ بنجاح";
         }
     }
     catch (Exception ex)
     {
         return "Erorr on save";
         throw;
     }
 }