<?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 produtoPage extends Page
    {
        protected function DoBeforeCreate()
        {
            $this->SetTitle('Produto');
            $this->SetMenuLabel('Produto');
            $this->SetHeader(GetPagesHeader());
            $this->SetFooter(GetPagesFooter());
    
            $this->dataset = new TableDataset(
                MyConnectionFactory::getInstance(),
                GetConnectionOptions(),
                '`produto`');
            $this->dataset->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')
                )
            );
            $this->dataset->AddLookupField('cfop', 'cfop', new IntegerField('id_codigo_cfop'), new StringField('cfop', false, false, false, false, 'cfop_cfop', 'cfop_cfop_cfop'), 'cfop_cfop_cfop');
            $this->dataset->AddLookupField('ncm', 'ncm', new IntegerField('id_codigo_ncm'), 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('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');
            $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');
        }
    
        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_produto', 'id_produto', 'Id Produto'),
                new FilterColumn($this->dataset, 'unidade', 'unidade', 'Unidade'),
                new FilterColumn($this->dataset, 'descricao', 'descricao', 'Descrição'),
                new FilterColumn($this->dataset, 'preco_venda', 'preco_venda', 'Preço Venda'),
                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, 'peso_liquido_kg', 'peso_liquido_kg', 'Peso Liquido Kg'),
                new FilterColumn($this->dataset, 'peso_bruto_kg', 'peso_bruto_kg', 'Peso Bruto Kg'),
                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', 'Código PIS'),
                new FilterColumn($this->dataset, 'cd_cofins', 'cd_cofins_ds_tabela', 'Código Cofins'),
                new FilterColumn($this->dataset, 'icms_origem', 'icms_origem_ds_tabela', 'Icms Origem'),
                new FilterColumn($this->dataset, 'icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo'),
                new FilterColumn($this->dataset, 'ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal')
            );
        }
    
        protected function setupQuickFilter(QuickFilter $quickFilter, FixedKeysArray $columns)
        {
    
        }
    
        protected function setupColumnFilter(ColumnFilter $columnFilter)
        {
            $columnFilter
                ->setOptionsFor('cfop')
                ->setOptionsFor('ncm')
                ->setOptionsFor('cd_cst_icms')
                ->setOptionsFor('cd_cst_ipi')
                ->setOptionsFor('cd_pis')
                ->setOptionsFor('cd_cofins')
                ->setOptionsFor('icms_origem')
                ->setOptionsFor('icms_modalidade_base_calculo')
                ->setOptionsFor('ipi_codigo_enquadramento_legal');
        }
    
        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 id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto', 'Id Produto', $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 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 descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('produtoGrid_descricao_handler_list');
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
            
            //
            // View column for preco_venda field
            //
            $column = new NumberViewColumn('preco_venda', 'preco_venda', 'Preço Venda', $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 peso_liquido_kg field
            //
            $column = new NumberViewColumn('peso_liquido_kg', 'peso_liquido_kg', 'Peso Liquido Kg', $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 peso_bruto_kg field
            //
            $column = new NumberViewColumn('peso_bruto_kg', 'peso_bruto_kg', 'Peso Bruto Kg', $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 ds_tabela field
            //
            $column = new TextViewColumn('cd_cst_icms', 'cd_cst_icms_ds_tabela', 'CST ICMS', $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('cd_cst_ipi', 'cd_cst_ipi_ds_tabela', 'CST IPI', $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('cd_pis', 'cd_pis_ds_tabela', 'Código PIS', $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('cd_cofins', 'cd_cofins_ds_tabela', 'Código Cofins', $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('icms_origem', 'icms_origem_ds_tabela', 'Icms Origem', $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('icms_modalidade_base_calculo', 'icms_modalidade_base_calculo_ds_tabela', 'Icms Modalidade Base Calculo', $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('ipi_codigo_enquadramento_legal', 'ipi_codigo_enquadramento_legal_ds_tabela', 'Ipi Codigo Enquadramento Legal', $this->dataset);
            $column->SetOrderable(true);
            $column->setMinimalVisibility(ColumnVisibility::PHONE);
            $column->SetDescription('');
            $column->SetFixedWidth(null);
            $grid->AddViewColumn($column);
        }
    
        protected function AddSingleRecordViewColumns(Grid $grid)
        {
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto', 'Id Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $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 descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('produtoGrid_descricao_handler_view');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for preco_venda field
            //
            $column = new NumberViewColumn('preco_venda', 'preco_venda', 'Preço Venda', $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 peso_liquido_kg field
            //
            $column = new NumberViewColumn('peso_liquido_kg', 'peso_liquido_kg', 'Peso Liquido Kg', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for peso_bruto_kg field
            //
            $column = new NumberViewColumn('peso_bruto_kg', 'peso_bruto_kg', 'Peso Bruto Kg', $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', 'Código PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddSingleRecordViewColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'Código 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 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 descricao field
            //
            $editor = new TextAreaEdit('descricao_edit', 60, 2);
            $editor->setPlaceholder('máximo de 120 caracteres');
            $editColumn = new CustomEditColumn('Descrição', 'descricao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for preco_venda field
            //
            $editor = new TextEdit('preco_venda_edit');
            $editColumn = new CustomEditColumn('Preço Venda', 'preco_venda', $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, 'id_codigo_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, 'id_codigo_ncm', '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 peso_liquido_kg field
            //
            $editor = new TextEdit('peso_liquido_kg_edit');
            $editColumn = new CustomEditColumn('Peso Liquido Kg', 'peso_liquido_kg', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddEditColumn($editColumn);
            
            //
            // Edit column for peso_bruto_kg field
            //
            $editor = new TextEdit('peso_bruto_kg_edit');
            $editColumn = new CustomEditColumn('Peso Bruto Kg', 'peso_bruto_kg', $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(
                'Código 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(
                'Código 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);
        }
    
        protected function AddMultiEditColumns(Grid $grid)
        {
            //
            // 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 descricao field
            //
            $editor = new TextAreaEdit('descricao_edit', 60, 2);
            $editor->setPlaceholder('máximo de 120 caracteres');
            $editColumn = new CustomEditColumn('Descrição', 'descricao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for preco_venda field
            //
            $editor = new TextEdit('preco_venda_edit');
            $editColumn = new CustomEditColumn('Preço Venda', 'preco_venda', $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, 'id_codigo_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, 'id_codigo_ncm', '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(
                'Código 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(
                'Código Cofins', 
                'cd_cofins', 
                $editor, 
                $this->dataset, 'cd_tabela', 'ds_tabela', $lookupDataset);
            $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 peso_liquido_kg field
            //
            $editor = new TextEdit('peso_liquido_kg_edit');
            $editColumn = new CustomEditColumn('Peso Liquido Kg', 'peso_liquido_kg', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddMultiEditColumn($editColumn);
            
            //
            // Edit column for peso_bruto_kg field
            //
            $editor = new TextEdit('peso_bruto_kg_edit');
            $editColumn = new CustomEditColumn('Peso Bruto Kg', 'peso_bruto_kg', $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 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 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);
        }
    
        protected function AddInsertColumns(Grid $grid)
        {
            //
            // 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 descricao field
            //
            $editor = new TextAreaEdit('descricao_edit', 60, 2);
            $editor->setPlaceholder('máximo de 120 caracteres');
            $editColumn = new CustomEditColumn('Descrição', 'descricao', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for preco_venda field
            //
            $editor = new TextEdit('preco_venda_edit');
            $editColumn = new CustomEditColumn('Preço Venda', 'preco_venda', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $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, 'id_codigo_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, 'id_codigo_ncm', '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);
            $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);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for peso_liquido_kg field
            //
            $editor = new TextEdit('peso_liquido_kg_edit');
            $editColumn = new CustomEditColumn('Peso Liquido Kg', 'peso_liquido_kg', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $this->ApplyCommonColumnEditProperties($editColumn);
            $grid->AddInsertColumn($editColumn);
            
            //
            // Edit column for peso_bruto_kg field
            //
            $editor = new TextEdit('peso_bruto_kg_edit');
            $editColumn = new CustomEditColumn('Peso Bruto Kg', 'peso_bruto_kg', $editor, $this->dataset);
            $editColumn->SetAllowSetToNull(true);
            $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(
                'Código 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(
                'Código 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);
            $grid->SetShowAddButton(true && $this->GetSecurityInfo()->HasAddGrant());
        }
    
        private function AddMultiUploadColumn(Grid $grid)
        {
    
        }
    
        protected function AddPrintColumns(Grid $grid)
        {
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto', 'Id Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $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 descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('produtoGrid_descricao_handler_print');
            $grid->AddPrintColumn($column);
            
            //
            // View column for preco_venda field
            //
            $column = new NumberViewColumn('preco_venda', 'preco_venda', 'Preço Venda', $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 peso_liquido_kg field
            //
            $column = new NumberViewColumn('peso_liquido_kg', 'peso_liquido_kg', 'Peso Liquido Kg', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddPrintColumn($column);
            
            //
            // View column for peso_bruto_kg field
            //
            $column = new NumberViewColumn('peso_bruto_kg', 'peso_bruto_kg', 'Peso Bruto Kg', $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', 'Código PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddPrintColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'Código 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('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 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);
        }
    
        protected function AddExportColumns(Grid $grid)
        {
            //
            // View column for id_produto field
            //
            $column = new NumberViewColumn('id_produto', 'id_produto', 'Id Produto', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(0);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator('');
            $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 descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('produtoGrid_descricao_handler_export');
            $grid->AddExportColumn($column);
            
            //
            // View column for preco_venda field
            //
            $column = new NumberViewColumn('preco_venda', 'preco_venda', 'Preço Venda', $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 peso_liquido_kg field
            //
            $column = new NumberViewColumn('peso_liquido_kg', 'peso_liquido_kg', 'Peso Liquido Kg', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddExportColumn($column);
            
            //
            // View column for peso_bruto_kg field
            //
            $column = new NumberViewColumn('peso_bruto_kg', 'peso_bruto_kg', 'Peso Bruto Kg', $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', 'Código PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddExportColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'Código 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('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 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);
        }
    
        private function AddCompareColumns(Grid $grid)
        {
            //
            // View column for unidade field
            //
            $column = new TextViewColumn('unidade', 'unidade', 'Unidade', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $column->SetMaxLength(75);
            $column->SetFullTextWindowHandlerName('produtoGrid_descricao_handler_compare');
            $grid->AddCompareColumn($column);
            
            //
            // View column for preco_venda field
            //
            $column = new NumberViewColumn('preco_venda', 'preco_venda', 'Preço Venda', $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 peso_liquido_kg field
            //
            $column = new NumberViewColumn('peso_liquido_kg', 'peso_liquido_kg', 'Peso Liquido Kg', $this->dataset);
            $column->SetOrderable(true);
            $column->setNumberAfterDecimal(2);
            $column->setThousandsSeparator('.');
            $column->setDecimalSeparator(',');
            $grid->AddCompareColumn($column);
            
            //
            // View column for peso_bruto_kg field
            //
            $column = new NumberViewColumn('peso_bruto_kg', 'peso_bruto_kg', 'Peso Bruto Kg', $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', 'Código PIS', $this->dataset);
            $column->SetOrderable(true);
            $grid->AddCompareColumn($column);
            
            //
            // View column for ds_tabela field
            //
            $column = new TextViewColumn('cd_cofins', 'cd_cofins_ds_tabela', 'Código 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('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 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);
        }
    
        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', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'produtoGrid_descricao_handler_list', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'produtoGrid_descricao_handler_print', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'produtoGrid_descricao_handler_compare', $column);
            GetApplication()->RegisterHTTPHandler($handler);
            
            //
            // View column for descricao field
            //
            $column = new TextViewColumn('descricao', 'descricao', 'Descrição', $this->dataset);
            $column->SetOrderable(true);
            $handler = new ShowTextBlobHandler($this->dataset, $this, 'produtoGrid_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)
        {
    
        }
    
        protected function doAfterUpdateRecord($page, $oldRowData, $rowData, $tableName, &$success, &$message, &$messageDisplayTime)
        {
    
        }
    
        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 produtoPage("produto", "produto.php", GetCurrentUserPermissionSetForDataSource("produto"), 'UTF-8');
        $Page->SetRecordPermission(GetCurrentUserRecordPermissionsForDataSource("produto"));
        GetApplication()->SetMainPage($Page);
        GetApplication()->Run();
    }
    catch(Exception $e)
    {
        ShowErrorPage($e);
    }
	
