protected void btnPesquisar_Click(object sender, EventArgs e) { if (Page.IsValid) { try { Professor professor = ObterObjetoProfessor(); manterProfessor = new ManterProfessor(); IList <Professor> ListaProfessor = manterProfessor.ObterProfessorPorFiltro(professor); WebFormHelper.PreencherGrid(ListaProfessor, this.dgvProfessor); if (ListaProfessor != null && ListaProfessor.Count > 0) { WebFormHelper.PreencherGrid(ListaProfessor, this.dgvProfessor); pnlProfessor.Visible = true; } else { pnlProfessor.Visible = false; WebFormHelper.ExibirMensagem(enumTipoMensagem.Alerta, "Nenhuma Informação Encontrada"); } } catch (AcademicoException ex) { WebFormHelper.ExibirMensagem(enumTipoMensagem.Erro, ex.Message); } } }
protected void btnSalvar_Click(object sender, EventArgs e) { try { if (Request["Id"] == null) { manterProfessor = new ManterProfessor(); professor = ObterObjetoProfessor(); manterProfessor.IncluirProfessor(professor); } else { professor = ObterObjetoProfessor(); manterProfessor.AlterarProfessor(professor); } Session.Remove("ProfessorEdit"); WebFormHelper.ExibirMensagem(enumTipoMensagem.Sucesso, "Dados Gravados com Sucesso !", "ListarProfessor.aspx"); } catch (AcademicoException ex) { WebFormHelper.ExibirMensagem(enumTipoMensagem.Erro, ex.Message); } }
protected void dgvProfessor_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("excluir")) { try { manterProfessor = new ManterProfessor(); int idProfessor = int.Parse(e.CommandArgument.ToString()); manterProfessor.ExcluirProfessor(idProfessor); WebFormHelper.ExibirMensagem(enumTipoMensagem.Sucesso, "Registro excluído com sucesso!", "ListarProfessor.aspx"); } catch (AcademicoException ex) { WebFormHelper.ExibirMensagem(enumTipoMensagem.Erro, ex.Message); return; } } else if (e.CommandName.Equals("editar")) { int idProfessor = int.Parse(e.CommandArgument.ToString()); //Session.Add("ProfessorEdit", idProfessor); Response.Redirect("EdicaoProfessor.aspx?Id=" + idProfessor.ToString(), false); } else if (e.CommandName.Equals("sincronizarComMoodle")) { int idProfessor = int.Parse(e.CommandArgument.ToString()); ExecutarSincronizacao(idProfessor); } }
private classes.Professor ObterObjetoProfessor() { if (Request["Id"] == null) { manterProfessor = new ManterProfessor(); professor = new classes.Professor(); professor.DataCadastro = DateTime.Now; } else { int idProfessor = int.Parse(Request["Id"].ToString()); professor = new ManterProfessor().ObterProfessorPorId(idProfessor); } //Nome professor.Nome = this.txtNome.Text.Trim(); //CPF professor.Cpf = this.txtCPF.Text.Trim(); //Data de Nascimento if (!string.IsNullOrWhiteSpace(this.txtDtNascimento.Text)) { professor.DataNascimento = CommonHelper.TratarData(this.txtDtNascimento.Text, "Data de Nascimento").Value; } else { professor.DataNascimento = null; } //Data de Desativação if (!string.IsNullOrWhiteSpace(this.txtDtDesativacao.Text)) { professor.DataDesativacao = CommonHelper.TratarData(this.txtDtDesativacao.Text, "Data de Desativação").Value; } else { professor.DataDesativacao = null; } //Ativo ? if (rblAtivo.SelectedItem != null && !string.IsNullOrWhiteSpace(rblAtivo.SelectedItem.Value)) { string valorInformadoParaAtivo = rblAtivo.SelectedItem.Value; if (valorInformadoParaAtivo.ToString().ToUpper().Equals("S")) { professor.Ativo = true; } else if (valorInformadoParaAtivo.ToString().ToUpper().Equals("N")) { professor.Ativo = false; } } else { professor.Ativo = false; } //Currículo professor.Curriculo = this.txtCurriculo.Text.Trim(); //Observações professor.Observacoes = this.txtObservacoes.Text.Trim(); //Nº do Telefone professor.Telefone = this.txtTelefone.Text.Trim(); //Nº do Telefone Celular professor.TelefoneCelular = this.txtTelefoneCelular.Text.Trim(); //RG professor.RG = this.txtRG.Text.Trim(); //Tipo do Documento professor.TipoDocumentoRG = this.txtTipoDocumento.Text.Trim(); //Data de Expedição if (!string.IsNullOrWhiteSpace(this.txtDtExpedicao.Text)) { professor.DataExpedicao = CommonHelper.TratarData(this.txtDtExpedicao.Text, "Data de Expedição").Value; } else { professor.DataExpedicao = null; } //Naturalidade professor.Naturalidade = this.txtNaturalidade.Text.Trim(); //Estado Civil if (this.ddlEstadoCivil.SelectedItem != null && !string.IsNullOrWhiteSpace(this.ddlEstadoCivil.SelectedItem.Value)) { professor.EstadoCivil = this.ddlEstadoCivil.SelectedItem.Value; } else { professor.EstadoCivil = null; } //Nome do Pai professor.NomePai = this.txtNomePai.Text.Trim(); //Nome da Mãe professor.NomeMae = this.txtNomeMae.Text.Trim(); //E-mail professor.Email = this.txtEmail.Text.Trim(); //Endereço professor.Endereco = this.txtEndereco.Text.Trim(); //Bairro professor.Bairro = this.txtBairro.Text.Trim(); //Cidade professor.Cidade = this.txtCidade.Text.Trim(); //UF if (this.ddlUF.SelectedItem != null && !string.IsNullOrWhiteSpace(this.ddlUF.SelectedItem.Value)) { professor.Estado = this.ddlUF.SelectedItem.Value; } else { professor.Estado = null; } return(professor); }