コード例 #1
0
        private bool UpdatePatient()
        {
            PatientGender gender = (PatientGender)(-1);

            if (radioButtonGenderMale.Checked)
            {
                gender = PatientGender.Male;
            }
            else if (radioButtonGenderFemale.Checked)
            {
                gender = PatientGender.Female;
            }

            PatientModel localPatient = new PatientModel
            {
                Id        = patientId,
                FirstName = textBoxFirstName.Text,
                LastName  = textBoxLastName.Text,
                Birthdate = dateTimePickerBirthdate.Value.ToShortDateString(),
                Gender    = gender
            };

            PatientValidator validator = new PatientValidator();

            ValidationResult results = validator.Validate(localPatient);

            if (results.IsValid == false)
            {
                MessageBox.Show(results.Errors[0].ToString());

                return(false);
            }

            patient = localPatient;

            SqliteDataAccess.UpdatePatient(localPatient);

            return(true);
        }
コード例 #2
0
 public static void SavePatient(PatientModel patient)
 {
     using IDbConnection cnn = new SQLiteConnection(LoadConnectionString());
     cnn.Execute("insert into patients (firstname, lastname, birthdate, gender) values (@FirstName, @LastName, @Birthdate, @Gender)", patient);
 }