using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class ItensNotaCadastroPanel : FormularioModelo { private ModeloItensNota _itemNota = new ModeloItensNota(); // Controles - Vínculos private LV_TEXTBOX1 txtId, txtCodigo, txtCodNota, txtCodVendedor; // Controles - Dados do Item private LV_TEXTBOX1 txtCodItem, txtGtin, txtDescricao, txtUnidade, txtTipo; private Button btnBuscaItem; // Controles - Valores e Quantidades private LV_TEXTBOX1 txtQtd, txtPreco, txtDesconto, txtTotal; // Controles - Impostos e Fiscal private LV_TEXTBOX1 txtIcms, txtIpi, txtIss, txtCfop, txtCst; // Informações Adicionais private LV_TEXTBOX1 txtInfAdic; public ItensNotaCadastroPanel() { this.Titulo = "Detalhamento do Item na Nota Fiscal"; MontarInterface(); } private void MontarInterface() { // --- SEÇÃO 1: Referência da Nota e Vendedor --- content.Controls.Add(CreateSectionHeader("DADOS DA NOTA E ORIGEM", 20)); txtId = AddInput(content, "ID", 20, 50, 70, 30, true); txtCodigo = AddInput(content, "CÓD. LANÇ.", 100, 50, 100, 30); txtCodNota = AddInput(content, "Nº CONTROLE NOTA", 210, 50, 160, 30); txtCodVendedor = AddInput(content, "CÓD. VENDEDOR", 380, 50, 130, 30); txtTipo = AddInput(content, "TIPO (V/S)", 520, 50, 80, 30); // --- SEÇÃO 2: Dados do Produto/Serviço --- content.Controls.Add(CreateSectionHeader("ITEM SELECIONADO", 115)); txtCodItem = AddInput(content, "CÓD. ITEM", 20, 145, 100, 30); btnBuscaItem = CriarBotaoLupa(125, 161, OnBuscaItem); txtGtin = AddInput(content, "GTIN/EAN", 165, 145, 150, 30); txtDescricao = AddInput(content, "DESCRIÇÃO NA NOTA", 325, 145, 380, 30); txtUnidade = AddInput(content, "UN", 715, 145, 60, 30); // --- SEÇÃO 3: Comercial (Valores) --- content.Controls.Add(CreateSectionHeader("QUANTIDADES E VALORES COMERCIAIS", 210)); txtQtd = AddInput(content, "QUANTIDADE", 20, 240, 120, 30); txtPreco = AddInput(content, "PREÇO UNIT. (R$)", 150, 240, 140, 30); txtDesconto = AddInput(content, "DESCONTO (R$)", 300, 240, 140, 30); txtTotal = AddInput(content, "TOTAL LÍQUIDO", 450, 240, 150, 30, true); txtTotal.BackColor = Color.FromArgb(255, 250, 240); // Destaque para o resultado // --- SEÇÃO 4: Tributação Aplicada --- content.Controls.Add(CreateSectionHeader("IMPOSTOS E REGRAS FISCAIS", 305)); txtCfop = AddInput(content, "CFOP", 20, 335, 90, 30); txtCst = AddInput(content, "CST/CSOSN", 120, 335, 90, 30); txtIcms = AddInput(content, "ICMS (%)", 220, 335, 90, 30); txtIpi = AddInput(content, "IPI (%)", 320, 335, 90, 30); txtIss = AddInput(content, "ISS (%)", 420, 335, 90, 30); // --- SEÇÃO 5: Observações Adicionais --- content.Controls.Add(CreateSectionHeader("INFORMAÇÕES ADICIONAIS DO ITEM", 400)); txtInfAdic = AddInput(content, "DETALHES ADICIONAIS (TEXTO FISCAL)", 20, 430, 755, 50); content.Height = 520; } private Button CriarBotaoLupa(int x, int y, EventHandler clickEvent) { var btn = new Button { Text = "🔍", Location = new Point(x, y), Size = new Size(32, 30), BackColor = AccentBlue, ForeColor = Color.White, FlatStyle = FlatStyle.Flat, Cursor = Cursors.Hand }; btn.FlatAppearance.BorderSize = 0; btn.Click += clickEvent; content.Controls.Add(btn); return btn; } private void OnBuscaItem(object sender, EventArgs e) => MessageBox.Show("Busca de Itens para Nota"); private void PreencherModel() { _itemNota.CODIGO = txtCodigo.Text; _itemNota.COD_NOTA = txtCodNota.Text; _itemNota.TIPO = txtTipo.Text; _itemNota.COD_VENDEDOR = txtCodVendedor.Text; _itemNota.COD_ITEM = txtCodItem.Text; _itemNota.DESCRICAO = txtDescricao.Text; _itemNota.UNIDADE = txtUnidade.Text; _itemNota.QTD = txtQtd.Text; _itemNota.PRECO = txtPreco.Text; _itemNota.ICMS = txtIcms.Text; _itemNota.IPI = txtIpi.Text; _itemNota.ISS = txtIss.Text; _itemNota.DESCONTO = txtDesconto.Text; _itemNota.TOTAL = txtTotal.Text; _itemNota.CFOP = txtCfop.Text; _itemNota.CST = txtCst.Text; _itemNota.GTIN = txtGtin.Text; _itemNota.INF_ADIC = txtInfAdic.Text; } protected override void OnNovo() { _itemNota = new ModeloItensNota(); txtCodItem.Focus(); } protected override void OnSalvar() { try { PreencherModel(); MessageBox.Show("Item da nota fiscal atualizado!", "LevelOS", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Erro: " + ex.Message); } } protected override void OnAlterar() { } protected override void OnExcluir() { } protected override void OnLocalizar() { } protected override void OnCancelar() { OnNovo(); } } }