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 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";
                }
            }
        }
示例#3
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();
        }