Beispiel #1
0
        public void AddDoctor(Common.Doctor doctor, string txtCon, string txtOnc, string txtFD, Guid?ddCon, Guid?ddFD, Guid?ddOnc)
        {
            DataLayer.PatientsHandler dap = new DataLayer.PatientsHandler();
            BusinessLayer.UsersBL     emp = new UsersBL();
            int tempPId = (int)doctor.PatientId_FK;

            Common.Patient pat = new Common.Patient();
            if (txtOnc != "" || ddOnc != null)
            {
                if (txtOnc != "")
                {
                    Common.Doctor d = new Common.Doctor();
                    d.PatientId_FK  = tempPId;
                    d.DoctorType_FK = emp.GetDoctorType("Oncologist").DoctorTypeId;
                    d.DoctorName    = txtOnc;
                    d.DoctorDate    = DateTime.Today;
                    d.DoctorID      = Guid.NewGuid();
                    this.AddDoctorToDatabase(d);

                    pat = GetPatient((int)d.PatientId_FK);
                    pat.Oncologist_fk = d.DoctorID;
                    this.UpdatePatient(pat);
                }
                else
                {
                    Common.Doctor d = new Common.Doctor();
                    d.PatientId_FK   = tempPId;
                    d.DoctorType_FK  = emp.GetDoctorType("Oncologist").DoctorTypeId;
                    d.DEmployeeId_FK = ddOnc;
                    d.DoctorDate     = DateTime.Today;
                    d.DoctorID       = Guid.NewGuid();
                    this.AddDoctorToDatabase(d);

                    pat = GetPatient((int)d.PatientId_FK);
                    pat.Oncologist_fk = d.DoctorID;
                    this.UpdatePatient(pat);
                }
            }
            if (txtCon != "" || ddCon != null)
            {
                if (txtCon != "")
                {
                    Common.Doctor d = new Common.Doctor();
                    d.PatientId_FK  = tempPId;
                    d.DoctorType_FK = emp.GetDoctorType("Consultant").DoctorTypeId;
                    d.DoctorName    = txtCon;
                    d.DoctorDate    = DateTime.Today;
                    d.DoctorID      = Guid.NewGuid();
                    this.AddDoctorToDatabase(d);

                    pat = GetPatient((int)d.PatientId_FK);
                    pat.Consultant_fk = d.DoctorID;
                    this.UpdatePatient(pat);
                }
                else
                {
                    Common.Doctor d = new Common.Doctor();
                    d.PatientId_FK   = tempPId;
                    d.DoctorType_FK  = emp.GetDoctorType("Consultant").DoctorTypeId;
                    d.DEmployeeId_FK = ddCon;
                    d.DoctorDate     = DateTime.Today;
                    d.DoctorID       = Guid.NewGuid();
                    this.AddDoctorToDatabase(d);

                    pat = GetPatient((int)d.PatientId_FK);
                    pat.Consultant_fk = d.DoctorID;
                    this.UpdatePatient(pat);
                }
            }
            if (txtFD != "" || ddFD != null)
            {
                if (txtFD != "")
                {
                    Common.Doctor d = new Common.Doctor();
                    d.PatientId_FK  = tempPId;
                    d.DoctorType_FK = emp.GetDoctorType("FamilyDoctor").DoctorTypeId;
                    d.DoctorName    = txtFD;
                    d.DoctorDate    = DateTime.Today;
                    d.DoctorID      = Guid.NewGuid();
                    this.AddDoctorToDatabase(d);

                    pat = GetPatient((int)d.PatientId_FK);
                    pat.FamilyDoctor_fk = d.DoctorID;
                    this.UpdatePatient(pat);
                }
                else
                {
                    Common.Doctor d = new Common.Doctor();
                    d.PatientId_FK   = tempPId;
                    d.DoctorType_FK  = emp.GetDoctorType("FamilyDoctor").DoctorTypeId;
                    d.DEmployeeId_FK = ddFD;
                    d.DoctorDate     = DateTime.Today;
                    d.DoctorID       = Guid.NewGuid();
                    this.AddDoctorToDatabase(d);

                    pat = GetPatient((int)d.PatientId_FK);
                    pat.FamilyDoctor_fk = d.DoctorID;
                    this.UpdatePatient(pat);
                }
            }
        }
Beispiel #2
0
 public void AddDoctor(Common.Doctor doctor)
 {
     this.Entities.Doctors.Add(doctor);
     this.Entities.SaveChanges();
 }
Beispiel #3
0
 private void AddDoctorToDatabase(Common.Doctor doctor)
 {
     new DataLayer.PatientsHandler().AddDoctor(doctor);
 }