Exemplo n.º 1
0
        private void UpdateStackPanel()
        {
            while (AllUsers.Items.Count > 1)
            {
                AllUsers.Items.RemoveAt(1);
            }

            List <StackPanel> list = UsersInteraction.GetStackPanelList(user.TheClassesId.Value);

            foreach (var item in list)
            {
                AllUsers.Items.Add(item);
            }
        }
Exemplo n.º 2
0
        private void Upload_image_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofdPicture = new OpenFileDialog();

            ofdPicture.Filter =
                "Image files|*.bmp;*.jpg;*.gif;*.png;*.tif|All files|*.*";
            ofdPicture.FilterIndex = 1;

            if (ofdPicture.ShowDialog() == DialogResult.OK)
            {
                imgPicture.Source = new BitmapImage(new Uri(ofdPicture.FileName));
                UsersInteraction.SetImagePath(ofdPicture.FileName, user);
            }
        }
Exemplo n.º 3
0
        private void Registration_Click(object sender, RoutedEventArgs e)
        {
            string login = LoginBox.Text.ToLower();

            string password = PasswordBox.Password;

            string first_name  = First_NameBox.Text;
            string middle_name = Middle_NameBox.Text;
            string last_name   = Last_NameBox.Text;

            string phone = PhoneBox.Text;

            int    the_class = Int32.Parse(The_class_name.SelectedItem.ToString());
            string letter    = The_class_letter.SelectedValue.ToString();

            if (Position_name.SelectedIndex == -1)
            {
                MessageBox.Show("Выберите роль!");
                return;
            }

            if (login.Length == 0 || password.Length == 0 || first_name.Length == 0 || middle_name.Length == 0 || last_name.Length == 0)
            {
                MessageBox.Show("Пожалуйста, заполните все поля!", "Ошибка");
                return;
            }

            User user = new User
            {
                FirstName  = first_name,
                MiddleName = middle_name,
                LastName   = last_name,

                Login    = login,
                Password = PasswordInteraction.GetPasswordHash(password),

                Phone = phone,

                TheClassesId = unitOfWork.TheClasses.GetTheClassByNumber(the_class, letter)
            };


            if (UsersInteraction.RegisterRequestStatus(user) == false)
            {
                MessageBox.Show("Пользователь с таким логином уже зарегистрирован!", "Error");
                return;
            }

            if (Position_name.SelectedValue.ToString() == "Учитель")
            {
                int subject_id = Specialisation.SelectedIndex + 1;
                TeachersInteraction.Insert_Teacher(user, subject_id);
            }

            MessageBox.Show("Вы успешно зарегистрировались!", "Info");

            user = unitOfWork.Users.GetUserByName(first_name, last_name, middle_name);

            mainWindow.user = user;

            if (TeachersInteraction.IsTeacher(user))
            {
                mainWindow.Navigation.Navigate(new TeacherPage(mainWindow, TeachersInteraction.GetTeacherModel(user)));
            }
            else
            {
                mainWindow.Navigation.Navigate(new UserPage(mainWindow, user));
            }
        }