Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            SchoolEntities schoolEntities = new SchoolEntities();

            Tabl.ItemsSource = schoolEntities.Client.ToList(); //выводим данные из таблицы
        }
Пример #2
0
        private void search_TextChanged(object sender, TextChangedEventArgs e)
        {
            SchoolEntities schoolEntities = new SchoolEntities();
            var            i = from u in schoolEntities.Client
                               where ((u.FirstName.Contains(search.Text)) || (u.LastName.Contains(search.Text)) || (u.Patronymic.Contains(search.Text)) || (u.Email.Contains(search.Text)))//ищем совпаденя в полях
                               select new { u.FirstName, u.LastName, u.Patronymic, u.Email, u.Gender, u.Birthday, u.RegistrationDate };

            Tabl.ItemsSource = i.ToList();           //выводим новые поля
            kolvo.Text       = i.Count().ToString(); // выводим количество строк в таблице
        }
Пример #3
0
        private void addClient_Click(object sender, RoutedEventArgs e)
        {
            string   nName     = NewName.Text;
            string   nLastName = NewLastName.Text;
            string   nPatr     = NewPatr.Text;
            DateTime nBirth    = new DateTime();
            DateTime nRD       = new DateTime();
            string   nEmail    = NewEmail.Text;
            string   nPhone    = NewPhone.Text;
            string   nGendr    = NewGendr.Text;

            nBirth = Convert.ToDateTime(NewBirthday.Text);
            nRD    = Convert.ToDateTime(NewRegistrDate.Text);

            SchoolEntities schoolEntities = new SchoolEntities();

            if ((nName != null) & (nLastName != null) & (nRD != null) & (nEmail != null) & (nPhone != null) & (nGendr != null))
            {
                Client NClient = new Client
                {
                    FirstName        = nName,
                    LastName         = nLastName,
                    Patronymic       = nPatr,
                    Birthday         = nBirth,
                    RegistrationDate = nRD,
                    Email            = nEmail,
                    Phone            = nPhone,
                    GenderCode       = nGendr
                };

                schoolEntities.Client.Add(NClient);
                schoolEntities.SaveChanges();

                MainWindow mainWindow = new MainWindow();
                mainWindow.Visibility = Visibility.Visible;
                this.Close();
            }
            else
            {
                MessageBox.Show("заполните поля обозначенные знаком \"*\" ! ");
            }
        }