コード例 #1
0
        protected virtual void SetarModoPagina(ModosPagina modo)
        {
            try
            {
                this.ModoPagina = modo;
                MultiView   mtvPrincipal  = (MultiView)this.LocalizarControle("mtvPrincipal", this.Controls);
                Button      btnExcluir    = (Button)this.LocalizarControle("btnExcluir", this.Controls);
                Button      btnSalvar     = (Button)this.LocalizarControle("btnSalvar", this.Controls);
                Button      btnListagem   = (Button)this.LocalizarControle("btnListagem", this.Controls);
                Label       lblTitulo     = (Label)this.LocalizarControle("lblTitulo", this.Controls);
                ProPanel    pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
                ProPanel    pnlConsulta   = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
                ProGridView grdListagem   = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);

                btnSalvar.Visible   = true;
                btnListagem.Visible = true;
                switch (modo)
                {
                case ModosPagina.Listar:
                    PopularGridView();
                    lblTitulo.Text               = "<b>" + this.TituloPagina + ":</b> Consulta";
                    pnlConsulta.Visible          = true;
                    mtvPrincipal.ActiveViewIndex = 0;
                    btnExcluir.Visible           = false;
                    btnSalvar.Visible            = false;
                    btnListagem.Visible          = false;
                    break;

                case ModosPagina.Inserir:
                    lblTitulo.Text = "<b>" + this.TituloPagina + ":</b> Inclusão";
                    pnlManutencao.Clear();
                    mtvPrincipal.ActiveViewIndex = 1;
                    btnExcluir.Visible           = false;
                    pnlConsulta.Visible          = false;
                    grdListagem.SelectedIndex    = -1;
                    this.grdListagem_SelectedIndexChanged(this, EventArgs.Empty);
                    if (FocoInicial != null)
                    {
                        Focus(FocoInicial);
                    }
                    break;

                case ModosPagina.Alterar:
                    lblTitulo.Text = "<b>" + this.TituloPagina + ":</b> Alteração";
                    mtvPrincipal.ActiveViewIndex = 1;
                    btnExcluir.Visible           = true;
                    pnlConsulta.Visible          = false;
                    if (FocoInicial != null)
                    {
                        Focus(FocoInicial);
                    }
                    break;
                }
                VerificarPermissoes();
            }
            catch (Exception ex)
            {
                this.ExibirExcecao(ex);
            }
        }
コード例 #2
0
 protected override void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             if (PaginaSegura)
             {
                 if (!Contexto.Seguranca.Ler(this.GetType().BaseType.Name))
                 {
                     ProPanel pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsultaUC", this.Controls);
                     if (pnlConsulta != null)
                     {
                         pnlConsulta.Visible = false;
                     }
                     return;
                 }
             }
             PopularGridView();
             SetarModoPagina(ModosPagina.Listar);
             ProTextBox txtBusca = (ProTextBox)this.LocalizarControle("txtBusca", this.Controls);
             if (txtBusca != null)
             {
                 Focus(txtBusca);
             }
         }
     }
     catch (Exception ex)
     {
         ExibirExcecao(ex);
     }
 }
コード例 #3
0
 protected virtual void PopularGridView()
 {
     try
     {
         Label           lblBusca    = (Label)this.LocalizarControle("lblBusca", this.Controls);
         ProTextBox      txtBusca    = (ProTextBox)this.LocalizarControle("txtBusca", this.Controls);
         ProPanel        pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
         ProGridView     grdListagem = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);
         ProDropDownList ddlCampoBusca;
         grdListagem.SelectedIndex = -1;
         if (this.LocalizarControle("ddlCampoBusca", this.Controls) != null)
         {
             ddlCampoBusca = (ProDropDownList)this.LocalizarControle("ddlCampoBusca", this.Controls);
             if ((ddlCampoBusca.SelectedIndex != -1) && (ddlCampoBusca.Visible))
             {
                 txtBusca.DataField = ddlCampoBusca.SelectedItem.Value;
             }
         }
         else
         {
             lblBusca.Text      = grdListagem.Columns[grdListagem.SortColumnIndex].HeaderText + " : ";
             txtBusca.DataField = grdListagem.SortColumnName;
         }
         grdListagem.DataBind(this.Controladora.Consultar(pnlConsulta.GetFormData(), grdListagem.SortByDirection.ToString(), grdListagem.SortColumnName));
     }
     catch (Exception ex)
     {
         ExibirExcecao(ex);
     }
 }
コード例 #4
0
        protected virtual void SetarModoPagina(ModosPagina modo)
        {
            try
            {
                this.ModoPagina = modo;
                Button btnExcluir = (Button)this.LocalizarControle("btnExcluirUC", this.Controls);
                //Button btnNovoCadastro = (Button)this.LocalizarControle("btnNovoCadastroUC", this.Controls);
                ProPanel pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencaoUC", this.Controls);
                //ProPanel pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsultaUC",this.Controls);
                ProGridView        grdListagem = (ProGridView)this.LocalizarControle("grdListagemUC", this.Controls);
                ModalPopupExtender mpeUC       = (ModalPopupExtender)this.LocalizarControle("mpeUC", this.Controls);

                switch (modo)
                {
                case ModosPagina.Listar:
                    PopularGridView();
                    mpeUC.Hide();
                    break;

                case ModosPagina.Inserir:
                    pnlManutencao.Clear();
                    mpeUC.Show();
                    btnExcluir.Visible = false;
                    //btnNovoCadastro.Visible = false;
                    //pnlConsulta.Visible = false;
                    grdListagem.SelectedIndex = -1;
                    this.grdListagem_SelectedIndexChanged(this, EventArgs.Empty);
                    if (FocoInicial != null)
                    {
                        Focus(FocoInicial);
                    }
                    break;

                case ModosPagina.Alterar:
                    mpeUC.Show();
                    btnExcluir.Visible = true;
                    //btnNovoCadastro.Visible = true;
                    //pnlConsulta.Visible = false;
                    if (FocoInicial != null)
                    {
                        Focus(FocoInicial);
                    }
                    break;
                }
                PreencherIdPaiManutencao();
                BotaoNovoAtivo();
                VerificarPermissoes();
            }
            catch (Exception ex)
            {
                this.ExibirExcecao(ex);
            }
        }
コード例 #5
0
 protected virtual void btnLimpar_Click(object sender, EventArgs e)
 {
     try
     {
         ProPanel pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
         pnlConsulta.Clear();
     }
     catch (Exception ex)
     {
         ExibirExcecao(ex);
     }
 }
コード例 #6
0
        protected virtual void SetarModoPagina(ModosPagina modo)
        {
            try
            {
                this.ModoPagina = modo;
                MultiView   mtvPrincipal    = (MultiView)this.LocalizarControle("mtvPrincipal", this.Controls);
                Button      btnExcluir      = (Button)this.LocalizarControle("btnExcluir", this.Controls);
                Button      btnNovoCadastro = (Button)this.LocalizarControle("btnNovoCadastro", this.Controls);
                ProPanel    pnlManutencao   = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
                ProPanel    pnlConsulta     = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
                ProGridView grdListagem     = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);

                switch (modo)
                {
                case ModosPagina.Listar:
                    PopularGridView();
                    pnlConsulta.Visible          = true;
                    mtvPrincipal.ActiveViewIndex = 0;
                    break;

                case ModosPagina.Inserir:
                    pnlManutencao.Clear();
                    mtvPrincipal.ActiveViewIndex = 1;
                    btnExcluir.Visible           = false;
                    btnNovoCadastro.Visible      = false;
                    pnlConsulta.Visible          = false;
                    grdListagem.SelectedIndex    = -1;
                    this.grdListagem_SelectedIndexChanged(this, EventArgs.Empty);
                    if (FocoInicial != null)
                    {
                        Focus(FocoInicial);
                    }
                    break;

                case ModosPagina.Alterar:
                    mtvPrincipal.ActiveViewIndex = 1;
                    btnExcluir.Visible           = true;
                    btnNovoCadastro.Visible      = true;
                    pnlConsulta.Visible          = false;
                    if (FocoInicial != null)
                    {
                        Focus(FocoInicial);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                this.ExibirExcecao(ex);
            }
        }
コード例 #7
0
 protected virtual void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         this.Controladora.Excluir();
         ProPanel pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
         pnlManutencao.Clear();
         //ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ShowQuickMessage('Registro excluído com sucesso.');", true);
         SetarModoPagina(ModosPagina.Listar);
     }
     catch (Exception ex)
     {
         this.ExibirExcecao(ex);
     }
 }
コード例 #8
0
 protected virtual void PopularGridView()
 {
     try
     {
         Label       lblBusca    = (Label)this.LocalizarControle("lblBusca", this.Controls);
         ProTextBox  txtBusca    = (ProTextBox)this.LocalizarControle("txtBusca", this.Controls);
         ProPanel    pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
         ProGridView grdListagem = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);
         grdListagem.SelectedIndex = -1;
         lblBusca.Text             = grdListagem.Columns[grdListagem.SortColumnIndex].HeaderText + " : ";
         txtBusca.DataField        = grdListagem.SortColumnName;
         grdListagem.DataBind(this.Controladora.Consultar(pnlConsulta.GetFormData(), grdListagem.SortByDirection.ToString()));
     }
     catch (Exception ex)
     {
         ExibirExcecao(ex);
     }
 }
コード例 #9
0
        protected virtual void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Contexto.Seguranca.Deletar(this.GetType().BaseType.Name))
                {
                    throw new ViolacaoRegraException("Usuário não tem permissão para <b>excluir</b> registro.");
                }

                this.Controladora.Excluir();
                ProPanel pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencaoUC", this.Controls);
                pnlManutencao.Clear();
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ShowQuickMessage('Registro excluído com sucesso.');", true);
                SetarModoPagina(ModosPagina.Listar);
            }
            catch (Exception ex)
            {
                this.ExibirExcecao(ex);
            }
        }
コード例 #10
0
        protected virtual void Selecionar(int id)
        {
            try
            {
                ProPanel    pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
                ProGridView grdListagem   = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);

                SetarModoPagina(ModosPagina.Alterar);
                pnlManutencao.SetFormData(this.Controladora.Selecionar(id));
                grdListagem.SelectedIndex = -1;
            }
            catch (Pro.Dal.Exceptions.NotAutorizedException ex)
            {
                SetarModoPagina(ModosPagina.Listar);
                this.ExibirExcecao(ex);
            }
            catch (Exception ex)
            {
                this.ExibirExcecao(ex);
            }
        }
コード例 #11
0
 protected virtual void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         ProPanel pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
         if (this.Controladora.Salvar(pnlManutencao.GetFormData()) == Pro.Dal.CrudActionTypes.Insert)
         {
             pnlManutencao.Clear();
             this.Controladora.PrepararInclusao();
             //ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ShowQuickMessage('Registro inserido com sucesso.');", true);
         }
         //else
         //    ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ShowQuickMessage('<br>Registro atualizado com sucesso.');", true);
         //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "QuickMessage", "ShowQuickMessage('Registro atualizado com sucesso.');");
         //ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ShowQuickMessage('Registro atualizado com sucesso.');",true);
     }
     catch (Exception ex)
     {
         this.ExibirExcecao(ex);
     }
 }
コード例 #12
0
 public virtual void PopularGridView()
 {
     try
     {
         //Label lblBusca = (Label)this.LocalizarControle("lblBusca", this.Controls);
         //ProTextBox txtBusca = (ProTextBox)this.LocalizarControle("txtBusca", this.Controls);
         PreencherIdPaiConsulta();
         BotaoNovoAtivo();
         ProPanel    pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsultaUC", this.Controls);
         ProGridView grdListagem = (ProGridView)this.LocalizarControle("grdListagemUC", this.Controls);
         grdListagem.SelectedIndex = -1;
         //lblBusca.Text = grdListagem.Columns[grdListagem.SortColumnIndex].HeaderText + " : ";
         //txtBusca.DataField = grdListagem.SortColumnName;
         //grdListagem.DataBind(this.Controladora.Consultar(pnlConsulta.GetFormData(), grdListagem.SortByDirection.ToString()));
         grdListagem.DataBind(this.Controladora.Consultar(pnlConsulta.GetFormData(), grdListagem.SortByDirection.ToString(), grdListagem.SortColumnName));
     }
     catch (Exception ex)
     {
         ExibirExcecao(ex);
     }
 }
コード例 #13
0
 protected virtual void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         if (PaginaSegura)
         {
             if (ModoPagina == ModosPagina.Inserir)
             {
                 if (!Contexto.Seguranca.Inserir(this.GetType().BaseType.Name))
                 {
                     throw new ViolacaoRegraException("Usuário não tem permissão para <b>inserir</b> registro.");
                 }
             }
             else if (ModoPagina == ModosPagina.Alterar)
             {
                 if (!Contexto.Seguranca.Atualizar(this.GetType().BaseType.Name))
                 {
                     throw new ViolacaoRegraException("Usuário não tem permissão para <b>alterar</b> registro.");
                 }
             }
         }
         ProPanel pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
         if (this.Controladora.Salvar(pnlManutencao.GetFormData()) == Pro.Dal.CrudActionTypes.Insert)
         {
             pnlManutencao.Clear();
             this.Controladora.PrepararInclusao();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ExibirMensagem('Registro <b>inserido</b> com sucesso.');", true);
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "QuickMessage", "ExibirMensagem('Registro <b>atualizado</b> com sucesso.');", true);
         }
     }
     catch (Exception ex)
     {
         this.ExibirExcecao(ex);
     }
 }
コード例 #14
0
 protected override void PopularGridView()
 {
     try
     {
         Label       lblBusca    = (Label)this.LocalizarControle("lblBusca", this.Controls);
         ProTextBox  txtBusca    = (ProTextBox)this.LocalizarControle("txtBusca", this.Controls);
         ProPanel    pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
         ProGridView grdListagem = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);
         grdListagem.SelectedIndex = -1;
         lblBusca.Text             = grdListagem.Columns[grdListagem.SortColumnIndex].HeaderText + " : ";
         txtBusca.DataField        = grdListagem.SortColumnName;
         Dictionary <string, object> dct = pnlConsulta.GetFormData();
         foreach (KeyValuePair <string, int> kvp in this.Filtros)
         {
             dct.Add(kvp.Key, kvp.Value);
         }
         grdListagem.DataBind(this.Controladora.Consultar(dct, grdListagem.SortByDirection.ToString()));
     }
     catch (Exception ex)
     {
         ExibirExcecao(ex);
     }
 }
コード例 #15
0
        protected virtual void ExibirExcecao(Exception excecao)
        {
            System.Text.StringBuilder sMensagens = new System.Text.StringBuilder();

            switch (excecao.GetType().Name)
            {
            case "CampoNuloOuInvalidoException":
                foreach (string key in ((CampoNuloOuInvalidoException)excecao).Mensagens.Keys)
                {
                    sMensagens.Append("<li> " + ((CampoNuloOuInvalidoException)excecao).Mensagens[key].Replace("'", "") + "<br />");
                }

                this.ExibirAlerta(TiposMensagem.Alerta, "Campo inválido", sMensagens.ToString());
                break;

            case "ExecucaoException":
                string sExecucaoException = string.Empty;
                if (excecao.Message.IndexOf("#") > 0)
                {
                    string[] aMensagens = excecao.Message.Split(Convert.ToChar("#"));
                    sExecucaoException = aMensagens[0];
                }
                else
                {
                    sExecucaoException = excecao.Message.Replace("'", "").Replace("\"", "").Replace("\n", "").Replace("\r", "");
                }

                this.ExibirAlerta(TiposMensagem.Erro, "Erro na execução", sExecucaoException);
                break;

            case "ViolacaoRegraException":
                this.ExibirAlerta(TiposMensagem.Alerta, "Operação inválida", excecao.Message);
                break;

            case "NotAutorizedException":
                string sMsg = excecao.Message.Replace("'", "\"");
                if (sMsg.IndexOf("<b>Consultar</b>") != -1)
                {
                    View vwListagem = (View)Page.Form.FindControl("cphPadrao").FindControl("vwListagem");
                    if (vwListagem != null)
                    {
                        foreach (Control ctrl in vwListagem.Controls)
                        {
                            ctrl.Visible = false;
                        }
                    }

                    ProPanel pnlConsulta = (ProPanel)Page.Form.FindControl("cphPadrao").FindControl("pnlConsulta");
                    if (pnlConsulta != null)
                    {
                        pnlConsulta.Enabled = false;
                    }
                }
                this.ExibirAlerta(TiposMensagem.Alerta, "Operação não autorizada", sMsg);
                break;

            case "NaoAutenticadoException":
                HttpContext.Current.Items.Add("NaoAutenticado", excecao.Message);
                Server.Transfer("frmLogin.aspx");
                break;

            case "GenericaException":
                string sMensagem = string.Empty;
                sMensagem = excecao.Message.Replace("'", "").Replace("\"", "").Replace("\n", "").Replace("\r", "");

                this.ExibirAlerta(TiposMensagem.Erro, "Erro na execução", sMensagem);
                break;

            default:
                GenericaException ex = new GenericaException(excecao.Message, excecao);
                this.ExibirAlerta(TiposMensagem.Erro, "Erro na execução", "(" + ex.IdExcecao + "): Erro não identificado durante a execução da operação.");
                break;
            }
        }
コード例 #16
0
        /// <summary>
        /// Seta os métodos dos botões e controles da página de cadastro
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void Page_Init(object sender, EventArgs e)
        {
            try
            {
                Button btnExcluir = (Button)this.LocalizarControle("btnExcluir", this.Controls);
                if (btnExcluir != null)
                {
                    btnExcluir.OnClientClick = "messageBox(this,'PERGUNTA','SIMNAO','Confirmação de exclusão','Deseja realmente excluir este item ?',''); return false;";
                    btnExcluir.Click        += new EventHandler(btnExcluir_Click);
                }

                Button btnSalvar = (Button)this.LocalizarControle("btnSalvar", this.Controls);
                if (btnSalvar != null)
                {
                    btnSalvar.Click += new EventHandler(btnSalvar_Click);
                }

                Button btnListagem = (Button)this.LocalizarControle("btnListagem", this.Controls);
                btnListagem.Click += new EventHandler(btnListagem_Click);

                Button btnNovo = (Button)this.LocalizarControle("btnNovo", this.Controls);
                if (btnNovo != null)
                {
                    btnNovo.Click += new EventHandler(btnNovo_Click);
                }

                Button btnNovoCadastro = (Button)this.LocalizarControle("btnNovoCadastro", this.Controls);
                if (btnNovoCadastro != null)
                {
                    btnNovoCadastro.Click += new EventHandler(btnNovo_Click);
                }

                Button btnBuscar = (Button)this.LocalizarControle("btnBuscar", this.Controls);
                if (btnBuscar != null)
                {
                    btnBuscar.Click += new EventHandler(btnBuscar_Click);
                }

                ProTextBox txtBusca = (ProTextBox)this.LocalizarControle("txtBusca", this.Controls);
                if (txtBusca != null)
                {
                    txtBusca.Attributes.Add("onkeypress", "if(event.which || event.keyCode){if((event.which == 13) || (event.keyCode == 13)){event.keyCode=0; document.getElementById('" + btnBuscar.ClientID + "').click();return false;}else{return true;}}");
                }

                Button btnLimpar = (Button)this.LocalizarControle("btnLimpar", this.Controls);
                if (btnLimpar != null)
                {
                    btnLimpar.Click += new EventHandler(btnLimpar_Click);
                }

                ProGridView grdListagem = (ProGridView)this.LocalizarControle("grdListagem", this.Controls);
                grdListagem.SelectedIndexChanged += new EventHandler(grdListagem_SelectedIndexChanged);
                grdListagem.PageIndexChanging    += new GridViewPageEventHandler(grdListagem_PageIndexChanging);
                grdListagem.RowEditing           += new GridViewEditEventHandler(grdListagem_RowEditing);
                grdListagem.RowCommand           += new GridViewCommandEventHandler(grdListagem_RowCommand);
                grdListagem.RowDeleting          += new GridViewDeleteEventHandler(grdListagem_RowDeleting);
                grdListagem.Sorting += new GridViewSortEventHandler(grdListagem_Sorting);

                ProPanel pnlManutencao = (ProPanel)this.LocalizarControle("pnlManutencao", this.Controls);
                if (pnlManutencao != null)
                {
                    pnlManutencao.DefaultButton = "btnSalvar";
                }

                ProPanel pnlConsulta = (ProPanel)this.LocalizarControle("pnlConsulta", this.Controls);
                if (pnlConsulta != null)
                {
                    pnlConsulta.DefaultButton = "btnBuscar";
                }
            }
            catch (Exception ex)
            {
                ExibirExcecao(ex);
            }
        }