private void btnDashboard_Click(object sender, EventArgs e) { frmDashboard dash = new frmDashboard(idUser); this.Hide(); dash.ShowDialog(); this.Close(); }
private void frmDashboardAdm_Load(object sender, EventArgs e) { while (true) { try { string nome; con = new Connection("localhost", "5432", "postgres", "postgres", "admin"); string sql = "SELECT * FROM public.user WHERE id_user="******"Algo deu errado!\n\nFaça seu Login novamente!", MessageBoxIcon.Error); frmLogin login = new frmLogin(); this.Hide(); login.ShowDialog(); this.Close(); } break; } catch (Exception ex) { con.Close(); util.Msg("Algo deu errado!\n\nMais detalhes:" + ex.Message + "\n\nFaça seu Login novamente!", MessageBoxIcon.Error); frmLogin login = new frmLogin(); this.Hide(); login.ShowDialog(); this.Close(); } } }
void voltar() { switch (formOption) { case 0: //login frmLogin login = new frmLogin(); this.Hide(); login.ShowDialog(); this.Close(); break; case 1: //admin dashboard if (!backToDash) { frmConsultaEmprestimo consultaEmprestimo = new frmConsultaEmprestimo(userId, formOption); this.Hide(); consultaEmprestimo.ShowDialog(); this.Close(); } else { frmDashboardAdm adm = new frmDashboardAdm(userId); this.Hide(); adm.ShowDialog(); this.Close(); } break; case 2: //user dashboard frmDashboard dash = new frmDashboard(userId); this.Hide(); dash.ShowDialog(); this.Close(); break; case 3: //inicio frmInicio inicio = new frmInicio(); this.Hide(); inicio.ShowDialog(); this.Close(); break; default: formOption = 3; voltar(); break; } }
void voltar() { switch (formOption) { case 0: //login frmLogin login = new frmLogin(); this.Hide(); login.ShowDialog(); this.Close(); break; case 1: //admin dashboard frmDashboardAdm adm = new frmDashboardAdm(userId); this.Hide(); adm.ShowDialog(); this.Close(); break; case 2: //user dashboard frmDashboard dash = new frmDashboard(userId); this.Hide(); dash.ShowDialog(); this.Close(); break; case 3: //inicio frmInicio inicio = new frmInicio(); this.Hide(); inicio.ShowDialog(); this.Close(); break; case 4: //selUser frmSelecionaUser selUser = new frmSelecionaUser(userId, formUser); this.Hide(); selUser.ShowDialog(); this.Close(); break; default: formOption = 3; voltar(); break; } }
void subLogin() { try { if (valCampos()) { string user = txtUser.Text; string senha = txtSenha.Text; senha = util.Md5(senha); con = new Connection("localhost", "5432", "postgres", "postgres", "admin"); string sql = "SELECT * FROM public.user WHERE ra='" + user + "' OR login='******'"; NpgsqlDataReader dr = con.Select(sql); if (dr.HasRows) { dr.Read(); string senhaBanco = dr.GetString(4); if (senha == senhaBanco) { if (!dr.GetBoolean(12)) { if (dr.GetBoolean(11)) { if (util.ConfirmaMsg("Deseja ir ao Painel de Administração?")) { frmDashboardAdm adm = new frmDashboardAdm(dr.GetInt64(0)); this.Hide(); adm.ShowDialog(); this.Close(); } else { frmDashboard pan = new frmDashboard(dr.GetInt64(0)); this.Hide(); pan.ShowDialog(); this.Close(); } } else { frmDashboard pan = new frmDashboard(dr.GetInt64(0)); this.Hide(); pan.ShowDialog(); this.Close(); } } else { util.Msg("Este usuário está bloqueado!\n\nSe isso parece errado, contate um administrador!", MessageBoxIcon.Error); } } else { util.Msg("Senha incorreta!\n\nSe esqueceu sua senha, contate um administrador para alterá-la!", MessageBoxIcon.Error); txtSenha.Text = ""; txtSenha.Focus(); } } else { util.Msg("Usuário inexistente!", MessageBoxIcon.Error); txtUser.Text = ""; txtSenha.Text = ""; txtUser.Focus(); } con.Close(); } else { util.Msg("Alguns campos não foram preenchidos!", MessageBoxIcon.Error); } } catch (Exception ex) { util.Msg("Algo deu errado!\n\nMais detalhes:" + ex.Message, MessageBoxIcon.Error); } }