Example #1
0
        protected void rptDocumentos_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                ImageButton btnAdicionar = (ImageButton)e.Item.FindControl("btnAdicionar");
                if (btnAdicionar != null)
                {
                    btnAdicionar.CommandArgument = e.Item.ItemIndex.ToString();
                }

                ImageButton btnExcluir = (ImageButton)e.Item.FindControl("btnExcluir");
                if (btnExcluir != null)
                {
                    btnExcluir.CommandArgument = e.Item.ItemIndex.ToString();
                }

                HyperLink       hplDocumento   = (HyperLink)e.Item.FindControl("hplDocumento");
                RadioButtonList rblLinkArquivo = (RadioButtonList)e.Item.FindControl("rblLinkArquivo");

                Label lblErroLink = (Label)e.Item.FindControl("lblErroLink");
                if (lblErroLink != null)
                {
                    lblErroLink.Visible = false;
                }

                Label lblErroDescricao = (Label)e.Item.FindControl("lblErroDescricao");
                if (lblErroDescricao != null)
                {
                    lblErroDescricao.Visible = false;
                }

                byte aar_tipoDocumento = Convert.ToByte(DataBinder.Eval(e.Item.DataItem, "aar_tipoDocumento"));
                rblLinkArquivo.SelectedValue = aar_tipoDocumento.ToString();

                WebControls_Combos_UCComboNivelEnsino cmbTipoNivelEnsino = (WebControls_Combos_UCComboNivelEnsino)e.Item.FindControl("UCComboTipoNivelEnsino");
                int tne_id = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "tne_id"));
                cmbTipoNivelEnsino.Valor = tne_id;

                CheckBox chkPPP = (CheckBox)e.Item.FindControl("chkPPP");
                chkPPP.Checked = (bool)((DataBinder.Eval(e.Item.DataItem, "aar_planoPoliticoPedagogico")));

                if (rblLinkArquivo.SelectedValue == ((byte)ACA_ArquivoAreaBO.eTipoDocumento.Arquivo).ToString())
                {
                    Button btnUpload = (Button)e.Item.FindControl("btnUpload");
                    long   arq_id    = Convert.ToInt64(DataBinder.Eval(e.Item.DataItem, "arq_id"));
                    string arq_nome  = DataBinder.Eval(e.Item.DataItem, "arq_nome").ToString();

                    if (arq_id > 0)
                    {
                        hplDocumento.NavigateUrl = String.Format("~/FileHandler.ashx?file={0}", arq_id.ToString());
                        hplDocumento.Text        = string.IsNullOrEmpty(arq_nome) ? "Download" : arq_nome;
                        hplDocumento.Visible     = true;
                        btnUpload.Visible        = true;
                    }
                    else
                    {
                        hplDocumento.Visible = false;
                        btnUpload.Visible    = true;
                    }
                }
                else
                {
                    Button btnUpload = (Button)e.Item.FindControl("btnUpload");
                    btnUpload.Visible = false;

                    TextBox txtLink = (TextBox)e.Item.FindControl("txtLink");
                    if (!string.IsNullOrEmpty(txtLink.Text))
                    {
                        string httpLink = txtLink.Text;
                        if (!httpLink.Contains("://"))
                        {
                            txtLink.Text = "http://" + httpLink;
                        }
                        hplDocumento.NavigateUrl = txtLink.Text;
                        hplDocumento.Text        = txtLink.Text;

                        hplDocumento.Target  = "_blank";
                        hplDocumento.Visible = true;
                        txtLink.Visible      = false;
                    }
                    else
                    {
                        hplDocumento.Visible = false;
                        txtLink.Visible      = true;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Método que adiciona uma linha ao repeater de documentos.
        /// </summary>
        private void AdicionarLinhaRepeater()
        {
            bool valido = true;

            if (rptDocumentos.Items.Count > 0)
            {
                RadioButtonList rblLinkArquivo   = (RadioButtonList)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("rblLinkArquivo");
                TextBox         txtDescricao     = (TextBox)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("txtDescricao");
                Label           lblErroDescricao = (Label)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("lblErroDescricao");
                Label           lblArqId         = (Label)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("lblArqId");
                TextBox         txtLink          = (TextBox)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("txtLink");
                Label           lblErroLink      = (Label)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("lblErroLink");
                WebControls_Combos_UCComboNivelEnsino cmbTipoNivelEnsino = (WebControls_Combos_UCComboNivelEnsino)rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("UCComboTipoNivelEnsino");

                if (lblErroDescricao != null)
                {
                    lblErroDescricao.Visible = false;
                }
                if (lblErroLink != null)
                {
                    lblErroLink.Visible = false;
                }

                string msg = "";

                if (rblLinkArquivo != null && txtDescricao != null)
                {
                    long arq_id = 0;

                    if (string.IsNullOrEmpty(txtDescricao.Text))
                    {
                        msg = RetornaResource("DescricaoObrigatorio");
                        if (lblErroDescricao != null)
                        {
                            lblErroDescricao.Visible = true;
                        }
                        valido = false;
                    }

                    if (rblLinkArquivo.SelectedIndex == -1)
                    {
                        msg   += (!string.IsNullOrEmpty(msg) ? "<br/>" : "") + RetornaResource("TipoObrigatorio");
                        valido = false;
                    }

                    if (!string.IsNullOrEmpty(txtDescricao.Text) && rblLinkArquivo.SelectedIndex > -1 && (Convert.ToInt32(rblLinkArquivo.SelectedValue) == (byte)ACA_ArquivoAreaBO.eTipoDocumento.Arquivo && (!Int64.TryParse(lblArqId.Text, out arq_id) || arq_id <= 0)))
                    {
                        msg += (!string.IsNullOrEmpty(msg) ? "<br/>" : "") + RetornaResource("ArquivoObrigatorio");
                        if (lblErroLink != null)
                        {
                            lblErroLink.Visible = true;
                        }
                        valido = false;
                    }

                    if (!string.IsNullOrEmpty(txtDescricao.Text) && rblLinkArquivo.SelectedIndex > -1 && (Convert.ToInt32(rblLinkArquivo.SelectedValue) == (byte)ACA_ArquivoAreaBO.eTipoDocumento.Link && string.IsNullOrEmpty(txtLink.Text)))
                    {
                        msg += (!string.IsNullOrEmpty(msg) ? "<br/>" : "") + RetornaResource("LinkObrigatorio");
                        if (lblErroLink != null)
                        {
                            lblErroLink.Visible = true;
                        }
                        valido = false;
                    }

                    if (!string.IsNullOrEmpty(msg))
                    {
                        lblMensagemDocumentos.Text = UtilBO.GetErroMessage(msg, UtilBO.TipoMensagem.Alerta);
                    }

                    /*if (cmbTipoNivelEnsino.Valor == -1)
                     * {
                     *  //lblMensagemDocumentos.Text = UtilBO.GetErroMessage(RetornaResource(""), UtilBO.TipoMensagem.Alerta);
                     *  valido = false;
                     * }*/
                }
            }

            if (valido)
            {
                lblMensagemDocumentos.Text = "";
                List <ACA_ArquivoArea> listaArquivoArea = RetornaListaDocumentos();

                listaArquivoArea.Add
                (
                    new ACA_ArquivoArea
                {
                    tad_id = VS_tad_id
                    ,
                    uad_idSuperior = VS_permiteCadastroEscola ? uad_idSuperior : Guid.Empty
                    ,
                    esc_id = VS_permiteCadastroEscola ? esc_id : -1
                    ,
                    uni_id = VS_permiteCadastroEscola ? uni_id : -1
                    ,
                    id = Guid.NewGuid()
                    ,
                    aar_tipoDocumento = (byte)ACA_ArquivoAreaBO.eTipoDocumento.Link
                }
                );

                rptDocumentos.DataSource = listaArquivoArea;
                rptDocumentos.DataBind();

                rptDocumentos.Items[rptDocumentos.Items.Count - 1].FindControl("btnAdicionar").Visible = true;
            }
        }