Ejemplo n.º 1
0
        protected void LoadSession(SYS_Usuario entityUsuario)
        {
            __SessionWEB.__UsuarioWEB.Usuario = entityUsuario;

            System.Web.Configuration.PagesSection pagesSection = System.Configuration.ConfigurationManager.GetSection("system.web/pages") as System.Web.Configuration.PagesSection;
            if ((pagesSection != null))
            {
                __SessionWEB.TemaPadraoLogado = CFG_TemaPadraoBO.CarregarPorNome(pagesSection.Theme);
            }

            // Armazena o cid_id referente a entidade do usuário na Session
            Guid ene_id = SYS_EntidadeEnderecoBO.Select_ene_idBy_ent_id(__SessionWEB.__UsuarioWEB.Usuario.ent_id);
            SYS_EntidadeEndereco entityEntidadeEndereco = new SYS_EntidadeEndereco {
                ent_id = __SessionWEB.__UsuarioWEB.Usuario.ent_id, ene_id = ene_id
            };

            SYS_EntidadeEnderecoBO.GetEntity(entityEntidadeEndereco);

            END_Endereco entityEndereco = new END_Endereco {
                end_id = entityEntidadeEndereco.end_id
            };

            END_EnderecoBO.GetEntity(entityEndereco);
            __SessionWEB._cid_id = entityEndereco.cid_id;

            // Armazena o nome da pessoa ou o login do usuário na Session
            PES_Pessoa EntityPessoa = new PES_Pessoa {
                pes_id = __SessionWEB.__UsuarioWEB.Usuario.pes_id
            };

            PES_PessoaBO.GetEntity(EntityPessoa);
            __SessionWEB.UsuarioLogado = string.IsNullOrEmpty(EntityPessoa.pes_nome) ? __SessionWEB.__UsuarioWEB.Usuario.usu_login : EntityPessoa.pes_nome;
        }
Ejemplo n.º 2
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);
            }
        }
        /// <summary>
        /// Carrega o combo de temas com todos os temas ativos no sistema.
        /// </summary>
        public void Carregar()
        {
            bool mostraMensagemSelecione = MostrarMensagemSelecione;

            var temas = from CFG_TemaPadrao tema in CFG_TemaPadraoBO.SelecionaAtivos()
                        select new
            {
                tep_id = tema.tep_id
                ,
                tep_descricao = tema.tep_nome
            };

            ddlTemaPadrao.Items.Clear();
            ddlTemaPadrao.DataSource = temas;
            MostrarMensagemSelecione = mostraMensagemSelecione;
            ddlTemaPadrao.DataBind();

            SelecionaPrimeiroItem();
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
    /// <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);
        }
    }
Ejemplo n.º 7
0
    /// <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);
        }
    }