Пример #1
0
        public PatientViewModel(Nurse sessionDoctor)
        {
            try
            {
                ((IDatabaseCommutable)sessionDoctor).LoadFromDb(sessionDoctor.Id);
            }
            catch (KeyNotFoundException)
            {
                ErrorWindow errorWindow = new ErrorWindow("A database error occured");
                errorWindow.ShowDialog();
            }
            catch (HaveBeenFiredException e)
            {
                ErrorWindow errorWindow = new ErrorWindow(e);
                errorWindow.ShowDialog();
            }

            CurrentDoc = sessionDoctor;

            AllPatients = PatientLoader.LoadAll();

            foreach (Patient patient in CurrentDoc.Patients)
            {
                foreach (Patient patientFromAll in AllPatients)
                {
                    if (patientFromAll.Id == patient.Id)
                    {
                        AllPatients.Remove(patientFromAll);
                        break;
                    }
                }
            }
        }
Пример #2
0
        void IDatabaseCommutable.LoadFromDb(int uniqueId)
        {
            string query = "SELECT name, cabinet_num, birthdate, retired FROM Worker WHERE id = @docId";

            Dictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "docId", uniqueId }
            };

            Dictionary <int, object> reader = DBConnector.queryExecuteSingleResult(query, parameters);

            if (Convert.ToInt32(reader[3]) != 0)
            {
                throw new HaveBeenFiredException("You have been fired :(");
            }

            Id             = uniqueId;
            this.Name      = Convert.ToString(reader[0]);
            this.Cabinet   = Convert.ToInt32(reader[1]);
            this.Birthdate = Convert.ToDateTime(reader[2]);
            this.Patients  = PatientLoader.LoadByDoctorId(uniqueId);
        }
Пример #3
0
        public DoctorsViewModel(Nurse sessionDoctor)
        {
            try
            {
                ((IDatabaseCommutable)sessionDoctor).LoadFromDb(sessionDoctor.Id);
            }
            catch (KeyNotFoundException)
            {
                ErrorWindow errorWindow = new ErrorWindow("A database error occured");
                errorWindow.ShowDialog();
            }
            catch (HaveBeenFiredException e)
            {
                ErrorWindow errorWindow = new ErrorWindow(e);
                errorWindow.ShowDialog();
            }

            CurrentDoc = sessionDoctor;

            AllDoctors    = PatientLoader.LoadDoctors();
            AllNurses     = PatientLoader.LoadNurses();
            AllHeadPhyses = PatientLoader.LoadHeadPhyses();
        }