using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class NotasFaturasPanel : FormularioModelo { private ModeloNotasFaturas _fatura = new ModeloNotasFaturas(); // Controles de UI private LV_TEXTBOX1 txtId, txtCodNota, txtNumero, txtVencimento, txtValor, txtIndice; public NotasFaturasPanel() { this.Titulo = "Duplicatas / Faturas da Nota Fiscal"; MontarInterface(); } private void MontarInterface() { // --- Cabeçalho e Vínculo --- txtId = AddInput(content, "ID", 20, 30, 60, 30, true); txtCodNota = AddInput(content, "ID DA NOTA", 90, 30, 150, 30); txtIndice = AddInput(content, "ÍNDICE/SEQ", 250, 30, 100, 30); // --- Dados da Fatura --- content.Controls.Add(CreateSectionHeader("DADOS DA DUPLICATA", 85)); txtNumero = AddInput(content, "NÚMERO DO TÍTULO", 20, 115, 200, 30); txtVencimento = AddInput(content, "VENCIMENTO (DD/MM/AAAA)", 230, 115, 180, 30); txtValor = AddInput(content, "VALOR DA PARCELA (R$)", 420, 115, 150, 30); txtValor.ForeColor = Color.DarkBlue; txtValor.Font = new Font("Segoe UI", 10, FontStyle.Bold); content.Height = 200; } private void PreencherModel() { _fatura.COD_NOTA = txtCodNota.Text; _fatura.INDICE = txtIndice.Text; _fatura.NUMERO = txtNumero.Text; _fatura.VENCTO = txtVencimento.Text; _fatura.VALOR = txtValor.Text; } private void MapModelParaTela(ModeloNotasFaturas model) { txtId.Text = model.ID_NOTAS_FATURAS.ToString(); txtCodNota.Text = model.COD_NOTA; txtIndice.Text = model.INDICE; txtNumero.Text = model.NUMERO; txtVencimento.Text = model.VENCTO; txtValor.Text = model.VALOR; } // --- IMPLEMENTAÇÃO DOS MÉTODOS ABSTRATOS (O que estava faltando) --- protected override void OnNovo() { _fatura = new ModeloNotasFaturas(); txtId.Text = "0"; txtCodNota.Text = ""; txtIndice.Text = ""; txtNumero.Text = ""; txtVencimento.Text = ""; txtValor.Text = ""; txtCodNota.Focus(); } protected override void OnSalvar() { if (string.IsNullOrWhiteSpace(txtValor.Text) || string.IsNullOrWhiteSpace(txtVencimento.Text)) { MessageBox.Show("Valor e Vencimento são obrigatórios para gerar o financeiro.", "LevelOS Financeiro"); return; } PreencherModel(); // Lógica de banco de dados (Ex: BLL.Salvar(_fatura)) MessageBox.Show($"Fatura nº {txtNumero.Text} registrada no contas a receber!", "Sucesso"); } protected override void OnAlterar() { if (txtId.Text == "0") { MessageBox.Show("Selecione uma fatura para realizar a alteração."); return; } PreencherModel(); MessageBox.Show("Dados da duplicata atualizados."); } protected override void OnExcluir() { if (MessageBox.Show("Deseja realmente excluir esta parcela? Isso afetará o financeiro da nota.", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { OnNovo(); MessageBox.Show("Parcela removida."); } } protected override void OnLocalizar() { // Chamada para a Grid de Faturas/Duplicatas MessageBox.Show("Buscando duplicatas cadastradas..."); } protected override void OnCancelar() { } } }