예제 #1
0
 private void btn_Edit_Click(object sender, EventArgs e)
 {
     if (DGVPatient.SelectedRows[0] != null)
     {
         int       patientID       = Convert.ToInt32(DGVPatient.SelectedRows[0].Cells["PatientID"].Value);
         ACPatient _selectedPatint = patient.SelectPatientByID(patientID);
         txtName.Text    = _selectedPatint.PatientName;
         txtAddress.Text = _selectedPatint.Address;
         txtPhone.Text   = _selectedPatint.Phone;
         txtMobile.Text  = _selectedPatint.Mobile;
         DtpDOB.Value    = _selectedPatint.DOB.Value;
         txtNotes.Text   = _selectedPatint.Notes;
     }
 }
예제 #2
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();
     }
 }
예제 #3
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;
            }
        }