public List<CWEmpresa> Pesquisar(CWEmpresa _CWEmpresa, string _Order)
        {
            sSqlCondicao = string.Empty;

            sSql = @" Select *
                    from EMPRESA ";

            if (_CWEmpresa.Codigo > 0)
            {
                sSqlCondicao += "and Codigo = " + _CWEmpresa.Codigo;
            }

            if (!string.IsNullOrEmpty(_CWEmpresa.RazaoSocial))
            {
                sSqlCondicao += "and Nome like  '%" + _CWEmpresa.RazaoSocial + "%'";
            }

            if (sSqlCondicao.Length > 0)
                sSql += " where " + sSqlCondicao.Substring(3);

            if (!string.IsNullOrEmpty(_Order))
                sSql += " order by " + _Order;

            List<CWEmpresa> dtPesquisa = ExecutarQuery<CWEmpresa>(sSql);

            return dtPesquisa;
        }
        protected void btnPesquisar_Click(object sender, DirectEventArgs e)
        {
            CWEmpresa cwEmpresa = new CWEmpresa();

            cwEmpresa.RazaoSocial = txtRazaoSocial.Text;

            List<CWEmpresa> lstEmpresas = new Empresa().Pesquisar(cwEmpresa);

            grdPesquisa.DataSource = lstEmpresas;
            grdPesquisa.DataBind();
        }
        public void Salvar(CWEmpresa _CWEmpresa)
        {
            if (_CWEmpresa.Codigo > 0)
            {
                sSql = @" update EMPRESA set
                                Nome  = '" + _CWEmpresa.RazaoSocial + @"'
                            where
                                Codigo = " + _CWEmpresa.Codigo;
            }
            else
            {
                sSql = @" INSERT INTO EMPRESA
                                (Nome)
                            VALUES
                                ('" + _CWEmpresa.RazaoSocial + @"')";

            }

            Executar(sSql);
        }
 public List<CWEmpresa> Pesquisar(CWEmpresa _CWEmpresa)
 {
     return Pesquisar(_CWEmpresa, "");
 }