//MouseClick Auth and Click Panel //Mouse Click Autorization private void ButtonAuth_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrWhiteSpace(TextBoxLogin.Text) && !String.IsNullOrWhiteSpace(PasswordBoxPassword.Password)) { if (CreateLoadAnimation(MainAuthRegGrid)) { try { ReferenseDALClass user = new ReferenseDALClass(); if (user.SetConnectionDBCheckUser(TextBoxLogin.Text, PasswordBoxPassword.Password)) { userInfoList = user.userListInformantion; if (!ToggleButtonYesNo.StateClosed) { SerializeToggleButtonCheck(userInfoList); } else { try { using (StreamWriter sw = new StreamWriter("SET_COOKIEUSER.xml")) { sw.WriteLine(string.Empty); } } catch { } } loadedControl.StopAnimation(); new MainWindow(userInfoList).Show(); this.Close(); } else { loadedControl.StopAnimation(); ErrorReg("Неверный логин или пароль!"); } } catch { loadedControl.StopAnimation(); ErrorReg("Ошибка авторизации!"); } } } else { if (String.IsNullOrWhiteSpace(TextBoxLogin.Text)) { BorderLoginTextBox.Background = Brushes.Red; } if (String.IsNullOrWhiteSpace(PasswordBoxPassword.Password)) { BorderPasswordPasswordBox.Background = Brushes.Red; } } }
public HomePage(MainWindow mWindow) { InitializeComponent(); _mWindow = mWindow; ReferenseDALClass refClassDAL = new ReferenseDALClass(); loadedControl = new LoadingAnimation(); MainSheldueGrid.Children.Add(loadedControl); loadedControl.StartAnimation(); allSheldueList = _mWindow.GetSheldue; if (allSheldueList == null) { userNotes = new List <UserNotes>(refClassDAL.SetConnectionDBSelectAll(_mWindow._userInfo.ID)); _mWindow.KindThrowMessage.Foreground = FindResource("WarningForegroundColorUIElements") as SolidColorBrush; _mWindow.KindThrowMessage.Kind = MaterialDesignThemes.Wpf.PackIconKind.WarningOutline; _mWindow.TextBlockMessageThrow.Text = "Расписание загружается! Не закрывайте программу!"; Storyboard sb = _mWindow.FindResource("ShowMessageThrowGrid") as Storyboard; sb.Begin(); _mWindow.IsEnabled = false; switch (_mWindow._userInfo.Status) { case teacher: Task.Run(() => this.Dispatcher.BeginInvoke((ThreadStart) delegate() { LoadSheldueAsyncMethod(false); })); break; case student: Task.Run(() => this.Dispatcher.BeginInvoke((ThreadStart) delegate() { LoadSheldueAsyncMethod(true); })); break; } } else { ListViewSheldueDay.ItemsSource = allSheldueList; StopAnimation.Tick += new EventHandler(StopMethodAnimation); StopAnimation.Interval = new TimeSpan(0, 0, 1); StopAnimation.Start(); } DateTime firstDate = GetFirstDateOfWeek(DayOfWeek.Monday); var lastDate = GetLastDateOfWeek(DayOfWeek.Saturday); GetListDateOfWeek(firstDate, lastDate); refClassDAL.SetConnectionDBDeleteNote(listDate[0]); }
private async void ButtonReg_Click(object sender, RoutedEventArgs e) { CheckValidateForm checkValidate = new CheckValidateForm(); switch (PersonComboBox.SelectedIndex) { case 0: if (!String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password) && !String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { if (checkValidate.IsValidateEmail(TextBoxNameUser.Text)) { if (checkValidate.IsValidatePassword(PasswordBoxPasswordOrigin.Password)) { CreateLoadAnimation(MainAuthRegGrid); ReferenseDALClass refClassDAL = new ReferenseDALClass(); //await Task.Run((Action)delegate () { this.Dispatcher.BeginInvoke((ThreadStart)delegate () { var userExcl = methodsCheckUser.CheckExclusiveUser(TextBoxLogin.Text); }); }).ConfigureAwait(true); bool userExcl = refClassDAL.SetConnectionDBCheckExcluziveUser(TextBoxNameUser.Text); if (userExcl) { try { IFCore.User userLogin = new IFCore.User() { Email = TextBoxNameUser.Text, Password = cryptPassword.CalculateMD5Hash(PasswordBoxPasswordOrigin.Password).ToString() }; IFCore.UserInfo userInfo = new IFCore.UserInfo() { UserStatus = PersonComboBox.SelectedValue.ToString(), UserDepartment = TeacherNameorDepartment.SelectedValue.ToString(), UserGroup = GroupListComboBox.SelectedValue.ToString() }; await refClassDAL.SetConnectionDBRegUser(userLogin, userInfo); loadedControl.StopAnimation(); SeccessfulReg(); } catch (Exception ex) { string exs = ex.ToString(); loadedControl.StopAnimation(); ErrorReg("Ошибка регистрации!"); } } else { loadedControl.StopAnimation(); ErrorReg("Учащийся с таким e-mail, зарегистрирован!"); } } else { BorderPasswordBoxUser.Background = Brushes.Red; ErrorReg("Пароль не соотвествует требования!"); } } else { BorderTexBoxUser.Background = Brushes.Red; ErrorReg("Логин не соотвествует требования!"); } } else { if (String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password)) { BorderPasswordBoxUser.Background = Brushes.Red; } if (String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { BorderTexBoxUser.Background = Brushes.Red; } } break; case 1: if (!String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password) && !String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { if (checkValidate.IsValidateEmail(TextBoxNameUser.Text)) { if (checkValidate.IsValidatePassword(PasswordBoxPasswordOrigin.Password)) { CreateLoadAnimation(MainAuthRegGrid); ReferenseDALClass refClassDAL = new ReferenseDALClass(); bool userExcl = refClassDAL.SetConnectionDBCheckExcluziveUser(TextBoxNameUser.Text); if (userExcl) { try { await refClassDAL.SetConnectionDBRegUser( new User() { Email = TextBoxNameUser.Text, Password = cryptPassword.CalculateMD5Hash(PasswordBoxPasswordOrigin.Password).ToString() }, new UserInfo() { UserName = TeacherNameorDepartment.SelectedValue.ToString(), UserStatus = PersonComboBox.SelectedValue.ToString() }); loadedControl.StopAnimation(); SeccessfulReg(); } catch { loadedControl.StopAnimation(); ErrorReg("Ошибка регистрации!"); } } else { loadedControl.StopAnimation(); ErrorReg("Данный преподаватель, зарегистрирован!"); } } else { BorderPasswordBoxUser.Background = Brushes.Red; ErrorReg("Пароль не соотвествует требования!"); } } else { BorderTexBoxUser.Background = Brushes.Red; ErrorReg("Логин не соотвествует требования!"); } } else { if (String.IsNullOrWhiteSpace(PasswordBoxPasswordOrigin.Password)) { BorderPasswordBoxUser.Background = Brushes.Red; } if (String.IsNullOrWhiteSpace(TextBoxNameUser.Text)) { BorderTexBoxUser.Background = Brushes.Red; } } break; } }