- Adicionado ContratoEquipamentosCadastroPanel - Adicionado ConfigBoletosCadastroPanel (Gestão de convênios) - Adicionado ConfigCartoesCadastroPanel (Taxas e operadoras) - Adicionado ConfigImpressaoCadastroPanel (Coordenadas X/Y) - Adicionado DespesasCadastroPanel e DespFixaCadastroPanel - Adicionado ConfigEcfCadastroPanel (Hardware Fiscal) - Adicionado EmpresaCadastroPanel (Emitente e Web3/Crypto) - Adicionado EquipamentosCadastroPanel (Ativos e Garantia) - Adicionado EsquemasTecnicosCadastroPanel (Biblioteca de Manuais) - Adicionado FluxoCaixaCadastroPanel (Tesouraria) - Adicionado FornecedorItemVinculoPanel (Logística de Suprimentos) Padronização de interface utilizando FormularioModelo e LV_TEXTBOX1."
610 lines
26 KiB
C#
610 lines
26 KiB
C#
using CPM;
|
|
using DAL;
|
|
using MLL;
|
|
using BLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace UI
|
|
{
|
|
public class ContaReceberCadastroPanel : FormularioModelo
|
|
{
|
|
// ── CAMPOS DO FORMULÁRIO ──────────────────────────────────────────────
|
|
private LV_TEXTBOX1 txtId = null!;
|
|
private LV_TEXTBOX1 txtDescricao = null!;
|
|
private LV_COMBOBOXCUSTOM cmbStatus = null!;
|
|
private CheckBox chkAtivo = null!;
|
|
|
|
// Cliente — busca
|
|
private LV_TEXTBOX1 txtClienteId = null!;
|
|
private LV_TEXTBOX1 txtClienteNome = null!;
|
|
private Button btnBuscarCliente = null!;
|
|
|
|
// Plano de Contas — busca
|
|
private LV_TEXTBOX1 txtPlanoContaId = null!;
|
|
private LV_TEXTBOX1 txtPlanoContaNome = null!;
|
|
private Button btnBuscarPlanoConta = null!;
|
|
|
|
// Valores
|
|
private LV_TEXTBOX1 txtValor = null!;
|
|
private LV_TEXTBOX1 txtValorPago = null!;
|
|
private LV_TEXTBOX1 txtJuros = null!;
|
|
private LV_TEXTBOX1 txtMulta = null!;
|
|
private LV_TEXTBOX1 txtDesconto = null!;
|
|
|
|
// Datas
|
|
private LV_TEXTBOX1 txtDataEmissao = null!;
|
|
private LV_TEXTBOX1 txtDataVencimento = null!;
|
|
private LV_TEXTBOX1 txtDataPagamento = null!;
|
|
|
|
// Auditoria
|
|
private LV_TEXTBOX1 txtCriadoEm = null!;
|
|
private LV_TEXTBOX1 txtAtualizadoEm = null!;
|
|
|
|
// Observações
|
|
private LV_TEXTBOX1 txtObservacoes = null!;
|
|
|
|
// ── ESTADO ────────────────────────────────────────────────────────────
|
|
private enum ModoFormulario { Visualizacao, Novo, Edicao }
|
|
private ModoFormulario _modo = ModoFormulario.Visualizacao;
|
|
private int _idAtual = 0;
|
|
private int _clienteId = 0;
|
|
private int _planoContaId = 0;
|
|
private int? _contratoId = null;
|
|
|
|
// ── BLL ───────────────────────────────────────────────────────────────
|
|
// private ContaReceberBLL _bll = null!;
|
|
|
|
// ── CONSTRUTOR ────────────────────────────────────────────────────────
|
|
public ContaReceberCadastroPanel()
|
|
{
|
|
Titulo = "Contas a Receber";
|
|
BuildForm();
|
|
AplicarModo(ModoFormulario.Visualizacao);
|
|
}
|
|
|
|
// ── CONSTRUÇÃO DOS CAMPOS ─────────────────────────────────────────────
|
|
private void BuildForm()
|
|
{
|
|
// ── SEÇÃO: IDENTIFICAÇÃO ──────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Identificação", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 58, 80, 32, readOnly: true);
|
|
|
|
txtDescricao = AddInput(content, "Descrição", 120, 58, 400, 32);
|
|
txtDescricao.MaxLength = 255;
|
|
|
|
// Status
|
|
var lblStatus = new Label
|
|
{
|
|
Text = "Status",
|
|
Location = new Point(540, 58),
|
|
Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
|
|
ForeColor = TextDark,
|
|
AutoSize = true
|
|
};
|
|
cmbStatus = new LV_COMBOBOXCUSTOM
|
|
{
|
|
Location = new Point(540, 74),
|
|
Size = new Size(160, 32),
|
|
DropDownStyle = ComboBoxStyle.DropDownList,
|
|
BorderColor = BorderColor,
|
|
BackColor = Color.White,
|
|
ListBackColor = Color.White,
|
|
ListTextColor = TextDark,
|
|
IconColor = AccentBlue,
|
|
Font = new Font("Segoe UI", 9f)
|
|
};
|
|
cmbStatus.Items.Add("Pendente");
|
|
cmbStatus.Items.Add("Pago");
|
|
cmbStatus.Items.Add("Vencido");
|
|
cmbStatus.Items.Add("Cancelado");
|
|
cmbStatus.Items.Add("Parcial");
|
|
cmbStatus.SelectedIndex = 0;
|
|
_contratoId = null;
|
|
content.Controls.Add(lblStatus);
|
|
content.Controls.Add(cmbStatus);
|
|
|
|
chkAtivo = CreateCheckBox("Ativo", 720, 82);
|
|
chkAtivo.Checked = true;
|
|
content.Controls.Add(chkAtivo);
|
|
|
|
// ── SEÇÃO: FORNECEDOR ─────────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Cliente", 128));
|
|
|
|
var lblCliente = new Label
|
|
{
|
|
Text = "Cliente",
|
|
Location = new Point(20, 166),
|
|
Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
|
|
ForeColor = TextDark,
|
|
AutoSize = true
|
|
};
|
|
txtClienteId = new LV_TEXTBOX1
|
|
{
|
|
Location = new Point(20, 182),
|
|
Size = new Size(80, 32),
|
|
BorderColor = ReadOnlyBorder,
|
|
BorderFocusColor = AccentBlue,
|
|
ReadOnly = true,
|
|
BackColor = ReadOnlyBg
|
|
};
|
|
txtClienteNome = new LV_TEXTBOX1
|
|
{
|
|
Location = new Point(108, 182),
|
|
Size = new Size(300, 32),
|
|
BorderColor = ReadOnlyBorder,
|
|
BorderFocusColor = AccentBlue,
|
|
ReadOnly = true,
|
|
BackColor = ReadOnlyBg
|
|
};
|
|
btnBuscarCliente = new Button
|
|
{
|
|
Text = "🔍 Buscar",
|
|
Location = new Point(416, 182),
|
|
Size = new Size(90, 32),
|
|
BackColor = AccentBlue,
|
|
ForeColor = Color.White,
|
|
Font = new Font("Segoe UI Semibold", 8.5f),
|
|
Cursor = Cursors.Hand,
|
|
FlatStyle = FlatStyle.Flat,
|
|
Enabled = false
|
|
};
|
|
btnBuscarCliente.FlatAppearance.BorderSize = 0;
|
|
btnBuscarCliente.Click += BtnBuscarCliente_Click;
|
|
content.Controls.Add(lblCliente);
|
|
content.Controls.Add(txtClienteId);
|
|
content.Controls.Add(txtClienteNome);
|
|
content.Controls.Add(btnBuscarCliente);
|
|
|
|
// ── SEÇÃO: PLANO DE CONTAS ────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Plano de Contas", 234));
|
|
|
|
var lblPlanoConta = new Label
|
|
{
|
|
Text = "Plano de Contas",
|
|
Location = new Point(20, 272),
|
|
Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
|
|
ForeColor = TextDark,
|
|
AutoSize = true
|
|
};
|
|
txtPlanoContaId = new LV_TEXTBOX1
|
|
{
|
|
Location = new Point(20, 288),
|
|
Size = new Size(80, 32),
|
|
BorderColor = ReadOnlyBorder,
|
|
BorderFocusColor = AccentBlue,
|
|
ReadOnly = true,
|
|
BackColor = ReadOnlyBg
|
|
};
|
|
txtPlanoContaNome = new LV_TEXTBOX1
|
|
{
|
|
Location = new Point(108, 288),
|
|
Size = new Size(300, 32),
|
|
BorderColor = ReadOnlyBorder,
|
|
BorderFocusColor = AccentBlue,
|
|
ReadOnly = true,
|
|
BackColor = ReadOnlyBg
|
|
};
|
|
btnBuscarPlanoConta = new Button
|
|
{
|
|
Text = "🔍 Buscar",
|
|
Location = new Point(416, 288),
|
|
Size = new Size(90, 32),
|
|
BackColor = AccentBlue,
|
|
ForeColor = Color.White,
|
|
Font = new Font("Segoe UI Semibold", 8.5f),
|
|
Cursor = Cursors.Hand,
|
|
FlatStyle = FlatStyle.Flat,
|
|
Enabled = false
|
|
};
|
|
btnBuscarPlanoConta.FlatAppearance.BorderSize = 0;
|
|
btnBuscarPlanoConta.Click += BtnBuscarPlanoConta_Click;
|
|
content.Controls.Add(lblPlanoConta);
|
|
content.Controls.Add(txtPlanoContaId);
|
|
content.Controls.Add(txtPlanoContaNome);
|
|
content.Controls.Add(btnBuscarPlanoConta);
|
|
|
|
// Contrato — opcional
|
|
var lblContrato = new Label
|
|
{
|
|
Text = "Contrato (opcional)",
|
|
Location = new Point(20, 340),
|
|
Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
|
|
ForeColor = TextDark,
|
|
AutoSize = true
|
|
};
|
|
var txtContratoId = new LV_TEXTBOX1
|
|
{
|
|
Location = new Point(20, 356),
|
|
Size = new Size(160, 32),
|
|
BorderColor = BorderColor,
|
|
BorderFocusColor = AccentBlue
|
|
};
|
|
content.Controls.Add(lblContrato);
|
|
content.Controls.Add(txtContratoId);
|
|
|
|
// ── SEÇÃO: VALORES ────────────────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Valores", 410));
|
|
|
|
txtValor = AddInput(content, "Valor (R$)", 20, 448, 150, 32);
|
|
txtValorPago = AddInput(content, "Valor Pago (R$)", 190, 448, 150, 32);
|
|
txtJuros = AddInput(content, "Juros (R$)", 360, 448, 130, 32);
|
|
txtMulta = AddInput(content, "Multa (R$)", 510, 448, 130, 32);
|
|
txtDesconto = AddInput(content, "Desconto (R$)", 660, 448, 130, 32);
|
|
|
|
// ── SEÇÃO: DATAS ──────────────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Datas", 510));
|
|
|
|
txtDataEmissao = AddInput(content, "Emissão", 20, 548, 180, 32);
|
|
txtDataVencimento = AddInput(content, "Vencimento", 220, 548, 180, 32);
|
|
txtDataPagamento = AddInput(content, "Pagamento", 420, 548, 180, 32);
|
|
|
|
// ── SEÇÃO: OBSERVAÇÕES ────────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Observações", 610));
|
|
|
|
var lblObs = new Label
|
|
{
|
|
Text = "Observações",
|
|
Location = new Point(20, 648),
|
|
Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
|
|
ForeColor = TextDark,
|
|
AutoSize = true
|
|
};
|
|
txtObservacoes = new LV_TEXTBOX1
|
|
{
|
|
Location = new Point(20, 664),
|
|
Size = new Size(760, 70),
|
|
BorderColor = BorderColor,
|
|
BorderFocusColor = AccentBlue,
|
|
Multiline = true,
|
|
MaxLength = 500
|
|
};
|
|
content.Controls.Add(lblObs);
|
|
content.Controls.Add(txtObservacoes);
|
|
|
|
// ── SEÇÃO: AUDITORIA ──────────────────────────────────────────────
|
|
content.Controls.Add(CreateSectionHeader("Auditoria", 754));
|
|
|
|
txtCriadoEm = AddInput(content, "Criado em", 20, 792, 200, 32, readOnly: true);
|
|
txtAtualizadoEm = AddInput(content, "Atualizado em", 240, 792, 200, 32, readOnly: true);
|
|
|
|
content.Height = 860;
|
|
}
|
|
|
|
// ── CAMPOS EDITÁVEIS ──────────────────────────────────────────────────
|
|
private LV_TEXTBOX1[] CamposEditaveis() => new[]
|
|
{
|
|
txtDescricao, txtValor, txtValorPago, txtJuros,
|
|
txtMulta, txtDesconto, txtDataEmissao, txtDataVencimento,
|
|
txtDataPagamento, txtObservacoes
|
|
};
|
|
|
|
// ── MODOS DO FORMULÁRIO ───────────────────────────────────────────────
|
|
private void AplicarModo(ModoFormulario modo)
|
|
{
|
|
_modo = modo;
|
|
bool editando = modo == ModoFormulario.Novo || modo == ModoFormulario.Edicao;
|
|
|
|
foreach (var txt in CamposEditaveis())
|
|
{
|
|
txt.ReadOnly = !editando;
|
|
txt.BackColor = editando ? Color.White : ReadOnlyBg;
|
|
txt.BorderColor = editando ? BorderColor : ReadOnlyBorder;
|
|
}
|
|
|
|
cmbStatus.Enabled = editando;
|
|
cmbStatus.BorderColor = editando ? BorderColor : ReadOnlyBorder;
|
|
cmbStatus.BackColor = editando ? Color.White : ReadOnlyBg;
|
|
|
|
chkAtivo.Enabled = editando;
|
|
|
|
btnBuscarCliente.Enabled = editando;
|
|
btnBuscarPlanoConta.Enabled = editando;
|
|
|
|
btnNovo.Enabled = !editando;
|
|
btnAlterar.Enabled = !editando && _idAtual > 0;
|
|
btnExcluir.Enabled = !editando && _idAtual > 0;
|
|
btnLocalizar.Enabled = !editando;
|
|
btnSalvar.Enabled = editando;
|
|
btnCancelar.Enabled = editando;
|
|
|
|
if (modo == ModoFormulario.Novo) LimparCampos();
|
|
}
|
|
|
|
// ── BUSCA DE FORNECEDOR ───────────────────────────────────────────────
|
|
private void BtnBuscarCliente_Click(object? sender, EventArgs e)
|
|
{
|
|
// TODO: abrir formulário de busca de clientees
|
|
// var frm = new FormularioBuscarCliente();
|
|
// if (frm.ShowDialog() == DialogResult.OK)
|
|
// {
|
|
// _clienteId = frm.ClienteSelecionado.Id;
|
|
// txtClienteId.Text = _clienteId.ToString();
|
|
// txtClienteNome.Text = frm.ClienteSelecionado.Nome;
|
|
// }
|
|
MessageBox.Show("Implemente o formulário de busca de clientees.",
|
|
"Buscar Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
// ── BUSCA DE PLANO DE CONTAS ──────────────────────────────────────────
|
|
private void BtnBuscarPlanoConta_Click(object? sender, EventArgs e)
|
|
{
|
|
// TODO: abrir formulário de busca de plano de contas
|
|
// var frm = new FormularioBuscarPlanoConta();
|
|
// if (frm.ShowDialog() == DialogResult.OK)
|
|
// {
|
|
// _planoContaId = frm.PlanoContaSelecionado.Id;
|
|
// txtPlanoContaId.Text = _planoContaId.ToString();
|
|
// txtPlanoContaNome.Text = frm.PlanoContaSelecionado.Nome;
|
|
// }
|
|
MessageBox.Show("Implemente o formulário de busca de plano de contas.",
|
|
"Buscar Plano de Contas", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
// ── POPULAR / LIMPAR ──────────────────────────────────────────────────
|
|
private void PopularCampos(ModeloContaReceber m)
|
|
{
|
|
_idAtual = m.Id;
|
|
_clienteId = m.ClienteId;
|
|
_planoContaId = m.PlanoContaId;
|
|
|
|
txtId.Text = m.Id.ToString();
|
|
txtDescricao.Text = m.Descricao;
|
|
txtClienteId.Text = m.ClienteId.ToString();
|
|
_contratoId = m.ContratoId;
|
|
txtPlanoContaId.Text = m.PlanoContaId.ToString();
|
|
txtValor.Text = m.Valor.ToString("F2");
|
|
txtValorPago.Text = m.ValorPago?.ToString("F2") ?? string.Empty;
|
|
txtJuros.Text = m.Juros.ToString("F2");
|
|
txtMulta.Text = m.Multa.ToString("F2");
|
|
txtDesconto.Text = m.Desconto.ToString("F2");
|
|
txtDataEmissao.Text = m.DataEmissao?.ToString("dd/MM/yyyy") ?? string.Empty;
|
|
txtDataVencimento.Text = m.DataVencimento.ToString("dd/MM/yyyy");
|
|
txtDataPagamento.Text = m.DataPagamento?.ToString("dd/MM/yyyy") ?? string.Empty;
|
|
txtObservacoes.Text = m.Observacoes;
|
|
chkAtivo.Checked = m.Ativo;
|
|
txtCriadoEm.Text = m.CriadoEm.ToString("dd/MM/yyyy HH:mm");
|
|
txtAtualizadoEm.Text = m.AtualizadoEm.ToString("dd/MM/yyyy HH:mm");
|
|
|
|
SelecionarCombo(cmbStatus, m.Status);
|
|
}
|
|
|
|
private void LimparCampos()
|
|
{
|
|
_idAtual = 0;
|
|
_clienteId = 0;
|
|
_planoContaId = 0;
|
|
|
|
txtId.Text = string.Empty;
|
|
txtDescricao.Text = string.Empty;
|
|
txtClienteId.Text = string.Empty;
|
|
txtClienteNome.Text = string.Empty;
|
|
txtPlanoContaId.Text = string.Empty;
|
|
txtPlanoContaNome.Text = string.Empty;
|
|
txtValor.Text = string.Empty;
|
|
txtValorPago.Text = string.Empty;
|
|
txtJuros.Text = string.Empty;
|
|
txtMulta.Text = string.Empty;
|
|
txtDesconto.Text = string.Empty;
|
|
txtDataEmissao.Text = string.Empty;
|
|
txtDataVencimento.Text = string.Empty;
|
|
txtDataPagamento.Text = string.Empty;
|
|
txtObservacoes.Text = string.Empty;
|
|
chkAtivo.Checked = true;
|
|
txtCriadoEm.Text = string.Empty;
|
|
txtAtualizadoEm.Text = string.Empty;
|
|
cmbStatus.SelectedIndex = 0;
|
|
}
|
|
|
|
// ── HELPER COMBOBOX ───────────────────────────────────────────────────
|
|
private static void SelecionarCombo(LV_COMBOBOXCUSTOM cmb, string valor)
|
|
{
|
|
for (int i = 0; i < cmb.Items.Count; i++)
|
|
{
|
|
if (cmb.Items[i]?.ToString() == valor)
|
|
{
|
|
cmb.SelectedIndex = i;
|
|
return;
|
|
}
|
|
}
|
|
cmb.SelectedIndex = 0;
|
|
}
|
|
|
|
// ── VALIDAÇÃO ─────────────────────────────────────────────────────────
|
|
private bool Validar()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(txtDescricao.Text))
|
|
{
|
|
MessageBox.Show("Informe a descrição.", "Validação",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
txtDescricao.Focus();
|
|
return false;
|
|
}
|
|
|
|
if (_clienteId == 0)
|
|
{
|
|
MessageBox.Show("Selecione um cliente.", "Validação",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
btnBuscarCliente.Focus();
|
|
return false;
|
|
}
|
|
|
|
if (_planoContaId == 0)
|
|
{
|
|
MessageBox.Show("Selecione um plano de contas.", "Validação",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
btnBuscarPlanoConta.Focus();
|
|
return false;
|
|
}
|
|
|
|
if (!decimal.TryParse(txtValor.Text.Replace(",", "."),
|
|
System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out _))
|
|
{
|
|
MessageBox.Show("Informe um valor válido.", "Validação",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
txtValor.Focus();
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(txtDataVencimento.Text))
|
|
{
|
|
MessageBox.Show("Informe a data de vencimento.", "Validação",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
txtDataVencimento.Focus();
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// ── MONTAR MODELO ─────────────────────────────────────────────────────
|
|
private ModeloContaReceber MontarModelo()
|
|
{
|
|
decimal.TryParse(txtValor.Text.Replace(",", "."),
|
|
System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out decimal valor);
|
|
decimal.TryParse(txtValorPago.Text.Replace(",", "."),
|
|
System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out decimal valorPago);
|
|
decimal.TryParse(txtJuros.Text.Replace(",", "."),
|
|
System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out decimal juros);
|
|
decimal.TryParse(txtMulta.Text.Replace(",", "."),
|
|
System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out decimal multa);
|
|
decimal.TryParse(txtDesconto.Text.Replace(",", "."),
|
|
System.Globalization.NumberStyles.Any,
|
|
System.Globalization.CultureInfo.InvariantCulture, out decimal desconto);
|
|
|
|
DateTime.TryParseExact(txtDataVencimento.Text, "dd/MM/yyyy",
|
|
null, System.Globalization.DateTimeStyles.None, out DateTime dataVenc);
|
|
|
|
DateTime.TryParseExact(txtDataEmissao.Text, "dd/MM/yyyy",
|
|
null, System.Globalization.DateTimeStyles.None, out DateTime dataEmissao);
|
|
DateTime? dataEmissaoNull = string.IsNullOrWhiteSpace(txtDataEmissao.Text) ? null : dataEmissao;
|
|
|
|
DateTime.TryParseExact(txtDataPagamento.Text, "dd/MM/yyyy",
|
|
null, System.Globalization.DateTimeStyles.None, out DateTime dataPag);
|
|
DateTime? dataPagNull = string.IsNullOrWhiteSpace(txtDataPagamento.Text) ? null : dataPag;
|
|
|
|
return new ModeloContaReceber(
|
|
_idAtual,
|
|
0, // EmpresaId — preenchido pela BLL via sessão
|
|
_clienteId,
|
|
_planoContaId,
|
|
_contratoId,
|
|
txtDescricao.Text.Trim(),
|
|
valor,
|
|
string.IsNullOrWhiteSpace(txtValorPago.Text) ? null : valorPago,
|
|
juros,
|
|
multa,
|
|
desconto,
|
|
cmbStatus.SelectedItem?.ToString() ?? "Pendente",
|
|
dataEmissaoNull,
|
|
dataVenc,
|
|
dataPagNull,
|
|
txtObservacoes.Text.Trim(),
|
|
chkAtivo.Checked,
|
|
_modo == ModoFormulario.Novo ? DateTime.Now : DateTime.Parse(txtCriadoEm.Text),
|
|
DateTime.Now
|
|
);
|
|
}
|
|
|
|
// ── EVENTOS ABSTRATOS ─────────────────────────────────────────────────
|
|
protected override void OnNovo()
|
|
{
|
|
AplicarModo(ModoFormulario.Novo);
|
|
txtDescricao.Focus();
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
if (_idAtual == 0) return;
|
|
AplicarModo(ModoFormulario.Edicao);
|
|
txtDescricao.Focus();
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (_idAtual == 0) return;
|
|
|
|
var confirm = MessageBox.Show(
|
|
$"Deseja realmente excluir a conta \"{txtDescricao.Text}\"?",
|
|
"Confirmar exclusão",
|
|
MessageBoxButtons.YesNo,
|
|
MessageBoxIcon.Warning);
|
|
|
|
if (confirm != DialogResult.Yes) return;
|
|
|
|
try
|
|
{
|
|
// TODO: _bll.Excluir(_idAtual);
|
|
MessageBox.Show("Conta a receber excluída com sucesso.", "Sucesso",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
LimparCampos();
|
|
AplicarModo(ModoFormulario.Visualizacao);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Erro ao excluir:\n{ex.Message}", "Erro",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// TODO: abrir formulário de busca de contas a receber
|
|
// var frm = new FormularioBuscarContaReceber();
|
|
// if (frm.ShowDialog() == DialogResult.OK)
|
|
// {
|
|
// PopularCampos(frm.ContaSelecionada);
|
|
// AplicarModo(ModoFormulario.Visualizacao);
|
|
// }
|
|
MessageBox.Show("Implemente o formulário de busca de contas a receber.",
|
|
"Localizar", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
if (!Validar()) return;
|
|
|
|
var modelo = MontarModelo();
|
|
|
|
try
|
|
{
|
|
if (_modo == ModoFormulario.Novo)
|
|
{
|
|
// TODO: _bll.Criar(modelo);
|
|
MessageBox.Show("Conta a receber cadastrada com sucesso!", "Sucesso",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
else
|
|
{
|
|
// TODO: _bll.Atualizar(modelo);
|
|
MessageBox.Show("Conta a receber atualizada com sucesso!", "Sucesso",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
AplicarModo(ModoFormulario.Visualizacao);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Erro ao salvar:\n{ex.Message}", "Erro",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
if (_idAtual > 0)
|
|
{
|
|
// TODO: recarregar do banco se necessário
|
|
}
|
|
LimparCampos();
|
|
AplicarModo(ModoFormulario.Visualizacao);
|
|
}
|
|
}
|
|
} |