private void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUsername.Text)) { MetroFramework.MetroMessageBox.Show(this, "Va rugam sa introduceti un utilizator.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsername.Focus(); return; } if (string.IsNullOrEmpty(txtPassword.Text)) { MetroFramework.MetroMessageBox.Show(this, "Va rugam sa introduceti o parola.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Focus(); return; } try { using (BDISAppEntities db = new BDISAppEntities()) { var query = from u in db.Users where u.username == txtUsername.Text && u.password == txtPassword.Text select u; if (query.SingleOrDefault() != null) { this.Hide(); BDISAppDashboard app = new BDISAppDashboard(); app.ShowDialog(); } else { MetroFramework.MetroMessageBox.Show(this, "Utilizatorul sau parola nu sunt corecte.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BSIDAppDashboard_Load(object sender, EventArgs e) { _instance = this; }