protected void Button1_Click(object sender, EventArgs e)
 {
     string matricula = DropDownList1.SelectedValue;
     ProfessoresBO controleProfessores = new ProfessoresBO();
     controleProfessores.PersonificarProfessor(matricula);
     Response.Redirect("~/default/default.aspx");
 }
Ejemplo n.º 2
0
        public void ImportarProfessores()
        {
            bool existe = false;

            try
            {
                ProfessoresBO     controleProfessores    = new ProfessoresBO();
                IList <Professor> professoresCadastrados = (List <Professor>)controleProfessores.GetProfessores();
                IList <Professor> professoresImportados  = this.getProfessores();

                foreach (Professor profAtual in professoresImportados)
                {
                    foreach (Professor profCadastrado in professoresCadastrados)
                    {
                        if (profCadastrado.Equals(profAtual))
                        {
                            existe = true;
                            break;
                        }
                    }
                    if (!existe)
                    {
                        controleProfessores.InsertPessoa(profAtual, "pergunta", profAtual.Matricula);
                    }
                    else
                    {
                        existe = false;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
    protected void btnCadastrar_Click(object sender, EventArgs e)
    {
        Professor p = Professor.NewProfessor(txtMatricula.Text, txtNome.Text, txtEmail.Text);

        try
        {
            ProfessoresBO professores = new ProfessoresBO();
            professores.InsertPessoa(p,txtPergunta.Text,txtResposta.Text);
            lblStatus.Text = "Professor cadastrado com sucesso.";
            lblStatus.Visible = true;
            txtMatricula.Text = "";
            txtNome.Text = "";
            txtEmail.Text = "";
            txtPergunta.Text = "";
            txtResposta.Text = "";

        }
        catch (DataAccessException ex)
        {
                Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
        catch (SecurityException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        List<Professor> listaProf = null;
        try
        {

            ProfessoresBO boProfessor = new ProfessoresBO();
            listaProf = boProfessor.GetProfessores();
            if (listaProf.Count == 0)
            {
                lblStatus.Text = "Nenhum professor cadastrado";
                lblStatus.Visible = true;
                lblOnline.Visible = false;
            }
            else
            {
                grvListaProfessores.DataSource = listaProf;
                grvListaProfessores.DataBind();
            }
        }
        catch (BusinessData.DataAccess.DataAccessException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }

        string online = "Usuários online: ";
        foreach(Professor p in listaProf)
        {
            if(Membership.GetUser(p.Matricula).IsOnline)
                online += p.Nome + " (" + p.Matricula + ") ";
        }
        lblOnline.Text = online;
    }
Ejemplo n.º 5
0
    protected void btnResetaSenha_Click(object sender, EventArgs e)
    {
        try
        {
            ProfessoresBO boProfessores = new ProfessoresBO();
            Professor prof = (Professor)boProfessores.GetPessoaById(new Guid(Request.QueryString["GUID"]));

            MembershipUser pessoa = Membership.GetUser(prof.Id);
            string newPassword = pessoa.ResetPassword();
            Membership.UpdateUser(pessoa);

            // Nao envia mais email, erro no relay (?)

        //            boProfessores.ResetaSenha(prof);
            lblStatus.Text = "Senha resetada com sucesso: nova senha "+newPassword;
            lblStatus.Visible = true;
        }
        catch (ArgumentException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
        catch (Exception ex)
        {
            //ScriptManager.RegisterClientScriptBlock(this, GetType(), "Erro", "alert('Impossível resetar senha. Verifique se o usuário não está bloqueado');", true);
            //ScriptManager.RegisterClientScriptBlock(this, GetType(), "Erro", "alert('"+ex.Message+"')");//Impossível resetar senha. Verifique se o usuário não está bloqueado');", true);
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
    }
Ejemplo n.º 6
0
    protected void btnConfirmar_Click1(object sender, EventArgs e)
    {
        try
        {
            Disciplina.ValidaHorario(txtDataHora.Text);
            lblStatus.Text = "";

            Calendario cal = (Calendario)Session["Calendario"];

            TurmaBO turmaBO = new TurmaBO();
            Turma turma = turmaBO.GetTurmaById(new Guid(Request.QueryString["GUID"]), cal);

            if (turma != null)
            {
                DisciplinasBO controleDisciplinas = new DisciplinasBO();
                Disciplina disc = controleDisciplinas.GetDisciplina(ddlDisciplina.SelectedValue, cal);

                ProfessoresBO professorBO = new ProfessoresBO();
                Professor prof = (Professor)professorBO.GetPessoaById(new Guid(ddlProfessor.SelectedValue));

                CursosBO cursoBO = new CursosBO();
                Curso curso = cursoBO.GetCursoByCodigo(ddlCurso.SelectedValue);

                int testaCreditos = Disciplina.GetNumeroDeCreditos(txtDataHora.Text);
                if (testaCreditos == disc.Cred)
                {
                    turma.Disciplina = disc;
                    turma.Numero = Convert.ToInt32(txtNumero.Text);
                    turma.DataHora = txtDataHora.Text;
                    turma.Professor = prof;
                    turma.Curso = curso;
                    turmaBO.UpdateTurma(turma);
                    lblStatus.Text = "Turma atualizada com sucesso.";
                    lblStatus.Visible = true;
                    Response.Redirect("~/Turmas/ListaTurmas.aspx");
                }

                else Response.Redirect("~/Default/Erro.aspx?Erro=" + "Número de créditos incorreto para esta disciplina.");
            }

            else
            {
                lblStatus.Text = "Turma não pode ser atualizada.";
                lblStatus.Visible = true;
            }
        }
        catch (BusinessData.DataAccess.DataAccessException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
        catch (SecurityException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
    }
Ejemplo n.º 7
0
 protected void grvListaProfessores_RowEditing(object sender, GridViewEditEventArgs e)
 {
     try
     {
         ProfessoresBO boProfessor = new ProfessoresBO();
         Guid id = (Guid)grvListaProfessores.DataKeys[e.NewEditIndex].Value;
         Response.Redirect("~/Professores/AlteraProfessores.aspx?GUID=" + id.ToString());
     }
     catch (BusinessData.DataAccess.DataAccessException ex)
     {
         Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
     }
     catch (SecurityException ex)
     {
         Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
     }
 }
Ejemplo n.º 8
0
    protected void btnConfirmar_Click(object sender, EventArgs e)
    {
        try
        {
            ProfessoresBO boProfessores = new ProfessoresBO();
            Professor prof = (Professor)boProfessores.GetPessoaById(new Guid(Request.QueryString["GUID"]));
            if (prof != null)
            {
                boProfessores.UpdateEmail(prof, txtEmail.Text);
                lblStatus.Text = "Professor alterado com sucesso";
                lblStatus.Visible = true;
                txtEmail.Text = "";
                Response.Redirect("~/Professores/ListaProfessores.aspx");
            }
            else Response.Redirect("~/Default/Erro.aspx?Erro=" + "Professor não existente.");

        }
        catch (ArgumentException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
    }
Ejemplo n.º 9
0
    protected void grvListaProfessores_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            ProfessoresBO boProfessor = new ProfessoresBO();
            Professor p = (Professor)boProfessor.GetPessoaById((Guid)grvListaProfessores.DataKeys[e.RowIndex].Value);

            boProfessor.DeletePessoa(p);
            lblStatus.Text = "Professor excluído com sucesso";
            lblStatus.Visible = true;

            grvListaProfessores.DataSource = boProfessor.GetProfessores();
            grvListaProfessores.DataBind();
        }
        catch (BusinessData.DataAccess.DataAccessException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
        catch (SecurityException ex)
        {
            Response.Redirect("~/Default/Erro.aspx?Erro=" + ex.Message);
        }
    }
Ejemplo n.º 10
0
 private void VisualizarAlocacoesProfessor()
 {
     try
     {
         List<Alocacao> listaAlocacoes;
         ProfessoresBO controladorProfessores = new ProfessoresBO();
         Professor prof;
         if (ddlProfessores.SelectedIndex != 0)
         {
             if (txtData.Text.Length == 0)
             {
                 prof = (Professor)controladorProfessores.GetPessoaById(new Guid(ddlProfessores.SelectedValue));
                 listaAlocacoes = controladorAlocacoes.GetAlocacoesSemData((BusinessData.Entities.Calendario)Session["Calendario"], prof);
                 if (listaAlocacoes.Count != 0)
                 {
                     ((List<Alocacao>)listaAlocacoes).Sort();
                     dgAlocacoes.DataSource = listaAlocacoes;
                     dgAlocacoes.Visible = true;
                     dgAlocacoes.DataBind();
                     lblStatus.Visible = false;
                 }
                 else
                 {
                     lblStatus.Text = "Não existem alocações para este professor.";
                     lblStatus.Visible = true;
                     dgAlocacoes.Visible = false;
                 }
             }
             else
             {
                 prof = (Professor)controladorProfessores.GetPessoaById(new Guid(ddlProfessores.SelectedValue));
                 listaAlocacoes = controladorAlocacoes.GetAlocacoes((BusinessData.Entities.Calendario)Session["Calendario"], DateTime.Parse(txtData.Text), prof);
                 if (listaAlocacoes.Count != 0)
                 {
                     dgAlocacoes.DataSource = listaAlocacoes;
                     dgAlocacoes.Visible = true;
                     dgAlocacoes.DataBind();
                     lblStatus.Visible = false;
                 }
                 else
                 {
                     lblStatus.Text = "Não existem alocações para este professor na data selecionada.";
                     lblStatus.Visible = true;
                     dgAlocacoes.Visible = false;
                 }
             }
         }
         else
         {
             dgAlocacoes.Visible = false;
             lblStatus.Visible = true;
             lblStatus.Text = "Selecione um professor.";
         }
     }
     catch (FormatException)
     {
         dgAlocacoes.Visible = false;
         lblStatus.Text = "Digite uma data válida!";
     }
     catch (System.Data.SqlTypes.SqlTypeException)
     {
         dgAlocacoes.Visible = false;
         lblStatus.Text = "Digite uma data válida!";
     }
 }
Ejemplo n.º 11
0
 private void PopulaProfessores()
 {
     ProfessoresBO controladorProfessores = new ProfessoresBO();
     ddlProfessores.DataSource = controladorProfessores.GetProfessores();
     ddlProfessores.DataTextField = "Nome";
     ddlProfessores.DataValueField = "Id";
     ddlProfessores.DataBind();
 }
Ejemplo n.º 12
0
 public MembershipFactory()
 {
     professorBO = new ProfessoresBO();
     secretarioBO = new SecretariosBO();
 }
Ejemplo n.º 13
0
 private PessoaFactory()
 {
     professorBO  = new ProfessoresBO();
     secretarioBO = new SecretariosBO();
 }
Ejemplo n.º 14
0
        public void ImportarProfessores()
        {
            bool existe = false;
            try
            {
                ProfessoresBO controleProfessores = new ProfessoresBO();
                IList<Professor> professoresCadastrados = (List<Professor>)controleProfessores.GetProfessores();
                IList<Professor> professoresImportados = this.getProfessores();

                foreach (Professor profAtual in professoresImportados)
                {
                    foreach (Professor profCadastrado in professoresCadastrados)
                    {
                        if (profCadastrado.Equals(profAtual))
                        {
                            existe = true;
                            break;
                        }
                    }
                    if (!existe)
                    {
                        controleProfessores.InsertPessoa(profAtual, "pergunta", profAtual.Matricula);
                    }
                    else
                    {
                        existe = false;
                    }
                }
            }
            catch (Exception )
            {
                throw;
            }
        }
Ejemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["GUID"] != null)
            {
                try
                {
                    ProfessoresBO boProfessores = new ProfessoresBO();

                    try
                    {
                        Professor prof = (Professor)boProfessores.GetPessoaById(new Guid(Request.QueryString["GUID"]));
                        txtEmail.Text = prof.Email;
                        txtMatricula.Text = prof.Matricula;
                        txtNome.Text = prof.Nome;
                        SetBtnLockUnlockText();

                    }
                    catch (FormatException )
                    {
                        Response.Redirect("~/Professores/ListaProfessores.aspx");
                    }

                }
                catch (BusinessData.DataAccess.DataAccessException)
                {
                    Response.Redirect("~/Professores/ListaProfessores.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Professores/ListaProfessores.aspx");
            }

        }
    }
Ejemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["GUID"] != null)
            {
                try
                {
                    CursosBO cursoBO = new CursosBO();
                    DisciplinasBO discBO = new DisciplinasBO();
                    ProfessoresBO profBO = new ProfessoresBO();
                    TurmaBO boTurma = new TurmaBO();
                    Calendario cal = (Calendario)Session["Calendario"];

                    try
                    {
                        Turma turma = boTurma.GetTurmaById(new Guid(Request.QueryString["GUID"]), cal);
                        ddlDisciplina.DataSource = discBO.GetDisciplinas(cal);
                        ddlDisciplina.DataTextField = "Nome";
                        ddlDisciplina.DataValueField = "Cod";
                        ddlDisciplina.SelectedValue = turma.Disciplina.Cod;
                        ddlDisciplina.DataBind();

                        txtNumero.Text = Convert.ToString(turma.Numero);
                        txtDataHora.Text = turma.DataHora;

                        ddlProfessor.DataSource = profBO.GetProfessores();
                        ddlProfessor.DataTextField = "Nome";
                        ddlProfessor.DataValueField = "Id";
                        ddlProfessor.SelectedValue = (turma.Professor.Id).ToString();
                        ddlProfessor.DataBind();

                        ddlCurso.DataSource = cursoBO.GetCursos();
                        ddlCurso.DataTextField = "Nome";
                        ddlCurso.DataValueField = "Codigo";
                        ddlCurso.SelectedValue = turma.Curso.Codigo;
                        ddlCurso.DataBind();

                    }
                    catch(FormatException )
                    {
                        Response.Redirect("~/Turmas/ListaTurmas.aspx");
                    }

                }
                catch (BusinessData.DataAccess.DataAccessException )
                {
                    Response.Redirect("~/Turmas/ListaTurmas.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Turmas/ListaTurmas.aspx");
            }
        }
    }
Ejemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        listaTurmas = Session["listaTurmas"] as IList<Turma>;
        listaTurmasNone = Session["listaTurmasNone"] as IList<TurmaSemProfessor>;
        if (!Page.IsPostBack)
        {

            ProfessoresBO controleProfessores = new ProfessoresBO();
            listaProfessores = controleProfessores.GetProfessores();
            Session.Add("listaProfessores", listaProfessores);
        }
        listaProfessores = Session["listaProfessores"] as IList<Professor>;
    }
Ejemplo n.º 18
0
 public MembershipFactory()
 {
     professorBO  = new ProfessoresBO();
     secretarioBO = new SecretariosBO();
 }
Ejemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Calendario"] != null)
        {
            Label lbl = new Label();
            lbl.Text = "Calendário:";
            lbl.CssClass = "ms-toolbar";
            phCalendario.Controls.Add(lbl);

            //ASP.default_selecionacalendario_ascx calendar = (ASP.default_selecionacalendario_ascx)LoadControl("~/Default/SelecionaCalendario.ascx");
            Default_SelecionaCalendario_ calendar = (Default_SelecionaCalendario_)LoadControl("~/UserControls/SelecionaCalendario.ascx");
            calendar.CalendarioSelecionado += new EventHandler(calendar_CalendarioSelecionado);
            phCalendario.Controls.Add(calendar);

            Label userEmail = new Label();
            MembershipUser user = Membership.GetUser();
            if (user != null)
            {
                userEmail.Text = user.Email;
                userEmail.CssClass = "ms-toolbar";
                phActiveUser.Controls.Add(userEmail);
            }
            if (Roles.IsUserInRole("Admin"))
            {
                Control menu = LoadControl("~/UserControls/MenuAdmin.ascx");
                phMenu.Controls.Add(menu);
            }
            else if (Roles.IsUserInRole("Professor"))
            {
                if (Session["AppState"] != null && ((AppState)Session["AppState"]) != AppState.Admin)
                {
                    ProfessoresBO controleProfessores = new ProfessoresBO();
                    TurmaBO turmaBO = new TurmaBO();
                    Control menu = LoadControl("~/UserControls/MenuProfessor.ascx");
                    Calendario cal = (Calendario)Session["Calendario"];
                    //MembershipUser user = Membership.GetUser();
                    Guid professorId = new Guid(user.ProviderUserKey.ToString());

                    Professor prof = (Professor)controleProfessores.GetPessoaById(professorId);
                    AppState estado = (AppState)Session["AppState"];
                    string baseURL = "../Docentes/";
                    if (estado == AppState.Requisicoes)
                        baseURL += "EditarAula.aspx?GUID=";
                    if (estado == AppState.AtivoSemestre)
                        baseURL += "EditarAulaSemestre.aspx?GUID=";

                    try
                    {
                        int pos = 1;
                        List<Turma> listaTurmas = turmaBO.GetTurmas(cal, prof);
                        listaTurmas.Sort();
                        foreach (Turma t in listaTurmas)
                        {

                            Label x = new Label();
                            x.Text = "<span style=\"padding:4px\"> <a  href=\"" + baseURL + t.Id + "\">" + getNomeCurtoDisciplina(t.Disciplina) + " - " + t.Numero + "</a></span><br/>";
                            x.CssClass = "ms-toolbar-small";

                            //x.("left=3px;top=3px");
                            menu.Controls.AddAt(pos++, x);
                        }
                    }
                    finally
                    {
                        phMenu.Controls.Add(menu);
                    }
                }
            }
            else if (Roles.IsUserInRole("Secretario"))
            {
                if (Session["AppState"] != null && ((AppState)Session["AppState"]) != AppState.Admin)
                {
                    Control menu = LoadControl("~/UserControls/MenuSecretario.ascx");
                    phMenu.Controls.Add(menu);
                }
            }
        }
    }
Ejemplo n.º 20
0
 private PessoaFactory()
 {
     professorBO = new ProfessoresBO();
     secretarioBO = new SecretariosBO();
 }