Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var patient = new Patient
            {
                HospitalNumber = int.Parse(mtbHospitalId.Text),
                Title = (Title)Enum.Parse(typeof(Title), cboTitle.Text),
                LastName = txtLastName.Text,
                FirstName = txtFirstName.Text,
                OtherName = txtMname.Text,
                Gender = (Gender)Enum.Parse(typeof(Gender), cboTitle.Text),
                BirthDate = dtpBirthDate.Value,
                Phone = int.Parse(mtbPhone.Text),
                HomeAddress = txtHomeAdd.Text,
                MaritalStatus = (MaritalStatus)Enum.Parse(typeof(MaritalStatus), cboMaritalStatus.Text)
            };

            using (ClinicModel model = new ClinicModel())
            {
                model.Patients.Add(patient);
            }

            MessageBox.Show("New Patient Registered");

            Close();
        }
Exemplo n.º 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            txtDateAmend.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            var patient = new Patient()
            {
                Identifier = int.Parse(txtPid.Text),
                HospitalNumber = int.Parse(txtHospNum.Text),
                Title = (Title)Enum.Parse(typeof(Title), cmbtitle.Text),
                LastName = txtLname.Text,
                FirstName = txtFname.Text,
                MiddleName = txtMname.Text,
                Gender = (Gender)Enum.Parse(typeof(Gender), cmbGender.Text),
                BirthDate = DateTime.Parse(txtDob.Text),
                Phone = int.Parse(txtPhone.Text),
                MobilePhone = int.Parse(txtMPhone.Text),
                Email = txtEmail.Text,
                HomeAddress = txtHAddress.Text,
                City = txtCity.Text,
                State = txtState.Text,
                MaritalStatus = (MaritalStatus)Enum.Parse(typeof(MaritalStatus), cmbMStatus.Text),
                PatientConsultant = txtPatConsultant.Text,
                Nationality = txtNat.Text,
                StateOfOrigin = txtSOrigin.Text,
                Hometown = txtTOrigin.Text,
                PlaceOfBirth = txtPoB.Text,
                Religion = txtReligion.Text,
                Occupation = txtOccupation.Text,
                OfficeAddress = txtOAddress.Text,
                NationalIdType = cmbNIDType.Text,
                NationalIdNumber = txtNidNumber.Text,
                NextOfKin = txtNok.Text,
                AddressNextOfKin = txtNoKAddress.Text,
                PhoneNextOfKin = int.Parse(txtNoKPhone.Text),
                EmailNextOfKin = txtNoKEmail.Text,
                NextOfKinRelationship = cmbNokRelationship.Text,
                NameOfFather = txtFather.Text,
                NameOfMother = txtMother.Text,
                HealthInsuranceProvider = txtHealthIns.Text,
                AddressHealthInsuranceProvider = txtHealthAddr.Text,
                PhoneHealthInsuranceProvider = int.Parse(txtHealthPhone.Text),
                EmailHealthInsuranceProvider = txtHealthEmail.Text,
                DateAmended = txtDateAmend.Text,
                Photo = GetBytesFromImage()
            };

            using (ClinicModel context = new ClinicModel())
            {
                context.Patients.Add(patient);

                context.SaveChanges();
            }

            GetBytesFromImage();

            MessageBox.Show("Patient Record Updated");
        }