private void loadUserData() { DACNPM db = new DACNPM(); Entities.Account list = db.Accounts.Where(p => p.Username == Username).FirstOrDefault(); lbName.Text = list.Username; lbPost.Text = list.Type_Account.Name_Type; }
private void btnLogin_Click(object sender, EventArgs e) { if (txtUser.Text != "USERNAME" && txtUser.TextLength > 2) { if (txtPass.Text != "PASSWORD") { DACNPM db = new DACNPM(); var list = db.Accounts.Where(p => p.Username == txtUser.Text && p.UserPassword == txtPass.Text) .Select(p => p); if (list.ToList().Count != 0) { this.Hide(); //FormWellcome wellcome = new FormWellcome(); //wellcome.ShowDialog(); MainForm mainForm = new MainForm(txtUser.Text); mainForm.Show(); mainForm.FormClosed += Logout; } else { msgError("Incorrect username or password entered. \n Please try again."); txtPass.Text = "PASSWORD"; txtPass.UseSystemPasswordChar = false; txtUser.Focus(); } } else { msgError("Please enter password."); } } else { msgError("Please enter username."); txtPass.Text = "PASSWORD"; txtPass.UseSystemPasswordChar = false; txtUser.Focus(); } }