musicschool/musicschoolapp/WorkingWindow.xaml.cs

90 lines
3.4 KiB
C#
Raw Permalink Normal View History

using musicschoolapp.Pages;
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
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 musicschoolapp
{
/// <summary>
/// Логика взаимодействия для WorkingWindow.xaml
/// </summary>
public partial class WorkingWindow : Window
{
StudentEditingPage studentEditingPage;
CourseEditingPage c;
EnrollmentEditingPage s;
QuickEnroll qe;
Instr instr;
public WorkingWindow(User user)
{
InitializeComponent();
studentEditingPage = new StudentEditingPage();
qe = new QuickEnroll();
c = new CourseEditingPage(true);
s = new EnrollmentEditingPage(true);
instr = new Instr();
MenuPage menuPage = new MenuPage(studentEditingPage, c, s, instr);
if(user.permission_level >=2)
{
s = new EnrollmentEditingPage(true);
menuPage.courseButton.IsEnabled = true;
menuPage.studentButton.IsEnabled = true;
menuPage.enrollmentButton.IsEnabled = true;
menuPage.adminButton.IsEnabled = true;
menuPage.instrButton.IsEnabled = true;
}
else if(user.permission_level >= 1)
{
s = new EnrollmentEditingPage(true);
//menuPage.courseButton.IsEnabled = true;
//menuPage.studentButton.IsEnabled = true;
menuPage.enrollmentButton.IsEnabled = true;
menuPage.studentButton.IsEnabled = true;
menuPage.instrButton.IsEnabled = true;
}
else
{
menuPage.enrollmentButton.IsEnabled = true;
menuPage.quickEnrollButton.IsEnabled = false;
s = new EnrollmentEditingPage(false);
}
menuPage.enrollmentEditingPage = s;
identifier.Text = "Вы вошли как " + user.username + " с уровнем доступа " + user.permission_level;
MainFrame.Navigate(menuPage);
}
private void buttonUpdate_Click(object sender, RoutedEventArgs e)
{
if (MainFrame.NavigationService.Content == studentEditingPage)
{
MessageBox.Show("Обновлена ли база данных:" + studentEditingPage.updateDB().ToString());
}
else if (MainFrame.NavigationService.Content == c)
{
MessageBox.Show("Обновлена ли база данных Курсов:" + c.updateDB().ToString());
}
else if(MainFrame.NavigationService.Content == s)
{
MessageBox.Show("Обновлена ли база данных Зачисления:" + s.updateDB().ToString());
}
else if (MainFrame.NavigationService.Content == instr)
{
MessageBox.Show("Обновлена ли база данных Инструментов:" + instr.updateDB().ToString());
}
}
}
}