Beispiel #1
0
        /// <summary>
        /// Salva os dados da tela em uma entidade de Tema Padrão.
        /// </summary>
        private void Salvar()
        {
            try
            {
                CFG_TemaPadrao entity = new CFG_TemaPadrao
                {
                    tep_id = VS_tep_id
                    ,
                    tep_nome = txtNome.Text
                    ,
                    tep_descricao = txtDescricao.Text
                    ,
                    tep_tipoMenu = Convert.ToByte(ddlTipoMenu.SelectedValue)
                    ,
                    tep_tipoLogin = Convert.ToByte(ddlTipoLogin.SelectedValue)
                    ,
                    tep_exibeLinkLogin = chkExibeLinkLogin.Checked
                    ,
                    tep_exibeLogoCliente = chkExibeLogoCliente.Checked
                    ,
                    IsNew = VS_tep_id <= 0
                };

                if (CFG_TemaPadraoBO.Save(entity))
                {
                    ApplicationWEB._GravaLogSistema(VS_tep_id > 0 ? LOG_SistemaTipo.Update : LOG_SistemaTipo.Insert, String.Format("tep_id: {0}", entity.tep_id.ToString()));
                    __SessionWEB.PostMessages = UtilBO.GetErroMessage(String.Format("Tema padrão foi {0} com sucesso.", VS_tep_id > 0 ? "alterado" : "incluído"), UtilBO.TipoMensagem.Sucesso);

                    Response.Redirect(__SessionWEB._AreaAtual._Diretorio + "TemaPadrao/Busca.aspx", false);
                }
                else
                {
                    lblMensagem.Text = UtilBO.GetErroMessage("Erro ao tentar salva o tema padrão.", UtilBO.TipoMensagem.Erro);
                }
            }
            catch (DuplicateNameException ex)
            {
                lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
            }
            catch (ValidationException ex)
            {
                lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                lblMensagem.Text = UtilBO.GetErroMessage("Erro ao tentar salva o tema padrão.", UtilBO.TipoMensagem.Erro);
            }
        }
Beispiel #2
0
        protected override void ParamDeletar(QueryStoredProcedure qs, CFG_TemaPadrao entity)
        {
            base.ParamDeletar(qs, entity);

            Param               = qs.NewParameter();
            Param.DbType        = DbType.Byte;
            Param.ParameterName = "@tep_situacao";
            Param.Size          = 1;
            Param.Value         = (byte)CFG_TemaPadrao.eSituacao.Excluido;
            qs.Parameters.Add(Param);

            Param               = qs.NewParameter();
            Param.DbType        = DbType.DateTime;
            Param.ParameterName = "@tep_dataAlteracao";
            Param.Size          = 16;
            Param.Value         = DateTime.Now;
            qs.Parameters.Add(Param);
        }
        protected void grvTema_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Deletar")
            {
                try
                {
                    int index  = int.Parse(e.CommandArgument.ToString());
                    int tep_id = Convert.ToInt32(grvTema.DataKeys[index].Value.ToString());

                    CFG_TemaPadrao entity = new CFG_TemaPadrao {
                        tep_id = tep_id
                    };

                    if (CFG_TemaPadraoBO.Delete(entity))
                    {
                        grvTema.PageIndex = 0;
                        grvTema.DataBind();
                        ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Delete, "tep_id: " + tep_id);
                        lblMensagem.Text = UtilBO.GetErroMessage("Tema padrão excluído com sucesso.", UtilBO.TipoMensagem.Sucesso);
                    }
                    else
                    {
                        lblMensagem.Text = UtilBO.GetErroMessage("Erro ao tentar excluir o tema padrão.", UtilBO.TipoMensagem.Erro);
                    }
                }
                catch (ValidationException ex)
                {
                    lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
                }
                catch (Exception ex)
                {
                    ApplicationWEB._GravaErro(ex);
                    lblMensagem.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Erro);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Carrega os dados da tela de uma entidade de Tema Padrão.
        /// </summary>
        private void LoadFromEntity()
        {
            try
            {
                CFG_TemaPadrao entity = new CFG_TemaPadrao {
                    tep_id = VS_tep_id
                };
                CFG_TemaPadraoBO.GetEntity(entity);

                txtNome.Text      = entity.tep_nome;
                txtDescricao.Text = entity.tep_descricao;

                chkExibeLinkLogin.Checked   = entity.tep_exibeLinkLogin;
                chkExibeLogoCliente.Checked = entity.tep_exibeLogoCliente;

                ddlTipoMenu.SelectedValue  = entity.tep_tipoMenu.ToString();
                ddlTipoLogin.SelectedValue = entity.tep_tipoLogin.ToString();
            }
            catch (Exception ex)
            {
                ApplicationWEB._GravaErro(ex);
                lblMensagem.Text = UtilBO.GetErroMessage("Erro ao tentar carregar o tema padrão.", UtilBO.TipoMensagem.Erro);
            }
        }
    /// <summary>
    /// Carrega os dados da entidade nos controles caso seja alteração.
    /// </summary>
    private void _LoadFromEntity()
    {
        try
        {
            SYS_Entidade ent = new SYS_Entidade {
                ent_id = _VS_ent_id
            };
            SYS_EntidadeBO.GetEntity(ent);

            _VS_ent_id = ent.ent_id;
            _VS_ent_idSuperiorAntigo = ent.ent_idSuperior;
            UCComboTipoEntidade1._Combo.SelectedValue = ent.ten_id.ToString();
            _txtRazaoSocial.Text  = ent.ent_razaoSocial;
            _txtNomeFantasia.Text = (!string.IsNullOrEmpty(ent.ent_nomeFantasia) ? ent.ent_nomeFantasia : string.Empty);
            _txtSigla.Text        = (!string.IsNullOrEmpty(ent.ent_sigla) ? ent.ent_sigla : string.Empty);
            _txtCodigo.Text       = (!string.IsNullOrEmpty(ent.ent_codigo) ? ent.ent_codigo : string.Empty);
            _txtCNPJ.Text         = (!string.IsNullOrEmpty(ent.ent_cnpj) ? ent.ent_cnpj : string.Empty);
            _txtIE.Text           = (!string.IsNullOrEmpty(ent.ent_inscricaoEstadual) ? ent.ent_inscricaoEstadual : string.Empty);
            _txtIM.Text           = (!string.IsNullOrEmpty(ent.ent_inscricaoMunicipal) ? ent.ent_inscricaoMunicipal : string.Empty);
            UCComboEntidade1._Combo.SelectedValue = (ent.ent_idSuperior != Guid.Empty) ? Convert.ToString(ent.ent_idSuperior) : Guid.Empty.ToString();
            txtUrlAcesso.Text           = ent.ent_urlAcesso;
            chkExibeLogoCliente.Checked = ent.ent_exibeLogoCliente;

            if (ent.tep_id > 0)
            {
                UCComboTemaPadrao.Valor = ent.tep_id;
                UCComboTemaPadrao_IndexChanged();

                CFG_TemaPadrao entTema = new CFG_TemaPadrao {
                    tep_id = ent.tep_id
                };
                CFG_TemaPadraoBO.GetEntity(entTema);

                string caminho = "~/App_Themes/" + entTema.tep_nome + "/images/logos/";

                if (!string.IsNullOrEmpty(ent.ent_logoCliente) && UtilBO.ExisteArquivo(Server.MapPath(caminho + ent.ent_id + "_" + ent.ent_logoCliente)))
                {
                    imgLogoCliente.Visible  = true;
                    imgLogoCliente.ImageUrl = caminho + ent.ent_id + "_" + ent.ent_logoCliente;
                }

                UCComboTemaPaleta.Valor = ent.tpl_id > 0 ? new int[] { ent.tep_id, ent.tpl_id } : new int[] { -1, -1 };
            }
            else
            {
                UCComboTemaPadrao.Valor = -1;
            }

            _chkBloqueado.Checked = ent.ent_situacao == 2;

            DataTable dtEndereco = SYS_EntidadeEnderecoBO.CarregarEnderecosBy_Entidade(ent.ent_id);
            UCEnderecos1.CarregarEnderecosBanco(dtEndereco);

            DataTable dt = SYS_EntidadeContatoBO.GetSelect(_VS_ent_id, false, 1, 1);
            if (dt.Rows.Count == 0)
            {
                dt = null;
            }

            UCGridContato1._VS_contatos = dt;

            UCGridContato1._CarregarContato();

            UCComboTipoEntidade1._Combo.Enabled = false;
        }
        catch (Exception ex)
        {
            ApplicationWEB._GravaErro(ex);
            _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar carregar a entidade.", UtilBO.TipoMensagem.Erro);
        }
    }
    /// <summary>
    /// Insere e altera uma entidade
    /// </summary>
    private void _Salvar()
    {
        try
        {
            string msgErro;
            if (String.IsNullOrEmpty(_lblMessage.Text.Trim()) && !UCGridContato1.SalvaConteudoGrid(out msgErro))
            {
                UCGridContato1._MensagemErro.Visible = false;
                _lblMessage.Text     = msgErro;
                txtSelectedTab.Value = "2";
                return;
            }

            string    msg;
            DataTable dtEndereco;
            bool      cadastraEndereco = UCEnderecos1.RetornaEnderecoCadastrado(out dtEndereco, out msg);

            if (!cadastraEndereco)
            {
                throw new ValidationException(msg);
            }

            SYS_Entidade entityEntidade = new SYS_Entidade
            {
                ent_id = _VS_ent_id
                ,
                ten_id = new Guid(UCComboTipoEntidade1._Combo.SelectedValue)
                ,
                ent_razaoSocial = _txtRazaoSocial.Text
                ,
                ent_nomeFantasia = _txtNomeFantasia.Text
                ,
                ent_sigla = _txtSigla.Text
                ,
                ent_codigo = _txtCodigo.Text
                ,
                ent_cnpj = _txtCNPJ.Text
                ,
                ent_inscricaoEstadual = _txtIE.Text
                ,
                ent_inscricaoMunicipal = _txtIM.Text
                ,
                ent_idSuperior = new Guid(UCComboEntidade1._Combo.SelectedValue)
                ,
                ent_situacao = (_chkBloqueado.Checked ? Convert.ToByte(2) : Convert.ToByte(1))
                ,
                ent_urlAcesso = txtUrlAcesso.Text
                ,
                ent_logoCliente = !string.IsNullOrEmpty(fupLogoCliente.FileName) ?
                                  fupLogoCliente.FileName :
                                  (!string.IsNullOrEmpty(imgLogoCliente.ImageUrl) ? Path.GetFileName(imgLogoCliente.ImageUrl) : string.Empty)
                ,
                ent_exibeLogoCliente = chkExibeLogoCliente.Checked
                ,
                tep_id = UCComboTemaPadrao.Valor
                ,
                tpl_id = UCComboTemaPaleta.tpl_id
                ,
                IsNew = (_VS_ent_id != Guid.Empty) ? false : true
            };

            if (!entityEntidade.IsNew && string.IsNullOrEmpty(fupLogoCliente.FileName) && !string.IsNullOrEmpty(imgLogoCliente.ImageUrl))
            {
                entityEntidade.ent_logoCliente = entityEntidade.ent_logoCliente.Remove(0, entityEntidade.ent_id.ToString().Length + 1);
            }

            string tema = NomeTemaAtual;

            if (UCComboTemaPadrao.Valor > 0)
            {
                CFG_TemaPadrao entTema = new CFG_TemaPadrao {
                    tep_id = UCComboTemaPadrao.Valor
                };
                CFG_TemaPadraoBO.GetEntity(entTema);

                tema = entTema.tep_nome;
            }

            string caminho = Server.MapPath("~/App_Themes/" + tema + "/images/logos/");

            if (SYS_EntidadeBO.Save(entityEntidade, dtEndereco, UCGridContato1._VS_contatos, _VS_ent_idSuperiorAntigo, _VS_end_idAntigo, caminho, fupLogoCliente.FileName, fupLogoCliente.PostedFile, null))
            {
                if (_VS_ent_id == Guid.Empty)
                {
                    ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Insert, "ent_id: " + entityEntidade.ent_id);
                    __SessionWEB.PostMessages = UtilBO.GetErroMessage(String.Format("Entidade incluída com sucesso."), UtilBO.TipoMensagem.Sucesso);
                }
                else
                {
                    ApplicationWEB._GravaLogSistema(LOG_SistemaTipo.Update, "ent_id: " + entityEntidade.ent_id);
                    __SessionWEB.PostMessages = UtilBO.GetErroMessage(String.Format("Entidade alterada com sucesso."), UtilBO.TipoMensagem.Sucesso);
                }

                Response.Redirect(__SessionWEB._AreaAtual._Diretorio + "Entidade/Busca.aspx", false);
            }
            else
            {
                _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar a entidade.", UtilBO.TipoMensagem.Erro);
            }
        }
        catch (ValidationException ex)
        {
            _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
        }
        catch (ArgumentException ex)
        {
            _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
        }
        catch (DuplicateNameException ex)
        {
            _lblMessage.Text = UtilBO.GetErroMessage(ex.Message, UtilBO.TipoMensagem.Alerta);
        }
        catch (Exception ex)
        {
            ApplicationWEB._GravaErro(ex);
            _lblMessage.Text = UtilBO.GetErroMessage("Erro ao tentar salvar a entidade.", UtilBO.TipoMensagem.Erro);
        }
    }
Beispiel #7
0
 public override bool Delete(CFG_TemaPadrao entity)
 {
     __STP_DELETE = "NEW_CFG_TemaPadrao_UpdateSituacao";
     return(base.Delete(entity));
 }
Beispiel #8
0
 protected override bool Alterar(CFG_TemaPadrao entity)
 {
     __STP_UPDATE = "NEW_CFG_TemaPadrao_UPDATE";
     return(base.Alterar(entity));
 }
Beispiel #9
0
 protected override void ParamAlterar(QueryStoredProcedure qs, CFG_TemaPadrao entity)
 {
     entity.tep_dataAlteracao = DateTime.Now;
     base.ParamAlterar(qs, entity);
     qs.Parameters.RemoveAt("@tep_dataCriacao");
 }
Beispiel #10
0
 protected override void ParamInserir(QuerySelectStoredProcedure qs, CFG_TemaPadrao entity)
 {
     entity.tep_dataCriacao = entity.tep_dataAlteracao = DateTime.Now;
     base.ParamInserir(qs, entity);
 }