示例#1
0
        public UserProfile(int uId)
        {
            InitializeComponent();

            userId = uId;

            using (TheaterDBContext context = new TheaterDBContext())
            {
                var users = context.Users.ToList();

                foreach (Users u in users)
                {
                    if (u.UserId == userId)
                    {
                        TextBlockUserProfileName.Text       = u.UserFIO;
                        TextBlockUserProfileProfession.Text = context.Professions.Single(p => p.ProfessionId == u.ProfessionId).ProfessionName;
                        TextBlockUserProfileDOB.Text        = (u.UserDOB ?? DateTime.Now).ToString("d");
                        TextBlockUserProfileExperience.Text = u.UserExperience;
                        TextBlockUserProfileHeight.Text     = u.UserHight;
                        TextBlockUserProfileSex.Text        = u.UserSex;
                        TextBlockUserProfileSalary.Text     = u.UserSalary;
                        TextBlockUserProfileСhildrens.Text  = u.UserСhildrens.ToString();
                        TextBlockUserProfileAwards.Text     = u.UserAwards;
                    }
                }
            }
        }
示例#2
0
        private void ButtonSaveNewPlay_Click(object sender, RoutedEventArgs e)
        {
            if (TextBoxNewPlayName.Text != "" & TextBoxNewPlayAuthor.Text != "" & ComboBoxNewPlayGenre.SelectedIndex >= 0 & ComboBoxNewPlayParentalGuidance.SelectedIndex >= 0 & TextBoxNewPlayPremiere.Text != "")
            {
                using (TheaterDBContext context = new TheaterDBContext())
                {
                    Plays play = new Plays();

                    play.PlayName           = TextBoxNewPlayName.Text;
                    play.PlayAuthor         = TextBoxNewPlayAuthor.Text;
                    play.GenreId            = (ComboBoxNewPlayGenre.SelectedItem as Genres).GenreId;
                    play.ParentalGuidanceId = (ComboBoxNewPlayParentalGuidance.SelectedItem as ParentalGuidances).ParentalGuidanceId;
                    play.PlayPremiere       = TextBoxNewPlayPremiere.Text;

                    context.Plays.Add(play);
                    context.SaveChanges();

                    TextBoxNewPlayName.Text                      = "";
                    ComboBoxNewPlayGenre.SelectedItem            = null;
                    ComboBoxNewPlayParentalGuidance.SelectedItem = null;
                    TextBoxNewPlayAuthor.Text                    = "";
                    TextBoxNewPlayPremiere.Text                  = "";

                    TextBlockNewPlayError.Text = "";
                    TextBlockNewPlayOk.Text    = "Новый спектакль добавлен";
                }
            }
            else
            {
                TextBlockNewPlayOk.Text    = "";
                TextBlockNewPlayError.Text = "Все поля должны быть заполнены";
            }
        }
示例#3
0
        public UsersList()
        {
            InitializeComponent();

            using (TheaterDBContext context = new TheaterDBContext())
            {
                IEnumerable <PrfessionsName> enumerable;

                enumerable = (from i in context.Users
                              join j in context.Professions on i.ProfessionId equals j.ProfessionId
                              select new PrfessionsName()
                {
                    UserId = i.UserId,
                    UserLogin = i.UserLogin,
                    UserPassword = i.UserPassword,
                    UserFIO = i.UserFIO,
                    UserDOB = i.UserDOB,
                    ProfessionName = j.ProfessionName,
                    UserHight = i.UserHight,
                    UserSex = i.UserSex,
                    UserExperience = i.UserExperience,
                    UserSalary = i.UserSalary,
                    UserСhildrens = i.UserСhildrens,
                    UserAwards = i.UserAwards
                });

                enumerable = enumerable.Reverse();
                UsersListBox.ItemsSource = enumerable;
            }
        }
示例#4
0
        private void ButtonSavePlayEdit_Click(object sender, RoutedEventArgs e)
        {
            if (TextBoxPlayEditingName.Text != "" & ComboBoxPlayEditingGenre.SelectedIndex >= 0 & ComboBoxPlayEditingParentalGuidance.SelectedIndex >= 0 & TextBoxPlayEditingAuthor.Text != "" & TextBoxPlayEditingPremiere.Text != "")
            {
                using (TheaterDBContext context = new TheaterDBContext())
                {
                    var play = context.Plays.Single(p => p.PlayId == playId);

                    play.PlayName           = TextBoxPlayEditingName.Text;
                    play.PlayAuthor         = TextBoxPlayEditingAuthor.Text;
                    play.GenreId            = (ComboBoxPlayEditingGenre.SelectedItem as Genres).GenreId;
                    play.ParentalGuidanceId = (ComboBoxPlayEditingParentalGuidance.SelectedItem as ParentalGuidances).ParentalGuidanceId;
                    play.PlayPremiere       = TextBoxPlayEditingPremiere.Text;

                    context.SaveChanges();

                    TextBoxPlayEditingName.Text                      = "";
                    TextBoxPlayEditingAuthor.Text                    = "";
                    ComboBoxPlayEditingGenre.SelectedItem            = null;
                    ComboBoxPlayEditingParentalGuidance.SelectedItem = null;
                    TextBoxPlayEditingPremiere.Text                  = "";

                    TextBlockPlayEditingError.Text = "";
                    TextBlockPlayEditingOk.Text    = "Спектакль отредактирован";
                }
            }
            else
            {
                TextBlockPlayEditingOk.Text    = "";
                TextBlockPlayEditingError.Text = "Все поля должны быть заполнены";
            }
        }
示例#5
0
        public PlaysList()
        {
            InitializeComponent();

            using (TheaterDBContext context = new TheaterDBContext())
            {
                IEnumerable <ParentalGuidancesGenresValue> enumerable;

                enumerable = (from pl in context.Plays
                              join pa in context.ParentalGuidances on pl.ParentalGuidanceId equals pa.ParentalGuidanceId
                              join g in context.Genres on pl.GenreId equals g.GenreId
                              select new ParentalGuidancesGenresValue()
                {
                    PlayId = pl.PlayId,
                    PlayName = pl.PlayName,
                    PlayAuthor = pl.PlayAuthor,
                    GenreName = g.GenreName,
                    ParentalGuidanceValue = pa.ParentalGuidanceValue,
                    PlayPremiere = pl.PlayPremiere
                });

                enumerable = enumerable.Reverse();
                PlaysListBox.ItemsSource = enumerable;
            }
        }
示例#6
0
        public NewUser()
        {
            InitializeComponent();

            using (TheaterDBContext context = new TheaterDBContext())
            {
                var professions = (from u in context.Professions where u.ProfessionId != 1 select u).ToList();
                ComboBoxNewUserProfession.ItemsSource = professions;
            }
        }
示例#7
0
        public NewPlay()
        {
            InitializeComponent();

            using (TheaterDBContext context = new TheaterDBContext())
            {
                ComboBoxNewPlayGenre.ItemsSource            = context.Genres.ToList();
                ComboBoxNewPlayParentalGuidance.ItemsSource = context.ParentalGuidances.ToList();
            }
        }
示例#8
0
        public NewPerformance()
        {
            InitializeComponent();

            using (TheaterDBContext context = new TheaterDBContext())
            {
                var plays        = context.Plays.ToList();
                var directors    = (from u in context.Users where u.ProfessionId == 3 select u).ToList();
                var artDirectors = (from u in context.Users where u.ProfessionId == 4 select u).ToList();
                var dresser      = (from u in context.Users where u.ProfessionId == 6 select u).ToList();

                ComboBoxNewPerformancePlay.ItemsSource        = plays;
                ComboBoxNewPerformanceDirector.ItemsSource    = directors;
                ComboBoxNewPerformanceArtDirector.ItemsSource = artDirectors;
                ComboBoxNewPerformanceDresser.ItemsSource     = dresser;
            }
        }
示例#9
0
        private void ButtonSaveUserEditing_Click(object sender, RoutedEventArgs e)
        {
            if (TextBoxUserEditingFIO.Text != "" & ComboBoxUserEditingProfession.SelectedIndex >= 0 & TextBoxUserEditingDOB.Text != "" & TextBoxUserEditingSex.Text != "" & TextBoxUserEditingHight.Text != "" &
                TextBoxUserEditingExperience.Text != "" & TextBoxUserEditingSalary.Text != "" & TextBoxUserEditingChildrens.Text != "" & TextBoxUserEditingAwards.Text != "")
            {
                using (TheaterDBContext context = new TheaterDBContext())
                {
                    var user = context.Users.Single(u => u.UserId == userId);

                    user.UserFIO        = TextBoxUserEditingFIO.Text;
                    user.ProfessionId   = (ComboBoxUserEditingProfession.SelectedItem as Professions).ProfessionId;
                    user.UserDOB        = Convert.ToDateTime(TextBoxUserEditingDOB.Text);
                    user.UserSex        = TextBoxUserEditingSex.Text;
                    user.UserHight      = TextBoxUserEditingHight.Text;
                    user.UserExperience = TextBoxUserEditingExperience.Text;
                    user.UserSalary     = TextBoxUserEditingSalary.Text;
                    user.UserСhildrens  = Convert.ToInt32(TextBoxUserEditingChildrens.Text);
                    user.UserAwards     = TextBoxUserEditingAwards.Text;

                    context.SaveChanges();

                    TextBoxUserEditingFIO.Text = "";
                    ComboBoxUserEditingProfession.SelectedItem = null;
                    TextBoxUserEditingDOB.Text        = "";
                    TextBoxUserEditingSex.Text        = "";
                    TextBoxUserEditingHight.Text      = "";
                    TextBoxUserEditingExperience.Text = "";
                    TextBoxUserEditingSalary.Text     = "";
                    TextBoxUserEditingChildrens.Text  = "";
                    TextBoxUserEditingAwards.Text     = "";

                    TextBlockUserEditingError.Text = "";
                    TextBlockUserEditingOk.Text    = "Пользователь отредактирован";
                }
            }
            else
            {
                TextBlockUserEditingOk.Text    = "";
                TextBlockUserEditingError.Text = "Все поля должны быть заполнены";
            }
        }
示例#10
0
        public PlayEdit(int pId)
        {
            InitializeComponent();

            playId = pId;

            using (TheaterDBContext context = new TheaterDBContext())
            {
                var play = context.Plays.Single(u => u.PlayId == playId);

                ComboBoxPlayEditingGenre.ItemsSource  = context.Genres.ToList();
                ComboBoxPlayEditingGenre.SelectedItem = context.Genres.Single(g => g.GenreId == play.GenreId);

                ComboBoxPlayEditingParentalGuidance.ItemsSource  = context.ParentalGuidances.ToList();
                ComboBoxPlayEditingParentalGuidance.SelectedItem = context.ParentalGuidances.Single(pa => pa.ParentalGuidanceId == play.ParentalGuidanceId);

                TextBoxPlayEditingName.Text     = play.PlayName;
                TextBoxPlayEditingAuthor.Text   = play.PlayAuthor;
                TextBoxPlayEditingPremiere.Text = play.PlayPremiere;
            }
        }
示例#11
0
        private void ButtonSaveNewPerformance_Click(object sender, RoutedEventArgs e)
        {
            if (ComboBoxNewPerformancePlay.SelectedIndex >= 0 & ComboBoxNewPerformanceDirector.SelectedIndex >= 0 & ComboBoxNewPerformanceArtDirector.SelectedIndex >= 0 & ComboBoxNewPerformanceDresser.SelectedIndex >= 0 &
                TextBoxNewPerformanceDate.Text != "" & TextBoxNewPerformanceTime.Text != "" & TextBoxNewPerformanceLocation.Text != "" & TextBoxNewPerformancePrice.Text != "")
            {
                using (TheaterDBContext context = new TheaterDBContext())
                {
                    Performances performance = new Performances();

                    performance.PlayId = (ComboBoxNewPerformancePlay.SelectedItem as Plays).PlayId;
                    performance.PerformanceDirector    = (ComboBoxNewPerformanceDirector.SelectedItem as Users).UserFIO.ToString();
                    performance.PerformanceArtDirector = (ComboBoxNewPerformanceArtDirector.SelectedItem as Users).UserFIO.ToString();
                    performance.PerformanceDresser     = (ComboBoxNewPerformanceDresser.SelectedItem as Users).UserFIO.ToString();
                    performance.PerformanceDate        = Convert.ToDateTime(TextBoxNewPerformanceDate.Text);
                    performance.PerformanceTime        = Convert.ToDateTime(TextBoxNewPerformanceTime.Text);
                    performance.PerformanceLocation    = TextBoxNewPerformanceLocation.Text;
                    performance.PerformancePrice       = TextBoxNewPerformancePrice.Text;

                    context.Performances.Add(performance);
                    context.SaveChanges();

                    ComboBoxNewPerformancePlay.SelectedItem        = null;
                    ComboBoxNewPerformanceDirector.SelectedItem    = null;
                    ComboBoxNewPerformanceArtDirector.SelectedItem = null;
                    ComboBoxNewPerformanceDresser.SelectedItem     = null;
                    TextBoxNewPerformanceDate.Text     = "";
                    TextBoxNewPerformanceTime.Text     = "";
                    TextBoxNewPerformanceLocation.Text = "";
                    TextBoxNewPerformancePrice.Text    = "";

                    TextBlockNewPerformanceError.Text = "";
                    TextBlockNewPerformanceOk.Text    = "Новая постановка добавлена";
                }
            }
            else
            {
                TextBlockNewPerformanceOk.Text    = "";
                TextBlockNewPerformanceError.Text = "Все поля должны быть заполнены";
            }
        }
示例#12
0
        private void ButtonSignInAdmin_Click(object sender, RoutedEventArgs e)
        {
            if (TextBoxSignInAdminLogin.Text != "" & PasswordBoxSignInAdminPassword.Password != "")              //проверка на пустые поля ввода
            {
                using (TheaterDBContext context = new TheaterDBContext())
                {
                    var   users     = context.Users.ToList();
                    Users user      = new Users();
                    bool  checkUser = false;

                    foreach (Users u in users)
                    {
                        if (u.UserLogin == TextBoxSignInAdminLogin.Text & u.UserPassword == PasswordBoxSignInAdminPassword.Password)                          //авторизация пользователя в базе
                        {
                            checkUser = true;
                            user      = u;
                            break;
                        }
                        else
                        {
                            checkUser = false;
                        }
                    }
                    if (checkUser)
                    {
                        Frames.frame.Content = new MainPage();                          //переход на главное окно
                    }
                    else
                    {
                        TextBlockAdminError.Text = "Введены неверные данные";
                    }
                }
            }
            else
            {
                TextBlockAdminError.Text = "Все поля должны быть заполнены";
            }
        }
示例#13
0
        public UserEdit(int uId)
        {
            InitializeComponent();

            userId = uId;

            using (TheaterDBContext context = new TheaterDBContext())
            {
                var user = context.Users.Single(u => u.UserId == userId);

                ComboBoxUserEditingProfession.ItemsSource  = context.Professions.ToList();
                ComboBoxUserEditingProfession.SelectedItem = context.Professions.Single(p => p.ProfessionId == user.ProfessionId);

                TextBoxUserEditingFIO.Text        = user.UserFIO;
                TextBoxUserEditingDOB.Text        = (user.UserDOB ?? DateTime.Now).ToString("d");
                TextBoxUserEditingHight.Text      = user.UserHight;
                TextBoxUserEditingSex.Text        = user.UserSex;
                TextBoxUserEditingSalary.Text     = user.UserSalary;
                TextBoxUserEditingChildrens.Text  = user.UserСhildrens.ToString();
                TextBoxUserEditingExperience.Text = user.UserExperience;
                TextBoxUserEditingAwards.Text     = user.UserAwards;
            }
        }
        public PerformancesList()
        {
            InitializeComponent();

            using (TheaterDBContext context = new TheaterDBContext())
            {
                IEnumerable <PlaysName> enumerable;

                enumerable = (from pe in context.Performances
                              join pl in context.Plays on pe.PlayId equals pl.PlayId
                              select new PlaysName()
                {
                    PerformanceId = pe.PerformanceId,
                    PlayName = pl.PlayName,
                    PerformanceDate = pe.PerformanceDate.ToString(),
                    PerformanceTime = pe.PerformanceTime.ToString(),
                    PerformanceLocation = pe.PerformanceLocation,
                    PerformancePrice = pe.PerformancePrice,
                });

                enumerable = enumerable.Reverse();
                PerformancesListBox.ItemsSource = enumerable;
            }
        }
 public MoviesController(TheaterDBContext context)
 {
     _context = context;
 }