Пример #1
0
        protected void CarregarAgenda()
        {
            // passa a data para o título, exemplo: "Domingo, 19 de fevereiro de 2016"
            txtTexto.Text = clData.SelectedDate.ToLongDateString();

            Agendamento_Model agenda = new Agendamento_Model();
            // carrega a agenda naquele dia
            Local_Model lmodel = new Local_Model();

            try
            {
                // pega do combobox se tiver algum local listado/selecionado
                if (ddLocal.Items.Count > 0)
                {
                    gvAgenda.DataSource = agenda.ListarDia(clData.SelectedDate, lmodel.Obter(Int32.Parse(ddLocal.SelectedValue)));
                }
                else // senão pega do cadastro do mediador logado
                {
                    gvAgenda.DataSource = agenda.ListarDia(clData.SelectedDate, lmodel.Obter(Master.GetLogado().id_local));
                }
                gvAgenda.DataBind();
                if (gvAgenda.Rows.Count > 0)
                {
                    gvAgenda.UseAccessibleHeader    = true;
                    gvAgenda.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
            }
            catch { }
        }
Пример #2
0
        protected void PreencherGrid()
        {
            Local_Model model = new Local_Model();

            gdvLista.DataSource = model.ListarPorNome(txtNome.Text, Master.GetAlcancePermissao(), cbSomenteAtivo.Checked);
            gdvLista.DataBind();

            if (gdvLista.Rows.Count > 0)
            {
                gdvLista.UseAccessibleHeader    = true;
                gdvLista.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
        protected void btnAgendar_Click(object sender, EventArgs e)
        {
            if (ValidaAgendamento())
            {
                Agendamento_Model model = new Agendamento_Model();

                agendamento a = new agendamento();

                DateTime dDataInicial, dDataFinal;

                dDataInicial = DateTime.Parse(txtData.Value + " " + txtHoraInicial.Value + ":00");
                dDataFinal   = DateTime.Parse(txtData.Value + " " + txtHoraFinal.Value + ":00");

                a.descricao      = txtDescricaoAgendamento.Value;
                a.id_solicitacao = int.Parse(txtId.Value);
                a.data_inicial   = dDataInicial;
                a.data_final     = dDataFinal;
                a.id_mediador    = Master.GetLogado().id;

                Local_Model mLocal = new Local_Model();
                if (model.VerificarDisponibilidade(a, mLocal.Obter(Master.GetLogado().id_local)))
                {
                    if (model.Inserir(a))
                    {
                        Master.Sucesso("Horário agendado com sucesso.");
                        LimpaCamposAgendamento();
                        InsereDescSoli("Solicitação já agendada.");
                    }
                    else
                    {
                        Master.Alerta("Erro ao agendar horário. Erro: " + model.message);
                    }
                }
                else
                {
                    // se model.message estiver vazio, então ele retornou false pois o horário está vago,
                    // se nao, houve erro na consulta
                    if (model.message == "")
                    {
                        Master.Alerta("O horário escolhido já está agendado, selecione outro horário.");
                    }
                    else
                    {
                        Master.Alerta("Erro ao agendar horário. Erro: " + model.message);
                    }
                }
            }
        }
        protected void PreencherCentros()
        {
            try
            {
                // preenche o combo que será utilizado para transferir a solicitação
                Local_Model model = new Local_Model();

                // preenche com todos os núcleos da cidade do mediador
                ddLocal.DataSource     = model.Listar(model.Obter(Master.GetLogado().id_local).id_cidade);
                ddLocal.DataValueField = "id";
                ddLocal.DataTextField  = "descricao";
                ddLocal.DataBind();
                ddLocal.SelectedIndex = 0;
            }
            catch { }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // pega a data de hoje
                clData.SelectedDate = DateTime.Today;

                // carrega nucleos de mediacao
                Local_Model l = new Local_Model();
                ddLocal.DataSource     = l.Listar(Master.GetAlcancePermissao());
                ddLocal.DataValueField = "id";
                ddLocal.DataTextField  = "descricao";
                ddLocal.DataBind();
                ddLocal.SelectedIndex = 0;
            }

            CarregarAgenda();
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Local_Model l = new Local_Model();
                ddLocal.DataSource     = l.ListarComEnderecoNaDesc();
                ddLocal.DataValueField = "ID";
                ddLocal.DataTextField  = "DESCRICAO";
                ddLocal.DataBind();
                ddLocal.SelectedIndex = 0;

                // ATRIBUIR O MAXLENGTH PARA OS CAMPOS
                txtDescCaso.MaxLength    = 250;
                txtNome.MaxLength        = 100;
                txtTelefone.MaxLength    = 20;
                txtEndereco.MaxLength    = 100;
                txtEmail.MaxLength       = 50;
                txtDadosPartes.MaxLength = 200;
            }
        }
Пример #7
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            //se a função valida retornar True, então permite cadastrar ou alterar o registro
            if (Valida())
            {
                local local = new local();
                local.numero_opm = txtOPM.Text;
                local.nome       = txtNome.Text;
                local.descricao  = txtDescricao.Value;
                local.CEP        = txtCEP.Text;
                local.logradouro = txtLogradouro.Value;
                local.numero     = txtNumero.Value;
                local.bairro     = txtBairro.Value;
                local.id_cidade  = Int32.Parse(ddCidade.SelectedValue);
                local.telefone   = txtTelefone.Text;
                if (txtDataInicioAtividade.Value != "")
                {
                    local.data_inicio_atividade = DateTime.Parse(txtDataInicioAtividade.Value);
                }
                local.ativo = cbbAtivo.Checked;

                Local_Model model = new Local_Model();

                // se tiver ID preenche o parâmetro
                if (txtID.Text != "Novo")
                {
                    local.id = int.Parse(txtID.Text);
                }

                // faz a inserção ou atualização do cadastro da cidade
                if (model.InserirAtualizar(local))
                {
                    txtID.Text = local.id.ToString();
                    Master.Sucesso("Registro salvo com sucesso.");
                }
                else
                {
                    Master.Alerta("Erro ao salvar o registro: " + model.message);
                }
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Master.GetNivelPermissao() < Mediador_Model.PERM_AVANCADO)
            {
                Response.Redirect("index.aspx");
            }

            cbTodos.Visible = (Master.GetNivelPermissao() >= Mediador_Model.PERM_ADMIN);      // Admin

            if (!IsPostBack)
            {
                // carrega nucleos de mediacao
                Local_Model l = new Local_Model();
                ddLocal.DataSource     = l.Listar(Master.GetAlcancePermissao());
                ddLocal.DataValueField = "id";
                ddLocal.DataTextField  = "descricao";
                ddLocal.DataBind();
                ddLocal.SelectedIndex = 0;

                PreencherGrid();
            }
        }
        protected void Listar()
        {
            Local_Model model = new Local_Model();

            listaNucleos = model.ListarPorNome("", "", true);
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Master.GetNivelPermissao() < Mediador_Model.PERM_ADMIN)
            {
                Response.Redirect("index.aspx");
            }

            if (!IsPostBack)
            {
                // tamanho dos campos de acordo com o banco de dados
                txtNome.MaxLength       = 100;
                txtDescricao.MaxLength  = 50;
                txtBairro.MaxLength     = 50;
                txtLogradouro.MaxLength = 100;
                txtNumero.MaxLength     = 10;
                txtCEP.MaxLength        = 9;
                txtOPM.MaxLength        = 9;
                //txtDataInicioAtividade.MaxLength = 10;
                txtTelefone.MaxLength = 20;

                // carrega cidades
                Cidade_Model c = new Cidade_Model();
                ddCidade.DataSource     = c.Listar();
                ddCidade.DataValueField = "id";
                ddCidade.DataTextField  = "nome";
                ddCidade.DataBind();
                ddCidade.SelectedIndex = 0;

                cbbAtivo.Checked = true;

                // declara ID e verifica se existe ID no txtID ou no endereço
                int id = 0;

                if (txtID.Text != "Novo")
                {
                    // recupera o id
                    try
                    {
                        id = int.Parse(txtID.Text);
                    }
                    catch (Exception)
                    {
                        Master.Alerta("Erro ao carregar o cadastro.");
                    }
                }

                if (Request.QueryString["ID"] != null)
                {
                    //recupera o id
                    id         = int.Parse(Request.QueryString["ID"]);
                    txtID.Text = id.ToString();
                }

                // se houver ID informado, então carrega o registro do ID informado
                if (id != 0)
                {
                    try
                    {
                        // declara o objeto model
                        Local_Model model = new Local_Model();
                        //recupera o produto do id informado
                        local local = model.Obter(id);

                        // verifica se tem permissão de editar o local acessado
                        if (!Master.VerificarAlcance(local.numero_opm))
                        {
                            Response.Redirect("index.aspx");
                        }

                        //preencher caixas de texto com valores de produto
                        txtID.Text                   = local.id.ToString();
                        txtOPM.Text                  = local.numero_opm;
                        txtNome.Text                 = local.nome;
                        txtDescricao.Value           = local.descricao;
                        txtNumero.Value              = local.numero;
                        txtLogradouro.Value          = local.logradouro;
                        txtBairro.Value              = local.bairro;
                        txtDataInicioAtividade.Value = DateTime.Parse(local.data_inicio_atividade.ToString()).ToString("yyyy-MM-dd");
                        txtCEP.Text                  = local.CEP;
                        txtTelefone.Text             = local.telefone;
                        cbbAtivo.Checked             = local.ativo;
                        ddCidade.SelectedValue       = local.id_cidade.ToString();
                    }
                    catch (Exception)
                    {
                        Master.Alerta("Registro não encontrado.");
                    }
                }
                else
                {
                    txtID.Text = "Novo";
                }
            }
        }
Пример #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Master.GetNivelPermissao() < Mediador_Model.PERM_ADMIN)
            {
                Response.Redirect("index.aspx");
            }

            if (!IsPostBack)
            {
                // tamanho dos campos de acordo com o banco de dados
                txtNome.MaxLength           = 100;
                txtPatente.MaxLength        = 50;
                txtUsuario.MaxLength        = 50;
                txtSenha.MaxLength          = 50;
                txtConfirmarSenha.MaxLength = 50;
                txtRE.MaxLength             = 8;
                txtAlcance.MaxLength        = 9;

                // carrega nucleos de mediacao
                Local_Model l = new Local_Model();
                ddLocal.DataSource     = l.Listar(Master.GetAlcancePermissao());
                ddLocal.DataValueField = "id";
                ddLocal.DataTextField  = "descricao";
                ddLocal.DataBind();
                ddLocal.SelectedIndex = 0;

                cbbAtivo.Checked = true;

                // declara ID e verifica se existe ID no txtID ou no endereço
                int id = 0;

                if (txtID.Text != "Novo")
                {
                    // recupera o id
                    try
                    {
                        id = int.Parse(txtID.Text);
                    }
                    catch (Exception)
                    {
                        Master.Alerta("Erro ao carregar o cadastro.");
                    }
                }

                if (Request.QueryString["ID"] != null)
                {
                    //recupera o id
                    id         = int.Parse(Request.QueryString["ID"]);
                    txtID.Text = id.ToString();
                }

                // se houver ID informado, então carrega o registro do ID informado
                if (id != 0)
                {
                    try
                    {
                        // declara o objeto model
                        Mediador_Model model = new Mediador_Model();
                        //recupera o id informado
                        mediador med = model.Obter(id);

                        //preencher caixas de texto com valores
                        txtID.Text                     = med.id.ToString();
                        txtRE.Value                    = med.RE;
                        txtNome.Value                  = med.nome;
                        txtPatente.Value               = med.patente;
                        ddLocal.SelectedValue          = med.id_local.ToString();
                        ddNivelPermissao.SelectedValue = med.nivel_permissao.ToString();
                        txtAlcance.Value               = med.alcance;
                        txtUsuario.Value               = med.usuario;
                        txtSenha.Value                 = "";
                        txtConfirmarSenha.Value        = "";
                        cbbAtivo.Checked               = med.ativo;
                    }
                    catch (Exception)
                    {
                        Master.Alerta("Registro não encontrado.");
                    }
                }
                else
                {
                    txtID.Text = "Novo";
                }
            }
        }
Пример #12
0
        protected bool FinalizarMediacao()
        {
            if (ValidarDepoimentos())
            {
                // função que irá salvar os dados da mediação no banco e gerar o termo de mediação
                Mediacao_Model model = new Mediacao_Model();

                mediacao m = new mediacao();

                // pega o mediador logado
                mediador med = Master.GetLogado();

                int id_agendamento = 0;
                if (Session["med_agendamento"] != null)
                {
                    id_agendamento = Int32.Parse(Session["med_agendamento"].ToString());
                }

                m.numero           = model.GerarProximoNumero(med.id_local);
                m.tema_conflito    = txtTemaConflito.Value;
                m.id_tipo_registro = Int32.Parse(ddTipoRegistro.SelectedValue);
                m.data_mediacao    = DateTime.Parse(txtData.Value + " " + txtHora.Value + ":00");
                m.id_mediador      = med.id;
                m.id_local         = med.id_local;
                m.objeto           = txtObjetoMediacao.Text;
                m.resolucao        = Char.Parse(ddResolucao.SelectedValue);
                // SE teve acordo entra as partes, status 1 CONCLUIDO
                // SENAO   status 0 PENDENTE
                if (m.resolucao == 'A')
                {
                    m.status = Mediacao_Model.STATUS_CONCLUIDO;
                }
                else
                {
                    m.status = Mediacao_Model.STATUS_PENDENTE;
                }
                // pega o id da cidade do local
                Local_Model l_model = new Local_Model();
                m.id_cidade = l_model.Obter(med.id_local).id_cidade;

                if (id_agendamento != 0)
                {
                    m.id_agendamento = id_agendamento;
                }

                mediacao_parte mp = null;

                // após inserir a mediação, é necessário inserir as partes

                List <mediacao_parte> mpLista = new List <mediacao_parte>();
                foreach (Control ctr in TextBoxPlaceHolder.Controls)
                {
                    if (ctr is TextBox)
                    {
                        // percorre a lista de pessoas verificando de qual pessoa é aquele depoimento
                        foreach (pessoa p in lista)
                        {
                            if (ctr.ID.Contains(p.cpf))
                            {
                                mp = new mediacao_parte();
                                // depoimento da pessoa
                                mp.descricao_caso = ((TextBox)ctr).Text;
                                // quando encontrar a pessoa do depoimento então passa o CPF para o Identificador
                                mp.pessoa_id = p.cpf;
                                mpLista.Add(mp);
                            }
                        }
                    }
                }

                if (model.InserirMediacaoTotal(m, mpLista))
                {
                    Session.Remove("med_agendamento");
                    Response.Redirect("detail_mediacao.aspx?ID=" + m.id.ToString());
                    return(true);
                }
                else
                {
                    Master.Alerta("Erro: " + model.message);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #13
0
        protected void Finalizar()
        {
            try
            {
                Solicitacao_Model model            = new Solicitacao_Model();
                BackEnd.Controllers.solicitacao sl = new BackEnd.Controllers.solicitacao();

                sl.data = DateTime.Now;

                // passo 1
                sl.solicitante_nome     = txtNome.Value;
                sl.solicitante_endereco = txtEndereco.Value;
                sl.solicitante_telefone = txtTelefone.Value;
                sl.solicitante_email    = txtEmail.Value;

                // passo 2
                sl.descricao_caso  = txtDescCaso.Text;
                sl.detalhes_partes = txtDadosPartes.Text;

                // passo 3
                String sPeriodo = "";
                String sDia     = "";
                foreach (ListItem item in cbgPeriodo.Items)
                {
                    if (item.Selected)
                    {
                        sPeriodo = sPeriodo + item.Text + "; ";
                    }
                }
                foreach (ListItem item in cbgDia.Items)
                {
                    if (item.Selected)
                    {
                        sDia = sDia + item.Text + "; ";
                    }
                }

                sl.solicitante_periodo_atendimento = sPeriodo;
                sl.solicitante_dia_atendimento     = sDia;
                sl.id_local = int.Parse(ddLocal.SelectedValue);

                //PEGAR O ID SELECIONADO NO DDLOCAL E BUSCAR A CIDADE PARA ATRIBUIR NO CAMPO SL.CIDADE_ABERTURA
                local       l      = new local();
                Local_Model lmodel = new Local_Model();
                l = lmodel.Obter(int.Parse(ddLocal.SelectedValue));

                // ATRIBUI O ID DA CIDADE VINCULADA AO LOCAL
                sl.id_cidade_abertura = l.id_cidade;

                // insere a solicitação
                if (!model.Inserir(sl))
                {
                    Master.Alerta(model.message);
                }
                else
                {
                    Response.Redirect("solicitacao_concluido.aspx");
                }
            } catch (Exception E)
            {
                Master.Alerta(E.Message);
            }
        }