using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class DespFixaCadastroPanel : FormularioModelo { private ModeloDespFixa _despFixa = new ModeloDespFixa(); // Controles - Identificação e Vínculo private LV_TEXTBOX1 txtId, txtCodigo, txtTipo, txtCodCliente, txtNomeCliente; private Button btnBuscaCliente; // Controles - Financeiro e Classificação private LV_TEXTBOX1 txtValor, txtVencimento, txtPlanoContas, txtObservacao; public DespFixaCadastroPanel() { this.Titulo = "Cadastro de Despesas Fixas (Recorrentes)"; MontarInterface(); } private void MontarInterface() { // --- SEÇÃO 1: Identificação da Despesa --- content.Controls.Add(CreateSectionHeader("DADOS DA DESPESA RECORRENTE", 20)); txtId = AddInput(content, "ID", 20, 50, 70, 30, true); txtCodigo = AddInput(content, "CÓD. INTERNO", 100, 50, 100, 30); txtTipo = AddInput(content, "TIPO (Ex: Fixa/Mensal)", 210, 50, 180, 30); // Beneficiário / Fornecedor txtCodCliente = AddInput(content, "CÓD. BENEF.", 20, 105, 90, 30); btnBuscaCliente = CriarBotaoLupa(115, 121, OnBuscaCliente); txtNomeCliente = AddInput(content, "NOME DO BENEFICIÁRIO / FORNECEDOR", 155, 105, 450, 30, true); // --- SEÇÃO 2: Configurações Financeiras --- content.Controls.Add(CreateSectionHeader("VALORES E PROGRAMAÇÃO", 175)); txtValor = AddInput(content, "VALOR MENSAL (R$)", 20, 205, 180, 30); txtVencimento = AddInput(content, "DIA DE VENCIMENTO", 210, 205, 150, 30); txtPlanoContas = AddInput(content, "PLANO DE CONTAS", 370, 205, 235, 30); // --- SEÇÃO 3: Notas Adicionais --- content.Controls.Add(CreateSectionHeader("OBSERVAÇÕES", 270)); txtObservacao = AddInput(content, "NOTAS SOBRE ESTE CONTRATO/DESPESA", 20, 300, 585, 60); content.Height = 420; } 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 OnBuscaCliente(object sender, EventArgs e) { MessageBox.Show("Abrir busca de Fornecedores/Clientes"); } private void PreencherModel() { _despFixa.CODIGO = txtCodigo.Text; _despFixa.TIPO = txtTipo.Text; _despFixa.COD_CLIENTE = txtCodCliente.Text; _despFixa.VALOR = txtValor.Text; _despFixa.VENCIMENTO = txtVencimento.Text; _despFixa.PLANO_CONTAS = txtPlanoContas.Text; _despFixa.OBSERVACAO = txtObservacao.Text; } protected override void OnNovo() { _despFixa = new ModeloDespFixa(); txtTipo.Text = "MENSAL"; txtCodigo.Focus(); } protected override void OnSalvar() { try { PreencherModel(); // BLL.Salvar(_despFixa); MessageBox.Show("Despesa fixa configurada com sucesso!"); } 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(); } } }