private void btnConfirm_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.passwordTextBox1.Text) || String.IsNullOrEmpty(this.passwordTextBox2.Text)) { return; } if (!this.passwordTextBox1.Text.Equals(this.passwordTextBox2.Text)) { return; } if (this.passwordTextBox1.Text.Length < AuthorizationBusinessService.PASSWORD_CHAR_MIN) { return; } this.lblError.Text = String.Empty; LoginForm loginForm = (LoginForm)_formsService.GetFormByCode(FormTypeCodes.LoginForm); string hash = new AuthorizationBusinessService().HashPassword(this.passwordTextBox1.Text); MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm); mainForm.loggedUser = _formsService.UsersService.SaveUserPassword(loginForm.GetUserName.Text, hash); _formsService.ResetFormTextBoxes(this.Controls); _formsService.ActivateForm(FormTypeCodes.MainForm); _formsService.ResetFormTextBoxes(loginForm.Controls); }
private void LoadDocumentDetails(DocumentDTO document) { if (document == null) { throw new ArgumentNullException("document"); } DocumentDetailsForm form = (DocumentDetailsForm)_formsService.GetFormByCode(FormTypeCodes.DocumentDetailsForm); form.documentDto = document; _formsService.ActivateForm(FormTypeCodes.DocumentDetailsForm); }
private void btnRegister_Click(object sender, EventArgs e) { try { if (AnyErrors()) { return; } lblError.Text = String.Empty; UserDTO user = new UserDTO(); user.UserName = this.userNameTextBox.Text; user.PasswordHash = new AuthorizationBusinessService().HashPassword(this.passwordTextBox1.Text); user.HasEmptyPassword = false; user.FirstName = this.txtBoxFirstName.Text; user.LastName = this.txtBoxLastName.Text; user.Email = this.txtBoxEmail.Text; user.ContactPhone = this.txtBoxPhone.Text; user.OfficeNumber = this.txtBoxOfficeNumber.Text; user.Title = this.txtBoxTitle.Text; user.IsValid = true; user.AuthorizationRole = AuthorizationRoleCodes.Operator; MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm); mainForm.loggedUser = _formsService.UsersService.SaveUserDTO(user); _formsService.ActivateForm(FormTypeCodes.MainForm); _formsService.ResetFormTextBoxes(this.Controls); } catch (Exception ex) { BusinessServiceBase.logger.Error(ex.Message); this.lblError.Text = "Došlo je do sistemske greške. Kontaktirajte administratora."; } }
private void TryToLogin() { try { if (String.IsNullOrEmpty(this.UserName.Text)) { return; } _user = _formsService.UsersService.LoadUserByName(this.UserName.Text); if (_user.HasEmptyPassword && this.Password.Text.Equals("")) { _formsService.ActivateForm(FormTypeCodes.NewPasswordForm); this.lblError.Text = String.Empty; return; } if (String.IsNullOrEmpty(this.Password.Text)) { this.lblError.Text = String.Format("Morate uneti lozinku."); return; } string inputHash = _authorizationService.HashPassword(this.Password.Text); if (inputHash.Equals(_user.PasswordHash)) { MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm); mainForm.loggedUser = _user; _formsService.ActivateForm(FormTypeCodes.MainForm); _formsService.ResetFormTextBoxes(this.Controls); this.lblError.Text = String.Empty; return; } this.lblError.Text = String.Format("Uneta lozinka nije ispravna."); } catch (UserNotFoundException ex) { this.lblError.Text = String.Format("{0}'{1}'.", ex.Message, this.UserName.Text); } catch (Exception ex) { BusinessServiceBase.logger.Error(ex); this.lblError.Text = "Došlo je do sistemske greške. Kontaktirajte administratora."; } }
private void btnSaveComment_Click(object sender, EventArgs e) { try { if (!_loadedDocumentVersionId.HasValue || String.IsNullOrEmpty(this.txtBoxNewComment.Text)) { return; } CommentDTO commentDto = new CommentDTO(); MainForm form = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm); commentDto.UserId = form.loggedUser.Id; commentDto.DocumentVersionId = _loadedDocumentVersionId.Value; commentDto.Text = this.txtBoxNewComment.Text; _formsService.DocumentsService.SaveNewComment(commentDto); this.txtBoxNewComment.Text = String.Empty; LoadComments(_loadedDocumentVersionId.Value); } catch (Exception ex) { BusinessServiceBase.logger.Error(ex.Message); } }