using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class NotasConsumidorItensPanel : FormularioModelo { private ModeloNotasConsumidorItens _item = new ModeloNotasConsumidorItens(); private TabControl tabFiscal; private TabPage tpProduto, tpIcms, tpPisCofins, tpFcp; public NotasConsumidorItensPanel() { this.Titulo = "Itens da NFC-e (Venda ao Consumidor)"; this.Size = new Size(900, 650); MontarInterface(); } private void MontarInterface() { tabFiscal = new TabControl { Dock = DockStyle.Fill, Font = new Font("Segoe UI", 9) }; tpProduto = new TabPage("1. Produto/Valores"); tpIcms = new TabPage("2. ICMS/ST"); tpPisCofins = new TabPage("3. PIS/COFINS"); tpFcp = new TabPage("4. FCP/Efetivo"); tabFiscal.TabPages.AddRange(new[] { tpProduto, tpIcms, tpPisCofins, tpFcp }); content.Controls.Add(tabFiscal); ConfigurarAbaProduto(); ConfigurarAbaIcms(); } private void ConfigurarAbaProduto() { AddInput(tpProduto, "DESCRIÇÃO DO ITEM", 20, 20, 500, 30).Name = "ITEM_XPROD"; AddInput(tpProduto, "CÓD. INTERNO", 20, 80, 150, 30); AddInput(tpProduto, "NCM", 180, 80, 120, 30); AddInput(tpProduto, "CFOP", 310, 80, 80, 30); AddInput(tpProduto, "QUANTIDADE", 20, 140, 120, 30).ForeColor = Color.Blue; AddInput(tpProduto, "VLR UNITÁRIO", 150, 140, 120, 30); AddInput(tpProduto, "DESCONTO (-)", 280, 140, 120, 30).ForeColor = Color.Red; AddInput(tpProduto, "TOTAL ITEM", 410, 140, 150, 30).Font = new Font("Segoe UI", 10, FontStyle.Bold); } private void ConfigurarAbaIcms() { AddInput(tpIcms, "CST/CSOSN", 20, 20, 100, 30); AddInput(tpIcms, "ORIGEM", 130, 20, 60, 30); AddInput(tpIcms, "BASE CÁLC. ICMS", 20, 80, 150, 30); AddInput(tpIcms, "ALÍQUOTA %", 180, 80, 100, 30); AddInput(tpIcms, "VALOR ICMS", 290, 80, 150, 30); AddInput(tpIcms, "MVA ST %", 20, 140, 100, 30); AddInput(tpIcms, "BASE ICMS ST", 130, 140, 150, 30); AddInput(tpIcms, "VALOR ICMS ST", 290, 140, 150, 30); } // --- IMPLEMENTAÇÃO DOS MÉTODOS OBRIGATÓRIOS --- protected override void OnNovo() { _item = new ModeloNotasConsumidorItens(); LimparInterfaceRecursiva(tabFiscal); tabFiscal.SelectedTab = tpProduto; } protected override void OnSalvar() { if (string.IsNullOrWhiteSpace(_item.ITEM_XPROD) && string.IsNullOrWhiteSpace(tabFiscal.TabPages[0].Controls[0].Text)) { MessageBox.Show("A descrição do produto é obrigatória.", "Validação LevelOS"); return; } // Lógica para persistir _item no banco... MessageBox.Show("Dados fiscais do item salvos com sucesso."); } protected override void OnAlterar() { if (_item.ID_NOTAS_CONSU_ITENS == 0) { MessageBox.Show("Localize um item antes de alterar."); return; } MessageBox.Show("Registro atualizado."); } protected override void OnExcluir() { if (MessageBox.Show("Remover este item e seus tributos?", "Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes) { OnNovo(); } } protected override void OnLocalizar() { // Chamada para grid de busca de itens da nota MessageBox.Show("Localizando itens da NFC-e..."); } protected override void OnCancelar() { } private void LimparInterfaceRecursiva(Control content) { foreach (Control c in content.Controls) { if (c is LV_TEXTBOX1 t) t.Text = ""; if (c.HasChildren) LimparInterfaceRecursiva(c); } } } }