290 lines
16 KiB
C#
290 lines
16 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace UI.Dashboards.Fiscal
|
|
{
|
|
public class SatFiscalConsumidorItensPanel : FormularioModelo
|
|
{
|
|
// Aplicação de (?) para sanar os avisos de campos não nulos ao sair do construtor (NRT net8.0)
|
|
private TabControl? tabItens;
|
|
|
|
// --- ABA 1: DADOS GERAIS DO PRODUTO ---
|
|
private LV_TEXTBOX1? txtIdSatFiscalConsItens, txtCodigo, txtCodNfce, txtItemTipo, txtItemCean, txtItemCprod, txtItemXprod, txtItemInfAdic, txtDataCadastro;
|
|
|
|
// --- ABA 2: QUANTIDADES, VALORES E COMERCIAL ---
|
|
private LV_TEXTBOX1? txtItemCfop, txtItemNcm, txtItemUncom, txtItemQcom, txtItemVprod, txtItemVoutro, txtItemVfrete, txtItemVseg, txtItemVdesc, txtItemVTotTrib, txtItemCest, txtCProdAnp, txtCBenef;
|
|
|
|
// --- ABA 3: ICMS (NORMAL E ST) ---
|
|
private LV_TEXTBOX1? txtItemOrigem, txtItemCst, txtItemIcmsModBc, txtItemIcmsPRedBc, txtItemIcmsVBc, txtItemIcmsPIcms, txtItemIcmsVIcms, txtItemIcmsVIcmsDeson, txtItemIcmsMotDesIcms, txtItemIcmsModBcSt, txtItemIcmsPMvast, txtItemIcmsPRedBcSt, txtItemIcmsVBcSt, txtItemIcmsPIcmsSt, txtItemIcmsVIcmsSt;
|
|
|
|
// --- ABA 4: FCP (FUNDO DE COMBATE À POBREZA) ---
|
|
private LV_TEXTBOX1? txtItemPFcp, txtItemVFcp, txtItemVBcFcp, txtItemVBcFcpSt, txtItemPFcpSt, txtItemVFcpSt, txtItemPSt, txtItemVBcFcpStRet, txtItemPFcpStRet, txtItemVFcpStRet;
|
|
|
|
// --- ABA 5: PIS, COFINS E EFETIVOS ---
|
|
private LV_TEXTBOX1? txtItemPisCst, txtItemPisVBc, txtItemPisPPis, txtItemPisVPis, txtItemCofinsCst, txtItemCofinsVBc, txtItemCofinsPCofins, txtItemCofinsVCofins, txtVIcmsSubstituto, txtPRedBcEfet, txtVBcEfet, txtPIcmsEfet, txtVIcmsEfet;
|
|
|
|
public SatFiscalConsumidorItensPanel()
|
|
{
|
|
this.Titulo = "DETALHAMENTO DE ITENS DO CUPOM FISCAL";
|
|
MontarInterfaceCompleta();
|
|
}
|
|
|
|
private void MontarInterfaceCompleta()
|
|
{
|
|
tabItens = new TabControl
|
|
{
|
|
Location = new Point(10, 10),
|
|
Size = new Size(1060, 520),
|
|
Font = new Font("Segoe UI", 9.5f)
|
|
};
|
|
|
|
var tpGeral = new TabPage("Dados do Produto");
|
|
var tpComercial = new TabPage("Valores e Códigos");
|
|
var tpIcms = new TabPage("ICMS Normal / ST");
|
|
var tpFcp = new TabPage("FCP");
|
|
var tpPisCofins = new TabPage("PIS / COFINS / Efetivos");
|
|
|
|
// Simplificação da inicialização de coleção aceita pelo compilador moderno
|
|
tabItens.TabPages.AddRange([tpGeral, tpComercial, tpIcms, tpFcp, tpPisCofins]);
|
|
content.Controls.Add(tabItens);
|
|
|
|
ConfigurarAbaGeral(tpGeral);
|
|
ConfigurarAbaComercial(tpComercial);
|
|
ConfigurarAbaIcms(tpIcms);
|
|
ConfigurarAbaFcp(tpFcp);
|
|
ConfigurarAbaPisCofins(tpPisCofins);
|
|
}
|
|
|
|
private void ConfigurarAbaGeral(TabPage tp)
|
|
{
|
|
tp.Controls.Add(CreateSectionHeader("Identificação e Chaves do Item", 15));
|
|
txtIdSatFiscalConsItens = AddInput(tp, "ID ITEM REG.", 20, 50, 100, 28, true);
|
|
txtCodigo = AddInput(tp, "CÓDIGO INT.", 135, 50, 110, 28);
|
|
txtCodNfce = AddInput(tp, "CÓD. VÍNCULO NFC-E", 260, 50, 150, 28);
|
|
txtItemTipo = AddInput(tp, "TIPO ITEM", 425, 50, 120, 28);
|
|
txtDataCadastro = AddInput(tp, "DATA CADASTRO", 560, 50, 180, 28, true);
|
|
|
|
tp.Controls.Add(CreateSectionHeader("Especificações do Produto", 120));
|
|
txtItemCprod = AddInput(tp, "CÓD. COMERCIAL DO PRODUTO", 20, 155, 200, 28);
|
|
txtItemCean = AddInput(tp, "CÓDIGO EAN (CÓD. BARRAS)", 235, 155, 220, 28);
|
|
txtItemXprod = AddInput(tp, "DESCRIÇÃO DO PRODUTO / SERVIÇO", 20, 215, 600, 28);
|
|
txtItemInfAdic = AddInput(tp, "INFORMAÇÕES ADICIONAIS DO ITEM", 20, 275, 600, 28);
|
|
}
|
|
|
|
private void ConfigurarAbaComercial(TabPage tp)
|
|
{
|
|
tp.Controls.Add(CreateSectionHeader("Classificações Fiscais Obrigatórias", 15));
|
|
txtItemCfop = AddInput(tp, "CFOP", 20, 50, 90, 28);
|
|
txtItemNcm = AddInput(tp, "NCM", 125, 50, 120, 28);
|
|
txtItemCest = AddInput(tp, "CEST", 260, 50, 120, 28);
|
|
txtCProdAnp = AddInput(tp, "CÓD. ANP (COMBUSTÍVEIS)", 395, 50, 180, 28);
|
|
txtCBenef = AddInput(tp, "BENEFÍCIO FISCAL (CBENEF)", 590, 50, 180, 28);
|
|
|
|
tp.Controls.Add(CreateSectionHeader("Valores Comerciais, Quantidades e Rateios", 120));
|
|
txtItemUncom = AddInput(tp, "UNIDADE MEDIDA", 20, 155, 100, 28);
|
|
txtItemQcom = AddInput(tp, "QUANTIDADE COMERCIAL", 135, 155, 140, 28);
|
|
txtItemVprod = AddInput(tp, "VALOR BRUTO PROD. (R$)", 290, 155, 150, 28);
|
|
txtItemVdesc = AddInput(tp, "VALOR DESCONTO (R$)", 455, 155, 140, 28);
|
|
|
|
txtItemVfrete = AddInput(tp, "RATEIO FRETE (R$)", 20, 215, 140, 28);
|
|
txtItemVseg = AddInput(tp, "RATEIO SEGURO (R$)", 175, 215, 140, 28);
|
|
txtItemVoutro = AddInput(tp, "OUTRAS DESPESAS (R$)", 330, 215, 150, 28);
|
|
txtItemVTotTrib = AddInput(tp, "VALOR APROX. TRIBUTOS", 495, 215, 160, 28);
|
|
}
|
|
|
|
private void ConfigurarAbaIcms(TabPage tp)
|
|
{
|
|
tp.Controls.Add(CreateSectionHeader("ICMS Regra Geral e Base de Cálculo", 15));
|
|
txtItemOrigem = AddInput(tp, "ORIGEM PROD.", 20, 50, 100, 28);
|
|
txtItemCst = AddInput(tp, "CST / CSOSN", 135, 50, 100, 28);
|
|
txtItemIcmsModBc = AddInput(tp, "MODALIDADE BC ICMS", 250, 50, 150, 28);
|
|
txtItemIcmsPRedBc = AddInput(tp, "% REDUÇÃO BC", 415, 50, 120, 28);
|
|
txtItemIcmsVBc = AddInput(tp, "VALOR BC ICMS", 550, 50, 130, 28);
|
|
txtItemIcmsPIcms = AddInput(tp, "ALÍQUOTA ICMS", 695, 50, 120, 28);
|
|
txtItemIcmsVIcms = AddInput(tp, "VALOR ICMS", 830, 50, 130, 28);
|
|
|
|
tp.Controls.Add(CreateSectionHeader("ICMS Desonerado e Regras de Substituição Tributária (ST)", 120));
|
|
txtItemIcmsVIcmsDeson = AddInput(tp, "VALOR ICMS DESON.", 20, 155, 150, 28);
|
|
txtItemIcmsMotDesIcms = AddInput(tp, "MOTIVO DESON.", 185, 155, 140, 28); // Corrigido a inconsistência de caixa alta/baixa
|
|
txtItemIcmsModBcSt = AddInput(tp, "MODALIDADE BC ST", 340, 155, 140, 28);
|
|
txtItemIcmsPMvast = AddInput(tp, "% MVA ST", 495, 155, 110, 28);
|
|
txtItemIcmsPRedBcSt = AddInput(tp, "% REDUÇÃO BC ST", 620, 155, 130, 28);
|
|
|
|
txtItemIcmsVBcSt = AddInput(tp, "VALOR BASE CÁLCULO ST", 20, 215, 170, 28);
|
|
txtItemIcmsPIcmsSt = AddInput(tp, "ALÍQUOTA ICMS ST", 205, 215, 140, 28);
|
|
txtItemIcmsVIcmsSt = AddInput(tp, "VALOR DO ICMS ST", 360, 215, 150, 28);
|
|
}
|
|
|
|
private void ConfigurarAbaFcp(TabPage tp)
|
|
{
|
|
tp.Controls.Add(CreateSectionHeader("Fundo de Combate à Pobreza - ICMS Normal e ST", 15));
|
|
txtItemVBcFcp = AddInput(tp, "VALOR BC FCP", 20, 50, 130, 28);
|
|
txtItemPFcp = AddInput(tp, "% ALÍQUOTA FCP", 165, 50, 130, 28);
|
|
txtItemVFcp = AddInput(tp, "VALOR DO FCP", 310, 50, 130, 28);
|
|
|
|
txtItemVBcFcpSt = AddInput(tp, "VALOR BC FCP ST", 455, 50, 140, 28);
|
|
txtItemPFcpSt = AddInput(tp, "% ALÍQUOTA FCP ST", 610, 50, 140, 28);
|
|
txtItemVFcpSt = AddInput(tp, "VALOR DO FCP ST", 765, 50, 140, 28);
|
|
|
|
tp.Controls.Add(CreateSectionHeader("Fundo de Combate à Pobreza Retido Anteriormente", 120));
|
|
txtItemPSt = AddInput(tp, "% ALÍQUOTA ICMS ST RET.", 20, 155, 180, 28);
|
|
txtItemVBcFcpStRet = AddInput(tp, "VALOR BC FCP ST RET.", 215, 155, 160, 28);
|
|
txtItemPFcpStRet = AddInput(tp, "% ALÍQUOTA FCP ST RET.", 390, 155, 170, 28);
|
|
txtItemVFcpStRet = AddInput(tp, "VALOR DO FCP ST RET.", 575, 155, 160, 28); // Corrigido nomenclatura para bater com a propriedade da classe
|
|
}
|
|
|
|
private void ConfigurarAbaPisCofins(TabPage tp)
|
|
{
|
|
tp.Controls.Add(CreateSectionHeader("Contribuições para o PIS", 15));
|
|
txtItemPisCst = AddInput(tp, "CST PIS", 20, 50, 100, 28);
|
|
txtItemPisVBc = AddInput(tp, "VALOR BC PIS", 135, 50, 130, 28);
|
|
txtItemPisPPis = AddInput(tp, "% ALÍQUOTA PIS", 280, 50, 120, 28);
|
|
txtItemPisVPis = AddInput(tp, "VALOR DO PIS", 415, 50, 130, 28);
|
|
|
|
tp.Controls.Add(CreateSectionHeader("Contribuições para a COFINS", 120));
|
|
txtItemCofinsCst = AddInput(tp, "CST COFINS", 20, 155, 100, 28);
|
|
txtItemCofinsVBc = AddInput(tp, "VALOR BC COFINS", 135, 155, 130, 28);
|
|
txtItemCofinsPCofins = AddInput(tp, "% ALÍQUOTA COFINS", 280, 155, 140, 28);
|
|
txtItemCofinsVCofins = AddInput(tp, "VALOR DO COFINS", 435, 155, 140, 28);
|
|
|
|
tp.Controls.Add(CreateSectionHeader("Indicadores de Valores Fiscais Efetivos", 225));
|
|
txtVIcmsSubstituto = AddInput(tp, "VALOR ICMS SUBST.", 20, 260, 150, 28);
|
|
txtPRedBcEfet = AddInput(tp, "% REDUÇÃO BC EFET.", 185, 260, 150, 28);
|
|
txtVBcEfet = AddInput(tp, "VALOR BC EFETIVA", 350, 260, 140, 28);
|
|
txtPIcmsEfet = AddInput(tp, "% ALÍQUOTA ICMS EFET.", 505, 260, 160, 28);
|
|
txtVIcmsEfet = AddInput(tp, "VALOR ICMS EFETIVO", 680, 260, 150, 28);
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS DO FORMULÁRIO MODELO ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
// Substituição por função local (atende à sugestão do analisador C# moderno)
|
|
void LimparRecursivo(Control.ControlCollection controls)
|
|
{
|
|
foreach (Control c in controls)
|
|
{
|
|
if (c is LV_TEXTBOX1 txt && !txt.ReadOnly) txt.Text = string.Empty;
|
|
if (c.HasChildren) LimparRecursivo(c.Controls);
|
|
}
|
|
}
|
|
|
|
if (tabItens != null)
|
|
{
|
|
LimparRecursivo(tabItens.Controls);
|
|
tabItens.SelectedIndex = 0;
|
|
}
|
|
|
|
if (txtIdSatFiscalConsItens != null) txtIdSatFiscalConsItens.Text = "0";
|
|
if (txtDataCadastro != null) txtDataCadastro.Text = DateTime.Now.ToString("g");
|
|
|
|
txtItemCprod?.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
// Proteção nula com operador condicional para checagem segura
|
|
if (string.IsNullOrWhiteSpace(txtItemCprod?.Text))
|
|
{
|
|
MessageBox.Show("O código comercial do produto é obrigatório.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
if (tabItens != null) tabItens.SelectedIndex = 0;
|
|
txtItemCprod?.Focus();
|
|
return;
|
|
}
|
|
|
|
// Mapeamento usando Operador de Coalescência Nula (??) para garantir strings limpas
|
|
var item = new ModeloSatFiscalConsumidorItens
|
|
{
|
|
ID_SAT_FISCAL_CONS_ITENS = string.IsNullOrEmpty(txtIdSatFiscalConsItens?.Text) ? 0 : Convert.ToInt32(txtIdSatFiscalConsItens.Text),
|
|
CODIGO = txtCodigo?.Text ?? string.Empty,
|
|
COD_NFCE = txtCodNfce?.Text ?? string.Empty,
|
|
ITEM_TIPO = txtItemTipo?.Text ?? string.Empty,
|
|
ITEM_CEAN = txtItemCean?.Text ?? string.Empty,
|
|
ITEM_CPROD = txtItemCprod.Text,
|
|
ITEM_XPROD = txtItemXprod?.Text ?? string.Empty,
|
|
ITEM_INF_ADIC = txtItemInfAdic?.Text ?? string.Empty,
|
|
ITEM_CFOP = txtItemCfop?.Text ?? string.Empty,
|
|
ITEM_NCM = txtItemNcm?.Text ?? string.Empty,
|
|
ITEM_UNCOM = txtItemUncom?.Text ?? string.Empty,
|
|
ITEM_QCOM = txtItemQcom?.Text ?? string.Empty,
|
|
ITEM_VPROD = txtItemVprod?.Text ?? string.Empty,
|
|
ITEM_VOUTRO = txtItemVoutro?.Text ?? string.Empty,
|
|
ITEM_VFRETE = txtItemVfrete?.Text ?? string.Empty,
|
|
ITEM_VSEG = txtItemVseg?.Text ?? string.Empty,
|
|
ITEM_VDESC = txtItemVdesc?.Text ?? string.Empty,
|
|
ITEM_vTotTrib = txtItemVTotTrib?.Text ?? string.Empty,
|
|
ITEM_ORIGEM = txtItemOrigem?.Text ?? string.Empty,
|
|
ITEM_CST = txtItemCst?.Text ?? string.Empty,
|
|
DATA_CADASTRO = txtDataCadastro?.Text ?? string.Empty,
|
|
ITEM_ICMS_modBC = txtItemIcmsModBc?.Text ?? string.Empty,
|
|
ITEM_ICMS_pRedBC = txtItemIcmsPRedBc?.Text ?? string.Empty,
|
|
ITEM_ICMS_vBC = txtItemIcmsVBc?.Text ?? string.Empty,
|
|
ITEM_ICMS_pICMS = txtItemIcmsPIcms?.Text ?? string.Empty,
|
|
ITEM_ICMS_vICMS = txtItemIcmsVIcms?.Text ?? string.Empty,
|
|
ITEM_ICMS_vICMSDeson = txtItemIcmsVIcmsDeson?.Text ?? string.Empty,
|
|
ITEM_ICMS_motDesICMS = txtItemIcmsMotDesIcms?.Text ?? string.Empty,
|
|
ITEM_ICMS_modBCST = txtItemIcmsModBcSt?.Text ?? string.Empty,
|
|
ITEM_ICMS_pMVAST = txtItemIcmsPMvast?.Text ?? string.Empty,
|
|
ITEM_ICMS_pRedBCST = txtItemIcmsPRedBcSt?.Text ?? string.Empty,
|
|
ITEM_ICMS_vBCST = txtItemIcmsVBcSt?.Text ?? string.Empty,
|
|
ITEM_ICMS_pICMSST = txtItemIcmsPIcmsSt?.Text ?? string.Empty,
|
|
ITEM_ICMS_vICMSST = txtItemIcmsVIcmsSt?.Text ?? string.Empty,
|
|
ITEM_cProdANP = txtCProdAnp?.Text ?? string.Empty,
|
|
ITEM_CEST = txtItemCest?.Text ?? string.Empty,
|
|
CBenef = txtCBenef?.Text ?? string.Empty,
|
|
ITEM_pFCP = txtItemPFcp?.Text ?? string.Empty,
|
|
ITEM_vFCP = txtItemVFcp?.Text ?? string.Empty,
|
|
ITEM_vBCFCP = txtItemVBcFcp?.Text ?? string.Empty,
|
|
ITEM_vBCFCPST = txtItemVBcFcpSt?.Text ?? string.Empty,
|
|
ITEM_pFCPST = txtItemPFcpSt?.Text ?? string.Empty,
|
|
ITEM_vFCPST = txtItemVFcpSt?.Text ?? string.Empty,
|
|
ITEM_pST = txtItemPSt?.Text ?? string.Empty,
|
|
ITEM_vBCFCPSTRet = txtItemVBcFcpStRet?.Text ?? string.Empty,
|
|
ITEM_pFCPSTRet = txtItemPFcpStRet?.Text ?? string.Empty,
|
|
ITEM_vFCPSTRet = txtItemVFcpStRet?.Text ?? string.Empty,
|
|
ITEM_PIS_CST = txtItemPisCst?.Text ?? string.Empty,
|
|
ITEM_PIS_vBC = txtItemPisVBc?.Text ?? string.Empty,
|
|
ITEM_PIS_pPIS = txtItemPisPPis?.Text ?? string.Empty,
|
|
ITEM_PIS_vPIS = txtItemPisVPis?.Text ?? string.Empty,
|
|
ITEM_COFINS_CST = txtItemCofinsCst?.Text ?? string.Empty,
|
|
ITEM_COFINS_vBC = txtItemCofinsVBc?.Text ?? string.Empty,
|
|
ITEM_COFINS_pCOFINS = txtItemCofinsPCofins?.Text ?? string.Empty,
|
|
ITEM_COFINS_vCOFINS = txtItemCofinsVCofins?.Text ?? string.Empty,
|
|
VICMSSubstituto = txtVIcmsSubstituto?.Text ?? string.Empty,
|
|
PRedBCEfet = txtPRedBcEfet?.Text ?? string.Empty,
|
|
VBCEfet = txtVBcEfet?.Text ?? string.Empty,
|
|
PICMSEfet = txtPIcmsEfet?.Text ?? string.Empty,
|
|
VICMSEfet = txtVIcmsEfet?.Text ?? string.Empty
|
|
};
|
|
|
|
// Processa o objeto preenchido nas camadas inferiores
|
|
MessageBox.Show($"Item {item.ITEM_CPROD} gravado com sucesso!", "LevelOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
txtItemXprod?.Focus();
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Confirma a exclusão deste item?", "LevelOS", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
|
{
|
|
OnNovo();
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// Vinculado à Grid de busca global
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
OnNovo();
|
|
}
|
|
}
|
|
} |