private void AddDevice_Click(object sender, EventArgs e)
        {
            int row      = PatientsList.SelectedCells[0].RowIndex;
            int userCode = int.Parse(PatientsList.Rows[row].Cells[0].Value.ToString());

            Patient selectedPat = _container.PatientSet.Find(userCode);

            AddDeviceForm newDeviceType = new AddDeviceForm();

            if (newDeviceType.ShowDialog() != DialogResult.Cancel)
            {
                DeviceFunction type = newDeviceType.function;

                bool exist = false;

                foreach (Device d in selectedPat.Device)
                {
                    if (d.Function == type)
                    {
                        exist = true;
                    }
                }

                if (exist)
                {
                    MessageBox.Show("Данный тип прибора уже закреплен за пациентом.");
                }
                else
                {
                    Device newDevice = InformationSystem.CreateDevice(selectedPat, type);
                    InformationSystem.AddDevice(newDevice, selectedPat);
                }
            }
        }
Exemple #2
0
        private void AddPatient_Click(object sender, EventArgs e)
        {
            EntityModelContainer container = new EntityModelContainer();

            int row = SearchResults.SelectedCells[0].RowIndex;

            Patient selectedPat =
                container.PatientSet.Find(int.Parse(SearchResults.Rows[row].Cells[0].Value.ToString()));

            AddDeviceForm newDeviceType = new AddDeviceForm();

            if (newDeviceType.ShowDialog() == DialogResult.OK)
            {
                DeviceFunction type  = newDeviceType.function;
                bool           exist = false;

                foreach (Device d in selectedPat.Device)
                {
                    if (d.Function == type)
                    {
                        exist = true;
                    }
                }

                if (exist)
                {
                    if (MessageBox.Show(
                            "Данный тип прибора уже закреплен за пациентом. Добавить пациента в список пациентов?", "",
                            MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        InformationSystem.AddDoctorPatientConnection(user, selectedPat);
                        this.Close();
                    }
                }
                else
                {
                    Device newDevice = InformationSystem.CreateDevice(selectedPat, type);
                    InformationSystem.AddDevice(newDevice, selectedPat);

                    InformationSystem.AddDoctorPatientConnection(user, selectedPat);
                    this.Close();
                }
            }

            container.SaveChanges();
        }
        private void SignUp_Click(object sender, EventArgs e)
        {
            string   name      = NewName.Text;
            DateTime birthDate = NewDateBirth.Value;
            Male     male      = NewMale.Checked ? Male.Male : Male.Female;
            byte     height    = byte.Parse(NewHeight.Text);
            byte     weight    = byte.Parse(NewWeight.Text);

            _container = new EntityModelContainer();
            Patient newPatient = InformationSystem.CreatePatient(name, birthDate, male, height, weight, user);

            InformationSystem.AddPatient(newPatient, user);

            DeviceFunction deviceType = 0;

            switch (NewDeviceType.SelectedIndex)
            {
            case 0:
                deviceType = DeviceFunction.Glucometer;
                break;

            case 1:
                deviceType = DeviceFunction.HeartRateMonitor;
                break;

            case 2:
                deviceType = DeviceFunction.BloodPressureMonitor;
                break;
            }

            Device newDevice = InformationSystem.CreateDevice(newPatient, deviceType);

            InformationSystem.AddDevice(newDevice, newPatient);

            DoctorMessage informMessage = InformationSystem.CreatePatientMessage(user, newPatient, AllowAccess.Checked);

            InformationSystem.AddDoctorMessage(informMessage);

            MessageBox.Show("Пациент успешно зарегистрирован");

            this.Close();
        }