private void Login() { l.Username = txtUsername.Text.Trim(); l.Password = txtPassword.Text.Trim(); l.UserType = cmbUserType.Text.Trim(); //Checking the login credentials var sucess = dal.loginCheck(l); if (sucess) { //Login Successfull //MessageBox.Show("Login Successful."); loggedIn = l.Username; //Need to open Respective Forms based on User Type switch (l.UserType) { case "Admin": { //Display Admin Dashboard var admin = new FrmAdminDashboard(); admin.Show(); Hide(); } break; case "User": { //Display User Dashboard var user = new FrmUserDashboard(); user.Show(); Hide(); } break; default: { //Display an error message MessageBox.Show(Resources.frmLogin_Login_Invalid_User_Type_); } break; } } else { //login Failed MessageBox.Show(Resources.frmLogin_Login_Login_Failed__Try_Again); } }
private void btnLogin_Click(object sender, EventArgs e) { l.username = txtUsername.Text.Trim(); l.password = txtPassword.Text.Trim(); l.user_type = cmbUserType.Text.Trim(); //checking the login credentials bool sucess = dal.loginCheck(l); if (sucess == true) { //login successfull MessageBox.Show("Login Successfull"); loggedIn = l.username; //Need to open resp. forms based on user type switch (l.user_type) { case "Admin": { //display Admin dashboard FrmAdminDashboard admin = new FrmAdminDashboard(); admin.Show(); this.Hide(); } break; case "User": { //display user dashboard FrmUserDashboard user = new FrmUserDashboard(); user.Show(); this.Hide(); } break; default: { //display an error message MessageBox.Show("Invalid User Type"); } break; } } else { //login failed MessageBox.Show("Login Failed! Try Again."); } }
private void BtnLogin_Click(object sender, EventArgs e) { if (MskSicil.Text.Trim() == "" || TxtPassword.Text.Trim() == "") { MessageBox.Show("Lütfen Sicil Numaranızla Birlikte Şifrenizi Giriniz", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } object[] infos = personnelManager.Login(MskSicil.Text, TxtPassword.Text); if (infos == null) { MessageBox.Show("Hatalı Sicil No Veya Şifre Girdiniz", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MessageBox.Show("Sayın " + infos[2] + " Hoşgeldiniz", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); if (infos[5].ConInt() == 1) { DialogResult dr = MessageBox.Show("Admin Pencerenizi Açmak İster Misiniz ? ", "Soru", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { FrmAdminDashboard frmAdminDashboard = new FrmAdminDashboard(); frmAdminDashboard.infos = infos; frmAdminDashboard.Show(); } else { ShowWorkerDahsboard(infos); } this.Hide(); } else { ShowWorkerDahsboard(infos); this.Hide(); } }
private void btnLogin_Click(object sender, EventArgs e) { try { if (Validator.IsDataPresent(txtUsername)) { if (Validator.IsDataPresent(txtPassword)) { char c = txtUsername.Text.First(); if (c == 'A') { Admin admin = (Admin)Validator.IsValidInputId(typeof(Admin), txtUsername.Text); if (admin != null) { if (admin.Password.Equals(txtPassword.Text)) { MessageBox.Show("Login Successfull!!", "Success Message"); this.Hide(); FrmAdminDashboard adminForm = new FrmAdminDashboard(admin); adminForm.Show(); } else { throw new CustomMadeException("Wrong Password!!"); } } else { throw new CustomMadeException("No admin with id " + txtUsername.Text + " exists"); } } else if (c == 'M') { Manager manager = (Manager)Validator.IsValidInputId(typeof(Manager), txtUsername.Text); if (manager != null) { if (manager.Password.Equals(txtPassword.Text)) { MessageBox.Show("Login Successfull!!", "Success Message"); this.Hide(); FrmManagerDashboard managerForm = new FrmManagerDashboard(manager); managerForm.Show(); } else { throw new CustomMadeException("Wrong Password!!"); } } else { throw new CustomMadeException("No manager with id " + txtUsername.Text + " exists"); } } else if (c == 'R') { Reportee reportee = (Reportee)Validator.IsValidInputId(typeof(Reportee), txtUsername.Text); if (reportee != null) { if (reportee.Password.Equals(txtPassword.Text)) { MessageBox.Show("Login Successfull!!", "Success Message"); this.Hide(); ReporteeDashboard reporteeForm = new ReporteeDashboard(); reporteeForm.Show(); } else { throw new CustomMadeException("Wrong Password!!"); } } else { throw new CustomMadeException("No reportee with id " + txtUsername.Text + " exists"); } } else { throw new CustomMadeException("Invalid Id!!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }