using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class ContasCorrentesCadastroPanel : FormularioModelo { private ModeloContasContas _contaBancaria = new ModeloContasContas(); // Controles private LV_TEXTBOX1 txtId, txtCodigo, txtDescricao, txtSaldoInicial; public ContasCorrentesCadastroPanel() { // Nome mais amigável na barra de título this.Titulo = "Cadastro de Contas e Caixas"; MontarInterface(); } private void MontarInterface() { // --- SEÇÃO ÚNICA: Dados da Conta --- content.Controls.Add(CreateSectionHeader("INFORMAÇÕES DA CONTA CORRENTE / CAIXA", 20)); // Linha 1: ID e Código (ex: 001, CTA-01) txtId = AddInput(content, "ID", 20, 50, 80, 30, true); txtCodigo = AddInput(content, "CÓDIGO INTERNO", 110, 50, 150, 30); // Linha 2: Descrição (ex: "Banco do Brasil - Ag. 1234", "Caixa Geral", "Cofre") txtDescricao = AddInput(content, "NOME / DESCRIÇÃO DA CONTA", 20, 105, 500, 30); // Linha 3: Saldo Inicial // x=20, y=160 (105 + 55 de espaçamento) txtSaldoInicial = AddInput(content, "SALDO INICIAL (R$)", 20, 160, 200, 30); // Como é um formulário pequeno, ajustamos o content para não sobrar scroll content.Height = 300; } private void PreencherModel() { _contaBancaria.ID_CONTAS_CONTAS = int.TryParse(txtId.Text, out int id) ? id : 0; _contaBancaria.CODIGO = txtCodigo.Text; _contaBancaria.DESCRICAO = txtDescricao.Text; _contaBancaria.SALDO_INI = txtSaldoInicial.Text; } // --- MÉTODOS OBRIGATÓRIOS DA BASE --- protected override void OnNovo() { _contaBancaria = new ModeloContasContas(); txtCodigo.Focus(); } protected override void OnSalvar() { try { PreencherModel(); // BLL.Salvar(_contaBancaria); MessageBox.Show("Conta/Caixa salvo com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Erro ao salvar: " + ex.Message); } } protected override void OnAlterar() { } protected override void OnExcluir() { } protected override void OnLocalizar() { } protected override void OnCancelar() { OnNovo(); } } }