using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class NotasDeServicosPanel : FormularioModelo { private ModeloNotasDeServicos _servico = new ModeloNotasDeServicos(); private TabControl tabNfse; private TabPage tpGeral, tpTomador, tpValores, tpFiscal; public NotasDeServicosPanel() { this.Titulo = "Emissão de Nota Fiscal de Serviço (NFS-e / RPS)"; this.Size = new Size(950, 700); MontarInterface(); } private void MontarInterface() { tabNfse = new TabControl { Dock = DockStyle.Fill, Font = new Font("Segoe UI", 9) }; tpGeral = new TabPage("1. Identificação/RPS"); tpTomador = new TabPage("2. Tomador (Cliente)"); tpValores = new TabPage("3. Valores e Retenções"); tpFiscal = new TabPage("4. Códigos Fiscais/Obra"); tabNfse.TabPages.AddRange(new[] { tpGeral, tpTomador, tpValores, tpFiscal }); content.Controls.Add(tabNfse); ConfigurarAbaGeral(); ConfigurarAbaTomador(); ConfigurarAbaValores(); } private void ConfigurarAbaGeral() { AddInput(tpGeral, "ID SISTEMA", 20, 20, 80, 30, true); AddInput(tpGeral, "NÚMERO RPS", 110, 20, 150, 30).Name = "IDE_RPS"; AddInput(tpGeral, "SÉRIE", 270, 20, 80, 30); AddInput(tpGeral, "DATA EMISSÃO", 360, 20, 150, 30); var txtDisc = AddInput(tpGeral, "DISCRIMINAÇÃO DOS SERVIÇOS", 20, 80, 500, 100); txtDisc.Multiline = true; txtDisc.Height = 100; } private void ConfigurarAbaTomador() { AddInput(tpTomador, "CNPJ / CPF", 20, 20, 200, 30); AddInput(tpTomador, "RAZÃO SOCIAL", 230, 20, 400, 30); AddInput(tpTomador, "E-MAIL", 20, 80, 300, 30); AddInput(tpTomador, "ENDEREÇO", 20, 140, 400, 30); AddInput(tpTomador, "CIDADE (CÓD. MUNICIPIO)", 430, 140, 200, 30); } private void ConfigurarAbaValores() { AddInput(tpValores, "VALOR TOTAL SERVIÇOS", 20, 20, 180, 30).ForeColor = Color.Blue; AddInput(tpValores, "BASE DE CÁLCULO", 210, 20, 180, 30); AddInput(tpValores, "ALÍQUOTA (%)", 400, 20, 100, 30); // Seção de Retenções content.Controls.Add(CreateSectionHeader("RETENÇÕES FEDERAIS", 80)); AddInput(tpValores, "PIS", 20, 110, 120, 30); AddInput(tpValores, "COFINS", 150, 110, 120, 30); AddInput(tpValores, "INSS", 280, 110, 120, 30); AddInput(tpValores, "IR", 410, 110, 120, 30); AddInput(tpValores, "CSLL", 540, 110, 120, 30); } // --- IMPLEMENTAÇÃO DOS MÉTODOS OBRIGATÓRIOS DA CLASSE ABSTRATA --- protected override void OnNovo() { _servico = new ModeloNotasDeServicos(); LimparCamposRecursivo(tabNfse); tabNfse.SelectedTab = tpGeral; } protected override void OnSalvar() { // Lógica para capturar dados da tela e validar if (string.IsNullOrWhiteSpace(_servico.IDE_RPS)) { // Simulação de preenchimento _servico.IDE_RPS = "Auto-Gerado"; } MessageBox.Show("NFS-e enviada para processamento na Prefeitura!", "LevelOS Fiscal"); } protected override void OnAlterar() { if (_servico.ID_NOTAS_SERVICOS == 0) { MessageBox.Show("Selecione uma nota emitida para retificar ou alterar."); return; } MessageBox.Show("Dados do RPS atualizados localmente."); } protected override void OnExcluir() { if (MessageBox.Show("Deseja cancelar esta NFS-e? (Isso enviará um evento de cancelamento)", "Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes) { MessageBox.Show("Solicitação de cancelamento enviada."); OnNovo(); } } protected override void OnLocalizar() { MessageBox.Show("Pesquisando Notas de Serviço no banco de dados..."); } protected override void OnCancelar() { } private void LimparCamposRecursivo(Control container) { foreach (Control c in container.Controls) { if (c is LV_TEXTBOX1 t) t.Text = ""; if (c.HasChildren) LimparCamposRecursivo(c); } } } }