/// <summary> /// Creates the login form with all the components /// This section also adds the login button and its functionality /// </summary> private void CreateLoginForm() { Form form = new Form() { Width = 300, Height = 275, BackColor = Color.WhiteSmoke, StartPosition = FormStartPosition.CenterScreen }; Label mainText = new Label() { Left = 125, Top = 10, Text = "Login", Font = new Font("Arial", 11, FontStyle.Bold) }; Label loginText = new Label() { Left = 10, Top = 40, Text = "User", Font = new Font("Arial", 11, FontStyle.Bold), TextAlign = ContentAlignment.MiddleLeft }; TextBox loginInput = new TextBox() { Left = 10, Top = 70, Font = new Font("Arial", 9), Width = 120, MaxLength = 15 }; Label passText = new Label() { Left = 10, Top = 100, Text = "Password", Font = new Font("Arial", 11, FontStyle.Bold), TextAlign = ContentAlignment.MiddleLeft }; TextBox passInput = new TextBox() { Left = 10, Top = 130, Font = new Font("Arial", 9), Width = 120, PasswordChar = '*' }; Button logButton = new Button { Font = new Font("Arial", 11, FontStyle.Bold), Text = "Login", Dock = DockStyle.Bottom, Height = 40 }; Button cancelButon = new Button { Font = new Font("Arial", 11, FontStyle.Bold), Text = "Cancel", Dock = DockStyle.Bottom, Height = 40, DialogResult = DialogResult.Cancel }; cancelButon.Click += (o, e) => { form.Close(); }; logButton.Click += async(o, e) => { if (VerifyEmptyLogin(loginInput.Text, passInput.Text)) { var logResult = await AccountActions.Login(new List <string> { $"user={loginInput.Text}", $"password={passInput.Text}" }); if (logResult) { MessageBox.Show("Welcome Back"); form.Close(); } else { MessageBox.Show("User or password is incorrect"); } } else { MessageBox.Show("Something is not right here, make sure all fields are filled"); } }; form.Controls.Add(mainText); form.Controls.Add(loginText); form.Controls.Add(loginInput); form.Controls.Add(passText); form.Controls.Add(passInput); form.Controls.Add(logButton); form.Controls.Add(cancelButon); form.ShowDialog(); }