Exemplo n.º 1
0
        /// <summary>
        /// Method validates and adds a new patient, clears the patient's list and adds the newst patient to it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddSubmit_Click(object sender, RoutedEventArgs e)
        {
            ClientModel client = new ClientModel();

            client.FirstName   = txtAddFirstName.Text;
            client.LastName    = txtAddLastName.Text;
            client.Pesel       = txtAddPesel.Text;
            client.PhoneNumber = txtAddPhoneNumber.Text;
            client.Street      = txtAddStreet.Text;
            client.City        = txtAddCity.Text;
            client.ZipCode     = txtAddZipCode.Text;

            try
            {
                client.Validate();
                client.ID            = client.Add(client);
                lblAddStatus.Content = "Dodano nowego pacjenta: " + client.FirstName + " " + client.LastName;
                clearAddForm();
                clearFindForm();
                enableFindForm(false);
                //ClientList.Add(client);
                //MyDataGridFind.Items.Refresh();
                txtId.Text      = client.ID.ToString();
                txtId.IsEnabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Błąd!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        public void Test2()
        {
            var client = new ClientModel();

            client.FirstName = "Marcin";
            client.LastName  = "Duda";
            client.Pesel     = "12345678101";

            bool isValid = client.Validate();

            Assert.AreEqual(true, isValid);
            Assert.ThrowsException <SQLiteException>(() => client.Add(client)); //duplicate pesel exception
        }
Exemplo n.º 3
0
        public void Test1()
        {
            var client = new ClientModel();

            client.FirstName = "Adam";
            client.LastName  = "Kowalski";
            client.Pesel     = "12345678101";

            bool isValid = client.Validate();
            int  id      = client.Add(client);

            Assert.AreEqual(true, isValid);
            Assert.IsTrue(id > 0);
        }