private void Begin_Click(object sender, RoutedEventArgs e)
        {
            SearchPatient wind = new SearchPatient(user, DateTime.Now);

            wind.Show();
            Close();
        }
Exemple #2
0
        private void Back_Click(object sender, RoutedEventArgs e)
        {
            SearchPatient wind = new SearchPatient(user, datetime1);

            wind.Show();
            Close();
        }
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            if (Surname.Text != "" && FirstName.Text != "" && Street.Text != "" && House.Text != "" &&
                ValidationText(Surname.Text) && ValidationText(FirstName.Text) &&
                ValidationNumber(House.Text) && ValidationText(Street.Text))
            {
                PATIENT newP;
                if (isNew)
                {
                    newP = new PATIENT();
                }
                else
                {
                    newP = u.Patients.Get(pat.PATIENT_ID);
                }
                newP.SURNAME   = Surname.Text;
                newP.FIRSTNAME = FirstName.Text;
                if (FatherName.Text != "")
                {
                    newP.FATHERSNAME = FatherName.Text;
                }
                if (GenderW.IsChecked == true)
                {
                    newP.GENDER = "ж";
                }
                else
                {
                    newP.GENDER = "м";
                }

                DateTime dt;
                if (DateTime.TryParse(DateBlock.Text, out dt))
                {
                    newP.BDAY = dt;
                }
                else
                {
                    MessageBox.Show("Дата рождения введена некорректно.\nЭто поле не будет занесено в базу данных");
                }

                if (Telephone.Text != "")
                {
                    newP.TELEPHONE = Telephone.Text;
                }
                else
                {
                    newP.TELEPHONE = null;
                }

                ADDRESS newAdr;
                if (isNew)
                {
                    newAdr = new ADDRESS();
                }
                else
                {
                    newAdr = a;
                }
                newAdr.STREET = Street.Text;
                newAdr.HOUSE  = House.Text;

                if (Housing.Text != "")
                {
                    newAdr.HOUSING = Housing.Text;
                }
                else
                {
                    newAdr.HOUSING = null;
                }
                int flat;
                if (Flat.Text != "" && int.TryParse(Flat.Text, out flat))
                {
                    newAdr.FLAT = flat;
                }
                else
                {
                    newAdr.FLAT = null;
                }

                if (isNew)
                {
                    u.Addresses.Create(newAdr);
                }

                //db.SaveChanges();
                u.Save();
                if (isNew)
                {
                    newP.ADDRESS_ID = newAdr.ADDRESS_ID;

                    u.Patients.Create(newP);
                    u.Save();
                }

                SearchPatient wind = new SearchPatient(user, datetime1);
                wind.Show();
                Close();
            }
            else
            {
                MessageBox.Show("Заполните поля корректной информацией!");
            }
        }