© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
8 replies
Bourbon

I don't know how to get information from several tables

There are Users and Passports tables.
Information is output from the Users table, but it is not output from the Passports table. What can be done?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace StudyGroupDiary
{
    /// <summary>
    /// Логика взаимодействия для PersonalBusinessPage.xaml
    /// </summary>
    public partial class PersonalBusinessPage : Page
    {
        private Users _currentUsers = new Users();

        public PersonalBusinessPage(Users selectedUsers)
        {
            InitializeComponent();

            if (selectedUsers != null)
            {
                _currentUsers = selectedUsers;
            }
            DataContext = _currentUsers;

        }

        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentUsers.Name))
                errors.AppendLine("Укажите Имя!");
            if (string.IsNullOrWhiteSpace(_currentUsers.Surname))
                errors.AppendLine("Укажите Фамилию!");
            if (string.IsNullOrWhiteSpace(_currentUsers.MiddleName))
                errors.AppendLine("Укажите Отчество!");
            if (string.IsNullOrWhiteSpace(_currentUsers.Role))
                errors.AppendLine("Укажите Роль!");
            if (string.IsNullOrWhiteSpace(_currentUsers.DateOfBirth))
                errors.AppendLine("Укажите дату рождения!");
            if (string.IsNullOrWhiteSpace(_currentUsers.Gender))
                errors.AppendLine("Укажите пол!");

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }

            if (_currentUsers.UserID == 0)
                StudyGroupDiaryBDEntities.GetContext().Users.Add(_currentUsers);
            try
            {
                StudyGroupDiaryBDEntities.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace StudyGroupDiary
{
    /// <summary>
    /// Логика взаимодействия для PersonalBusinessPage.xaml
    /// </summary>
    public partial class PersonalBusinessPage : Page
    {
        private Users _currentUsers = new Users();

        public PersonalBusinessPage(Users selectedUsers)
        {
            InitializeComponent();

            if (selectedUsers != null)
            {
                _currentUsers = selectedUsers;
            }
            DataContext = _currentUsers;

        }

        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentUsers.Name))
                errors.AppendLine("Укажите Имя!");
            if (string.IsNullOrWhiteSpace(_currentUsers.Surname))
                errors.AppendLine("Укажите Фамилию!");
            if (string.IsNullOrWhiteSpace(_currentUsers.MiddleName))
                errors.AppendLine("Укажите Отчество!");
            if (string.IsNullOrWhiteSpace(_currentUsers.Role))
                errors.AppendLine("Укажите Роль!");
            if (string.IsNullOrWhiteSpace(_currentUsers.DateOfBirth))
                errors.AppendLine("Укажите дату рождения!");
            if (string.IsNullOrWhiteSpace(_currentUsers.Gender))
                errors.AppendLine("Укажите пол!");

            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }

            if (_currentUsers.UserID == 0)
                StudyGroupDiaryBDEntities.GetContext().Users.Add(_currentUsers);
            try
            {
                StudyGroupDiaryBDEntities.GetContext().SaveChanges();
                MessageBox.Show("Информация сохранена!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
    }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

❔ i don't know how to start.
C#CC# / help
4y ago
I don't know how to do this
C#CC# / help
2y ago
❔ I received an assignment that I don't know how to get around
C#CC# / help
4y ago
I don't know how to structure my program...
C#CC# / help
3y ago