<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *                                   ATTENTION!
 * If you see this message in your browser (Internet Explorer, Mozilla Firefox, Google Chrome, etc.)
 * this means that PHP is not properly installed on your web server. Please refer to the PHP manual
 * for more details: http://php.net/manual/install.php 
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 */

    include_once dirname(__FILE__) . '/components/startup.php';
    include_once dirname(__FILE__) . '/components/application.php';
    include_once dirname(__FILE__) . '/' . 'authorization.php';


    include_once dirname(__FILE__) . '/' . 'database_engine/mysql_engine.php';
    include_once dirname(__FILE__) . '/' . 'components/page/page_includes.php';

    function GetConnectionOptions()
    {
        $result = GetGlobalConnectionOptions();
        $result['client_encoding'] = 'utf8';
        GetApplication()->GetUserAuthentication()->applyIdentityToConnectionOptions($result);
        return $result;
    }

    
    
    
    
    // OnBeforePageExecute event handler
    
    
    
    class pedido_pedido_item01Page extends DetailPage
    {
        protected function DoBeforeCreate()
        {
            $this->SetTitle('ITENS ');
            $this->SetMenuLabel('ITENS');
            $this->SetHeader(GetPagesHeader());
            $this->SetFooter(GetPagesFooter());
    
            $this->dataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`pedido_item`');
            $this->dataset->addFields(
                array(
                    new IntegerField('id_pedido_item', true, true, true),
                    new IntegerField('id_pedido'),
                    new IntegerField('id_produto'),
                    new StringField('descricao'),
                    new StringField('unidade'),
                    new IntegerField('qtd_orcamento', true),
                    new IntegerField('qtd_pedido', true),
                    new IntegerField('qtd_faturada', true),
                    new IntegerField('qtd_a_faturar', true),
                    new IntegerField('preco'),
                    new IntegerField('vlr_desconto'),
                    new StringField('cfop'),
                    new StringField('ncm'),
                    new StringField('cd_cst_icms'),
                    new StringField('cd_cst_ipi'),
                    new StringField('cd_pis'),
                    new StringField('cd_cofins'),
                    new IntegerField('base_icms'),
                    new IntegerField('aliquota_icms'),
                    new IntegerField('aliquota_ipi'),
                    new StringField('pedido_compra'),
                    new IntegerField('icms_origem'),
                    new IntegerField('icms_modalidade_base_calculo'),
                    new IntegerField('ipi_codigo_enquadramento_legal'),
                    new IntegerField('nr_item_pedido_compra')
                )
            );
            $this->dataset->AddLookupField('id_produto', 'produto', new IntegerField('id_produto'), new IntegerField('id_produto', false, false, false, false, 'id_produto_id_produto', 'id_produto_id_produto_produto'), 'id_produto_id_produto_produto');
            $this->dataset->AddLookupField('cfop', 'cfop', new StringField('cfop'), new StringField('cfop', false, false, false, false, 'cfop_cfop', 'cfop_cfop_cfop'), 'cfop_cfop_cfop');
            $this->dataset->AddLookupField('ncm', 'ncm', new StringField('numero'), new StringField('numero', false, false, false, false, 'ncm_numero', 'ncm_numero_ncm'), 'ncm_numero_ncm');
            $this->dataset->AddLookupField('cd_cst_icms', 'icms_situacao_tributaria', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'cd_cst_icms_ds_tabela', 'cd_cst_icms_ds_tabela_icms_situacao_tributaria'), 'cd_cst_icms_ds_tabela_icms_situacao_tributaria');
            $this->dataset->AddLookupField('cd_cst_ipi', 'ipi_situacao_tributaria', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'cd_cst_ipi_ds_tabela', 'cd_cst_ipi_ds_tabela_ipi_situacao_tributaria'), 'cd_cst_ipi_ds_tabela_ipi_situacao_tributaria');
            $this->dataset->AddLookupField('cd_pis', 'pis_situacao_tributaria', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'cd_pis_ds_tabela', 'cd_pis_ds_tabela_pis_situacao_tributaria'), 'cd_pis_ds_tabela_pis_situacao_tributaria');
            $this->dataset->AddLookupField('cd_cofins', 'cofins_situacao_tributaria', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'cd_cofins_ds_tabela', 'cd_cofins_ds_tabela_cofins_situacao_tributaria'), 'cd_cofins_ds_tabela_cofins_situacao_tributaria');
            $this->dataset->AddLookupField('icms_origem', 'icms_origem', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'icms_origem_ds_tabela', 'icms_origem_ds_tabela_icms_origem'), 'icms_origem_ds_tabela_icms_origem');
            $this->dataset->AddLookupField('ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'ipi_codigo_enquadramento_legal_ds_tabela', 'ipi_codigo_enquadramento_legal_ds_tabela_ipi_codigo_enquadramento_legal'), 'ipi_codigo_enquadramento_legal_ds_tabela_ipi_codigo_enquadramento_legal');
            $this->dataset->AddLookupField('icms_modalidade_base_calculo', 'icms_modalidade_base_calculo', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'icms_modalidade_base_calculo_ds_tabela', 'icms_modalidade_base_calculo_ds_tabela_icms_modalidade_base_calculo'), 'icms_modalidade_base_calculo_ds_tabela_icms_modalidade_base_calculo');
        }
    
        protected function DoPrepare() {
    
        }
    
        protected function CreatePageNavigator()
        {
            $result = new CompositePageNavigator($this);
            
            $partitionNavigator = new PageNavigator('pnav', $this, $this->dataset);
            $partitionNavigator->SetRowsPerPage(20);
            $result->AddPageNavigator($partitionNavigator);
            
            return $result;
        }
    
        protected function CreateRssGenerator()
        {
            return null;
        }
    
        protected function setupCharts()
        {
    
        }
    
        protected function getFiltersColumns()
        {
            return array(
                new FilterColumn($this->dataset, 'id_pedido_item', 'id_pedido_item', 'Id Pedido Item'),
                new FilterColumn($this->dataset, 'id_pedido', 'id_pedido', 'Id Pedido'),
                new FilterColumn($this->dataset, 'pedido_compra', 'pedido_compra', 'Pedido de Compra (PC)'),
                new FilterColumn($this->dataset, 'id_produto', 'id_produto_id_produto', 'Produto'),
                new FilterColumn($this->dataset, 'descricao', 'descricao', 'Descrição Complementar'),
                new FilterColumn($this->dataset, 'unidade', 'unidade', 'Unidade'),
                new FilterColumn($this->dataset, 'qtd_orcamento', 'qtd_orcamento', 'Qtd Orçamento'),
                new FilterColumn($this->dataset, 'qtd_pedido', 'qtd_pedido', 'Qtd Pedido'),
                new FilterColumn($this->dataset, 'qtd_faturada', 'qtd_faturada', 'Qtd Faturada'),
                new FilterColumn($this->dataset, 'preco', 'preco', 'Preço'),
                new FilterColumn($this->dataset, 'vlr_desconto', 'vlr_desconto', 'Valor de Desconto'),
                new FilterColumn($this->dataset, 'cfop', 'cfop_cfop', 'CFOP'),
                new FilterColumn($this->dataset, 'ncm', 'ncm_numero', 'NCM'),
                new FilterColumn($this->dataset, 'aliquota_icms', 'aliquota_icms', 'Aliquota ICMS'),
                new FilterColumn($this->dataset, 'aliquota_ipi', 'aliquota_ipi', 'Aliquota IPI'),
                new FilterColumn($this->dataset, 'qtd_a_faturar', 'qtd_a_faturar', 'Qtd A Faturar'),
                new FilterColumn($this->dataset, 'cd_cst_icms', 'cd_cst_icms_ds_tabela', 'CST ICMS'),
                new FilterColumn($this->dataset, 'cd_cst_ipi', 'cd_cst_ipi_ds_tabela', 'CST IPI'),
                new FilterColumn($this->dataset, 'cd_pis', 'cd_pis_ds_tabela', 'PIS'),
                new FilterColumn($this->dataset, 'cd_cofins', 'cd_cofins_ds_tabela', 'COFINS'),
                new FilterColumn($this->dataset, 'base_icms', 'base_icms', 'Base Icms'),
                new FilterColumn($this->dataset, 'icms_origem', 'icms_origem_ds_tabela', 'Icms Origem'),
                new FilterColumn($this->dataset, 'ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal'),
                new FilterColumn($this->dataset, 'icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo'),
                new FilterColumn($this->dataset, 'nr_item_pedido_compra', 'nr_item_pedido_compra', 'Nr Item PC')
            );
        }
    
        protected function setupQuickFilter(QuickFilter $quickFilter, FixedKeysArray $columns)
        {
    
        }
    
        protected function setupColumnFilter(ColumnFilter $columnFilter)
        {
            $columnFilter
                ->setOptionsFor('id_produto')
                ->setOptionsFor('cfop')
                ->setOptionsFor('ncm');
        }
    
        protected function setupFilterBuilder(FilterBuilder $filterBuilder, FixedKeysArray $columns)
        {
    
        }
    
        protected function AddOperationsColumns(Grid $grid)
        {
            $actions = $grid->getActions();
            $actions->setCaption($this->GetLocalizerCaptions()->GetMessageString('Actions'));
            $actions->setPosition(ActionList::POSITION_LEFT);
            
            if ($this->GetSecurityInfo()->HasViewGrant())
            {
                $operation = new AjaxOperation(OPERATION_VIEW,
                    $this->GetLocalizerCaptions()->GetMessageString('View'),
                    $this->GetLocalizerCaptions()->GetMessageString('View'), $this->dataset,
                    $this->GetModalGridViewHandler(), $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
            }
            
            if ($this->GetSecurityInfo()->HasEditGrant())
            {
                $operation = new AjaxOperation(OPERATION_EDIT,
                    $this->GetLocalizerCaptions()->GetMessageString('Edit'),
                    $this->GetLocalizerCaptions()->GetMessageString('Edit'), $this->dataset,
                    $this->GetGridEditHandler(), $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
                $operation->OnShow->AddListener('ShowEditButtonHandler', $this);
            }
            
            if ($this->GetSecurityInfo()->HasDeleteGrant())
            {
                $operation = new LinkOperation($this->GetLocalizerCaptions()->GetMessageString('Delete'), OPERATION_DELETE, $this->dataset, $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
                $operation->OnShow->AddListener('ShowDeleteButtonHandler', $this);
                $operation->SetAdditionalAttribute('data-modal-operation', 'delete');
                $operation->SetAdditionalAttribute('data-delete-handler-name', $this->GetModalGridDeleteHandler());
            }
        }
    
        protected function AddFieldColumns(Grid $grid, $withDetails = true)
        {
            //
            // View column for pedido_compra field
            //
            $column = new TextViewColumn('pedido_compra', 'pedido_compra', 'Pedido de Compra (PC)', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for nr_item_pedido_compra field
            //
            $column = new NumberViewColumn('nr_item_pedido_compra', 'nr_item_pedido_compra', 'Nr Item PC', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto_id_produto', 'Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator(',');
            $column->setDecimalSeparator('.');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('DetailGridpedido.pedido_item01_descricao_handler_list');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for unidade field
            //
            $column = new TextViewColumn('unidade', 'unidade', 'Unidade', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for qtd_orcamento field
            //
            $column = new NumberViewColumn('qtd_orcamento', 'qtd_orcamento', 'Qtd Orçamento', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for qtd_pedido field
            //
            $column = new NumberViewColumn('qtd_pedido', 'qtd_pedido', 'Qtd Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for qtd_faturada field
            //
            $column = new NumberViewColumn('qtd_faturada', 'qtd_faturada', 'Qtd Faturada', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for preco field
            //
            $column = new NumberViewColumn('preco', 'preco', 'Preço', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for vlr_desconto field
            //
            $column = new NumberViewColumn('vlr_desconto', 'vlr_desconto', 'Valor de Desconto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for cfop field
            //
            $column = new TextViewColumn('cfop', 'cfop_cfop', 'CFOP', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for numero field
            //
            $column = new TextViewColumn('ncm', 'ncm_numero', 'NCM', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for aliquota_icms field
            //
            $column = new NumberViewColumn('aliquota_icms', 'aliquota_icms', 'Aliquota ICMS', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for aliquota_ipi field
            //
            $column = new NumberViewColumn('aliquota_ipi', 'aliquota_ipi', 'Aliquota IPI', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for qtd_a_faturar field
            //
            $column = new NumberViewColumn('qtd_a_faturar', 'qtd_a_faturar', 'Qtd A Faturar', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
        }
    
        protected function AddSingleRecordViewColumns(Grid $grid)
        {
            //
            // View column for pedido_compra field
            //
            $column = new TextViewColumn('pedido_compra', 'pedido_compra', 'Pedido de Compra (PC)', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for nr_item_pedido_compra field
            //
            $column = new NumberViewColumn('nr_item_pedido_compra', 'nr_item_pedido_compra', 'Nr Item PC', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto_id_produto', 'Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator(',');
            $column->setDecimalSeparator('.');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('DetailGridpedido.pedido_item01_descricao_handler_view');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for unidade field
            //
            $column = new TextViewColumn('unidade', 'unidade', 'Unidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for qtd_orcamento field
            //
            $column = new NumberViewColumn('qtd_orcamento', 'qtd_orcamento', 'Qtd Orçamento', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for qtd_pedido field
            //
            $column = new NumberViewColumn('qtd_pedido', 'qtd_pedido', 'Qtd Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for qtd_faturada field
            //
            $column = new NumberViewColumn('qtd_faturada', 'qtd_faturada', 'Qtd Faturada', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for preco field
            //
            $column = new NumberViewColumn('preco', 'preco', 'Preço', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for vlr_desconto field
            //
            $column = new NumberViewColumn('vlr_desconto', 'vlr_desconto', 'Valor de Desconto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for cfop field
            //
            $column = new TextViewColumn('cfop', 'cfop_cfop', 'CFOP', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for numero field
            //
            $column = new TextViewColumn('ncm', 'ncm_numero', 'NCM', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for aliquota_icms field
            //
            $column = new NumberViewColumn('aliquota_icms', 'aliquota_icms', 'Aliquota ICMS', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for aliquota_ipi field
            //
            $column = new NumberViewColumn('aliquota_ipi', 'aliquota_ipi', 'Aliquota IPI', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for qtd_a_faturar field
            //
            $column = new NumberViewColumn('qtd_a_faturar', 'qtd_a_faturar', 'Qtd A Faturar', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_icms', 'cd_cst_icms_ds_tabela', 'CST ICMS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_ipi', 'cd_cst_ipi_ds_tabela', 'CST IPI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_pis', 'cd_pis_ds_tabela', 'PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'COFINS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_origem', 'icms_origem_ds_tabela', 'Icms Origem', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
        }
    
        protected function AddEditColumns(Grid $grid)
        {
            //
            // Edit column for pedido_compra field
            //
            $editor = new TextEdit('pedido_compra_edit');
            $editor->SetMaxLength(20);
            $editColumn = new CustomEditColumn('Pedido de Compra (PC)', 'pedido_compra', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for nr_item_pedido_compra field
            //
            $editor = new TextEdit('nr_item_pedido_compra_edit');
            $editColumn = new CustomEditColumn('Nr Item PC', 'nr_item_pedido_compra', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for id_produto field
            //
            $editor = new ComboBox('id_produto_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`produto`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_produto', true, true, true),
                    new StringField('unidade'),
                    new StringField('descricao'),
                    new IntegerField('preco_venda'),
                    new StringField('cfop'),
                    new StringField('ncm'),
                    new IntegerField('peso_liquido_kg'),
                    new IntegerField('peso_bruto_kg'),
                    new StringField('cd_cst_icms'),
                    new StringField('cd_cst_ipi'),
                    new StringField('cd_pis'),
                    new StringField('cd_cofins'),
                    new IntegerField('aliquota_icms'),
                    new IntegerField('aliquota_ipi'),
                    new IntegerField('icms_origem'),
                    new IntegerField('icms_modalidade_base_calculo'),
                    new IntegerField('ipi_codigo_enquadramento_legal')
                )
            );
            $lookupDataset->setOrderByField('id_produto', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Produto', 
                'id_produto', 
                $editor, 
                $this->dataset, 'id_produto', 'id_produto', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for descricao field
            //
            $editor = new TextAreaEdit('descricao_edit', 60, 2);
            $editor->setPlaceholder('máximo de 120 caracteres');
            $editColumn = new CustomEditColumn('Descrição Complementar', 'descricao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for unidade field
            //
            $editor = new TextEdit('unidade_edit');
            $editor->SetMaxLength(3);
            $editColumn = new CustomEditColumn('Unidade', 'unidade', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for qtd_orcamento field
            //
            $editor = new TextEdit('qtd_orcamento_edit');
            $editColumn = new CustomEditColumn('Qtd Orçamento', 'qtd_orcamento', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for qtd_pedido field
            //
            $editor = new TextEdit('qtd_pedido_edit');
            $editColumn = new CustomEditColumn('Qtd Pedido', 'qtd_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for qtd_faturada field
            //
            $editor = new TextEdit('qtd_faturada_edit');
            $editColumn = new CustomEditColumn('Qtd Faturada', 'qtd_faturada', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for preco field
            //
            $editor = new TextEdit('preco_edit');
            $editColumn = new CustomEditColumn('Preço', 'preco', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for vlr_desconto field
            //
            $editor = new TextEdit('vlr_desconto_edit');
            $editColumn = new CustomEditColumn('Valor de Desconto', 'vlr_desconto', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for cfop field
            //
            $editor = new ComboBox('cfop_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cfop`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_codigo_cfop', true, true, true),
                    new StringField('cfop', true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('cfop', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CFOP', 
                'cfop', 
                $editor, 
                $this->dataset, 'cfop', 'cfop', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for ncm field
            //
            $editor = new ComboBox('ncm_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ncm`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_codigo_ncm', true, true, true),
                    new StringField('numero', true),
                    new IntegerField('aliquota_ipi', true)
                )
            );
            $lookupDataset->setOrderByField('numero', 'ASC');
            $editColumn = new LookUpEditColumn(
                'NCM', 
                'ncm', 
                $editor, 
                $this->dataset, 'numero', 'numero', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for aliquota_icms field
            //
            $editor = new TextEdit('aliquota_icms_edit');
            $editColumn = new CustomEditColumn('Aliquota ICMS', 'aliquota_icms', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for aliquota_ipi field
            //
            $editor = new TextEdit('aliquota_ipi_edit');
            $editColumn = new CustomEditColumn('Aliquota IPI', 'aliquota_ipi', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for cd_cst_icms field
            //
            $editor = new ComboBox('cd_cst_icms_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CST ICMS', 
                'cd_cst_icms', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for cd_cst_ipi field
            //
            $editor = new ComboBox('cd_cst_ipi_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ipi_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CST IPI', 
                'cd_cst_ipi', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for cd_pis field
            //
            $editor = new ComboBox('cd_pis_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`pis_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'PIS', 
                'cd_pis', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for cd_cofins field
            //
            $editor = new ComboBox('cd_cofins_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cofins_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'COFINS', 
                'cd_cofins', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for icms_origem field
            //
            $editor = new ComboBox('icms_origem_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_origem`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Icms Origem', 
                'icms_origem', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for icms_modalidade_base_calculo field
            //
            $editor = new ComboBox('icms_modalidade_base_calculo_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_modalidade_base_calculo`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Icms Modalidade Base Calculo', 
                'icms_modalidade_base_calculo', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for ipi_codigo_enquadramento_legal field
            //
            $editor = new ComboBox('ipi_codigo_enquadramento_legal_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ipi_codigo_enquadramento_legal`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Ipi Codigo Enquadramento Legal', 
                'ipi_codigo_enquadramento_legal', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for qtd_a_faturar field
            //
            $editor = new TextEdit('qtd_a_faturar_edit');
            $editColumn = new CustomEditColumn('Qtd A Faturar', 'qtd_a_faturar', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
        }
    
        protected function AddMultiEditColumns(Grid $grid)
        {
            //
            // Edit column for id_pedido field
            //
            $editor = new TextEdit('id_pedido_edit');
            $editColumn = new CustomEditColumn('Id Pedido', 'id_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for id_produto field
            //
            $editor = new ComboBox('id_produto_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`produto`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_produto', true, true, true),
                    new StringField('unidade'),
                    new StringField('descricao'),
                    new IntegerField('preco_venda'),
                    new StringField('cfop'),
                    new StringField('ncm'),
                    new IntegerField('peso_liquido_kg'),
                    new IntegerField('peso_bruto_kg'),
                    new StringField('cd_cst_icms'),
                    new StringField('cd_cst_ipi'),
                    new StringField('cd_pis'),
                    new StringField('cd_cofins'),
                    new IntegerField('aliquota_icms'),
                    new IntegerField('aliquota_ipi'),
                    new IntegerField('icms_origem'),
                    new IntegerField('icms_modalidade_base_calculo'),
                    new IntegerField('ipi_codigo_enquadramento_legal')
                )
            );
            $lookupDataset->setOrderByField('id_produto', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Produto', 
                'id_produto', 
                $editor, 
                $this->dataset, 'id_produto', 'id_produto', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for descricao field
            //
            $editor = new TextAreaEdit('descricao_edit', 60, 2);
            $editor->setPlaceholder('máximo de 120 caracteres');
            $editColumn = new CustomEditColumn('Descrição Complementar', 'descricao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for unidade field
            //
            $editor = new TextEdit('unidade_edit');
            $editor->SetMaxLength(3);
            $editColumn = new CustomEditColumn('Unidade', 'unidade', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for qtd_orcamento field
            //
            $editor = new TextEdit('qtd_orcamento_edit');
            $editColumn = new CustomEditColumn('Qtd Orçamento', 'qtd_orcamento', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for qtd_pedido field
            //
            $editor = new TextEdit('qtd_pedido_edit');
            $editColumn = new CustomEditColumn('Qtd Pedido', 'qtd_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for qtd_faturada field
            //
            $editor = new TextEdit('qtd_faturada_edit');
            $editColumn = new CustomEditColumn('Qtd Faturada', 'qtd_faturada', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for preco field
            //
            $editor = new TextEdit('preco_edit');
            $editColumn = new CustomEditColumn('Preço', 'preco', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for cfop field
            //
            $editor = new ComboBox('cfop_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cfop`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_codigo_cfop', true, true, true),
                    new StringField('cfop', true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('cfop', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CFOP', 
                'cfop', 
                $editor, 
                $this->dataset, 'cfop', 'cfop', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for ncm field
            //
            $editor = new ComboBox('ncm_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ncm`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_codigo_ncm', true, true, true),
                    new StringField('numero', true),
                    new IntegerField('aliquota_ipi', true)
                )
            );
            $lookupDataset->setOrderByField('numero', 'ASC');
            $editColumn = new LookUpEditColumn(
                'NCM', 
                'ncm', 
                $editor, 
                $this->dataset, 'numero', 'numero', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for cd_cst_icms field
            //
            $editor = new ComboBox('cd_cst_icms_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CST ICMS', 
                'cd_cst_icms', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for cd_cst_ipi field
            //
            $editor = new ComboBox('cd_cst_ipi_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ipi_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CST IPI', 
                'cd_cst_ipi', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for cd_pis field
            //
            $editor = new ComboBox('cd_pis_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`pis_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'PIS', 
                'cd_pis', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for cd_cofins field
            //
            $editor = new ComboBox('cd_cofins_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cofins_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'COFINS', 
                'cd_cofins', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for base_icms field
            //
            $editor = new TextEdit('base_icms_edit');
            $editColumn = new CustomEditColumn('Base Icms', 'base_icms', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for aliquota_icms field
            //
            $editor = new TextEdit('aliquota_icms_edit');
            $editColumn = new CustomEditColumn('Aliquota ICMS', 'aliquota_icms', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for aliquota_ipi field
            //
            $editor = new TextEdit('aliquota_ipi_edit');
            $editColumn = new CustomEditColumn('Aliquota IPI', 'aliquota_ipi', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for qtd_a_faturar field
            //
            $editor = new TextEdit('qtd_a_faturar_edit');
            $editColumn = new CustomEditColumn('Qtd A Faturar', 'qtd_a_faturar', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for vlr_desconto field
            //
            $editor = new TextEdit('vlr_desconto_edit');
            $editColumn = new CustomEditColumn('Valor de Desconto', 'vlr_desconto', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for pedido_compra field
            //
            $editor = new TextEdit('pedido_compra_edit');
            $editor->SetMaxLength(20);
            $editColumn = new CustomEditColumn('Pedido de Compra (PC)', 'pedido_compra', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for icms_origem field
            //
            $editor = new ComboBox('icms_origem_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_origem`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Icms Origem', 
                'icms_origem', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for ipi_codigo_enquadramento_legal field
            //
            $editor = new ComboBox('ipi_codigo_enquadramento_legal_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ipi_codigo_enquadramento_legal`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Ipi Codigo Enquadramento Legal', 
                'ipi_codigo_enquadramento_legal', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for icms_modalidade_base_calculo field
            //
            $editor = new ComboBox('icms_modalidade_base_calculo_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_modalidade_base_calculo`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Icms Modalidade Base Calculo', 
                'icms_modalidade_base_calculo', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for nr_item_pedido_compra field
            //
            $editor = new TextEdit('nr_item_pedido_compra_edit');
            $editColumn = new CustomEditColumn('Nr Item PC', 'nr_item_pedido_compra', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
        }
    
        protected function AddInsertColumns(Grid $grid)
        {
            //
            // Edit column for pedido_compra field
            //
            $editor = new TextEdit('pedido_compra_edit');
            $editor->SetMaxLength(20);
            $editColumn = new CustomEditColumn('Pedido de Compra (PC)', 'pedido_compra', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for nr_item_pedido_compra field
            //
            $editor = new TextEdit('nr_item_pedido_compra_edit');
            $editColumn = new CustomEditColumn('Nr Item PC', 'nr_item_pedido_compra', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for id_produto field
            //
            $editor = new ComboBox('id_produto_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`produto`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_produto', true, true, true),
                    new StringField('unidade'),
                    new StringField('descricao'),
                    new IntegerField('preco_venda'),
                    new StringField('cfop'),
                    new StringField('ncm'),
                    new IntegerField('peso_liquido_kg'),
                    new IntegerField('peso_bruto_kg'),
                    new StringField('cd_cst_icms'),
                    new StringField('cd_cst_ipi'),
                    new StringField('cd_pis'),
                    new StringField('cd_cofins'),
                    new IntegerField('aliquota_icms'),
                    new IntegerField('aliquota_ipi'),
                    new IntegerField('icms_origem'),
                    new IntegerField('icms_modalidade_base_calculo'),
                    new IntegerField('ipi_codigo_enquadramento_legal')
                )
            );
            $lookupDataset->setOrderByField('id_produto', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Produto', 
                'id_produto', 
                $editor, 
                $this->dataset, 'id_produto', 'id_produto', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for descricao field
            //
            $editor = new TextAreaEdit('descricao_edit', 60, 2);
            $editor->setPlaceholder('máximo de 120 caracteres');
            $editColumn = new CustomEditColumn('Descrição Complementar', 'descricao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for unidade field
            //
            $editor = new TextEdit('unidade_edit');
            $editor->SetMaxLength(3);
            $editColumn = new CustomEditColumn('Unidade', 'unidade', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for qtd_orcamento field
            //
            $editor = new TextEdit('qtd_orcamento_edit');
            $editColumn = new CustomEditColumn('Qtd Orçamento', 'qtd_orcamento', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for qtd_pedido field
            //
            $editor = new TextEdit('qtd_pedido_edit');
            $editColumn = new CustomEditColumn('Qtd Pedido', 'qtd_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for qtd_faturada field
            //
            $editor = new TextEdit('qtd_faturada_edit');
            $editColumn = new CustomEditColumn('Qtd Faturada', 'qtd_faturada', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for preco field
            //
            $editor = new TextEdit('preco_edit');
            $editColumn = new CustomEditColumn('Preço', 'preco', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for vlr_desconto field
            //
            $editor = new TextEdit('vlr_desconto_edit');
            $editColumn = new CustomEditColumn('Valor de Desconto', 'vlr_desconto', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for cfop field
            //
            $editor = new ComboBox('cfop_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cfop`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_codigo_cfop', true, true, true),
                    new StringField('cfop', true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('cfop', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CFOP', 
                'cfop', 
                $editor, 
                $this->dataset, 'cfop', 'cfop', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for ncm field
            //
            $editor = new ComboBox('ncm_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ncm`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_codigo_ncm', true, true, true),
                    new StringField('numero', true),
                    new IntegerField('aliquota_ipi', true)
                )
            );
            $lookupDataset->setOrderByField('numero', 'ASC');
            $editColumn = new LookUpEditColumn(
                'NCM', 
                'ncm', 
                $editor, 
                $this->dataset, 'numero', 'numero', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for aliquota_icms field
            //
            $editor = new TextEdit('aliquota_icms_edit');
            $editColumn = new CustomEditColumn('Aliquota ICMS', 'aliquota_icms', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for aliquota_ipi field
            //
            $editor = new TextEdit('aliquota_ipi_edit');
            $editColumn = new CustomEditColumn('Aliquota IPI', 'aliquota_ipi', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for cd_cst_icms field
            //
            $editor = new ComboBox('cd_cst_icms_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CST ICMS', 
                'cd_cst_icms', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for cd_cst_ipi field
            //
            $editor = new ComboBox('cd_cst_ipi_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ipi_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'CST IPI', 
                'cd_cst_ipi', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for cd_pis field
            //
            $editor = new ComboBox('cd_pis_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`pis_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'PIS', 
                'cd_pis', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for cd_cofins field
            //
            $editor = new ComboBox('cd_cofins_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cofins_situacao_tributaria`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'COFINS', 
                'cd_cofins', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for icms_origem field
            //
            $editor = new ComboBox('icms_origem_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_origem`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Icms Origem', 
                'icms_origem', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for icms_modalidade_base_calculo field
            //
            $editor = new ComboBox('icms_modalidade_base_calculo_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`icms_modalidade_base_calculo`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Icms Modalidade Base Calculo', 
                'icms_modalidade_base_calculo', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for ipi_codigo_enquadramento_legal field
            //
            $editor = new ComboBox('ipi_codigo_enquadramento_legal_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`ipi_codigo_enquadramento_legal`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Ipi Codigo Enquadramento Legal', 
                'ipi_codigo_enquadramento_legal', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for qtd_a_faturar field
            //
            $editor = new TextEdit('qtd_a_faturar_edit');
            $editColumn = new CustomEditColumn('Qtd A Faturar', 'qtd_a_faturar', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            $grid->SetShowAddButton(true && $this->GetSecurityInfo()->HasAddGrant());
        }
    
        private function AddMultiUploadColumn(Grid $grid)
        {
    
        }
    
        protected function AddPrintColumns(Grid $grid)
        {
            //
            // View column for pedido_compra field
            //
            $column = new TextViewColumn('pedido_compra', 'pedido_compra', 'Pedido de Compra (PC)', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto_id_produto', 'Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator(',');
            $column->setDecimalSeparator('.');
            $grid->AddPrintColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('DetailGridpedido.pedido_item01_descricao_handler_print');
            $grid->AddPrintColumn($column);
            
            //
            // View column for unidade field
            //
            $column = new TextViewColumn('unidade', 'unidade', 'Unidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for qtd_orcamento field
            //
            $column = new NumberViewColumn('qtd_orcamento', 'qtd_orcamento', 'Qtd Orçamento', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for qtd_pedido field
            //
            $column = new NumberViewColumn('qtd_pedido', 'qtd_pedido', 'Qtd Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for qtd_faturada field
            //
            $column = new NumberViewColumn('qtd_faturada', 'qtd_faturada', 'Qtd Faturada', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for preco field
            //
            $column = new NumberViewColumn('preco', 'preco', 'Preço', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for vlr_desconto field
            //
            $column = new NumberViewColumn('vlr_desconto', 'vlr_desconto', 'Valor de Desconto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for cfop field
            //
            $column = new TextViewColumn('cfop', 'cfop_cfop', 'CFOP', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for numero field
            //
            $column = new TextViewColumn('ncm', 'ncm_numero', 'NCM', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for aliquota_icms field
            //
            $column = new NumberViewColumn('aliquota_icms', 'aliquota_icms', 'Aliquota ICMS', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for aliquota_ipi field
            //
            $column = new NumberViewColumn('aliquota_ipi', 'aliquota_ipi', 'Aliquota IPI', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for qtd_a_faturar field
            //
            $column = new NumberViewColumn('qtd_a_faturar', 'qtd_a_faturar', 'Qtd A Faturar', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_icms', 'cd_cst_icms_ds_tabela', 'CST ICMS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_ipi', 'cd_cst_ipi_ds_tabela', 'CST IPI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_pis', 'cd_pis_ds_tabela', 'PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'COFINS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_origem', 'icms_origem_ds_tabela', 'Icms Origem', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for nr_item_pedido_compra field
            //
            $column = new NumberViewColumn('nr_item_pedido_compra', 'nr_item_pedido_compra', 'Nr Item PC', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddPrintColumn($column);
        }
    
        protected function AddExportColumns(Grid $grid)
        {
            //
            // View column for pedido_compra field
            //
            $column = new TextViewColumn('pedido_compra', 'pedido_compra', 'Pedido de Compra (PC)', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto_id_produto', 'Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator(',');
            $column->setDecimalSeparator('.');
            $grid->AddExportColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('DetailGridpedido.pedido_item01_descricao_handler_export');
            $grid->AddExportColumn($column);
            
            //
            // View column for unidade field
            //
            $column = new TextViewColumn('unidade', 'unidade', 'Unidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for qtd_orcamento field
            //
            $column = new NumberViewColumn('qtd_orcamento', 'qtd_orcamento', 'Qtd Orçamento', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for qtd_pedido field
            //
            $column = new NumberViewColumn('qtd_pedido', 'qtd_pedido', 'Qtd Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for qtd_faturada field
            //
            $column = new NumberViewColumn('qtd_faturada', 'qtd_faturada', 'Qtd Faturada', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for preco field
            //
            $column = new NumberViewColumn('preco', 'preco', 'Preço', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for vlr_desconto field
            //
            $column = new NumberViewColumn('vlr_desconto', 'vlr_desconto', 'Valor de Desconto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for cfop field
            //
            $column = new TextViewColumn('cfop', 'cfop_cfop', 'CFOP', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for numero field
            //
            $column = new TextViewColumn('ncm', 'ncm_numero', 'NCM', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for aliquota_icms field
            //
            $column = new NumberViewColumn('aliquota_icms', 'aliquota_icms', 'Aliquota ICMS', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for aliquota_ipi field
            //
            $column = new NumberViewColumn('aliquota_ipi', 'aliquota_ipi', 'Aliquota IPI', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for qtd_a_faturar field
            //
            $column = new NumberViewColumn('qtd_a_faturar', 'qtd_a_faturar', 'Qtd A Faturar', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_icms', 'cd_cst_icms_ds_tabela', 'CST ICMS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_ipi', 'cd_cst_ipi_ds_tabela', 'CST IPI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_pis', 'cd_pis_ds_tabela', 'PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'COFINS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_origem', 'icms_origem_ds_tabela', 'Icms Origem', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for nr_item_pedido_compra field
            //
            $column = new NumberViewColumn('nr_item_pedido_compra', 'nr_item_pedido_compra', 'Nr Item PC', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddExportColumn($column);
        }
    
        private function AddCompareColumns(Grid $grid)
        {
            //
            // View column for pedido_compra field
            //
            $column = new TextViewColumn('pedido_compra', 'pedido_compra', 'Pedido de Compra (PC)', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto_id_produto', 'Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator(',');
            $column->setDecimalSeparator('.');
            $grid->AddCompareColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('DetailGridpedido.pedido_item01_descricao_handler_compare');
            $grid->AddCompareColumn($column);
            
            //
            // View column for unidade field
            //
            $column = new TextViewColumn('unidade', 'unidade', 'Unidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for qtd_orcamento field
            //
            $column = new NumberViewColumn('qtd_orcamento', 'qtd_orcamento', 'Qtd Orçamento', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for qtd_pedido field
            //
            $column = new NumberViewColumn('qtd_pedido', 'qtd_pedido', 'Qtd Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for qtd_faturada field
            //
            $column = new NumberViewColumn('qtd_faturada', 'qtd_faturada', 'Qtd Faturada', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for preco field
            //
            $column = new NumberViewColumn('preco', 'preco', 'Preço', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for vlr_desconto field
            //
            $column = new NumberViewColumn('vlr_desconto', 'vlr_desconto', 'Valor de Desconto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for cfop field
            //
            $column = new TextViewColumn('cfop', 'cfop_cfop', 'CFOP', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for numero field
            //
            $column = new TextViewColumn('ncm', 'ncm_numero', 'NCM', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for aliquota_icms field
            //
            $column = new NumberViewColumn('aliquota_icms', 'aliquota_icms', 'Aliquota ICMS', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for aliquota_ipi field
            //
            $column = new NumberViewColumn('aliquota_ipi', 'aliquota_ipi', 'Aliquota IPI', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for qtd_a_faturar field
            //
            $column = new NumberViewColumn('qtd_a_faturar', 'qtd_a_faturar', 'Qtd A Faturar', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_icms', 'cd_cst_icms_ds_tabela', 'CST ICMS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_ipi', 'cd_cst_ipi_ds_tabela', 'CST IPI', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_pis', 'cd_pis_ds_tabela', 'PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'COFINS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_origem', 'icms_origem_ds_tabela', 'Icms Origem', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for nr_item_pedido_compra field
            //
            $column = new NumberViewColumn('nr_item_pedido_compra', 'nr_item_pedido_compra', 'Nr Item PC', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddCompareColumn($column);
        }
    
        private function AddCompareHeaderColumns(Grid $grid)
        {
    
        }
    
        public function GetPageDirection()
        {
            return null;
        }
    
        public function isFilterConditionRequired()
        {
            return false;
        }
    
        protected function ApplyCommonColumnEditProperties(CustomEditColumn $column)
        {
            $column->SetDisplaySetToNullCheckBox(false);
            $column->SetDisplaySetToDefaultCheckBox(false);
    		$column->SetVariableContainer($this->GetColumnVariableContainer());
        }
    
        function GetCustomClientScript()
        {
            return ;
        }
        
        function GetOnPageLoadedClientScript()
        {
            return ;
        }
        
        public function GetEnableModalGridInsert() { return true; }
        public function GetEnableModalSingleRecordView() { return true; }
        
        public function GetEnableModalGridEdit() { return true; }
        
        protected function GetEnableModalGridDelete() { return true; }
    
        protected function CreateGrid()
        {
            $result = new Grid($this, $this->dataset);
            if ($this->GetSecurityInfo()->HasDeleteGrant())
               $result->SetAllowDeleteSelected(false);
            else
               $result->SetAllowDeleteSelected(false);   
            
            ApplyCommonPageSettings($this, $result);
            
            $result->SetUseImagesForActions(true);
            $result->SetUseFixedHeader(false);
            $result->SetShowLineNumbers(false);
            $result->SetViewMode(ViewMode::TABLE);
            $result->setEnableRuntimeCustomization(true);
            $result->setAllowCompare(true);
            $this->AddCompareHeaderColumns($result);
            $this->AddCompareColumns($result);
            $result->setMultiEditAllowed($this->GetSecurityInfo()->HasEditGrant() && false);
            $result->setTableBordered(false);
            $result->setTableCondensed(false);
            
            $result->SetHighlightRowAtHover(false);
            $result->SetWidth('');
            $this->AddOperationsColumns($result);
            $this->AddFieldColumns($result);
            $this->AddSingleRecordViewColumns($result);
            $this->AddEditColumns($result);
            $this->AddMultiEditColumns($result);
            $this->AddInsertColumns($result);
            $this->AddPrintColumns($result);
            $this->AddExportColumns($result);
            $this->AddMultiUploadColumn($result);
    
    
            $this->SetShowPageList(true);
            $this->SetShowTopPageNavigator(true);
            $this->SetShowBottomPageNavigator(true);
            $this->setPrintListAvailable(false);
            $this->setPrintListRecordAvailable(false);
            $this->setPrintOneRecordAvailable(false);
            $this->setAllowPrintSelectedRecords(true);
            $this->setExportListAvailable(array('pdf', 'excel', 'word'));
            $this->setExportSelectedRecordsAvailable(array('pdf', 'excel', 'word', 'xml', 'csv'));
            $this->setExportListRecordAvailable(array());
            $this->setExportOneRecordAvailable(array('pdf', 'excel', 'word'));
    
            return $result;
        }
     
        protected function setClientSideEvents(Grid $grid) {
    
        }
    
        protected function doRegisterHandlers() {
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'DetailGridpedido.pedido_item01_descricao_handler_list', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'DetailGridpedido.pedido_item01_descricao_handler_print', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'DetailGridpedido.pedido_item01_descricao_handler_compare', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição Complementar', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'DetailGridpedido.pedido_item01_descricao_handler_view', $column);
            GetApplication()->RegisterHTTPHandler($handler);
        }
       
        protected function doCustomRenderColumn($fieldName, $fieldData, $rowData, &$customText, &$handled)
        { 
    
        }
    
        protected function doCustomRenderPrintColumn($fieldName, $fieldData, $rowData, &$customText, &$handled)
        { 
    
        }
    
        protected function doCustomRenderExportColumn($exportType, $fieldName, $fieldData, $rowData, &$customText, &$handled)
        { 
    
        }
    
        protected function doCustomDrawRow($rowData, &$cellFontColor, &$cellFontSize, &$cellBgColor, &$cellItalicAttr, &$cellBoldAttr)
        {
    
        }
    
        protected function doExtendedCustomDrawRow($rowData, &$rowCellStyles, &$rowStyles, &$rowClasses, &$cellClasses)
        {
    
        }
    
        protected function doCustomRenderTotal($totalValue, $aggregate, $columnName, &$customText, &$handled)
        {
    
        }
    
        protected function doCustomDefaultValues(&$values, &$handled) 
        {
    
        }
    
        protected function doCustomCompareColumn($columnName, $valueA, $valueB, &$result)
        {
    
        }
    
        protected function doBeforeInsertRecord($page, &$rowData, $tableName, &$cancel, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doBeforeUpdateRecord($page, $oldRowData, &$rowData, $tableName, &$cancel, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doBeforeDeleteRecord($page, &$rowData, $tableName, &$cancel, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doAfterInsertRecord($page, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
            $cp_sql = 'select ifnull(if(pedido.situacao="ORCAMENTO",sum(qtd_orcamento*(preco-vlr_desconto)),sum(qtd_pedido*(preco-vlr_desconto))),0) as vlr from pedido_item
             inner join pedido on pedido.id_pedido=pedido_item.id_pedido
             where pedido_item.id_pedido='.$rowData['id_pedido'];
            $cp_produtos = $this->GetConnection()->ExecScalarSQL($cp_sql);
            $cp_sql = 'select ifnull(sum(vlr_desconto),0) as vlr from pedido_item where id_pedido='.$rowData['id_pedido'];
            $cp_desconto = $this->GetConnection()->ExecScalarSQL($cp_sql);
            
            $cp_sql = 'UPDATE pedido SET pedido.total_produtos=' .$cp_produtos. ', pedido.valor_desc=' .$cp_desconto. ', pedido.total_pedido=' .$cp_produtos. '+pedido.valor_frete+pedido.valor_acrescimo- ' .$cp_desconto. ' WHERE id_pedido='.$rowData['id_pedido'];
            $this->GetConnection()->ExecSQL($cp_sql);
        }
    
        protected function doAfterUpdateRecord($page, $oldRowData, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
            $cp_sql = 'select ifnull(if(pedido.situacao="ORCAMENTO",sum(qtd_orcamento*(preco-vlr_desconto)),sum(qtd_pedido*(preco-vlr_desconto))),0) as vlr from pedido_item inner join pedido on pedido.id_pedido=pedido_item.id_pedido where pedido_item.id_pedido='.$rowData['id_pedido'];
            $cp_produtos = $this->GetConnection()->ExecScalarSQL($cp_sql);
            $cp_sql = 'select ifnull(sum(vlr_desconto),0) as vlr from pedido_item where id_pedido='.$rowData['id_pedido'];
            $cp_desconto = $this->GetConnection()->ExecScalarSQL($cp_sql);
            
            $cp_sql = 'UPDATE pedido SET pedido.total_produtos=' .$cp_produtos. ', pedido.valor_desc=' .$cp_desconto. ', pedido.total_pedido=' .$cp_produtos. '+pedido.valor_frete+pedido.valor_acrescimo- ' .$cp_desconto. ' WHERE id_pedido='.$rowData['id_pedido'];
            $this->GetConnection()->ExecSQL($cp_sql);
        }
    
        protected function doAfterDeleteRecord($page, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doCustomHTMLHeader($page, &$customHtmlHeaderText)
        { 
    
        }
    
        protected function doGetCustomTemplate($type, $part, $mode, &$result, &$params)
        {
    
        }
    
        protected function doGetCustomExportOptions(Page $page, $exportType, $rowData, &$options)
        {
    
        }
    
        protected function doFileUpload($fieldName, $rowData, &$result, &$accept, $originalFileName, $originalFileExtension, $fileSize, $tempFileName)
        {
    
        }
    
        protected function doPrepareChart(Chart $chart)
        {
    
        }
    
        protected function doPrepareColumnFilter(ColumnFilter $columnFilter)
        {
    
        }
    
        protected function doPrepareFilterBuilder(FilterBuilder $filterBuilder, FixedKeysArray $columns)
        {
    
        }
    
        protected function doGetSelectionFilters(FixedKeysArray $columns, &$result)
        {
    
        }
    
        protected function doGetCustomFormLayout($mode, FixedKeysArray $columns, FormLayout $layout)
        {
    
        }
    
        protected function doGetCustomColumnGroup(FixedKeysArray $columns, ViewColumnGroup $columnGroup)
        {
    
        }
    
        protected function doPageLoaded()
        {
    
        }
    
        protected function doCalculateFields($rowData, $fieldName, &$value)
        {
    
        }
    
        protected function doGetCustomPagePermissions(Page $page, PermissionSet &$permissions, &$handled)
        {
    
        }
    
        protected function doGetCustomRecordPermissions(Page $page, &$usingCondition, $rowData, &$allowEdit, &$allowDelete, &$mergeWithDefault, &$handled)
        {
    
        }
    
    }
    
    // OnBeforePageExecute event handler
    
    
    
    class pedidoPage extends Page
    {
        protected function DoBeforeCreate()
        {
            $this->SetTitle('Orçamento / Pedido Interno');
            $this->SetMenuLabel('Orçamento / Pedido Interno');
            $this->SetHeader(GetPagesHeader());
            $this->SetFooter(GetPagesFooter());
    
            $this->dataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`pedido`');
            $this->dataset->addFields(
                array(
                    new IntegerField('id_pedido', true, true, true),
                    new StringField('pedido_o'),
                    new DateTimeField('emissao'),
                    new IntegerField('finalidade_emissao'),
                    new StringField('entrega'),
                    new IntegerField('id_cadastro'),
                    new IntegerField('id_vendedor'),
                    new IntegerField('id_condicao_pg'),
                    new IntegerField('id_transportadora'),
                    new IntegerField('tp_frete'),
                    new StringField('responsavel'),
                    new IntegerField('total_produtos', true),
                    new IntegerField('valor_desc', true),
                    new IntegerField('valor_frete', true),
                    new IntegerField('valor_acrescimo', true),
                    new IntegerField('total_pedido'),
                    new StringField('observacao'),
                    new StringField('st_pedido'),
                    new StringField('obervacao_nota'),
                    new StringField('situacao'),
                    new IntegerField('id_licencas'),
                    new DateField('validade')
                )
            );
            $this->dataset->AddLookupField('id_cadastro', 'cadastro', new IntegerField('id_cadastro'), new StringField('nome', false, false, false, false, 'id_cadastro_nome', 'id_cadastro_nome_cadastro'), 'id_cadastro_nome_cadastro');
            $this->dataset->AddLookupField('id_vendedor', 'vendedor', new IntegerField('id_vendedor'), new StringField('fantasia', false, false, false, false, 'id_vendedor_fantasia', 'id_vendedor_fantasia_vendedor'), 'id_vendedor_fantasia_vendedor');
            $this->dataset->AddLookupField('id_condicao_pg', 'condicao_pg', new IntegerField('id_condicao_pg'), new StringField('descricao', false, false, false, false, 'id_condicao_pg_descricao', 'id_condicao_pg_descricao_condicao_pg'), 'id_condicao_pg_descricao_condicao_pg');
            $this->dataset->AddLookupField('id_transportadora', 'transportadora', new IntegerField('id_transportadora'), new StringField('nome', false, false, false, false, 'id_transportadora_nome', 'id_transportadora_nome_transportadora'), 'id_transportadora_nome_transportadora');
            $this->dataset->AddLookupField('tp_frete', 'modalidade_frete', new IntegerField('id_tabelas'), new StringField('ds_tabela', false, false, false, false, 'tp_frete_ds_tabela', 'tp_frete_ds_tabela_modalidade_frete'), 'tp_frete_ds_tabela_modalidade_frete');
            $this->dataset->AddLookupField('id_licencas', 'licencas', new IntegerField('id_licencas'), new StringField('fantasia', false, false, false, false, 'id_licencas_fantasia', 'id_licencas_fantasia_licencas'), 'id_licencas_fantasia_licencas');
            $this->dataset->AddLookupField('finalidade_emissao', 'finalidade_emissao', new StringField('cd_tabela'), new StringField('ds_tabela', false, false, false, false, 'finalidade_emissao_ds_tabela', 'finalidade_emissao_ds_tabela_finalidade_emissao'), 'finalidade_emissao_ds_tabela_finalidade_emissao');
        }
    
        protected function DoPrepare() {
    
        }
    
        protected function CreatePageNavigator()
        {
            $result = new CompositePageNavigator($this);
            
            $partitionNavigator = new PageNavigator('pnav', $this, $this->dataset);
            $partitionNavigator->SetRowsPerPage(20);
            $result->AddPageNavigator($partitionNavigator);
            
            return $result;
        }
    
        protected function CreateRssGenerator()
        {
            return null;
        }
    
        protected function setupCharts()
        {
    
        }
    
        protected function getFiltersColumns()
        {
            return array(
                new FilterColumn($this->dataset, 'id_pedido', 'id_pedido', 'Id Pedido'),
                new FilterColumn($this->dataset, 'pedido_o', 'pedido_o', 'Referencia'),
                new FilterColumn($this->dataset, 'emissao', 'emissao', 'Emissão'),
                new FilterColumn($this->dataset, 'entrega', 'entrega', 'Entrega'),
                new FilterColumn($this->dataset, 'id_cadastro', 'id_cadastro_nome', 'Cliente'),
                new FilterColumn($this->dataset, 'id_vendedor', 'id_vendedor_fantasia', 'Vendedor'),
                new FilterColumn($this->dataset, 'id_condicao_pg', 'id_condicao_pg_descricao', 'Condição Pgto'),
                new FilterColumn($this->dataset, 'tp_frete', 'tp_frete_ds_tabela', 'Tp Frete'),
                new FilterColumn($this->dataset, 'id_transportadora', 'id_transportadora_nome', 'Transportadora'),
                new FilterColumn($this->dataset, 'responsavel', 'responsavel', 'Responsavel'),
                new FilterColumn($this->dataset, 'total_produtos', 'total_produtos', 'Total Produtos'),
                new FilterColumn($this->dataset, 'valor_desc', 'valor_desc', 'Valor Desc'),
                new FilterColumn($this->dataset, 'valor_frete', 'valor_frete', 'Valor de Frete'),
                new FilterColumn($this->dataset, 'valor_acrescimo', 'valor_acrescimo', 'Valor Acréscimos'),
                new FilterColumn($this->dataset, 'total_pedido', 'total_pedido', 'Total Pedido'),
                new FilterColumn($this->dataset, 'observacao', 'observacao', 'Observação'),
                new FilterColumn($this->dataset, 'situacao', 'situacao', 'Situação'),
                new FilterColumn($this->dataset, 'id_licencas', 'id_licencas_fantasia', 'Id Licencas'),
                new FilterColumn($this->dataset, 'st_pedido', 'st_pedido', 'Status do Pedido'),
                new FilterColumn($this->dataset, 'obervacao_nota', 'obervacao_nota', 'Observação da Nota'),
                new FilterColumn($this->dataset, 'finalidade_emissao', 'finalidade_emissao_ds_tabela', 'Finalidade'),
                new FilterColumn($this->dataset, 'validade', 'validade', 'Validade')
            );
        }
    
        protected function setupQuickFilter(QuickFilter $quickFilter, FixedKeysArray $columns)
        {
            $quickFilter
                ->addColumn($columns['id_pedido'])
                ->addColumn($columns['pedido_o'])
                ->addColumn($columns['emissao'])
                ->addColumn($columns['entrega'])
                ->addColumn($columns['id_cadastro'])
                ->addColumn($columns['id_vendedor'])
                ->addColumn($columns['id_condicao_pg'])
                ->addColumn($columns['id_transportadora'])
                ->addColumn($columns['tp_frete'])
                ->addColumn($columns['responsavel'])
                ->addColumn($columns['total_produtos'])
                ->addColumn($columns['valor_frete'])
                ->addColumn($columns['valor_acrescimo'])
                ->addColumn($columns['total_pedido'])
                ->addColumn($columns['observacao'])
                ->addColumn($columns['situacao'])
                ->addColumn($columns['st_pedido'])
                ->addColumn($columns['obervacao_nota'])
                ->addColumn($columns['finalidade_emissao'])
                ->addColumn($columns['validade']);
        }
    
        protected function setupColumnFilter(ColumnFilter $columnFilter)
        {
            $columnFilter
                ->setOptionsFor('finalidade_emissao')
                ->setOptionsFor('emissao')
                ->setOptionsFor('entrega')
                ->setOptionsFor('id_cadastro')
                ->setOptionsFor('id_vendedor')
                ->setOptionsFor('id_condicao_pg')
                ->setOptionsFor('tp_frete')
                ->setOptionsFor('id_transportadora')
                ->setOptionsFor('validade');
        }
    
        protected function setupFilterBuilder(FilterBuilder $filterBuilder, FixedKeysArray $columns)
        {
            $main_editor = new TextEdit('id_pedido_edit');
            
            $filterBuilder->addColumn(
                $columns['id_pedido'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('pedido_o_edit');
            $main_editor->SetMaxLength(20);
            
            $filterBuilder->addColumn(
                $columns['pedido_o'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $main_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $main_editor,
                    FilterConditionOperator::BEGINS_WITH => $main_editor,
                    FilterConditionOperator::ENDS_WITH => $main_editor,
                    FilterConditionOperator::IS_LIKE => $main_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DateTimeEdit('emissao_edit', false, 'd.m.Y H:i:s');
            
            $filterBuilder->addColumn(
                $columns['emissao'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::DATE_EQUALS => $main_editor,
                    FilterConditionOperator::DATE_DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::TODAY => null,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('entrega_edit');
            
            $filterBuilder->addColumn(
                $columns['entrega'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DynamicCombobox('id_cadastro_edit', $this->CreateLinkBuilder());
            $main_editor->setAllowClear(true);
            $main_editor->setMinimumInputLength(0);
            $main_editor->SetAllowNullValue(false);
            $main_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_cadastro_search');
            
            $multi_value_select_editor = new RemoteMultiValueSelect('id_cadastro', $this->CreateLinkBuilder());
            $multi_value_select_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_cadastro_search');
            
            $filterBuilder->addColumn(
                $columns['id_cadastro'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DynamicCombobox('id_vendedor_edit', $this->CreateLinkBuilder());
            $main_editor->setAllowClear(true);
            $main_editor->setMinimumInputLength(0);
            $main_editor->SetAllowNullValue(false);
            $main_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_vendedor_search');
            
            $multi_value_select_editor = new RemoteMultiValueSelect('id_vendedor', $this->CreateLinkBuilder());
            $multi_value_select_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_vendedor_search');
            
            $filterBuilder->addColumn(
                $columns['id_vendedor'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DynamicCombobox('id_condicao_pg_edit', $this->CreateLinkBuilder());
            $main_editor->setAllowClear(true);
            $main_editor->setMinimumInputLength(0);
            $main_editor->SetAllowNullValue(false);
            $main_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_condicao_pg_search');
            
            $multi_value_select_editor = new RemoteMultiValueSelect('id_condicao_pg', $this->CreateLinkBuilder());
            $multi_value_select_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_condicao_pg_search');
            
            $filterBuilder->addColumn(
                $columns['id_condicao_pg'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DynamicCombobox('tp_frete_edit', $this->CreateLinkBuilder());
            $main_editor->setAllowClear(true);
            $main_editor->setMinimumInputLength(0);
            $main_editor->SetAllowNullValue(false);
            $main_editor->SetHandlerName('filter_builder_pedido_pedido_item01_tp_frete_search');
            
            $multi_value_select_editor = new RemoteMultiValueSelect('tp_frete', $this->CreateLinkBuilder());
            $multi_value_select_editor->SetHandlerName('filter_builder_pedido_pedido_item01_tp_frete_search');
            
            $text_editor = new TextEdit('tp_frete');
            
            $filterBuilder->addColumn(
                $columns['tp_frete'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $text_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $text_editor,
                    FilterConditionOperator::BEGINS_WITH => $text_editor,
                    FilterConditionOperator::ENDS_WITH => $text_editor,
                    FilterConditionOperator::IS_LIKE => $text_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $text_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DynamicCombobox('id_transportadora_edit', $this->CreateLinkBuilder());
            $main_editor->setAllowClear(true);
            $main_editor->setMinimumInputLength(0);
            $main_editor->SetAllowNullValue(false);
            $main_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_transportadora_search');
            
            $multi_value_select_editor = new RemoteMultiValueSelect('id_transportadora', $this->CreateLinkBuilder());
            $multi_value_select_editor->SetHandlerName('filter_builder_pedido_pedido_item01_id_transportadora_search');
            
            $filterBuilder->addColumn(
                $columns['id_transportadora'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('responsavel_edit');
            $main_editor->SetMaxLength(15);
            
            $filterBuilder->addColumn(
                $columns['responsavel'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $main_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $main_editor,
                    FilterConditionOperator::BEGINS_WITH => $main_editor,
                    FilterConditionOperator::ENDS_WITH => $main_editor,
                    FilterConditionOperator::IS_LIKE => $main_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('total_produtos_edit');
            
            $filterBuilder->addColumn(
                $columns['total_produtos'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('valor_frete_edit');
            
            $filterBuilder->addColumn(
                $columns['valor_frete'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('valor_acrescimo_edit');
            
            $filterBuilder->addColumn(
                $columns['valor_acrescimo'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('total_pedido_edit');
            
            $filterBuilder->addColumn(
                $columns['total_pedido'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('observacao');
            
            $filterBuilder->addColumn(
                $columns['observacao'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $main_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $main_editor,
                    FilterConditionOperator::BEGINS_WITH => $main_editor,
                    FilterConditionOperator::ENDS_WITH => $main_editor,
                    FilterConditionOperator::IS_LIKE => $main_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new ComboBox('situacao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $main_editor->addChoice('ORCAMENTO', 'ORÇAMENTO');
            $main_editor->addChoice('PEDIDO', 'PEDIDO');
            $main_editor->addChoice('CANCELADO', 'CANCELADO');
            $main_editor->addChoice('ATENDIDO', 'ATENDIDO');
            $main_editor->SetAllowNullValue(false);
            
            $multi_value_select_editor = new MultiValueSelect('situacao');
            $multi_value_select_editor->setChoices($main_editor->getChoices());
            
            $text_editor = new TextEdit('situacao');
            
            $filterBuilder->addColumn(
                $columns['situacao'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $text_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $text_editor,
                    FilterConditionOperator::BEGINS_WITH => $text_editor,
                    FilterConditionOperator::ENDS_WITH => $text_editor,
                    FilterConditionOperator::IS_LIKE => $text_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $text_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new ComboBox('st_pedido_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $main_editor->addChoice('AGUARDANDO', 'AGUARDANDO');
            $main_editor->addChoice('PENDENTE', 'PENDENTE');
            $main_editor->addChoice('FINALIZADO', 'FINALIZADO');
            $main_editor->SetAllowNullValue(false);
            
            $multi_value_select_editor = new MultiValueSelect('st_pedido');
            $multi_value_select_editor->setChoices($main_editor->getChoices());
            
            $text_editor = new TextEdit('st_pedido');
            
            $filterBuilder->addColumn(
                $columns['st_pedido'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $text_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $text_editor,
                    FilterConditionOperator::BEGINS_WITH => $text_editor,
                    FilterConditionOperator::ENDS_WITH => $text_editor,
                    FilterConditionOperator::IS_LIKE => $text_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $text_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new TextEdit('obervacao_nota');
            
            $filterBuilder->addColumn(
                $columns['obervacao_nota'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::CONTAINS => $main_editor,
                    FilterConditionOperator::DOES_NOT_CONTAIN => $main_editor,
                    FilterConditionOperator::BEGINS_WITH => $main_editor,
                    FilterConditionOperator::ENDS_WITH => $main_editor,
                    FilterConditionOperator::IS_LIKE => $main_editor,
                    FilterConditionOperator::IS_NOT_LIKE => $main_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DynamicCombobox('finalidade_emissao_edit', $this->CreateLinkBuilder());
            $main_editor->setAllowClear(true);
            $main_editor->setMinimumInputLength(0);
            $main_editor->SetAllowNullValue(false);
            $main_editor->SetHandlerName('filter_builder_pedido_pedido_item01_finalidade_emissao_search');
            
            $multi_value_select_editor = new RemoteMultiValueSelect('finalidade_emissao', $this->CreateLinkBuilder());
            $multi_value_select_editor->SetHandlerName('filter_builder_pedido_pedido_item01_finalidade_emissao_search');
            
            $filterBuilder->addColumn(
                $columns['finalidade_emissao'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::IN => $multi_value_select_editor,
                    FilterConditionOperator::NOT_IN => $multi_value_select_editor,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
            
            $main_editor = new DateTimeEdit('validade_edit', false, 'd.m.Y');
            
            $filterBuilder->addColumn(
                $columns['validade'],
                array(
                    FilterConditionOperator::EQUALS => $main_editor,
                    FilterConditionOperator::DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN => $main_editor,
                    FilterConditionOperator::IS_GREATER_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN => $main_editor,
                    FilterConditionOperator::IS_LESS_THAN_OR_EQUAL_TO => $main_editor,
                    FilterConditionOperator::IS_BETWEEN => $main_editor,
                    FilterConditionOperator::IS_NOT_BETWEEN => $main_editor,
                    FilterConditionOperator::DATE_EQUALS => $main_editor,
                    FilterConditionOperator::DATE_DOES_NOT_EQUAL => $main_editor,
                    FilterConditionOperator::TODAY => null,
                    FilterConditionOperator::IS_BLANK => null,
                    FilterConditionOperator::IS_NOT_BLANK => null
                )
            );
        }
    
        protected function AddOperationsColumns(Grid $grid)
        {
            $actions = $grid->getActions();
            $actions->setCaption($this->GetLocalizerCaptions()->GetMessageString('Actions'));
            $actions->setPosition(ActionList::POSITION_LEFT);
            
            if ($this->GetSecurityInfo()->HasViewGrant())
            {
                $operation = new AjaxOperation(OPERATION_VIEW,
                    $this->GetLocalizerCaptions()->GetMessageString('View'),
                    $this->GetLocalizerCaptions()->GetMessageString('View'), $this->dataset,
                    $this->GetModalGridViewHandler(), $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
            }
            
            if ($this->GetSecurityInfo()->HasEditGrant())
            {
                $operation = new AjaxOperation(OPERATION_EDIT,
                    $this->GetLocalizerCaptions()->GetMessageString('Edit'),
                    $this->GetLocalizerCaptions()->GetMessageString('Edit'), $this->dataset,
                    $this->GetGridEditHandler(), $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
                $operation->OnShow->AddListener('ShowEditButtonHandler', $this);
            }
            
            if ($this->GetSecurityInfo()->HasDeleteGrant())
            {
                $operation = new LinkOperation($this->GetLocalizerCaptions()->GetMessageString('Delete'), OPERATION_DELETE, $this->dataset, $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
                $operation->OnShow->AddListener('ShowDeleteButtonHandler', $this);
                $operation->SetAdditionalAttribute('data-modal-operation', 'delete');
                $operation->SetAdditionalAttribute('data-delete-handler-name', $this->GetModalGridDeleteHandler());
            }
            
            if ($this->GetSecurityInfo()->HasAddGrant())
            {
                $operation = new AjaxOperation(OPERATION_COPY,
                    $this->GetLocalizerCaptions()->GetMessageString('Copy'),
                    $this->GetLocalizerCaptions()->GetMessageString('Copy'), $this->dataset,
                    $this->GetModalGridCopyHandler(), $grid);
                $operation->setUseImage(true);
                $actions->addOperation($operation);
            }
        }
    
        protected function AddFieldColumns(Grid $grid, $withDetails = true)
        {
            if (GetCurrentUserPermissionSetForDataSource('pedido.pedido_item01')->HasViewGrant() && $withDetails)
            {
            //
            // View column for pedido_pedido_item01 detail
            //
            $column = new DetailColumn(array('id_pedido'), 'pedido.pedido_item01', 'pedido_pedido_item01_handler', $this->dataset, 'ITENS');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $grid->AddViewColumn($column);
            }
            
            //
            // View column for id_pedido field
            //
            $column = new NumberViewColumn('id_pedido', 'id_pedido', 'Id Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('finalidade_emissao', 'finalidade_emissao_ds_tabela', 'Finalidade', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for pedido_o field
            //
            $column = new TextViewColumn('pedido_o', 'pedido_o', 'Referencia', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for emissao field
            //
            $column = new DateTimeViewColumn('emissao', 'emissao', 'Emissão', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y H:i:s');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for entrega field
            //
            $column = new TextViewColumn('entrega', 'entrega', 'Entrega', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_cadastro', 'id_cadastro_nome', 'Cliente', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for fantasia field
            //
            $column = new TextViewColumn('id_vendedor', 'id_vendedor_fantasia', 'Vendedor', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('id_condicao_pg', 'id_condicao_pg_descricao', 'Condição Pgto', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('tp_frete', 'tp_frete_ds_tabela', 'Tp Frete', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_transportadora', 'id_transportadora_nome', 'Transportadora', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for responsavel field
            //
            $column = new TextViewColumn('responsavel', 'responsavel', 'Responsavel', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for total_produtos field
            //
            $column = new NumberViewColumn('total_produtos', 'total_produtos', 'Total Produtos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for valor_frete field
            //
            $column = new NumberViewColumn('valor_frete', 'valor_frete', 'Valor de Frete', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for valor_acrescimo field
            //
            $column = new NumberViewColumn('valor_acrescimo', 'valor_acrescimo', 'Valor Acréscimos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for total_pedido field
            //
            $column = new NumberViewColumn('total_pedido', 'total_pedido', 'Total Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_observacao_handler_list');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_obervacao_nota_handler_list');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for situacao field
            //
            $column = new TextViewColumn('situacao', 'situacao', 'Situação', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for st_pedido field
            //
            $column = new TextViewColumn('st_pedido', 'st_pedido', 'Status do Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for validade field
            //
            $column = new DateTimeViewColumn('validade', 'validade', 'Validade', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
        }
    
        protected function AddSingleRecordViewColumns(Grid $grid)
        {
            //
            // View column for id_pedido field
            //
            $column = new NumberViewColumn('id_pedido', 'id_pedido', 'Id Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for pedido_o field
            //
            $column = new TextViewColumn('pedido_o', 'pedido_o', 'Referencia', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for emissao field
            //
            $column = new DateTimeViewColumn('emissao', 'emissao', 'Emissão', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y H:i:s');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for entrega field
            //
            $column = new TextViewColumn('entrega', 'entrega', 'Entrega', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_cadastro', 'id_cadastro_nome', 'Cliente', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for fantasia field
            //
            $column = new TextViewColumn('id_vendedor', 'id_vendedor_fantasia', 'Vendedor', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('id_condicao_pg', 'id_condicao_pg_descricao', 'Condição Pgto', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('tp_frete', 'tp_frete_ds_tabela', 'Tp Frete', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_transportadora', 'id_transportadora_nome', 'Transportadora', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for responsavel field
            //
            $column = new TextViewColumn('responsavel', 'responsavel', 'Responsavel', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for total_produtos field
            //
            $column = new NumberViewColumn('total_produtos', 'total_produtos', 'Total Produtos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for valor_frete field
            //
            $column = new NumberViewColumn('valor_frete', 'valor_frete', 'Valor de Frete', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for valor_acrescimo field
            //
            $column = new NumberViewColumn('valor_acrescimo', 'valor_acrescimo', 'Valor Acréscimos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for total_pedido field
            //
            $column = new NumberViewColumn('total_pedido', 'total_pedido', 'Total Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_observacao_handler_view');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for situacao field
            //
            $column = new TextViewColumn('situacao', 'situacao', 'Situação', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for fantasia field
            //
            $column = new TextViewColumn('id_licencas', 'id_licencas_fantasia', 'Id Licencas', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for st_pedido field
            //
            $column = new TextViewColumn('st_pedido', 'st_pedido', 'Status do Pedido', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_obervacao_nota_handler_view');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('finalidade_emissao', 'finalidade_emissao_ds_tabela', 'Finalidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for validade field
            //
            $column = new DateTimeViewColumn('validade', 'validade', 'Validade', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y');
            $grid->AddSingleRecordViewColumn($column);
        }
    
        protected function AddEditColumns(Grid $grid)
        {
            //
            // Edit column for pedido_o field
            //
            $editor = new TextEdit('pedido_o_edit');
            $editor->SetMaxLength(20);
            $editColumn = new CustomEditColumn('Referencia', 'pedido_o', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for emissao field
            //
            $editor = new DateTimeEdit('emissao_edit', false, 'd.m.Y H:i:s');
            $editColumn = new CustomEditColumn('Emissão', 'emissao', $editor, $this->dataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for entrega field
            //
            $editor = new TextEdit('entrega_edit');
            $editColumn = new CustomEditColumn('Entrega', 'entrega', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for id_cadastro field
            //
            $editor = new ComboBox('id_cadastro_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cadastro`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_cadastro', true, true, true),
                    new StringField('nome'),
                    new StringField('endereco'),
                    new IntegerField('numero'),
                    new StringField('complemento'),
                    new StringField('bairro'),
                    new StringField('cep'),
                    new StringField('cidade'),
                    new StringField('cd_municipio'),
                    new StringField('estado'),
                    new StringField('telefone'),
                    new StringField('celular'),
                    new StringField('email'),
                    new StringField('contato'),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao'),
                    new StringField('identidade'),
                    new IntegerField('id_vendedor'),
                    new DateTimeField('data_mov_s'),
                    new StringField('endereco_cobranca'),
                    new StringField('observacao'),
                    new IntegerField('id_indicador_ie'),
                    new IntegerField('id_regime'),
                    new IntegerField('id_licencas')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Cliente', 
                'id_cadastro', 
                $editor, 
                $this->dataset, 'id_cadastro', 'nome', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for id_vendedor field
            //
            $editor = new ComboBox('id_vendedor_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`vendedor`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_vendedor', true, true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new StringField('cnpj', true),
                    new StringField('cpf', true),
                    new StringField('inscricao', true),
                    new StringField('identidade', true),
                    new IntegerField('comissao', true)
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Vendedor', 
                'id_vendedor', 
                $editor, 
                $this->dataset, 'id_vendedor', 'fantasia', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for id_condicao_pg field
            //
            $editor = new ComboBox('id_condicao_pg_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`condicao_pg`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_condicao_pg', true, true, true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('descricao', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Condição Pgto', 
                'id_condicao_pg', 
                $editor, 
                $this->dataset, 'id_condicao_pg', 'descricao', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for tp_frete field
            //
            $editor = new ComboBox('tp_frete_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`modalidade_frete`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Tp Frete', 
                'tp_frete', 
                $editor, 
                $this->dataset, 'id_tabelas', 'ds_tabela', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for id_transportadora field
            //
            $editor = new ComboBox('id_transportadora_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`transportadora`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_transportadora', true, true, true),
                    new StringField('nome', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new IntegerField('cd_frete', true),
                    new StringField('placa', true),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Transportadora', 
                'id_transportadora', 
                $editor, 
                $this->dataset, 'id_transportadora', 'nome', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for responsavel field
            //
            $editor = new TextEdit('responsavel_edit');
            $editor->SetMaxLength(15);
            $editColumn = new CustomEditColumn('Responsavel', 'responsavel', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for total_produtos field
            //
            $editor = new TextEdit('total_produtos_edit');
            $editColumn = new CustomEditColumn('Total Produtos', 'total_produtos', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for valor_frete field
            //
            $editor = new TextEdit('valor_frete_edit');
            $editColumn = new CustomEditColumn('Valor de Frete', 'valor_frete', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for valor_acrescimo field
            //
            $editor = new TextEdit('valor_acrescimo_edit');
            $editColumn = new CustomEditColumn('Valor Acréscimos', 'valor_acrescimo', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for total_pedido field
            //
            $editor = new TextEdit('total_pedido_edit');
            $editColumn = new CustomEditColumn('Total Pedido', 'total_pedido', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for observacao field
            //
            $editor = new TextAreaEdit('observacao_edit', 50, 8);
            $editColumn = new CustomEditColumn('Observação', 'observacao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for obervacao_nota field
            //
            $editor = new TextAreaEdit('obervacao_nota_edit', 50, 8);
            $editColumn = new CustomEditColumn('Observação da Nota', 'obervacao_nota', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for situacao field
            //
            $editor = new ComboBox('situacao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $editor->addChoice('ORCAMENTO', 'ORÇAMENTO');
            $editor->addChoice('PEDIDO', 'PEDIDO');
            $editor->addChoice('CANCELADO', 'CANCELADO');
            $editor->addChoice('ATENDIDO', 'ATENDIDO');
            $editColumn = new CustomEditColumn('Situação', 'situacao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for id_licencas field
            //
            $editor = new ComboBox('id_licencas_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`licencas`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_licencas', true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('logo'),
                    new StringField('logradouro', true),
                    new StringField('numero', true),
                    new StringField('complemento', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cod_municipio'),
                    new StringField('municipio', true),
                    new StringField('uf', true),
                    new StringField('telefone', true),
                    new StringField('email', true),
                    new StringField('cnae'),
                    new StringField('cnpj', true),
                    new StringField('ie', true),
                    new StringField('im'),
                    new StringField('responsavel', true),
                    new StringField('responsavel_cpf'),
                    new IntegerField('cd_regime_tributario'),
                    new StringField('st_ativo', true),
                    new IntegerField('aliq_pis'),
                    new IntegerField('aliq_cofins'),
                    new StringField('token'),
                    new StringField('token_homologacao'),
                    new StringField('login'),
                    new StringField('senha')
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $lookupDataset->AddCustomCondition(EnvVariablesUtils::EvaluateVariableTemplate($this->GetColumnVariableContainer(), 'licencas.id_licencas=%CURRENT_USER_ID%'));
            $editColumn = new LookUpEditColumn(
                'Id Licencas', 
                'id_licencas', 
                $editor, 
                $this->dataset, 'id_licencas', 'fantasia', $lookupDataset);
            $editColumn->SetReadOnly(true);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for st_pedido field
            //
            $editor = new ComboBox('st_pedido_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $editor->addChoice('AGUARDANDO', 'AGUARDANDO');
            $editor->addChoice('PENDENTE', 'PENDENTE');
            $editor->addChoice('FINALIZADO', 'FINALIZADO');
            $editColumn = new CustomEditColumn('Status do Pedido', 'st_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for finalidade_emissao field
            //
            $editor = new ComboBox('finalidade_emissao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`finalidade_emissao`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Finalidade', 
                'finalidade_emissao', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for validade field
            //
            $editor = new DateTimeEdit('validade_edit', false, 'd.m.Y');
            $editColumn = new CustomEditColumn('Validade', 'validade', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
        }
    
        protected function AddMultiEditColumns(Grid $grid)
        {
            //
            // Edit column for pedido_o field
            //
            $editor = new TextEdit('pedido_o_edit');
            $editor->SetMaxLength(20);
            $editColumn = new CustomEditColumn('Referencia', 'pedido_o', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for emissao field
            //
            $editor = new DateTimeEdit('emissao_edit', false, 'd.m.Y H:i:s');
            $editColumn = new CustomEditColumn('Emissão', 'emissao', $editor, $this->dataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for entrega field
            //
            $editor = new TextEdit('entrega_edit');
            $editColumn = new CustomEditColumn('Entrega', 'entrega', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for id_cadastro field
            //
            $editor = new ComboBox('id_cadastro_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cadastro`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_cadastro', true, true, true),
                    new StringField('nome'),
                    new StringField('endereco'),
                    new IntegerField('numero'),
                    new StringField('complemento'),
                    new StringField('bairro'),
                    new StringField('cep'),
                    new StringField('cidade'),
                    new StringField('cd_municipio'),
                    new StringField('estado'),
                    new StringField('telefone'),
                    new StringField('celular'),
                    new StringField('email'),
                    new StringField('contato'),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao'),
                    new StringField('identidade'),
                    new IntegerField('id_vendedor'),
                    new DateTimeField('data_mov_s'),
                    new StringField('endereco_cobranca'),
                    new StringField('observacao'),
                    new IntegerField('id_indicador_ie'),
                    new IntegerField('id_regime'),
                    new IntegerField('id_licencas')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Cliente', 
                'id_cadastro', 
                $editor, 
                $this->dataset, 'id_cadastro', 'nome', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for id_vendedor field
            //
            $editor = new ComboBox('id_vendedor_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`vendedor`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_vendedor', true, true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new StringField('cnpj', true),
                    new StringField('cpf', true),
                    new StringField('inscricao', true),
                    new StringField('identidade', true),
                    new IntegerField('comissao', true)
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Vendedor', 
                'id_vendedor', 
                $editor, 
                $this->dataset, 'id_vendedor', 'fantasia', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for id_condicao_pg field
            //
            $editor = new ComboBox('id_condicao_pg_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`condicao_pg`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_condicao_pg', true, true, true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('descricao', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Condição Pgto', 
                'id_condicao_pg', 
                $editor, 
                $this->dataset, 'id_condicao_pg', 'descricao', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for id_transportadora field
            //
            $editor = new ComboBox('id_transportadora_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`transportadora`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_transportadora', true, true, true),
                    new StringField('nome', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new IntegerField('cd_frete', true),
                    new StringField('placa', true),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Transportadora', 
                'id_transportadora', 
                $editor, 
                $this->dataset, 'id_transportadora', 'nome', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for tp_frete field
            //
            $editor = new ComboBox('tp_frete_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`modalidade_frete`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Tp Frete', 
                'tp_frete', 
                $editor, 
                $this->dataset, 'id_tabelas', 'ds_tabela', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for responsavel field
            //
            $editor = new TextEdit('responsavel_edit');
            $editor->SetMaxLength(15);
            $editColumn = new CustomEditColumn('Responsavel', 'responsavel', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for total_produtos field
            //
            $editor = new TextEdit('total_produtos_edit');
            $editColumn = new CustomEditColumn('Total Produtos', 'total_produtos', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for valor_desc field
            //
            $editor = new TextEdit('valor_desc_edit');
            $editColumn = new CustomEditColumn('Valor Desc', 'valor_desc', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for valor_frete field
            //
            $editor = new TextEdit('valor_frete_edit');
            $editColumn = new CustomEditColumn('Valor de Frete', 'valor_frete', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for valor_acrescimo field
            //
            $editor = new TextEdit('valor_acrescimo_edit');
            $editColumn = new CustomEditColumn('Valor Acréscimos', 'valor_acrescimo', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for total_pedido field
            //
            $editor = new TextEdit('total_pedido_edit');
            $editColumn = new CustomEditColumn('Total Pedido', 'total_pedido', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for observacao field
            //
            $editor = new TextAreaEdit('observacao_edit', 50, 8);
            $editColumn = new CustomEditColumn('Observação', 'observacao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for situacao field
            //
            $editor = new ComboBox('situacao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $editor->addChoice('ORCAMENTO', 'ORÇAMENTO');
            $editor->addChoice('PEDIDO', 'PEDIDO');
            $editor->addChoice('CANCELADO', 'CANCELADO');
            $editor->addChoice('ATENDIDO', 'ATENDIDO');
            $editColumn = new CustomEditColumn('Situação', 'situacao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for id_licencas field
            //
            $editor = new ComboBox('id_licencas_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`licencas`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_licencas', true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('logo'),
                    new StringField('logradouro', true),
                    new StringField('numero', true),
                    new StringField('complemento', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cod_municipio'),
                    new StringField('municipio', true),
                    new StringField('uf', true),
                    new StringField('telefone', true),
                    new StringField('email', true),
                    new StringField('cnae'),
                    new StringField('cnpj', true),
                    new StringField('ie', true),
                    new StringField('im'),
                    new StringField('responsavel', true),
                    new StringField('responsavel_cpf'),
                    new IntegerField('cd_regime_tributario'),
                    new StringField('st_ativo', true),
                    new IntegerField('aliq_pis'),
                    new IntegerField('aliq_cofins'),
                    new StringField('token'),
                    new StringField('token_homologacao'),
                    new StringField('login'),
                    new StringField('senha')
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $lookupDataset->AddCustomCondition(EnvVariablesUtils::EvaluateVariableTemplate($this->GetColumnVariableContainer(), 'licencas.id_licencas=%CURRENT_USER_ID%'));
            $editColumn = new LookUpEditColumn(
                'Id Licencas', 
                'id_licencas', 
                $editor, 
                $this->dataset, 'id_licencas', 'fantasia', $lookupDataset);
            $editColumn->SetReadOnly(true);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for st_pedido field
            //
            $editor = new ComboBox('st_pedido_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $editor->addChoice('AGUARDANDO', 'AGUARDANDO');
            $editor->addChoice('PENDENTE', 'PENDENTE');
            $editor->addChoice('FINALIZADO', 'FINALIZADO');
            $editColumn = new CustomEditColumn('Status do Pedido', 'st_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for obervacao_nota field
            //
            $editor = new TextAreaEdit('obervacao_nota_edit', 50, 8);
            $editColumn = new CustomEditColumn('Observação da Nota', 'obervacao_nota', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for finalidade_emissao field
            //
            $editor = new ComboBox('finalidade_emissao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`finalidade_emissao`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Finalidade', 
                'finalidade_emissao', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for validade field
            //
            $editor = new DateTimeEdit('validade_edit', false, 'd.m.Y');
            $editColumn = new CustomEditColumn('Validade', 'validade', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
        }
    
        protected function AddInsertColumns(Grid $grid)
        {
            //
            // Edit column for pedido_o field
            //
            $editor = new TextEdit('pedido_o_edit');
            $editor->SetMaxLength(20);
            $editColumn = new CustomEditColumn('Referencia', 'pedido_o', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for emissao field
            //
            $editor = new DateTimeEdit('emissao_edit', false, 'd.m.Y H:i:s');
            $editColumn = new CustomEditColumn('Emissão', 'emissao', $editor, $this->dataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for entrega field
            //
            $editor = new TextEdit('entrega_edit');
            $editColumn = new CustomEditColumn('Entrega', 'entrega', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for id_cadastro field
            //
            $editor = new ComboBox('id_cadastro_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cadastro`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_cadastro', true, true, true),
                    new StringField('nome'),
                    new StringField('endereco'),
                    new IntegerField('numero'),
                    new StringField('complemento'),
                    new StringField('bairro'),
                    new StringField('cep'),
                    new StringField('cidade'),
                    new StringField('cd_municipio'),
                    new StringField('estado'),
                    new StringField('telefone'),
                    new StringField('celular'),
                    new StringField('email'),
                    new StringField('contato'),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao'),
                    new StringField('identidade'),
                    new IntegerField('id_vendedor'),
                    new DateTimeField('data_mov_s'),
                    new StringField('endereco_cobranca'),
                    new StringField('observacao'),
                    new IntegerField('id_indicador_ie'),
                    new IntegerField('id_regime'),
                    new IntegerField('id_licencas')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Cliente', 
                'id_cadastro', 
                $editor, 
                $this->dataset, 'id_cadastro', 'nome', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for id_vendedor field
            //
            $editor = new ComboBox('id_vendedor_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`vendedor`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_vendedor', true, true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new StringField('cnpj', true),
                    new StringField('cpf', true),
                    new StringField('inscricao', true),
                    new StringField('identidade', true),
                    new IntegerField('comissao', true)
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Vendedor', 
                'id_vendedor', 
                $editor, 
                $this->dataset, 'id_vendedor', 'fantasia', $lookupDataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for id_condicao_pg field
            //
            $editor = new ComboBox('id_condicao_pg_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`condicao_pg`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_condicao_pg', true, true, true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('descricao', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Condição Pgto', 
                'id_condicao_pg', 
                $editor, 
                $this->dataset, 'id_condicao_pg', 'descricao', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for tp_frete field
            //
            $editor = new ComboBox('tp_frete_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`modalidade_frete`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Tp Frete', 
                'tp_frete', 
                $editor, 
                $this->dataset, 'id_tabelas', 'ds_tabela', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for id_transportadora field
            //
            $editor = new ComboBox('id_transportadora_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`transportadora`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_transportadora', true, true, true),
                    new StringField('nome', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new IntegerField('cd_frete', true),
                    new StringField('placa', true),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Transportadora', 
                'id_transportadora', 
                $editor, 
                $this->dataset, 'id_transportadora', 'nome', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for responsavel field
            //
            $editor = new TextEdit('responsavel_edit');
            $editor->SetMaxLength(15);
            $editColumn = new CustomEditColumn('Responsavel', 'responsavel', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('%CURRENT_USER_NAME%');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for total_produtos field
            //
            $editor = new TextEdit('total_produtos_edit');
            $editColumn = new CustomEditColumn('Total Produtos', 'total_produtos', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for valor_frete field
            //
            $editor = new TextEdit('valor_frete_edit');
            $editColumn = new CustomEditColumn('Valor de Frete', 'valor_frete', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for valor_acrescimo field
            //
            $editor = new TextEdit('valor_acrescimo_edit');
            $editColumn = new CustomEditColumn('Valor Acréscimos', 'valor_acrescimo', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for total_pedido field
            //
            $editor = new TextEdit('total_pedido_edit');
            $editColumn = new CustomEditColumn('Total Pedido', 'total_pedido', $editor, $this->dataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('0');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for observacao field
            //
            $editor = new TextAreaEdit('observacao_edit', 50, 8);
            $editColumn = new CustomEditColumn('Observação', 'observacao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for situacao field
            //
            $editor = new ComboBox('situacao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $editor->addChoice('ORCAMENTO', 'ORÇAMENTO');
            $editor->addChoice('PEDIDO', 'PEDIDO');
            $editor->addChoice('CANCELADO', 'CANCELADO');
            $editor->addChoice('ATENDIDO', 'ATENDIDO');
            $editColumn = new CustomEditColumn('Situação', 'situacao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $editColumn->SetInsertDefaultValue('ORÇAMENTO');
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for id_licencas field
            //
            $editor = new ComboBox('id_licencas_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`licencas`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_licencas', true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('logo'),
                    new StringField('logradouro', true),
                    new StringField('numero', true),
                    new StringField('complemento', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cod_municipio'),
                    new StringField('municipio', true),
                    new StringField('uf', true),
                    new StringField('telefone', true),
                    new StringField('email', true),
                    new StringField('cnae'),
                    new StringField('cnpj', true),
                    new StringField('ie', true),
                    new StringField('im'),
                    new StringField('responsavel', true),
                    new StringField('responsavel_cpf'),
                    new IntegerField('cd_regime_tributario'),
                    new StringField('st_ativo', true),
                    new IntegerField('aliq_pis'),
                    new IntegerField('aliq_cofins'),
                    new StringField('token'),
                    new StringField('token_homologacao'),
                    new StringField('login'),
                    new StringField('senha')
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $lookupDataset->AddCustomCondition(EnvVariablesUtils::EvaluateVariableTemplate($this->GetColumnVariableContainer(), 'licencas.id_licencas=%CURRENT_USER_ID%'));
            $editColumn = new LookUpEditColumn(
                'Id Licencas', 
                'id_licencas', 
                $editor, 
                $this->dataset, 'id_licencas', 'fantasia', $lookupDataset);
            $editColumn->SetReadOnly(true);
            $editColumn->SetInsertDefaultValue('%CURRENT_USER_ID%');
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for st_pedido field
            //
            $editor = new ComboBox('st_pedido_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $editor->addChoice('AGUARDANDO', 'AGUARDANDO');
            $editor->addChoice('PENDENTE', 'PENDENTE');
            $editor->addChoice('FINALIZADO', 'FINALIZADO');
            $editColumn = new CustomEditColumn('Status do Pedido', 'st_pedido', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for obervacao_nota field
            //
            $editor = new TextAreaEdit('obervacao_nota_edit', 50, 8);
            $editColumn = new CustomEditColumn('Observação da Nota', 'obervacao_nota', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for finalidade_emissao field
            //
            $editor = new ComboBox('finalidade_emissao_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect'));
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`finalidade_emissao`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $editColumn = new LookUpEditColumn(
                'Finalidade', 
                'finalidade_emissao', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $editColumn->GetCaption()));
            $editor->GetValidatorCollection()->AddValidator($validator);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for validade field
            //
            $editor = new DateTimeEdit('validade_edit', false, 'd.m.Y');
            $editColumn = new CustomEditColumn('Validade', 'validade', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            $grid->SetShowAddButton(true && $this->GetSecurityInfo()->HasAddGrant());
        }
    
        private function AddMultiUploadColumn(Grid $grid)
        {
    
        }
    
        protected function AddPrintColumns(Grid $grid)
        {
            //
            // View column for id_pedido field
            //
            $column = new NumberViewColumn('id_pedido', 'id_pedido', 'Id Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddPrintColumn($column);
            
            //
            // View column for pedido_o field
            //
            $column = new TextViewColumn('pedido_o', 'pedido_o', 'Referencia', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for emissao field
            //
            $column = new DateTimeViewColumn('emissao', 'emissao', 'Emissão', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y H:i:s');
            $grid->AddPrintColumn($column);
            
            //
            // View column for entrega field
            //
            $column = new TextViewColumn('entrega', 'entrega', 'Entrega', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_cadastro', 'id_cadastro_nome', 'Cliente', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for fantasia field
            //
            $column = new TextViewColumn('id_vendedor', 'id_vendedor_fantasia', 'Vendedor', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('id_condicao_pg', 'id_condicao_pg_descricao', 'Condição Pgto', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('tp_frete', 'tp_frete_ds_tabela', 'Tp Frete', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_transportadora', 'id_transportadora_nome', 'Transportadora', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for responsavel field
            //
            $column = new TextViewColumn('responsavel', 'responsavel', 'Responsavel', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for total_produtos field
            //
            $column = new NumberViewColumn('total_produtos', 'total_produtos', 'Total Produtos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for valor_frete field
            //
            $column = new NumberViewColumn('valor_frete', 'valor_frete', 'Valor de Frete', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for valor_acrescimo field
            //
            $column = new NumberViewColumn('valor_acrescimo', 'valor_acrescimo', 'Valor Acréscimos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for total_pedido field
            //
            $column = new NumberViewColumn('total_pedido', 'total_pedido', 'Total Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_observacao_handler_print');
            $grid->AddPrintColumn($column);
            
            //
            // View column for situacao field
            //
            $column = new TextViewColumn('situacao', 'situacao', 'Situação', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for st_pedido field
            //
            $column = new TextViewColumn('st_pedido', 'st_pedido', 'Status do Pedido', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_obervacao_nota_handler_print');
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('finalidade_emissao', 'finalidade_emissao_ds_tabela', 'Finalidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for validade field
            //
            $column = new DateTimeViewColumn('validade', 'validade', 'Validade', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y');
            $grid->AddPrintColumn($column);
        }
    
        protected function AddExportColumns(Grid $grid)
        {
            //
            // View column for id_pedido field
            //
            $column = new NumberViewColumn('id_pedido', 'id_pedido', 'Id Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $grid->AddExportColumn($column);
            
            //
            // View column for pedido_o field
            //
            $column = new TextViewColumn('pedido_o', 'pedido_o', 'Referencia', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for emissao field
            //
            $column = new DateTimeViewColumn('emissao', 'emissao', 'Emissão', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y H:i:s');
            $grid->AddExportColumn($column);
            
            //
            // View column for entrega field
            //
            $column = new TextViewColumn('entrega', 'entrega', 'Entrega', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_cadastro', 'id_cadastro_nome', 'Cliente', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for fantasia field
            //
            $column = new TextViewColumn('id_vendedor', 'id_vendedor_fantasia', 'Vendedor', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('id_condicao_pg', 'id_condicao_pg_descricao', 'Condição Pgto', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('tp_frete', 'tp_frete_ds_tabela', 'Tp Frete', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_transportadora', 'id_transportadora_nome', 'Transportadora', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for responsavel field
            //
            $column = new TextViewColumn('responsavel', 'responsavel', 'Responsavel', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for total_produtos field
            //
            $column = new NumberViewColumn('total_produtos', 'total_produtos', 'Total Produtos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for valor_frete field
            //
            $column = new NumberViewColumn('valor_frete', 'valor_frete', 'Valor de Frete', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for valor_acrescimo field
            //
            $column = new NumberViewColumn('valor_acrescimo', 'valor_acrescimo', 'Valor Acréscimos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for total_pedido field
            //
            $column = new NumberViewColumn('total_pedido', 'total_pedido', 'Total Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_observacao_handler_export');
            $grid->AddExportColumn($column);
            
            //
            // View column for situacao field
            //
            $column = new TextViewColumn('situacao', 'situacao', 'Situação', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for st_pedido field
            //
            $column = new TextViewColumn('st_pedido', 'st_pedido', 'Status do Pedido', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_obervacao_nota_handler_export');
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('finalidade_emissao', 'finalidade_emissao_ds_tabela', 'Finalidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for validade field
            //
            $column = new DateTimeViewColumn('validade', 'validade', 'Validade', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y');
            $grid->AddExportColumn($column);
        }
    
        private function AddCompareColumns(Grid $grid)
        {
            //
            // View column for pedido_o field
            //
            $column = new TextViewColumn('pedido_o', 'pedido_o', 'Referencia', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for emissao field
            //
            $column = new DateTimeViewColumn('emissao', 'emissao', 'Emissão', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y H:i:s');
            $grid->AddCompareColumn($column);
            
            //
            // View column for entrega field
            //
            $column = new TextViewColumn('entrega', 'entrega', 'Entrega', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_cadastro', 'id_cadastro_nome', 'Cliente', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for fantasia field
            //
            $column = new TextViewColumn('id_vendedor', 'id_vendedor_fantasia', 'Vendedor', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('id_condicao_pg', 'id_condicao_pg_descricao', 'Condição Pgto', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('tp_frete', 'tp_frete_ds_tabela', 'Tp Frete', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for nome field
            //
            $column = new TextViewColumn('id_transportadora', 'id_transportadora_nome', 'Transportadora', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for responsavel field
            //
            $column = new TextViewColumn('responsavel', 'responsavel', 'Responsavel', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for total_produtos field
            //
            $column = new NumberViewColumn('total_produtos', 'total_produtos', 'Total Produtos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for valor_frete field
            //
            $column = new NumberViewColumn('valor_frete', 'valor_frete', 'Valor de Frete', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for valor_acrescimo field
            //
            $column = new NumberViewColumn('valor_acrescimo', 'valor_acrescimo', 'Valor Acréscimos', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for total_pedido field
            //
            $column = new NumberViewColumn('total_pedido', 'total_pedido', 'Total Pedido', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_observacao_handler_compare');
            $grid->AddCompareColumn($column);
            
            //
            // View column for situacao field
            //
            $column = new TextViewColumn('situacao', 'situacao', 'Situação', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for st_pedido field
            //
            $column = new TextViewColumn('st_pedido', 'st_pedido', 'Status do Pedido', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('pedidoGrid_obervacao_nota_handler_compare');
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('finalidade_emissao', 'finalidade_emissao_ds_tabela', 'Finalidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for validade field
            //
            $column = new DateTimeViewColumn('validade', 'validade', 'Validade', $this->dataset);
            $column->SetOrderable(true);
            $column->SetDateTimeFormat('d.m.Y');
            $grid->AddCompareColumn($column);
        }
    
        private function AddCompareHeaderColumns(Grid $grid)
        {
    
        }
    
        public function GetPageDirection()
        {
            return null;
        }
    
        public function isFilterConditionRequired()
        {
            return false;
        }
    
        protected function ApplyCommonColumnEditProperties(CustomEditColumn $column)
        {
            $column->SetDisplaySetToNullCheckBox(false);
            $column->SetDisplaySetToDefaultCheckBox(false);
    		$column->SetVariableContainer($this->GetColumnVariableContainer());
        }
    
        function CreateMasterDetailRecordGrid()
        {
            $result = new Grid($this, $this->dataset);
            
            $this->AddFieldColumns($result, false);
            $this->AddPrintColumns($result);
            $this->AddExportColumns($result);
            
            $result->SetAllowDeleteSelected(false);
            $result->SetShowUpdateLink(false);
            $result->SetShowKeyColumnsImagesInHeader(false);
            $result->SetViewMode(ViewMode::TABLE);
            $result->setEnableRuntimeCustomization(false);
            $result->setTableBordered(false);
            $result->setTableCondensed(false);
            
            $this->setupGridColumnGroup($result);
            $this->attachGridEventHandlers($result);
            
            return $result;
        }
        
        function GetCustomClientScript()
        {
            return ;
        }
        
        function GetOnPageLoadedClientScript()
        {
            return ;
        }
        
        public function GetEnableModalGridInsert() { return true; }
        public function GetEnableModalSingleRecordView() { return true; }
        
        public function GetEnableModalGridEdit() { return true; }
        
        protected function GetEnableModalGridDelete() { return true; }
        
        public function GetEnableModalGridCopy() { return true; }
    
        protected function CreateGrid()
        {
            $result = new Grid($this, $this->dataset);
            if ($this->GetSecurityInfo()->HasDeleteGrant())
               $result->SetAllowDeleteSelected(false);
            else
               $result->SetAllowDeleteSelected(false);   
            
            ApplyCommonPageSettings($this, $result);
            
            $result->SetUseImagesForActions(true);
            $defaultSortedColumns = array();
            $defaultSortedColumns[] = new SortColumn('id_pedido', 'DESC');
            $result->setDefaultOrdering($defaultSortedColumns);
            $result->SetUseFixedHeader(false);
            $result->SetShowLineNumbers(false);
            $result->SetViewMode(ViewMode::TABLE);
            $result->setEnableRuntimeCustomization(true);
            $result->setAllowCompare(true);
            $this->AddCompareHeaderColumns($result);
            $this->AddCompareColumns($result);
            $result->setMultiEditAllowed($this->GetSecurityInfo()->HasEditGrant() && false);
            $result->setTableBordered(false);
            $result->setTableCondensed(false);
            
            $result->SetHighlightRowAtHover(false);
            $result->SetWidth('');
            $this->AddOperationsColumns($result);
            $this->AddFieldColumns($result);
            $this->AddSingleRecordViewColumns($result);
            $this->AddEditColumns($result);
            $this->AddMultiEditColumns($result);
            $this->AddInsertColumns($result);
            $this->AddPrintColumns($result);
            $this->AddExportColumns($result);
            $this->AddMultiUploadColumn($result);
    
    
            $this->SetShowPageList(true);
            $this->SetShowTopPageNavigator(true);
            $this->SetShowBottomPageNavigator(true);
            $this->setPrintListAvailable(false);
            $this->setPrintListRecordAvailable(false);
            $this->setPrintOneRecordAvailable(false);
            $this->setAllowPrintSelectedRecords(true);
            $this->setExportListAvailable(array('pdf', 'excel', 'word'));
            $this->setExportSelectedRecordsAvailable(array('pdf', 'excel', 'word', 'xml', 'csv'));
            $this->setExportListRecordAvailable(array());
            $this->setExportOneRecordAvailable(array('pdf', 'excel', 'word'));
    
            return $result;
        }
     
        protected function setClientSideEvents(Grid $grid) {
    
        }
    
        protected function doRegisterHandlers() {
            $detailPage = new pedido_pedido_item01Page('pedido_pedido_item01', $this, array('id_pedido'), array('id_pedido'), $this->GetForeignKeyFields(), $this->CreateMasterDetailRecordGrid(), $this->dataset, GetCurrentUserPermissionSetForDataSource('pedido.pedido_item01'), 'UTF-8');
            $detailPage->SetRecordPermission(GetCurrentUserRecordPermissionsForDataSource('pedido.pedido_item01'));
            $detailPage->SetHttpHandlerName('pedido_pedido_item01_handler');
            $handler = new PageHTTPHandler('pedido_pedido_item01_handler', $detailPage);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_observacao_handler_list', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_obervacao_nota_handler_list', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_observacao_handler_print', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_obervacao_nota_handler_print', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_observacao_handler_compare', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_obervacao_nota_handler_compare', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`cadastro`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_cadastro', true, true, true),
                    new StringField('nome'),
                    new StringField('endereco'),
                    new IntegerField('numero'),
                    new StringField('complemento'),
                    new StringField('bairro'),
                    new StringField('cep'),
                    new StringField('cidade'),
                    new StringField('cd_municipio'),
                    new StringField('estado'),
                    new StringField('telefone'),
                    new StringField('celular'),
                    new StringField('email'),
                    new StringField('contato'),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao'),
                    new StringField('identidade'),
                    new IntegerField('id_vendedor'),
                    new DateTimeField('data_mov_s'),
                    new StringField('endereco_cobranca'),
                    new StringField('observacao'),
                    new IntegerField('id_indicador_ie'),
                    new IntegerField('id_regime'),
                    new IntegerField('id_licencas')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $handler = new DynamicSearchHandler($lookupDataset, $this, 'filter_builder_pedido_pedido_item01_id_cadastro_search', 'id_cadastro', 'nome', null, 20);
            GetApplication()->RegisterHTTPHandler($handler);
            
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`vendedor`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_vendedor', true, true, true),
                    new StringField('nome', true),
                    new StringField('fantasia', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new StringField('cnpj', true),
                    new StringField('cpf', true),
                    new StringField('inscricao', true),
                    new StringField('identidade', true),
                    new IntegerField('comissao', true)
                )
            );
            $lookupDataset->setOrderByField('fantasia', 'ASC');
            $handler = new DynamicSearchHandler($lookupDataset, $this, 'filter_builder_pedido_pedido_item01_id_vendedor_search', 'id_vendedor', 'fantasia', null, 20);
            GetApplication()->RegisterHTTPHandler($handler);
            
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`condicao_pg`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_condicao_pg', true, true, true),
                    new StringField('descricao', true)
                )
            );
            $lookupDataset->setOrderByField('descricao', 'ASC');
            $handler = new DynamicSearchHandler($lookupDataset, $this, 'filter_builder_pedido_pedido_item01_id_condicao_pg_search', 'id_condicao_pg', 'descricao', null, 20);
            GetApplication()->RegisterHTTPHandler($handler);
            
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`modalidade_frete`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $handler = new DynamicSearchHandler($lookupDataset, $this, 'filter_builder_pedido_pedido_item01_tp_frete_search', 'id_tabelas', 'ds_tabela', null, 20);
            GetApplication()->RegisterHTTPHandler($handler);
            
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`transportadora`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_transportadora', true, true, true),
                    new StringField('nome', true),
                    new StringField('endereco', true),
                    new StringField('bairro', true),
                    new StringField('cep', true),
                    new StringField('cidade', true),
                    new StringField('estado', true),
                    new StringField('telefone', true),
                    new StringField('celular', true),
                    new StringField('email', true),
                    new StringField('contato', true),
                    new IntegerField('cd_frete', true),
                    new StringField('placa', true),
                    new StringField('cnpj'),
                    new StringField('cpf'),
                    new StringField('inscricao')
                )
            );
            $lookupDataset->setOrderByField('nome', 'ASC');
            $handler = new DynamicSearchHandler($lookupDataset, $this, 'filter_builder_pedido_pedido_item01_id_transportadora_search', 'id_transportadora', 'nome', null, 20);
            GetApplication()->RegisterHTTPHandler($handler);
            
            $lookupDataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`finalidade_emissao`');
            $lookupDataset->addFields(
                array(
                    new IntegerField('id_tabelas', true),
                    new StringField('nm_arquivo'),
                    new IntegerField('nu_campo'),
                    new StringField('nm_campo'),
                    new StringField('cd_tabela', true),
                    new StringField('ds_tabela')
                )
            );
            $lookupDataset->setOrderByField('ds_tabela', 'ASC');
            $handler = new DynamicSearchHandler($lookupDataset, $this, 'filter_builder_pedido_pedido_item01_finalidade_emissao_search', 'cd_tabela', 'ds_tabela', null, 20);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for observacao field
            //
            $column = new TextViewColumn('observacao', 'observacao', 'Observação', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_observacao_handler_view', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for obervacao_nota field
            //
            $column = new TextViewColumn('obervacao_nota', 'obervacao_nota', 'Observação da Nota', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'pedidoGrid_obervacao_nota_handler_view', $column);
            GetApplication()->RegisterHTTPHandler($handler);
        }
       
        protected function doCustomRenderColumn($fieldName, $fieldData, $rowData, &$customText, &$handled)
        { 
            if ($fieldName == 'situacao')
            {
               if ($fieldData == 'ORCAMENTO'){
                  $customText = '<a href="php/orcamento.php?id=' .$rowData['id_pedido'] .'" target="_blank">OR&Ccedil;AMENTO</a>';
                   $handled = true;
               }
               if ($fieldData == 'PEDIDO'){
                  $customText = '<a href="php/pedido.php?id=' .$rowData['id_pedido'] .'" target="_blank">PEDIDO</a>';
                   $handled = true;
               }   
            }
            if ($fieldName == 'st_pedido')
            {
               if ($fieldData != 'FINALIZADO'){
                  $customText = '<a href="php/emitir_nf.php?id=' .$rowData['id_pedido'] .'">Emitir NF</a>';
                   $handled = true;
               }   
            }
        }
    
        protected function doCustomRenderPrintColumn($fieldName, $fieldData, $rowData, &$customText, &$handled)
        { 
    
        }
    
        protected function doCustomRenderExportColumn($exportType, $fieldName, $fieldData, $rowData, &$customText, &$handled)
        { 
    
        }
    
        protected function doCustomDrawRow($rowData, &$cellFontColor, &$cellFontSize, &$cellBgColor, &$cellItalicAttr, &$cellBoldAttr)
        {
    
        }
    
        protected function doExtendedCustomDrawRow($rowData, &$rowCellStyles, &$rowStyles, &$rowClasses, &$cellClasses)
        {
    
        }
    
        protected function doCustomRenderTotal($totalValue, $aggregate, $columnName, &$customText, &$handled)
        {
    
        }
    
        protected function doCustomDefaultValues(&$values, &$handled) 
        {
    
        }
    
        protected function doCustomCompareColumn($columnName, $valueA, $valueB, &$result)
        {
    
        }
    
        protected function doBeforeInsertRecord($page, &$rowData, $tableName, &$cancel, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doBeforeUpdateRecord($page, $oldRowData, &$rowData, $tableName, &$cancel, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doBeforeDeleteRecord($page, &$rowData, $tableName, &$cancel, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doAfterInsertRecord($page, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
            $cp_sql = 'select ifnull(if(pedido.situacao="ORCAMENTO",sum(qtd_orcamento*(preco-vlr_desconto)),sum(qtd_pedido*(preco-vlr_desconto))),0) as vlr from pedido_item
             inner join pedido on pedido.id_pedido=pedido_item.id_pedido
             where pedido_item.id_pedido='.$rowData['id_pedido'];
            $cp_produtos = $this->GetConnection()->ExecScalarSQL($cp_sql);
            $cp_sql = 'select ifnull(sum(vlr_desconto),0) as vlr from pedido_item where id_pedido='.$rowData['id_pedido'];
            $cp_desconto = $this->GetConnection()->ExecScalarSQL($cp_sql);
            
            $cp_sql = 'UPDATE pedido SET pedido.total_produtos=' .$cp_produtos. ', pedido.valor_desc=' .$cp_desconto. ', pedido.total_pedido=' .$cp_produtos. '+pedido.valor_frete+pedido.valor_acrescimo- ' .$cp_desconto. ' WHERE id_pedido='.$rowData['id_pedido'];
            $this->GetConnection()->ExecSQL($cp_sql);
        }
    
        protected function doAfterUpdateRecord($page, $oldRowData, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
            $cp_sql = 'select ifnull(if(pedido.situacao="ORCAMENTO",sum(qtd_orcamento*(preco-vlr_desconto)),sum(qtd_pedido*(preco-vlr_desconto))),0) as vlr from pedido_item
             inner join pedido on pedido.id_pedido=pedido_item.id_pedido
             where pedido_item.id_pedido='.$rowData['id_pedido'];
            $cp_produtos = $this->GetConnection()->ExecScalarSQL($cp_sql);
            $cp_sql = 'select ifnull(sum(vlr_desconto),0) as vlr from pedido_item where id_pedido='.$rowData['id_pedido'];
            $cp_desconto = $this->GetConnection()->ExecScalarSQL($cp_sql);
            
            $cp_sql = 'UPDATE pedido SET pedido.total_produtos=' .$cp_produtos. ', pedido.valor_desc=' .$cp_desconto. ', pedido.total_pedido=' .$cp_produtos. '+pedido.valor_frete+pedido.valor_acrescimo- ' .$cp_desconto. ' WHERE id_pedido='.$rowData['id_pedido'];
            $this->GetConnection()->ExecSQL($cp_sql);
        }
    
        protected function doAfterDeleteRecord($page, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
    
        }
    
        protected function doCustomHTMLHeader($page, &$customHtmlHeaderText)
        { 
    
        }
    
        protected function doGetCustomTemplate($type, $part, $mode, &$result, &$params)
        {
    
        }
    
        protected function doGetCustomExportOptions(Page $page, $exportType, $rowData, &$options)
        {
    
        }
    
        protected function doFileUpload($fieldName, $rowData, &$result, &$accept, $originalFileName, $originalFileExtension, $fileSize, $tempFileName)
        {
    
        }
    
        protected function doPrepareChart(Chart $chart)
        {
    
        }
    
        protected function doPrepareColumnFilter(ColumnFilter $columnFilter)
        {
    
        }
    
        protected function doPrepareFilterBuilder(FilterBuilder $filterBuilder, FixedKeysArray $columns)
        {
    
        }
    
        protected function doGetSelectionFilters(FixedKeysArray $columns, &$result)
        {
    
        }
    
        protected function doGetCustomFormLayout($mode, FixedKeysArray $columns, FormLayout $layout)
        {
    
        }
    
        protected function doGetCustomColumnGroup(FixedKeysArray $columns, ViewColumnGroup $columnGroup)
        {
    
        }
    
        protected function doPageLoaded()
        {
    
        }
    
        protected function doCalculateFields($rowData, $fieldName, &$value)
        {
    
        }
    
        protected function doGetCustomPagePermissions(Page $page, PermissionSet &$permissions, &$handled)
        {
    
        }
    
        protected function doGetCustomRecordPermissions(Page $page, &$usingCondition, $rowData, &$allowEdit, &$allowDelete, &$mergeWithDefault, &$handled)
        {
    
        }
    
    }

    SetUpUserAuthorization();

    try
    {
        $Page = new pedidoPage("pedido", "pedido.php", GetCurrentUserPermissionSetForDataSource("pedido"), 'UTF-8');
        $Page->SetRecordPermission(GetCurrentUserRecordPermissionsForDataSource("pedido"));
        GetApplication()->SetMainPage($Page);
        GetApplication()->Run();
    }
    catch(Exception $e)
    {
        ShowErrorPage($e);
    }
	
