private void SubmitAuthorization_ClickAsync(object sender, EventArgs e) { if (!((loginLineTextField.Text == "") || (passwordLineTextField.Text == ""))) { if (loginLineTextField.Text[0] >= '0' && loginLineTextField.Text[0] <= '9') { loginLineTextField.Text = ""; passwordLineTextField.Text = ""; incorrectLabel.ForeColor = Color.Red; incorrectLabel.Visible = true; } var res = serviceAuthorization.AuthorityVerify(loginLineTextField.Text, passwordLineTextField.Text); (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.CurrentUser = res.Result; if ((Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.CurrentUser != null) { (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.NameLabel.Text = (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.CurrentUser.FirstName; (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.PositionLabel.Text = (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.CurrentUser.Position; (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.RatingLabel.Text = (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.CurrentUser.Rating.ToString(); (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.AccessContoll((Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.CurrentUser.AccessModifier); (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.SeedListViewAsync(); (Form.ActiveForm as ManagementSystemForm).UserControlMainMenu.ListDoneTaskView(); (Form.ActiveForm as ManagementSystemForm).AuthorityUserControl.Visible = false; (Form.ActiveForm as ManagementSystemForm).MainPanel.Controls.Add((Form.ActiveForm as ManagementSystemForm).UserControlMainMenu); (Form.ActiveForm as ManagementSystemForm).MainPanel.Controls.Remove((Form.ActiveForm as ManagementSystemForm).AuthorityUserControl); } else { loginLineTextField.Text = ""; passwordLineTextField.Text = ""; incorrectLabel.Visible = true; } } }