示例#1
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");
            }
        }
    }
示例#2
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);
        }
    }
    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);
        }
    }
示例#4
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 || testaCreditos == disc.Cred + 1)
                {
                    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);
        }
    }
示例#5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string        matricula           = DropDownList1.SelectedValue;
        ProfessoresBO controleProfessores = new ProfessoresBO();

        controleProfessores.PersonificarProfessor(matricula);
        Response.Redirect("~/default/default.aspx");
    }
示例#6
0
    private void PopulaProfessores()
    {
        ProfessoresBO controladorProfessores = new ProfessoresBO();

        ddlProfessores.DataSource     = controladorProfessores.GetProfessores();
        ddlProfessores.DataTextField  = "Nome";
        ddlProfessores.DataValueField = "Id";
        ddlProfessores.DataBind();
    }
示例#7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     controleProfs = new ProfessoresBO();
     profs         = new Dictionary <string, Professor>();
     discs         = new Dictionary <string, Disciplina>();
     catDisBo      = new CategoriaDisciplinaBO();
     controleDiscs = new DisciplinasBO();
     turmasBO      = new TurmaBO();
     cursosBO      = new CursosBO();
 }
示例#8
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");
            }
        }
    }
示例#9
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>;
 }
示例#10
0
    public void ImportarProfessores()
    {
        // Import profs from Excel data
        var data = from c in excel.Worksheet("profs")
                   select c;

        foreach (var s in data)
        {
            profs.Add(Professor.NewProfessor(s[0], s[1], s[2]));
        }

        bool existe = false;

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

            foreach (Professor profAtual in professoresImportados)
            {
                foreach (Professor profCadastrado in professoresCadastrados)
                {
                    if (profCadastrado.Equals(profAtual))
                    {
                        output.InnerHtml += "<font color=\"red\">" + profAtual.Nome + " já existe!</font><br>";
                        //ListBox1.Items.Add(profAtual.Nome + " já existe");
                        existe = true;
                        break;
                    }
                }
                if (!existe)
                {
                    output.InnerHtml += "Adicionando " + profAtual.Nome + " (" +
                                        profAtual.Matricula + ") - " + profAtual.Email + "<br>";
                    //ListBox1.Items.Add(profAtual.ToString());
                    controleProfessores.InsertPessoa(profAtual, "pergunta", profAtual.Matricula);
                }
                else
                {
                    existe = false;
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
示例#11
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);
     }
 }
示例#12
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);
        }
    }
示例#13
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;
    }
示例#14
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);
     }
 }
示例#15
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!";
     }
 }
示例#16
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/MenuProfessor2.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:2px\"> <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);
                }
            }
        }
    }
示例#17
0
    private void ImportarTurmas(Calendario calId)
    {
        ProfessoresBO    profsBO = new ProfessoresBO();
        List <Professor> profs   = profsBO.GetProfessores();

        DisciplinasBO     discipBO = new DisciplinasBO();
        List <Disciplina> discs    = discipBO.GetDisciplinaInCalendario(calId.Id);

        TurmaBO      turmasBO          = new TurmaBO();
        List <Turma> turmasCadastradas = turmasBO.GetTurmas(calId);
        List <Turma> turmasNovas       = new List <Turma>();

        CursosBO cursosBO = new CursosBO();
        Curso    curso    = cursosBO.GetCursoByCodigo(codcurso);

        if (curso == null)
        {
            output.InnerHtml += "<font color=\"red\">Erro: curso " + codcurso + " inexistente!</font>";
            return;
        }
        output.InnerHtml += "<h2>" + curso.Nome + " (" + curso.Vinculo + ")</h2>";

        // Import turmas from Excel data
        var data = from c in excel.Worksheet("turmas")
                   select c;

        // cod, nro, horario, prof

        // Processa cada turma
        foreach (var s in data)
        {
            string cod = s[0];
            if (cod.Contains("-"))
            {
                cod = cod.Substring(0, cod.IndexOf('-'));
            }
            int    nro     = Int32.Parse(s[1]);
            string horario = s[2];
            string matr    = s[3];

            Disciplina disc = (from d in discs
                               where d.Cod == cod
                               select d).FirstOrDefault();
            if (disc == null)
            {
                output.InnerHtml += "<font color=\"red\">Erro: disciplina " + cod + " inexistente!</font>";
                continue;
            }
            output.InnerHtml += "Turma: " + disc.CodCred + " - " + disc.Nome + " (" + nro + ") - " + horario + " - " + matr + "<br>";

            Professor prof = (from p in profs
                              where p.Matricula == matr
                              select p).FirstOrDefault();
            if (prof == null)
            {
                output.InnerHtml += "<font color=\"red\">Professor " + matr + " não cadastrado!</font><br><br>";
            }

            Turma atual = (from t in turmasCadastradas
                           where t.Disciplina.Cod == cod && t.Numero == nro
                           select t).FirstOrDefault();
            if (atual == null)
            {
                Turma nova = Turma.NewTurma(nro, calId, disc, horario, prof, curso);
                turmasBO.InsereTurma(nova);
            }
            else
            {
                output.InnerHtml += "<font color=\"red\">&nbsp;&nbsp;&nbsp;&nbsp;Turma já cadastrada!</font><br><br>";
            }
        }
    }