diff --git a/UI/Dashboards/Cadastros/Cheguescadastropanel.cs b/UI/Dashboards/Cadastros/Cheguescadastropanel.cs
new file mode 100644
index 0000000..d60921c
--- /dev/null
+++ b/UI/Dashboards/Cadastros/Cheguescadastropanel.cs
@@ -0,0 +1,516 @@
+using CPM;
+using DAL;
+using MLL;
+using BLL;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace UI
+{
+ public class CheguesCadastroPanel : FormularioModelo
+ {
+ // ── CAMPOS DO FORMULÁRIO ──────────────────────────────────────────────
+ private LV_TEXTBOX1 txtId = null!;
+ private LV_TEXTBOX1 txtCodigo = null!;
+ private LV_COMBOBOXCUSTOM cmbTipo = null!;
+
+ // Banco
+ private LV_TEXTBOX1 txtBanco = null!;
+ private LV_TEXTBOX1 txtAgencia = null!;
+ private LV_TEXTBOX1 txtConta = null!;
+ private LV_TEXTBOX1 txtNumero = null!;
+ private LV_TEXTBOX1 txtValor = null!;
+
+ // Cliente + Fornecedor — busca
+ private LV_TEXTBOX1 txtCliente = null!;
+ private Button btnBuscarCliente = null!;
+ private LV_TEXTBOX1 txtFornecedor = null!;
+ private Button btnBuscarFornecedor = null!;
+ private LV_TEXTBOX1 txtEmitente = null!;
+
+ // Datas e compensação
+ private LV_TEXTBOX1 txtEmitido = null!;
+ private LV_TEXTBOX1 txtCompensar = null!;
+ private LV_TEXTBOX1 txtCodConta = null!;
+ private CheckBox chkOk = null!;
+
+ // Observações
+ private LV_TEXTBOX1 txtObs = null!;
+
+ // ── ESTADO ────────────────────────────────────────────────────────────
+ private enum ModoFormulario { Visualizacao, Novo, Edicao }
+ private ModoFormulario _modo = ModoFormulario.Visualizacao;
+ private int _idAtual = 0;
+
+ // ── BLL ───────────────────────────────────────────────────────────────
+ // private ChegueBLL _bll = null!;
+
+ // ── CONSTRUTOR ────────────────────────────────────────────────────────
+ public CheguesCadastroPanel()
+ {
+ Titulo = "Cadastro de Cheques";
+ 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);
+ txtCodigo = AddInput(content, "Código", 120, 58, 160, 32);
+ txtCodigo.MaxLength = 50;
+
+ // Tipo
+ var lblTipo = new Label
+ {
+ Text = "Tipo",
+ Location = new Point(300, 58),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ cmbTipo = new LV_COMBOBOXCUSTOM
+ {
+ Location = new Point(300, 74),
+ Size = new Size(180, 32),
+ DropDownStyle = ComboBoxStyle.DropDownList,
+ BorderColor = BorderColor,
+ BackColor = Color.White,
+ ListBackColor = Color.White,
+ ListTextColor = TextDark,
+ IconColor = AccentBlue,
+ Font = new Font("Segoe UI", 9f)
+ };
+ cmbTipo.Items.Add("Recebido");
+ cmbTipo.Items.Add("Emitido");
+ cmbTipo.Items.Add("Devolvido");
+ cmbTipo.Items.Add("Cancelado");
+ cmbTipo.SelectedIndex = 0;
+ content.Controls.Add(lblTipo);
+ content.Controls.Add(cmbTipo);
+
+ // ── SEÇÃO: DADOS BANCÁRIOS ────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Dados Bancários", 128));
+
+ txtBanco = AddInput(content, "Banco", 20, 166, 220, 32);
+ txtBanco.MaxLength = 100;
+
+ txtAgencia = AddInput(content, "Agência", 260, 166, 140, 32);
+ txtAgencia.MaxLength = 20;
+
+ txtConta = AddInput(content, "Conta", 420, 166, 140, 32);
+ txtConta.MaxLength = 30;
+
+ txtNumero = AddInput(content, "Número", 580, 166, 120, 32);
+ txtNumero.MaxLength = 20;
+
+ txtValor = AddInput(content, "Valor", 20, 228, 160, 32);
+ txtValor.MaxLength = 20;
+
+ txtEmitido = AddInput(content, "Data Emissão", 200, 228, 160, 32);
+ txtEmitido.MaxLength = 20;
+
+ txtCompensar = AddInput(content, "Data Compensação", 380, 228, 160, 32);
+ txtCompensar.MaxLength = 20;
+
+ // CheckBox OK — compensado
+ chkOk = CreateCheckBox("Compensado (OK)", 560, 238);
+ content.Controls.Add(chkOk);
+
+ // ── SEÇÃO: PARTES ENVOLVIDAS ──────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Partes Envolvidas", 290));
+
+ // Cliente + botão buscar
+ var lblCliente = new Label
+ {
+ Text = "Cliente",
+ Location = new Point(20, 328),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtCliente = new LV_TEXTBOX1
+ {
+ Location = new Point(20, 344),
+ Size = new Size(220, 32),
+ BorderColor = BorderColor,
+ BorderFocusColor = AccentBlue,
+ ReadOnly = true,
+ BackColor = ReadOnlyBg
+ };
+ btnBuscarCliente = new Button
+ {
+ Text = "🔍 Buscar",
+ Location = new Point(248, 344),
+ 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(txtCliente);
+ content.Controls.Add(btnBuscarCliente);
+
+ // Fornecedor + botão buscar
+ var lblFornecedor = new Label
+ {
+ Text = "Fornecedor",
+ Location = new Point(360, 328),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtFornecedor = new LV_TEXTBOX1
+ {
+ Location = new Point(360, 344),
+ Size = new Size(220, 32),
+ BorderColor = BorderColor,
+ BorderFocusColor = AccentBlue,
+ ReadOnly = true,
+ BackColor = ReadOnlyBg
+ };
+ btnBuscarFornecedor = new Button
+ {
+ Text = "🔍 Buscar",
+ Location = new Point(588, 344),
+ 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
+ };
+ btnBuscarFornecedor.FlatAppearance.BorderSize = 0;
+ btnBuscarFornecedor.Click += BtnBuscarFornecedor_Click;
+ content.Controls.Add(lblFornecedor);
+ content.Controls.Add(txtFornecedor);
+ content.Controls.Add(btnBuscarFornecedor);
+
+ txtEmitente = AddInput(content, "Emitente", 20, 396, 340, 32);
+ txtEmitente.MaxLength = 150;
+
+ txtCodConta = AddInput(content, "Cód. Conta", 380, 396, 160, 32);
+ txtCodConta.MaxLength = 50;
+
+ // ── SEÇÃO: OBSERVAÇÕES ────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Observações", 450));
+
+ var lblObs = new Label
+ {
+ Text = "Observações",
+ Location = new Point(20, 488),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtObs = new LV_TEXTBOX1
+ {
+ Location = new Point(20, 504),
+ Size = new Size(680, 70),
+ BorderColor = BorderColor,
+ BorderFocusColor = AccentBlue,
+ Multiline = true,
+ MaxLength = 500
+ };
+ content.Controls.Add(lblObs);
+ content.Controls.Add(txtObs);
+
+ content.Height = 610;
+ }
+
+ // ── CAMPOS EDITÁVEIS ──────────────────────────────────────────────────
+ private LV_TEXTBOX1[] CamposEditaveis() => new[]
+ {
+ txtCodigo, txtBanco, txtAgencia, txtConta, txtNumero,
+ txtValor, txtEmitido, txtCompensar, txtEmitente, txtCodConta, txtObs
+ };
+
+ // ── 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;
+ }
+
+ cmbTipo.Enabled = editando;
+ cmbTipo.BorderColor = editando ? BorderColor : ReadOnlyBorder;
+ cmbTipo.BackColor = editando ? Color.White : ReadOnlyBg;
+
+ chkOk.Enabled = editando;
+
+ btnBuscarCliente.Enabled = editando;
+ btnBuscarFornecedor.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 CLIENTE ──────────────────────────────────────────────────
+ private void BtnBuscarCliente_Click(object? sender, EventArgs e)
+ {
+ // TODO: abrir formulário de busca de clientes
+ // var frm = new FormularioBuscarCliente();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // txtCliente.Text = frm.ClienteSelecionado.CODIGO;
+
+ MessageBox.Show("Implemente o formulário de busca de clientes.",
+ "Buscar Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ // ── BUSCA DE FORNECEDOR ───────────────────────────────────────────────
+ private void BtnBuscarFornecedor_Click(object? sender, EventArgs e)
+ {
+ // TODO: abrir formulário de busca de fornecedores
+ // var frm = new FormularioBuscarFornecedor();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // txtFornecedor.Text = frm.FornecedorSelecionado.CODIGO;
+
+ MessageBox.Show("Implemente o formulário de busca de fornecedores.",
+ "Buscar Fornecedor", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ // ── POPULAR / LIMPAR ──────────────────────────────────────────────────
+ private void PopularCampos(ModeloChegues m)
+ {
+ _idAtual = m.ID_CHEGUES;
+
+ txtId.Text = m.ID_CHEGUES.ToString();
+ txtCodigo.Text = m.CODIGO;
+ txtBanco.Text = m.BANCO;
+ txtAgencia.Text = m.AGENCIA;
+ txtConta.Text = m.CONTA;
+ txtNumero.Text = m.NUMERO;
+ txtValor.Text = m.VALOR;
+ txtCliente.Text = m.CLIENTE;
+ txtFornecedor.Text = m.FORNECEDOR;
+ txtEmitente.Text = m.EMITENTE;
+ txtEmitido.Text = m.EMITIDO;
+ txtCompensar.Text = m.COMPENSAR;
+ txtCodConta.Text = m.COD_CONTA;
+ txtObs.Text = m.OBS;
+ chkOk.Checked = m.OK == "S" || m.OK == "1" || m.OK?.ToLower() == "true";
+
+ SelecionarCombo(cmbTipo, m.TIPO);
+ }
+
+ private void LimparCampos()
+ {
+ _idAtual = 0;
+
+ txtId.Text = string.Empty;
+ txtCodigo.Text = string.Empty;
+ txtBanco.Text = string.Empty;
+ txtAgencia.Text = string.Empty;
+ txtConta.Text = string.Empty;
+ txtNumero.Text = string.Empty;
+ txtValor.Text = string.Empty;
+ txtCliente.Text = string.Empty;
+ txtFornecedor.Text = string.Empty;
+ txtEmitente.Text = string.Empty;
+ txtEmitido.Text = string.Empty;
+ txtCompensar.Text = string.Empty;
+ txtCodConta.Text = string.Empty;
+ txtObs.Text = string.Empty;
+ chkOk.Checked = false;
+ cmbTipo.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(txtCodigo.Text))
+ {
+ MessageBox.Show("Informe o código do cheque.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtCodigo.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtBanco.Text))
+ {
+ MessageBox.Show("Informe o banco.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtBanco.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtNumero.Text))
+ {
+ MessageBox.Show("Informe o número do cheque.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtNumero.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtValor.Text))
+ {
+ MessageBox.Show("Informe o valor do cheque.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtValor.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtEmitido.Text))
+ {
+ MessageBox.Show("Informe a data de emissão.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtEmitido.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ // ── MONTAR MODELO ─────────────────────────────────────────────────────
+ private ModeloChegues MontarModelo() => new ModeloChegues(
+ _idAtual,
+ txtCodigo.Text.Trim(),
+ txtBanco.Text.Trim(),
+ txtAgencia.Text.Trim(),
+ txtValor.Text.Trim(),
+ txtCliente.Text.Trim(),
+ txtFornecedor.Text.Trim(),
+ txtEmitido.Text.Trim(),
+ txtCompensar.Text.Trim(),
+ chkOk.Checked ? "S" : "N",
+ cmbTipo.SelectedItem?.ToString() ?? string.Empty,
+ txtConta.Text.Trim(),
+ txtNumero.Text.Trim(),
+ txtObs.Text.Trim(),
+ txtCodConta.Text.Trim(),
+ txtEmitente.Text.Trim()
+ );
+
+ // ── EVENTOS ABSTRATOS ─────────────────────────────────────────────────
+ protected override void OnNovo()
+ {
+ AplicarModo(ModoFormulario.Novo);
+ txtCodigo.Focus();
+ }
+
+ protected override void OnAlterar()
+ {
+ if (_idAtual == 0) return;
+ AplicarModo(ModoFormulario.Edicao);
+ txtCodigo.Focus();
+ }
+
+ protected override void OnExcluir()
+ {
+ if (_idAtual == 0) return;
+
+ var confirm = MessageBox.Show(
+ $"Deseja realmente excluir o cheque \"{txtNumero.Text}\"?",
+ "Confirmar exclusão",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning);
+
+ if (confirm != DialogResult.Yes) return;
+
+ try
+ {
+ // TODO: _bll.Excluir(_idAtual);
+ MessageBox.Show("Cheque excluído 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 cheques
+ // var frm = new FormularioBuscarCheques();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // {
+ // PopularCampos(frm.ChequeSelecionado);
+ // AplicarModo(ModoFormulario.Visualizacao);
+ // }
+
+ MessageBox.Show("Implemente o formulário de busca de cheques.",
+ "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("Cheque cadastrado com sucesso!", "Sucesso",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ // TODO: _bll.Atualizar(modelo);
+ MessageBox.Show("Cheque atualizado 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/UI/Dashboards/Cadastros/Clientesenderecoscadastropanel.cs b/UI/Dashboards/Cadastros/Clientesenderecoscadastropanel.cs
new file mode 100644
index 0000000..768358f
--- /dev/null
+++ b/UI/Dashboards/Cadastros/Clientesenderecoscadastropanel.cs
@@ -0,0 +1,452 @@
+using CPM;
+using DAL;
+using MLL;
+using BLL;
+using System;
+using System.Drawing;
+using System.Net.Http;
+using System.Text.Json;
+using System.Windows.Forms;
+
+namespace UI
+{
+ public class ClientesEnderecosCadastroPanel : FormularioModelo
+ {
+ // ── CAMPOS DO FORMULÁRIO ──────────────────────────────────────────────
+ private LV_TEXTBOX1 txtId = null!;
+ private LV_TEXTBOX1 txtCodigo = null!;
+
+ // Cliente — busca
+ private LV_TEXTBOX1 txtCodCliente = null!;
+ private Button btnBuscarCliente = null!;
+
+ // Endereço
+ private LV_TEXTBOX1 txtCep = null!;
+ private Button btnBuscarCep = null!;
+ private LV_TEXTBOX1 txtLogradouro = null!;
+ private LV_TEXTBOX1 txtNumero = null!;
+ private LV_TEXTBOX1 txtComplem = null!;
+ private LV_TEXTBOX1 txtBairro = null!;
+ private LV_TEXTBOX1 txtCidade = null!;
+ private LV_TEXTBOX1 txtUf = null!;
+ private LV_TEXTBOX1 txtDataCadastro = null!;
+
+ // ── ESTADO ────────────────────────────────────────────────────────────
+ private enum ModoFormulario { Visualizacao, Novo, Edicao }
+ private ModoFormulario _modo = ModoFormulario.Visualizacao;
+ private int _idAtual = 0;
+
+ // ── BLL ───────────────────────────────────────────────────────────────
+ // private ClientesEnderecosBLL _bll = null!;
+
+ // ── CONSTRUTOR ────────────────────────────────────────────────────────
+ public ClientesEnderecosCadastroPanel()
+ {
+ Titulo = "Cadastro de Endereços de Clientes";
+ 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);
+ txtCodigo = AddInput(content, "Código", 120, 58, 160, 32);
+ txtCodigo.MaxLength = 50;
+
+ // ── SEÇÃO: CLIENTE ────────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Cliente", 110));
+
+ var lblCodCliente = new Label
+ {
+ Text = "Cód. Cliente",
+ Location = new Point(20, 148),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtCodCliente = new LV_TEXTBOX1
+ {
+ Location = new Point(20, 164),
+ Size = new Size(200, 32),
+ BorderColor = BorderColor,
+ BorderFocusColor = AccentBlue,
+ ReadOnly = true,
+ BackColor = ReadOnlyBg
+ };
+ btnBuscarCliente = new Button
+ {
+ Text = "🔍 Buscar",
+ Location = new Point(228, 164),
+ 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(lblCodCliente);
+ content.Controls.Add(txtCodCliente);
+ content.Controls.Add(btnBuscarCliente);
+
+ // ── SEÇÃO: ENDEREÇO ───────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Endereço", 218));
+
+ // CEP + botão buscar
+ var lblCep = new Label
+ {
+ Text = "CEP",
+ Location = new Point(20, 256),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtCep = new LV_TEXTBOX1
+ {
+ Location = new Point(20, 272),
+ Size = new Size(140, 32),
+ BorderColor = BorderColor,
+ BorderFocusColor = AccentBlue,
+ MaxLength = 9
+ };
+ btnBuscarCep = new Button
+ {
+ Text = "🔍 Buscar CEP",
+ Location = new Point(168, 272),
+ Size = new Size(120, 32),
+ BackColor = AccentBlue,
+ ForeColor = Color.White,
+ Font = new Font("Segoe UI Semibold", 8.5f),
+ Cursor = Cursors.Hand,
+ FlatStyle = FlatStyle.Flat,
+ Enabled = false
+ };
+ btnBuscarCep.FlatAppearance.BorderSize = 0;
+ btnBuscarCep.Click += BtnBuscarCep_Click;
+ content.Controls.Add(lblCep);
+ content.Controls.Add(txtCep);
+ content.Controls.Add(btnBuscarCep);
+
+ // Logradouro — preenchido via CEP mas editável para ajustes
+ txtLogradouro = AddInput(content, "Logradouro", 20, 334, 460, 32);
+ txtLogradouro.MaxLength = 200;
+
+ txtNumero = AddInput(content, "Número", 500, 334, 100, 32);
+ txtNumero.MaxLength = 20;
+
+ txtComplem = AddInput(content, "Complemento", 20, 396, 280, 32);
+ txtComplem.MaxLength = 100;
+
+ txtBairro = AddInput(content, "Bairro", 320, 396, 280, 32);
+ txtBairro.MaxLength = 100;
+
+ txtCidade = AddInput(content, "Cidade", 20, 458, 340, 32);
+ txtCidade.MaxLength = 100;
+
+ txtUf = AddInput(content, "UF", 380, 458, 60, 32);
+ txtUf.MaxLength = 2;
+
+ // ── SEÇÃO: AUDITORIA ──────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Auditoria", 516));
+
+ txtDataCadastro = AddInput(content, "Data de Cadastro", 20, 554, 200, 32, readOnly: true);
+
+ content.Height = 620;
+ }
+
+ // ── CAMPOS PREENCHIDOS PELO CEP — editáveis mas com visual distinto ───
+ private LV_TEXTBOX1[] CamposEndereco() => new[]
+ { txtLogradouro, txtBairro, txtCidade, txtUf };
+
+ // ── CAMPOS EDITÁVEIS NORMAIS ──────────────────────────────────────────
+ private LV_TEXTBOX1[] CamposEditaveis() => new[]
+ { txtCodigo, txtCep, txtLogradouro, txtNumero, txtComplem, txtBairro, txtCidade, txtUf };
+
+ // ── 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;
+ }
+
+ btnBuscarCliente.Enabled = editando;
+ btnBuscarCep.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 CLIENTE ──────────────────────────────────────────────────
+ private void BtnBuscarCliente_Click(object? sender, EventArgs e)
+ {
+ // TODO: abrir formulário de busca de clientes
+ // var frm = new FormularioBuscarCliente();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // txtCodCliente.Text = frm.ClienteSelecionado.CODIGO;
+
+ MessageBox.Show("Implemente o formulário de busca de clientes.",
+ "Buscar Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ // ── BUSCA DE CEP (ViaCEP) ─────────────────────────────────────────────
+ private async void BtnBuscarCep_Click(object? sender, EventArgs e)
+ {
+ string cep = txtCep.Text.Trim().Replace("-", "").Replace(".", "");
+
+ if (cep.Length != 8)
+ {
+ MessageBox.Show("Informe um CEP válido com 8 dígitos.", "CEP inválido",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtCep.Focus();
+ return;
+ }
+
+ btnBuscarCep.Enabled = false;
+ btnBuscarCep.Text = "Buscando...";
+
+ try
+ {
+ using var http = new HttpClient();
+ var json = await http.GetStringAsync($"https://viacep.com.br/ws/{cep}/json/");
+ using var doc = JsonDocument.Parse(json);
+ var root = doc.RootElement;
+
+ if (root.TryGetProperty("erro", out _))
+ {
+ MessageBox.Show("CEP não encontrado.", "CEP inválido",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
+ }
+
+ txtLogradouro.Text = root.GetProperty("logradouro").GetString() ?? string.Empty;
+ txtBairro.Text = root.GetProperty("bairro").GetString() ?? string.Empty;
+ txtCidade.Text = root.GetProperty("localidade").GetString() ?? string.Empty;
+ txtUf.Text = root.GetProperty("uf").GetString() ?? string.Empty;
+
+ // Foca no número após preencher o endereço
+ txtNumero.Focus();
+ }
+ catch
+ {
+ MessageBox.Show("Não foi possível buscar o CEP. Verifique sua conexão.",
+ "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ finally
+ {
+ btnBuscarCep.Enabled = true;
+ btnBuscarCep.Text = "🔍 Buscar CEP";
+ }
+ }
+
+ // ── POPULAR / LIMPAR ──────────────────────────────────────────────────
+ private void PopularCampos(ModeloClientesEnderecos m)
+ {
+ _idAtual = m.ID_COD_CLIENTE_END;
+
+ txtId.Text = m.ID_COD_CLIENTE_END.ToString();
+ txtCodigo.Text = m.CODIGO;
+ txtCodCliente.Text = m.COD_CLIENTE;
+ txtCep.Text = m.CEP;
+ txtLogradouro.Text = m.LOGRADOURO;
+ txtNumero.Text = m.NUMERO;
+ txtComplem.Text = m.COMPLEM;
+ txtBairro.Text = m.BAIRRO;
+ txtCidade.Text = m.CIDADE;
+ txtUf.Text = m.UF;
+ txtDataCadastro.Text = m.DATA_CADASTRO;
+ }
+
+ private void LimparCampos()
+ {
+ _idAtual = 0;
+
+ txtId.Text = string.Empty;
+ txtCodigo.Text = string.Empty;
+ txtCodCliente.Text = string.Empty;
+ txtCep.Text = string.Empty;
+ txtLogradouro.Text = string.Empty;
+ txtNumero.Text = string.Empty;
+ txtComplem.Text = string.Empty;
+ txtBairro.Text = string.Empty;
+ txtCidade.Text = string.Empty;
+ txtUf.Text = string.Empty;
+ txtDataCadastro.Text = string.Empty;
+ }
+
+ // ── VALIDAÇÃO ─────────────────────────────────────────────────────────
+ private bool Validar()
+ {
+ if (string.IsNullOrWhiteSpace(txtCodCliente.Text))
+ {
+ MessageBox.Show("Selecione um cliente.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ btnBuscarCliente.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtCep.Text))
+ {
+ MessageBox.Show("Informe o CEP.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtCep.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtLogradouro.Text))
+ {
+ MessageBox.Show("Informe o logradouro.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtLogradouro.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtCidade.Text))
+ {
+ MessageBox.Show("Informe a cidade.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtCidade.Focus();
+ return false;
+ }
+
+ if (string.IsNullOrWhiteSpace(txtUf.Text))
+ {
+ MessageBox.Show("Informe a UF.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ txtUf.Focus();
+ return false;
+ }
+
+ return true;
+ }
+
+ // ── MONTAR MODELO ─────────────────────────────────────────────────────
+ private ModeloClientesEnderecos MontarModelo() => new ModeloClientesEnderecos(
+ _idAtual,
+ txtCodigo.Text.Trim(),
+ txtCodCliente.Text.Trim(),
+ txtLogradouro.Text.Trim(),
+ txtNumero.Text.Trim(),
+ txtComplem.Text.Trim(),
+ txtBairro.Text.Trim(),
+ txtCidade.Text.Trim(),
+ txtUf.Text.Trim().ToUpper(),
+ txtCep.Text.Trim(),
+ txtDataCadastro.Text.Trim()
+ );
+
+ // ── EVENTOS ABSTRATOS ─────────────────────────────────────────────────
+ protected override void OnNovo()
+ {
+ AplicarModo(ModoFormulario.Novo);
+ btnBuscarCliente.Focus();
+ }
+
+ protected override void OnAlterar()
+ {
+ if (_idAtual == 0) return;
+ AplicarModo(ModoFormulario.Edicao);
+ txtCep.Focus();
+ }
+
+ protected override void OnExcluir()
+ {
+ if (_idAtual == 0) return;
+
+ var confirm = MessageBox.Show(
+ $"Deseja realmente excluir o endereço \"{txtLogradouro.Text}, {txtNumero.Text}\"?",
+ "Confirmar exclusão",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning);
+
+ if (confirm != DialogResult.Yes) return;
+
+ try
+ {
+ // TODO: _bll.Excluir(_idAtual);
+ MessageBox.Show("Endereço excluído 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 endereços
+ // var frm = new FormularioBuscarClientesEnderecos();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // {
+ // PopularCampos(frm.EnderecoSelecionado);
+ // AplicarModo(ModoFormulario.Visualizacao);
+ // }
+
+ MessageBox.Show("Implemente o formulário de busca de endereços.",
+ "Localizar", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ protected override void OnSalvar()
+ {
+ if (!Validar()) return;
+
+ var modelo = MontarModelo();
+
+ try
+ {
+ if (_modo == ModoFormulario.Novo)
+ {
+ // TODO: modelo.DATA_CADASTRO = DateTime.Now.ToString("dd/MM/yyyy");
+ // _bll.Criar(modelo);
+ MessageBox.Show("Endereço cadastrado com sucesso!", "Sucesso",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ // TODO: _bll.Atualizar(modelo);
+ MessageBox.Show("Endereço atualizado 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/UI/Dashboards/Cadastros/ConfigCadastroPanel.cs b/UI/Dashboards/Cadastros/ConfigCadastroPanel.cs
new file mode 100644
index 0000000..284c20b
--- /dev/null
+++ b/UI/Dashboards/Cadastros/ConfigCadastroPanel.cs
@@ -0,0 +1,732 @@
+using BLL;
+using CPM;
+using DAL;
+using MLL;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using static System.Runtime.InteropServices.JavaScript.JSType;
+
+namespace UI
+{
+ public class ConfigCadastroPanel : FormularioModelo
+ {
+ // ── TABS ──────────────────────────────────────────────────────────────
+ private TabControl tabMain = null!;
+
+ // ── ABA 1: GERAL ──────────────────────────────────────────────────────
+ private LV_TEXTBOX1 txtId = null!;
+ private LV_TEXTBOX1 txtEstoque = null!;
+ private LV_TEXTBOX1 txtOficina = null!;
+ private LV_TEXTBOX1 txtOficinaDono = null!;
+ private LV_TEXTBOX1 txtBanco = null!;
+ private LV_TEXTBOX1 txtContas = null!;
+ private LV_TEXTBOX1 txtVendasL1 = null!;
+ private LV_TEXTBOX1 txtVendasL2 = null!;
+ private LV_TEXTBOX1 txtModeloVenda = null!;
+ private LV_TEXTBOX1 txtPrnPortVenda = null!;
+ private LV_TEXTBOX1 txtCopiasVenda = null!;
+ private LV_TEXTBOX1 txtVersao = null!;
+ private LV_TEXTBOX1 txtVersaoP = null!;
+ private LV_TEXTBOX1 txtSerial = null!;
+ private LV_TEXTBOX1 txtSerial2 = null!;
+ private LV_TEXTBOX1 txtNossoNumero = null!;
+ private LV_TEXTBOX1 txtRevenda = null!;
+ private LV_TEXTBOX1 txtCodFab = null!;
+ private LV_TEXTBOX1 txtSHCompras = null!;
+ private LV_TEXTBOX1 txtDataCadastro = null!;
+
+ // ── ABA 2: SMTP ───────────────────────────────────────────────────────
+ private LV_TEXTBOX1 txtSmtpServer = null!;
+ private LV_TEXTBOX1 txtSmtpUser = null!;
+ private LV_TEXTBOX1 txtSmtpPass = null!;
+ private LV_TEXTBOX1 txtSmtpTit = null!;
+ private LV_TEXTBOX1 txtSmtpEmail = null!;
+ private LV_TEXTBOX1 txtSmtpCc = null!;
+ private LV_TEXTBOX1 txtSmtpPort = null!;
+ private LV_TEXTBOX1 txtSmtpSsl = null!;
+ private LV_TEXTBOX1 txtSmtpCok = null!;
+ private LV_TEXTBOX1 txtSmtpSemAutentica = null!;
+
+ // ── ABA 3: CARTÃO ─────────────────────────────────────────────────────
+ private LV_TEXTBOX1 txtCartaoRegOk = null!;
+ private LV_TEXTBOX1 txtCartaoDebtDireto = null!;
+ private LV_TEXTBOX1 txtCartaoCredDireto = null!;
+ private LV_TEXTBOX1 txtCartaoCredComiss = null!;
+ private LV_TEXTBOX1 txtCartaoDebtComiss = null!;
+ private LV_TEXTBOX1 txtCartaoCredParcela = null!;
+ private LV_TEXTBOX1 txtComissVendas = null!;
+ private LV_TEXTBOX1 txtMaxDesVendas = null!;
+
+ // ── ABA 4: NFe ────────────────────────────────────────────────────────
+ private LV_TEXTBOX1 txtNfeFormaEmissao = null!;
+ private LV_TEXTBOX1 txtNfeEnfe = null!;
+ private LV_TEXTBOX1 txtNfeEmailOk = null!;
+ private LV_TEXTBOX1 txtUltimaImpressao = null!;
+ private LV_TEXTBOX1 txtDataSaida = null!;
+ private LV_TEXTBOX1 txtImpressa = null!;
+ private LV_TEXTBOX1 txtFreteNumero = null!;
+
+ // ── ABA 5: DESTINATÁRIO ───────────────────────────────────────────────
+ private LV_TEXTBOX1 txtDestNome = null!;
+ private LV_TEXTBOX1 txtDestEndereco = null!;
+ private LV_TEXTBOX1 txtDestBairro = null!;
+ private LV_TEXTBOX1 txtDestCidade = null!;
+ private LV_TEXTBOX1 txtDestUf = null!;
+ private LV_TEXTBOX1 txtDestCep = null!;
+ private LV_TEXTBOX1 txtDestCodPais = null!;
+ private LV_TEXTBOX1 txtDestTel = null!;
+ private LV_TEXTBOX1 txtDestFax = null!;
+ private LV_TEXTBOX1 txtDestEmail = null!;
+ private LV_TEXTBOX1 txtDestIeRg = null!;
+ private LV_TEXTBOX1 txtDestCnpjCpf = null!;
+
+ // ── ABA 6: FRETE E VALORES ────────────────────────────────────────────
+ private LV_TEXTBOX1 txtFreteNome = null!;
+ private LV_TEXTBOX1 txtFreteUf = null!;
+ private LV_TEXTBOX1 txtFreteCnpjCpf = null!;
+ private LV_TEXTBOX1 txtFreteIeRg = null!;
+ private LV_TEXTBOX1 txtFreteEndereco = null!;
+ private LV_TEXTBOX1 txtFreteMunicipio = null!;
+ private LV_TEXTBOX1 txtFreteTuf = null!;
+ private LV_TEXTBOX1 txtVFrete = null!;
+ private LV_TEXTBOX1 txtVSeguro = null!;
+ private LV_TEXTBOX1 txtVOutros = null!;
+
+ // ── ABA 7: TRIBUTOS ───────────────────────────────────────────────────
+ private LV_TEXTBOX1 txtValorDesconto = null!;
+ private LV_TEXTBOX1 txtValorIrrf = null!;
+ private LV_TEXTBOX1 txtValorIrpj = null!;
+ private LV_TEXTBOX1 txtValorPis = null!;
+ private LV_TEXTBOX1 txtValorCofins = null!;
+ private LV_TEXTBOX1 txtValorCsll = null!;
+ private LV_TEXTBOX1 txtValorBenef = null!;
+ private LV_TEXTBOX1 txtValorInss = null!;
+ private LV_TEXTBOX1 txtValorSimples = null!;
+ private LV_TEXTBOX1 txtTotalDesc = null!;
+ private LV_TEXTBOX1 txtTotalDeducoes = null!;
+ private LV_TEXTBOX1 txtTotalServicos = null!;
+ private LV_TEXTBOX1 txtTotalProdutos = null!;
+ private LV_TEXTBOX1 txtTotalIss = null!;
+ private LV_TEXTBOX1 txtTotalIrrf = null!;
+ private LV_TEXTBOX1 txtTotalIrpj = null!;
+ private LV_TEXTBOX1 txtTotalPis = null!;
+ private LV_TEXTBOX1 txtTotalCofins = null!;
+ private LV_TEXTBOX1 txtTotalCsll = null!;
+ private LV_TEXTBOX1 txtTotalInss = null!;
+ private LV_TEXTBOX1 txtTotalSimples = null!;
+ private LV_TEXTBOX1 txtDbCsIcmsS = null!;
+ private LV_TEXTBOX1 txtDbCsFrete = null!;
+ private LV_TEXTBOX1 txtDbCsSeguro = null!;
+ private LV_TEXTBOX1 txtDbCsDespesas = null!;
+ private LV_TEXTBOX1 txtDbCinFrete = null!;
+ private LV_TEXTBOX1 txtDbCinSeguro = null!;
+ private LV_TEXTBOX1 txtDbCinDespesas = null!;
+ private LV_TEXTBOX1 txtDbCinDesconto = null!;
+ private LV_TEXTBOX1 txtDbCsIss = null!;
+ private LV_TEXTBOX1 txtDbCsIrrf = null!;
+ private LV_TEXTBOX1 txtDbCsIrpj = null!;
+ private LV_TEXTBOX1 txtDbCsPis = null!;
+ private LV_TEXTBOX1 txtDbCsCofins = null!;
+ private LV_TEXTBOX1 txtDbCsCsll = null!;
+ private LV_TEXTBOX1 txtDbCsInss = null!;
+ private LV_TEXTBOX1 txtDbCsSimples = null!;
+
+ // ── ESTADO ────────────────────────────────────────────────────────────
+ private enum ModoFormulario { Visualizacao, Edicao }
+ private ModoFormulario _modo = ModoFormulario.Visualizacao;
+ private int _idAtual = 0;
+
+ // ── BLL ───────────────────────────────────────────────────────────────
+ // private ConfigBLL _bll = null!;
+
+ // ── CONSTRUTOR ────────────────────────────────────────────────────────
+ public ConfigCadastroPanel()
+ {
+ Titulo = "Configurações do Sistema";
+ BuildForm();
+
+ // Botão extra — Gerar Ficha
+ var btnGerarFicha = CreateToolbarButton("Gerar Ficha", Color.FromArgb(99, 102, 241));
+ btnGerarFicha.Click += (s, e) => OnGerarFicha();
+ AddToolbarButton(btnGerarFicha);
+
+ AplicarModo(ModoFormulario.Visualizacao);
+ }
+
+ // ── CONSTRUÇÃO DO FORMULÁRIO ──────────────────────────────────────────
+ private void BuildForm()
+ {
+ tabMain = new TabControl
+ {
+ Location = new Point(10, 10),
+ Size = new Size(1060, 860),
+ Font = new Font("Segoe UI", 9f)
+ };
+
+ tabMain.TabPages.Add(BuildAbaGeral());
+ tabMain.TabPages.Add(BuildAbaSmtp());
+ tabMain.TabPages.Add(BuildAbaCartao());
+ tabMain.TabPages.Add(BuildAbaNfe());
+ tabMain.TabPages.Add(BuildAbaDestinatario());
+ tabMain.TabPages.Add(BuildAbaFrete());
+ tabMain.TabPages.Add(BuildAbaTributos());
+
+ content.Controls.Add(tabMain);
+ content.Height = 900;
+ }
+
+ // ── HELPER: cria painel de aba com scroll ─────────────────────────────
+ private static Panel CriarPainelAba()
+ {
+ var pnl = new Panel
+ {
+ Dock = DockStyle.Fill,
+ AutoScroll = true,
+ BackColor = Color.White,
+ Padding = new Padding(10)
+ };
+ return pnl;
+ }
+
+ // ── HELPER: AddInput dentro de painel de aba ──────────────────────────
+ private LV_TEXTBOX1 AbaInput(Panel parent, string label, int x, int y, int w, bool readOnly = false)
+ {
+ return AddInput(parent, label, x, y, w, 32, readOnly);
+ }
+
+ // ── ABA 1: GERAL ──────────────────────────────────────────────────────
+ private TabPage BuildAbaGeral()
+ {
+ var tab = new TabPage("⚙️ Geral") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Identificação", 10));
+ txtId = AbaInput(pnl, "ID", 10, 48, 80, readOnly: true);
+ txtVersao = AbaInput(pnl, "Versão", 110, 48, 140, readOnly: true);
+ txtVersaoP = AbaInput(pnl, "Versão P", 270, 48, 140, readOnly: true);
+ txtSerial = AbaInput(pnl, "Serial", 430, 48, 200);
+ txtSerial2 = AbaInput(pnl, "Serial 2", 650, 48, 200);
+
+ pnl.Controls.Add(CreateSectionHeader("Sistema", 108));
+ txtEstoque = AbaInput(pnl, "Estoque", 10, 146, 200);
+ txtOficina = AbaInput(pnl, "Oficina", 230, 146, 200);
+ txtOficinaDono = AbaInput(pnl, "Dono Oficina", 450, 146, 280);
+
+ txtBanco = AbaInput(pnl, "Banco", 10, 208, 200);
+ txtContas = AbaInput(pnl, "Contas", 230, 208, 200);
+ txtNossoNumero = AbaInput(pnl, "Nosso Número", 450, 208, 200);
+ txtRevenda = AbaInput(pnl, "Revenda", 670, 208, 120);
+
+ pnl.Controls.Add(CreateSectionHeader("Vendas", 268));
+ txtVendasL1 = AbaInput(pnl, "Vendas L1", 10, 306, 200);
+ txtVendasL2 = AbaInput(pnl, "Vendas L2", 230, 306, 200);
+ txtModeloVenda = AbaInput(pnl, "Modelo Venda", 450, 306, 160);
+ txtPrnPortVenda = AbaInput(pnl, "Porta Imp.", 630, 306, 120);
+ txtCopiasVenda = AbaInput(pnl, "Cópias", 770, 306, 80);
+
+ pnl.Controls.Add(CreateSectionHeader("Outros", 366));
+ txtSHCompras = AbaInput(pnl, "SH Compras", 10, 404, 160);
+ txtCodFab = AbaInput(pnl, "Cód. Fab.", 190, 404, 160);
+ txtDataCadastro = AbaInput(pnl, "Data Cadastro", 370, 404, 160, readOnly: true);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── ABA 2: SMTP ───────────────────────────────────────────────────────
+ private TabPage BuildAbaSmtp()
+ {
+ var tab = new TabPage("📩 SMTP") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Servidor", 10));
+ txtSmtpServer = AbaInput(pnl, "Servidor SMTP", 10, 48, 300);
+ txtSmtpPort = AbaInput(pnl, "Porta", 330, 48, 100);
+ txtSmtpSsl = AbaInput(pnl, "SSL", 450, 48, 100);
+ txtSmtpSemAutentica = AbaInput(pnl, "Sem Autenticação", 570, 48, 160);
+
+ pnl.Controls.Add(CreateSectionHeader("Credenciais", 108));
+ txtSmtpUser = AbaInput(pnl, "Usuário", 10, 146, 300);
+ txtSmtpPass = AbaInput(pnl, "Senha", 330, 146, 200);
+ txtSmtpPass.PasswordChar = '●';
+ txtSmtpCok = AbaInput(pnl, "Chave OK", 550, 146, 160);
+
+ pnl.Controls.Add(CreateSectionHeader("E-mail", 206));
+ txtSmtpTit = AbaInput(pnl, "Título", 10, 244, 400);
+ txtSmtpEmail = AbaInput(pnl, "E-mail", 10, 306, 300);
+ txtSmtpCc = AbaInput(pnl, "CC", 330, 306, 300);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── ABA 3: CARTÃO ─────────────────────────────────────────────────────
+ private TabPage BuildAbaCartao()
+ {
+ var tab = new TabPage("💳 Cartão") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Configurações de Cartão", 10));
+ txtCartaoRegOk = AbaInput(pnl, "Reg. OK", 10, 48, 160);
+ txtCartaoDebtDireto = AbaInput(pnl, "Déb. Direto", 190, 48, 160);
+ txtCartaoCredDireto = AbaInput(pnl, "Cré. Direto", 370, 48, 160);
+ txtCartaoCredParcela = AbaInput(pnl, "Cré. Parcela", 550, 48, 160);
+
+ txtCartaoCredComiss = AbaInput(pnl, "Comissão Crédito", 10, 110, 200);
+ txtCartaoDebtComiss = AbaInput(pnl, "Comissão Débito", 230, 110, 200);
+
+ pnl.Controls.Add(CreateSectionHeader("Vendas", 170));
+ txtComissVendas = AbaInput(pnl, "Comissão Vendas (%)", 10, 208, 200);
+ txtMaxDesVendas = AbaInput(pnl, "Desconto Máximo (%)", 230, 208, 200);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── ABA 4: NFe ────────────────────────────────────────────────────────
+ private TabPage BuildAbaNfe()
+ {
+ var tab = new TabPage("🧾 NFe") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Configurações NFe", 10));
+ txtNfeFormaEmissao = AbaInput(pnl, "Forma Emissão", 10, 48, 200);
+ txtNfeEnfe = AbaInput(pnl, "eNFe", 230, 48, 160);
+ txtNfeEmailOk = AbaInput(pnl, "E-mail OK", 410, 48, 160);
+
+ pnl.Controls.Add(CreateSectionHeader("Impressão", 108));
+ txtUltimaImpressao = AbaInput(pnl, "Última Impressão", 10, 146, 200);
+ txtDataSaida = AbaInput(pnl, "Data Saída", 230, 146, 160);
+ txtImpressa = AbaInput(pnl, "Impressa", 410, 146, 160);
+ txtFreteNumero = AbaInput(pnl, "Nº Frete", 590, 146, 120);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── ABA 5: DESTINATÁRIO ───────────────────────────────────────────────
+ private TabPage BuildAbaDestinatario()
+ {
+ var tab = new TabPage("📦 Destinatário") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Dados do Destinatário", 10));
+ txtDestNome = AbaInput(pnl, "Nome", 10, 48, 500);
+ txtDestCnpjCpf = AbaInput(pnl, "CNPJ/CPF", 530, 48, 200);
+ txtDestIeRg = AbaInput(pnl, "IE/RG", 750, 48, 160);
+
+ pnl.Controls.Add(CreateSectionHeader("Endereço", 108));
+ txtDestEndereco = AbaInput(pnl, "Endereço", 10, 146, 400);
+ txtDestBairro = AbaInput(pnl, "Bairro", 430, 146, 220);
+ txtDestCidade = AbaInput(pnl, "Cidade", 10, 208, 300);
+ txtDestUf = AbaInput(pnl, "UF", 330, 208, 60);
+ txtDestCep = AbaInput(pnl, "CEP", 410, 208, 140);
+ txtDestCodPais = AbaInput(pnl, "Cód. País", 570, 208, 100);
+
+ pnl.Controls.Add(CreateSectionHeader("Contato", 268));
+ txtDestTel = AbaInput(pnl, "Telefone", 10, 306, 200);
+ txtDestFax = AbaInput(pnl, "Fax", 230, 306, 200);
+ txtDestEmail = AbaInput(pnl, "E-mail", 450, 306, 300);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── ABA 6: FRETE E VALORES ────────────────────────────────────────────
+ private TabPage BuildAbaFrete()
+ {
+ var tab = new TabPage("🚚 Frete") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Transportadora", 10));
+ txtFreteNome = AbaInput(pnl, "Nome", 10, 48, 300);
+ txtFreteCnpjCpf = AbaInput(pnl, "CNPJ/CPF", 330, 48, 200);
+ txtFreteIeRg = AbaInput(pnl, "IE/RG", 550, 48, 160);
+ txtFreteEndereco = AbaInput(pnl, "Endereço", 10, 110, 340);
+ txtFreteMunicipio = AbaInput(pnl, "Município", 370, 110, 240);
+ txtFreteUf = AbaInput(pnl, "UF", 630, 110, 60);
+ txtFreteTuf = AbaInput(pnl, "TUF", 710, 110, 80);
+
+ pnl.Controls.Add(CreateSectionHeader("Valores", 170));
+ txtVFrete = AbaInput(pnl, "Valor Frete", 10, 208, 160);
+ txtVSeguro = AbaInput(pnl, "Valor Seguro", 190, 208, 160);
+ txtVOutros = AbaInput(pnl, "Outros", 370, 208, 160);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── ABA 7: TRIBUTOS ───────────────────────────────────────────────────
+ private TabPage BuildAbaTributos()
+ {
+ var tab = new TabPage("📊 Tributos") { BackColor = Color.White };
+ var pnl = CriarPainelAba();
+
+ pnl.Controls.Add(CreateSectionHeader("Valores Unitários", 10));
+ txtValorDesconto = AbaInput(pnl, "Desconto", 10, 48, 120);
+ txtValorIrrf = AbaInput(pnl, "IRRF", 150, 48, 120);
+ txtValorIrpj = AbaInput(pnl, "IRPJ", 290, 48, 120);
+ txtValorPis = AbaInput(pnl, "PIS", 430, 48, 120);
+ txtValorCofins = AbaInput(pnl, "COFINS", 570, 48, 120);
+ txtValorCsll = AbaInput(pnl, "CSLL", 710, 48, 120);
+ txtValorBenef = AbaInput(pnl, "Benef.", 10, 110, 120);
+ txtValorInss = AbaInput(pnl, "INSS", 150, 110, 120);
+ txtValorSimples = AbaInput(pnl, "Simples", 290, 110, 120);
+
+ pnl.Controls.Add(CreateSectionHeader("Totais", 170));
+ txtTotalDesc = AbaInput(pnl, "Desc.", 10, 208, 120);
+ txtTotalDeducoes = AbaInput(pnl, "Deduções", 150, 208, 120);
+ txtTotalServicos = AbaInput(pnl, "Serviços", 290, 208, 120);
+ txtTotalProdutos = AbaInput(pnl, "Produtos", 430, 208, 120);
+ txtTotalIss = AbaInput(pnl, "ISS", 570, 208, 120);
+ txtTotalIrrf = AbaInput(pnl, "IRRF", 710, 208, 120);
+ txtTotalIrpj = AbaInput(pnl, "IRPJ", 10, 270, 120);
+ txtTotalPis = AbaInput(pnl, "PIS", 150, 270, 120);
+ txtTotalCofins = AbaInput(pnl, "COFINS", 290, 270, 120);
+ txtTotalCsll = AbaInput(pnl, "CSLL", 430, 270, 120);
+ txtTotalInss = AbaInput(pnl, "INSS", 570, 270, 120);
+ txtTotalSimples = AbaInput(pnl, "Simples", 710, 270, 120);
+
+ pnl.Controls.Add(CreateSectionHeader("DB — Campos Serviço", 330));
+ txtDbCsIcmsS = AbaInput(pnl, "ICMS-S", 10, 368, 120);
+ txtDbCsFrete = AbaInput(pnl, "Frete", 150, 368, 120);
+ txtDbCsSeguro = AbaInput(pnl, "Seguro", 290, 368, 120);
+ txtDbCsDespesas = AbaInput(pnl, "Despesas", 430, 368, 120);
+ txtDbCsIss = AbaInput(pnl, "ISS", 570, 368, 120);
+ txtDbCsIrrf = AbaInput(pnl, "IRRF", 710, 368, 120);
+ txtDbCsIrpj = AbaInput(pnl, "IRPJ", 10, 430, 120);
+ txtDbCsPis = AbaInput(pnl, "PIS", 150, 430, 120);
+ txtDbCsCofins = AbaInput(pnl, "COFINS", 290, 430, 120);
+ txtDbCsCsll = AbaInput(pnl, "CSLL", 430, 430, 120);
+ txtDbCsInss = AbaInput(pnl, "INSS", 570, 430, 120);
+ txtDbCsSimples = AbaInput(pnl, "Simples", 710, 430, 120);
+
+ pnl.Controls.Add(CreateSectionHeader("DB — Campos Entrada", 490));
+ txtDbCinFrete = AbaInput(pnl, "Frete", 10, 528, 120);
+ txtDbCinSeguro = AbaInput(pnl, "Seguro", 150, 528, 120);
+ txtDbCinDespesas = AbaInput(pnl, "Despesas", 290, 528, 120);
+ txtDbCinDesconto = AbaInput(pnl, "Desconto", 430, 528, 120);
+
+ tab.Controls.Add(pnl);
+ return tab;
+ }
+
+ // ── TODOS OS CAMPOS EDITÁVEIS ─────────────────────────────────────────
+ private LV_TEXTBOX1[] TodosCamposEditaveis() => new[]
+ {
+ txtEstoque, txtOficina, txtOficinaDono, txtBanco, txtContas,
+ txtVendasL1, txtVendasL2, txtModeloVenda, txtPrnPortVenda, txtCopiasVenda,
+ txtSerial, txtSerial2, txtNossoNumero, txtRevenda, txtCodFab, txtSHCompras,
+ txtSmtpServer, txtSmtpUser, txtSmtpPass, txtSmtpTit, txtSmtpEmail,
+ txtSmtpCc, txtSmtpPort, txtSmtpSsl, txtSmtpCok, txtSmtpSemAutentica,
+ txtCartaoRegOk, txtCartaoDebtDireto, txtCartaoCredDireto, txtCartaoCredComiss,
+ txtCartaoDebtComiss, txtCartaoCredParcela, txtComissVendas, txtMaxDesVendas,
+ txtNfeFormaEmissao, txtNfeEnfe, txtNfeEmailOk, txtUltimaImpressao,
+ txtDataSaida, txtImpressa, txtFreteNumero,
+ txtDestNome, txtDestEndereco, txtDestBairro, txtDestCidade, txtDestUf,
+ txtDestCep, txtDestCodPais, txtDestTel, txtDestFax, txtDestEmail,
+ txtDestIeRg, txtDestCnpjCpf,
+ txtFreteNome, txtFreteUf, txtFreteCnpjCpf, txtFreteIeRg, txtFreteEndereco,
+ txtFreteMunicipio, txtFreteTuf, txtVFrete, txtVSeguro, txtVOutros,
+ txtValorDesconto, txtValorIrrf, txtValorIrpj, txtValorPis, txtValorCofins,
+ txtValorCsll, txtValorBenef, txtValorInss, txtValorSimples,
+ txtTotalDesc, txtTotalDeducoes, txtTotalServicos, txtTotalProdutos, txtTotalIss,
+ txtTotalIrrf, txtTotalIrpj, txtTotalPis, txtTotalCofins, txtTotalCsll,
+ txtTotalInss, txtTotalSimples,
+ txtDbCsIcmsS, txtDbCsFrete, txtDbCsSeguro, txtDbCsDespesas, txtDbCsIss,
+ txtDbCsIrrf, txtDbCsIrpj, txtDbCsPis, txtDbCsCofins, txtDbCsCsll,
+ txtDbCsInss, txtDbCsSimples,
+ txtDbCinFrete, txtDbCinSeguro, txtDbCinDespesas, txtDbCinDesconto
+ };
+
+ // ── MODOS DO FORMULÁRIO ───────────────────────────────────────────────
+ private void AplicarModo(ModoFormulario modo)
+ {
+ _modo = modo;
+ bool editando = modo == ModoFormulario.Edicao;
+
+ foreach (var txt in TodosCamposEditaveis())
+ {
+ txt.ReadOnly = !editando;
+ txt.BackColor = editando ? Color.White : ReadOnlyBg;
+ txt.BorderColor = editando ? BorderColor : ReadOnlyBorder;
+ }
+
+ btnNovo.Enabled = !editando;
+ btnAlterar.Enabled = !editando && _idAtual > 0;
+ btnExcluir.Enabled = !editando && _idAtual > 0;
+ btnLocalizar.Enabled = !editando;
+ btnSalvar.Enabled = editando;
+ btnCancelar.Enabled = editando;
+ }
+
+ // ── POPULAR CAMPOS ────────────────────────────────────────────────────
+ public void PopularCampos(ModeloConfig m)
+ {
+ _idAtual = m.ID_CONFIG;
+
+ txtId.Text = m.ID_CONFIG.ToString();
+ txtEstoque.Text = m.ESTOQUE;
+ txtOficina.Text = m.OFICINA;
+ txtOficinaDono.Text = m.OFICINADONO;
+ txtBanco.Text = m.BANCO;
+ txtContas.Text = m.CONTAS;
+ txtVendasL1.Text = m.VENDASL1;
+ txtVendasL2.Text = m.VENDASL2;
+ txtModeloVenda.Text = m.MODELOVENDA;
+ txtPrnPortVenda.Text = m.PRNPORTVENDA;
+ txtCopiasVenda.Text = m.COPIASVENDA;
+ txtVersao.Text = m.VERSAO;
+ txtVersaoP.Text = m.VERSAOP;
+ txtSerial.Text = m.SERIAL;
+ txtSerial2.Text = m.SERIAL2;
+ txtNossoNumero.Text = m.NOSSONUMERO;
+ txtRevenda.Text = m.REVENDA;
+ txtCodFab.Text = m.COD_FAB;
+ txtSHCompras.Text = m.SHCompras;
+ txtDataCadastro.Text = m.DATA_CADASTRO;
+
+ txtSmtpServer.Text = m.SMTP_SERVER;
+ txtSmtpUser.Text = m.SMTP_USER;
+ txtSmtpPass.Text = m.SMTP_PASS;
+ txtSmtpTit.Text = m.SMTP_TIT;
+ txtSmtpEmail.Text = m.SMTP_EMAIL;
+ txtSmtpCc.Text = m.SMTP_CC;
+ txtSmtpPort.Text = m.SMTP_PORT;
+ txtSmtpSsl.Text = m.SMTP_SSL;
+ txtSmtpCok.Text = m.SMTP_COK;
+ txtSmtpSemAutentica.Text = m.SMTP_SEMAUTENTICA;
+
+ txtCartaoRegOk.Text = m.CARTAO_REG_OK;
+ txtCartaoDebtDireto.Text = m.CARTAO_DEBT_DIRETO;
+ txtCartaoCredDireto.Text = m.CARTAO_CRED_DIRETO;
+ txtCartaoCredComiss.Text = m.CARTAO_CRED_COMISS;
+ txtCartaoDebtComiss.Text = m.CARTAO_DEBT_COMISS;
+ txtCartaoCredParcela.Text = m.CARTAO_CRED_PARCELA;
+ txtComissVendas.Text = m.COMISS_VENDAS;
+ txtMaxDesVendas.Text = m.MAXDES_VENDAS;
+
+ txtNfeFormaEmissao.Text = m.NFE_FORMA_EMISSAO;
+ txtNfeEnfe.Text = m.NFE_ENFE;
+ txtNfeEmailOk.Text = m.NFE_EMAIL_OK;
+ txtUltimaImpressao.Text = m.ULTIMA_IMPRESSAO;
+ txtDataSaida.Text = m.DATA_SAIDA;
+ txtImpressa.Text = m.IMPRESSA;
+ txtFreteNumero.Text = m.FRETE_NUMERO;
+
+ txtDestNome.Text = m.DESTINATARIO_NOME;
+ txtDestEndereco.Text = m.DESTINATARIO_ENDERECO;
+ txtDestBairro.Text = m.DESTINATARIO_BAIRRO;
+ txtDestCidade.Text = m.DESTINATARIO_CIDADE;
+ txtDestUf.Text = m.DESTINATARIO_UF;
+ txtDestCep.Text = m.DESTINATARIO_CEP;
+ txtDestCodPais.Text = m.DESTINATARIO_COD_PAIS;
+ txtDestTel.Text = m.DESTINATARIO_TEL;
+ txtDestFax.Text = m.DESTINATARIO_FAX;
+ txtDestEmail.Text = m.DESTINATARIO_EMAIL;
+ txtDestIeRg.Text = m.DESTINATARIO_IE_RG;
+ txtDestCnpjCpf.Text = m.DESTINATARIO_CNPJCPF;
+
+ txtFreteNome.Text = m.FRETE_NOME;
+ txtFreteUf.Text = m.FRETE_UF;
+ txtFreteCnpjCpf.Text = m.FRETE_CNPJCPF;
+ txtFreteIeRg.Text = m.FRETE_IERG;
+ txtFreteEndereco.Text = m.FRETE_ENDERECO;
+ txtFreteMunicipio.Text = m.FRETE_MUNICIPIO;
+ txtFreteTuf.Text = m.FRETE_TUF;
+ txtVFrete.Text = m.V_FRETE;
+ txtVSeguro.Text = m.V_SEGURO;
+ txtVOutros.Text = m.V_OUTROS;
+
+ txtValorDesconto.Text = m.VALOR_DESCONTO;
+ txtValorIrrf.Text = m.VALOR_IRRF;
+ txtValorIrpj.Text = m.VALOR_IRPJ;
+ txtValorPis.Text = m.VALOR_PIS;
+ txtValorCofins.Text = m.VALOR_COFINS;
+ txtValorCsll.Text = m.VALOR_CSLL;
+ txtValorBenef.Text = m.VALOR_BENEF;
+ txtValorInss.Text = m.VALOR_INSS;
+ txtValorSimples.Text = m.VALOR_SIMPLES;
+ txtTotalDesc.Text = m.TOTAL_DESC;
+ txtTotalDeducoes.Text = m.TOTAL_DEDUCOES;
+ txtTotalServicos.Text = m.TOTAL_SERVICOS;
+ txtTotalProdutos.Text = m.TOTAL_PRODUTOS;
+ txtTotalIss.Text = m.TOTAL_ISS;
+ txtTotalIrrf.Text = m.TOTAL_IRRF;
+ txtTotalIrpj.Text = m.TOTAL_IRPJ;
+ txtTotalPis.Text = m.TOTAL_PIS;
+ txtTotalCofins.Text = m.TOTAL_COFINS;
+ txtTotalCsll.Text = m.TOTAL_CSLL;
+ txtTotalInss.Text = m.TOTAL_INSS;
+ txtTotalSimples.Text = m.TOTAL_SIMPLES;
+ txtDbCsIcmsS.Text = m.DB_cs_ICMS_S;
+ txtDbCsFrete.Text = m.DB_cs_FRETE;
+ txtDbCsSeguro.Text = m.DB_cs_SEGURO;
+ txtDbCsDespesas.Text = m.DB_cs_DESPESAS;
+ txtDbCsIss.Text = m.DB_cs_ISS;
+ txtDbCsIrrf.Text = m.DB_cs_IRRF;
+ txtDbCsIrpj.Text = m.DB_cs_IRPJ;
+ txtDbCsPis.Text = m.DB_cs_PIS;
+ txtDbCsCofins.Text = m.DB_cs_COFINS;
+ txtDbCsCsll.Text = m.DB_cs_CSLL;
+ txtDbCsInss.Text = m.DB_cs_INSS;
+ txtDbCsSimples.Text = m.DB_cs_SIMPLES;
+ txtDbCinFrete.Text = m.DB_cin_FRETE;
+ txtDbCinSeguro.Text = m.DB_cin_SEGURO;
+ txtDbCinDespesas.Text = m.DB_cin_DESPESAS;
+ txtDbCinDesconto.Text = m.DB_cin_DESCONTO;
+ }
+
+ // ── MONTAR MODELO ─────────────────────────────────────────────────────
+ private ModeloConfig MontarModelo() => new ModeloConfig(
+ _idAtual,
+ txtEstoque.Text.Trim(), txtOficina.Text.Trim(),
+ txtBanco.Text.Trim(), txtContas.Text.Trim(),
+ txtVendasL1.Text.Trim(), txtVendasL2.Text.Trim(),
+ txtModeloVenda.Text.Trim(), txtPrnPortVenda.Text.Trim(),
+ txtCopiasVenda.Text.Trim(), txtVersao.Text.Trim(),
+ txtSerial.Text.Trim(), txtSerial2.Text.Trim(),
+ txtSmtpServer.Text.Trim(), txtSmtpUser.Text.Trim(),
+ txtSmtpPass.Text.Trim(), txtSmtpTit.Text.Trim(),
+ txtSmtpEmail.Text.Trim(), txtSmtpCc.Text.Trim(),
+ txtSmtpPort.Text.Trim(), txtSmtpSsl.Text.Trim(),
+ txtSmtpCok.Text.Trim(), txtOficinaDono.Text.Trim(),
+ txtNossoNumero.Text.Trim(), txtRevenda.Text.Trim(),
+ txtComissVendas.Text.Trim(), txtMaxDesVendas.Text.Trim(),
+ txtCartaoRegOk.Text.Trim(), txtCartaoDebtDireto.Text.Trim(),
+ txtCartaoCredDireto.Text.Trim(), txtCartaoCredComiss.Text.Trim(),
+ txtCartaoDebtComiss.Text.Trim(), txtVersaoP.Text.Trim(),
+ txtSHCompras.Text.Trim(), txtNfeFormaEmissao.Text.Trim(),
+ txtCartaoCredParcela.Text.Trim(), txtSmtpSemAutentica.Text.Trim(),
+ txtNfeEnfe.Text.Trim(), txtNfeEmailOk.Text.Trim(),
+ txtDataCadastro.Text.Trim(), txtUltimaImpressao.Text.Trim(),
+ txtDataSaida.Text.Trim(), txtImpressa.Text.Trim(),
+ txtFreteNumero.Text.Trim(), txtDestNome.Text.Trim(),
+ txtDestEndereco.Text.Trim(), txtDestBairro.Text.Trim(),
+ txtDestCidade.Text.Trim(), txtDestUf.Text.Trim(),
+ txtDestCep.Text.Trim(), txtDestCodPais.Text.Trim(),
+ txtDestTel.Text.Trim(), txtDestFax.Text.Trim(),
+ txtDestEmail.Text.Trim(), txtDestIeRg.Text.Trim(),
+ txtDestCnpjCpf.Text.Trim(), txtValorDesconto.Text.Trim(),
+ txtValorIrrf.Text.Trim(), txtValorIrpj.Text.Trim(),
+ txtValorPis.Text.Trim(), txtValorCofins.Text.Trim(),
+ txtValorCsll.Text.Trim(), txtValorBenef.Text.Trim(),
+ txtValorInss.Text.Trim(), txtValorSimples.Text.Trim(),
+ txtTotalDesc.Text.Trim(), txtTotalDeducoes.Text.Trim(),
+ txtTotalServicos.Text.Trim(), txtTotalProdutos.Text.Trim(),
+ txtTotalIss.Text.Trim(), txtTotalIrrf.Text.Trim(),
+ txtTotalIrpj.Text.Trim(), txtTotalPis.Text.Trim(),
+ txtTotalCofins.Text.Trim(), txtTotalCsll.Text.Trim(),
+ txtTotalInss.Text.Trim(), txtTotalSimples.Text.Trim(),
+ txtFreteNome.Text.Trim(), txtFreteUf.Text.Trim(),
+ txtFreteCnpjCpf.Text.Trim(), txtFreteIeRg.Text.Trim(),
+ txtFreteEndereco.Text.Trim(), txtFreteMunicipio.Text.Trim(),
+ txtFreteTuf.Text.Trim(), txtDbCsIcmsS.Text.Trim(),
+ txtDbCsFrete.Text.Trim(), txtDbCsSeguro.Text.Trim(),
+ txtDbCsDespesas.Text.Trim(), txtDbCinFrete.Text.Trim(),
+ txtDbCinSeguro.Text.Trim(), txtDbCinDespesas.Text.Trim(),
+ txtDbCinDesconto.Text.Trim(), txtDbCsIss.Text.Trim(),
+ txtDbCsIrrf.Text.Trim(), txtDbCsIrpj.Text.Trim(),
+ txtDbCsPis.Text.Trim(), txtDbCsCofins.Text.Trim(),
+ txtDbCsCsll.Text.Trim(), txtDbCsInss.Text.Trim(),
+ txtDbCsSimples.Text.Trim(), txtVFrete.Text.Trim(),
+ txtVSeguro.Text.Trim(), txtVOutros.Text.Trim(),
+ txtCodFab.Text.Trim()
+ );
+
+ // ── EVENTOS ABSTRATOS ─────────────────────────────────────────────────
+ protected override void OnNovo()
+ {
+ AplicarModo(ModoFormulario.Edicao);
+ // Limpa campos para novo registro
+ foreach (var txt in TodosCamposEditaveis())
+ txt.Text = string.Empty;
+ txtId.Text = string.Empty;
+ _idAtual = 0;
+ tabMain.SelectedIndex = 0;
+ }
+
+ protected override void OnExcluir()
+ {
+ if (_idAtual == 0) return;
+ var confirm = MessageBox.Show(
+ "Deseja realmente excluir esta configuração?",
+ "Confirmar exclusão",
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Warning);
+ if (confirm != DialogResult.Yes) return;
+ try
+ {
+ // TODO: _bll.Excluir(_idAtual);
+ foreach (var txt in TodosCamposEditaveis()) txt.Text = string.Empty;
+ txtId.Text = string.Empty;
+ _idAtual = 0;
+ AplicarModo(ModoFormulario.Visualizacao);
+ MessageBox.Show("Configuração excluída com sucesso.", "Sucesso",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Erro ao excluir:{ ex.Message} ", "Erro",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ protected override void OnLocalizar()
+ {
+ // TODO: abrir formulário de busca de configurações
+ // var frm = new FormularioBuscarConfig();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // {
+ // PopularCampos(frm.ConfigSelecionada);
+ // AplicarModo(ModoFormulario.Visualizacao);
+ // }
+ MessageBox.Show("Implemente o formulário de busca de configurações.",
+ "Localizar", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ private void OnGerarFicha()
+ {
+ if (_idAtual == 0)
+ {
+ MessageBox.Show("Carregue uma configuração antes de gerar a ficha.",
+ "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
+ }
+ // TODO: gerar PDF/relatório das configurações
+ // Ex: RelatorioConfig.Gerar(MontarModelo());
+ MessageBox.Show("Implemente a geração do PDF de configurações.",
+ "Gerar Ficha", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ protected override void OnAlterar()
+ {
+ AplicarModo(ModoFormulario.Edicao);
+ tabMain.SelectedIndex = 0;
+ }
+
+ protected override void OnSalvar()
+ {
+ var modelo = MontarModelo();
+ try
+ {
+ // TODO: _bll.Atualizar(modelo);
+ MessageBox.Show("Configurações salvas 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()
+ {
+ // TODO: recarregar do banco para descartar alterações
+ AplicarModo(ModoFormulario.Visualizacao);
+ }
+ }
+}
diff --git a/UI/Dashboards/Cadastros/ConfigCadastroPanel.resx b/UI/Dashboards/Cadastros/ConfigCadastroPanel.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/UI/Dashboards/Cadastros/ConfigCadastroPanel.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/UI/Dashboards/Cadastros/ContaPagarCadastroPanel.cs b/UI/Dashboards/Cadastros/ContaPagarCadastroPanel.cs
new file mode 100644
index 0000000..7fca11f
--- /dev/null
+++ b/UI/Dashboards/Cadastros/ContaPagarCadastroPanel.cs
@@ -0,0 +1,587 @@
+using CPM;
+using DAL;
+using MLL;
+using BLL;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace UI
+{
+ public class ContaPagarCadastroPanel : FormularioModelo
+ {
+ // ── CAMPOS DO FORMULÁRIO ──────────────────────────────────────────────
+ private LV_TEXTBOX1 txtId = null!;
+ private LV_TEXTBOX1 txtDescricao = null!;
+ private LV_COMBOBOXCUSTOM cmbStatus = null!;
+ private CheckBox chkAtivo = null!;
+
+ // Fornecedor — busca
+ private LV_TEXTBOX1 txtFornecedorId = null!;
+ private LV_TEXTBOX1 txtFornecedorNome = null!;
+ private Button btnBuscarFornecedor = 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 _fornecedorId = 0;
+ private int _planoContaId = 0;
+
+ // ── BLL ───────────────────────────────────────────────────────────────
+ // private ContaPagarBLL _bll = null!;
+
+ // ── CONSTRUTOR ────────────────────────────────────────────────────────
+ public ContaPagarCadastroPanel()
+ {
+ Titulo = "Contas a Pagar";
+ 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;
+ content.Controls.Add(lblStatus);
+ content.Controls.Add(cmbStatus);
+
+ chkAtivo = CreateCheckBox("Ativo", 750, 82);
+ chkAtivo.Checked = true;
+ content.Controls.Add(chkAtivo);
+
+ // ── SEÇÃO: FORNECEDOR ─────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Fornecedor", 128));
+
+ var lblFornecedor = new Label
+ {
+ Text = "Fornecedor",
+ Location = new Point(20, 166),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtFornecedorId = new LV_TEXTBOX1
+ {
+ Location = new Point(20, 182),
+ Size = new Size(80, 32),
+ BorderColor = ReadOnlyBorder,
+ BorderFocusColor = AccentBlue,
+ ReadOnly = true,
+ BackColor = ReadOnlyBg
+ };
+ txtFornecedorNome = new LV_TEXTBOX1
+ {
+ Location = new Point(108, 182),
+ Size = new Size(300, 32),
+ BorderColor = ReadOnlyBorder,
+ BorderFocusColor = AccentBlue,
+ ReadOnly = true,
+ BackColor = ReadOnlyBg
+ };
+ btnBuscarFornecedor = 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
+ };
+ btnBuscarFornecedor.FlatAppearance.BorderSize = 0;
+ btnBuscarFornecedor.Click += BtnBuscarFornecedor_Click;
+ content.Controls.Add(lblFornecedor);
+ content.Controls.Add(txtFornecedorId);
+ content.Controls.Add(txtFornecedorNome);
+ content.Controls.Add(btnBuscarFornecedor);
+
+ // ── 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);
+
+ // ── SEÇÃO: VALORES ────────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Valores", 340));
+
+ txtValor = AddInput(content, "Valor (R$)", 20, 378, 150, 32);
+ txtValorPago = AddInput(content, "Valor Pago (R$)", 190, 378, 150, 32);
+ txtJuros = AddInput(content, "Juros (R$)", 360, 378, 130, 32);
+ txtMulta = AddInput(content, "Multa (R$)", 510, 378, 130, 32);
+ txtDesconto = AddInput(content, "Desconto (R$)", 660, 378, 130, 32);
+
+ // ── SEÇÃO: DATAS ──────────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Datas", 440));
+
+ txtDataEmissao = AddInput(content, "Emissão", 20, 478, 180, 32);
+ txtDataVencimento = AddInput(content, "Vencimento", 220, 478, 180, 32);
+ txtDataPagamento = AddInput(content, "Pagamento", 420, 478, 180, 32);
+
+ // ── SEÇÃO: OBSERVAÇÕES ────────────────────────────────────────────
+ content.Controls.Add(CreateSectionHeader("Observações", 540));
+
+ var lblObs = new Label
+ {
+ Text = "Observações",
+ Location = new Point(20, 578),
+ Font = new Font("Segoe UI", 7.5f, FontStyle.Bold),
+ ForeColor = TextDark,
+ AutoSize = true
+ };
+ txtObservacoes = new LV_TEXTBOX1
+ {
+ Location = new Point(20, 594),
+ 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", 684));
+
+ txtCriadoEm = AddInput(content, "Criado em", 20, 722, 200, 32, readOnly: true);
+ txtAtualizadoEm = AddInput(content, "Atualizado em", 240, 722, 200, 32, readOnly: true);
+
+ content.Height = 790;
+ }
+
+ // ── 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;
+
+ btnBuscarFornecedor.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 BtnBuscarFornecedor_Click(object? sender, EventArgs e)
+ {
+ // TODO: abrir formulário de busca de fornecedores
+ // var frm = new FormularioBuscarFornecedor();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // {
+ // _fornecedorId = frm.FornecedorSelecionado.Id;
+ // txtFornecedorId.Text = _fornecedorId.ToString();
+ // txtFornecedorNome.Text = frm.FornecedorSelecionado.Nome;
+ // }
+ MessageBox.Show("Implemente o formulário de busca de fornecedores.",
+ "Buscar Fornecedor", 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(ModeloContaPagar m)
+ {
+ _idAtual = m.Id;
+ _fornecedorId = m.FornecedorId;
+ _planoContaId = m.PlanoContaId;
+
+ txtId.Text = m.Id.ToString();
+ txtDescricao.Text = m.Descricao;
+ txtFornecedorId.Text = m.FornecedorId.ToString();
+ 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;
+ _fornecedorId = 0;
+ _planoContaId = 0;
+
+ txtId.Text = string.Empty;
+ txtDescricao.Text = string.Empty;
+ txtFornecedorId.Text = string.Empty;
+ txtFornecedorNome.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 (_fornecedorId == 0)
+ {
+ MessageBox.Show("Selecione um fornecedor.", "Validação",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ btnBuscarFornecedor.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 ModeloContaPagar 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 ModeloContaPagar(
+ _idAtual,
+ 0, // EmpresaId — preenchido pela BLL via sessão
+ _fornecedorId,
+ _planoContaId,
+ 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 pagar 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 pagar
+ // var frm = new FormularioBuscarContaPagar();
+ // if (frm.ShowDialog() == DialogResult.OK)
+ // {
+ // PopularCampos(frm.ContaSelecionada);
+ // AplicarModo(ModoFormulario.Visualizacao);
+ // }
+ MessageBox.Show("Implemente o formulário de busca de contas a pagar.",
+ "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 pagar cadastrada com sucesso!", "Sucesso",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ else
+ {
+ // TODO: _bll.Atualizar(modelo);
+ MessageBox.Show("Conta a pagar 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);
+ }
+ }
+}
diff --git a/UI/Dashboards/Cadastros/ContaPagarCadastroPanel.resx b/UI/Dashboards/Cadastros/ContaPagarCadastroPanel.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/UI/Dashboards/Cadastros/ContaPagarCadastroPanel.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/UI/Dashboards/Dashmain/MainForm.cs b/UI/Dashboards/Dashmain/MainForm.cs
index 1cb99a7..387fe07 100644
--- a/UI/Dashboards/Dashmain/MainForm.cs
+++ b/UI/Dashboards/Dashmain/MainForm.cs
@@ -30,8 +30,12 @@ namespace UI
private readonly ChamadoCadastroPanel _pChamadoCadastroPanel;
+ //Sistma
+ private readonly ConfigCadastroPanel _pconfigCadastroPanel;
+
//Painel financeiro
private readonly BoletoCadastroPanel _pboletoCadastroPanel;
+ private readonly ContaPagarCadastroPanel _pcontaPagarCadastroPanel;
private readonly Panel _pOrdens;
private readonly Panel _pProdutos;
private readonly Panel _pEstoque;
@@ -63,6 +67,8 @@ namespace UI
_pservicosCadastroPanel = new ServicosCadastroPanel { Dock = DockStyle.Fill, Visible = false };
_pUsuarioCadastroPanel = new UsuariosCadastroPanel { Dock = DockStyle.Fill, Visible=false };
_pChamadoCadastroPanel = new ChamadoCadastroPanel { Dock = DockStyle.Fill, Visible = false };
+ _pconfigCadastroPanel = new ConfigCadastroPanel { Dock = DockStyle.Fill, Visible = false };
+ _pcontaPagarCadastroPanel = new ContaPagarCadastroPanel { Dock = DockStyle.Fill, Visible = false };
_pOrdens = PlaceholderPanel("Ordens de Serviço", Color.FromArgb(22, 163, 74));
_pProdutos = PlaceholderPanel("Catálogo de Produtos", Color.FromArgb(217, 119, 6));
_pEstoque = PlaceholderPanel("Controle de Estoque", Color.FromArgb(234, 88, 12));
@@ -80,6 +86,7 @@ namespace UI
mainContainer.Controls.Add(_pservicosCadastroPanel);
mainContainer.Controls.Add(_pUsuarioCadastroPanel);
mainContainer.Controls.Add(_pChamadoCadastroPanel);
+ mainContainer.Controls.Add(_pconfigCadastroPanel);
mainContainer.Controls.Add(_pEstoque);
mainContainer.Controls.Add(_pProdutos);
mainContainer.Controls.Add(_pOrdens);
@@ -88,7 +95,7 @@ namespace UI
mainContainer.Controls.Add(_pClientes);
mainContainer.Controls.Add(_dashboard);
mainContainer.Controls.Add(_pfuncionariosCadastro);
-
+ mainContainer.Controls.Add(_pcontaPagarCadastroPanel);
Controls.Add(mainContainer);
Controls.Add(_sidebar);
@@ -124,12 +131,14 @@ namespace UI
case 106: ShowPanel(_pEmpresa); break;
case 107: ShowPanel(_pUsuarioCadastroPanel); break;
+ case 201: ShowPanel(_pconfigCadastroPanel); break;
case 202: ShowPanel(_pEmpresaConfig); break;
+
case 300: ShowPanel(_pAgendaCadastro); break;
case 301: ShowPanel(_pAgendaConsulta); break;
case 309: ShowPanel(_pChamadoCadastroPanel); break;
-
+ case 402: ShowPanel(_pcontaPagarCadastroPanel); break;
case 500: ShowPanel(_pboletoCadastroPanel); break;
@@ -157,6 +166,8 @@ namespace UI
_pservicosCadastroPanel.Visible = (panelToShow == _pservicosCadastroPanel);
_pUsuarioCadastroPanel.Visible = (panelToShow == _pUsuarioCadastroPanel);
_pChamadoCadastroPanel.Visible = (panelToShow == _pChamadoCadastroPanel);
+ _pconfigCadastroPanel.Visible = (panelToShow == _pconfigCadastroPanel);
+ _pcontaPagarCadastroPanel.Visible = (panelToShow == _pcontaPagarCadastroPanel);
if (panelToShow.Visible)
{
panelToShow.BringToFront();
diff --git a/UI/Dashboards/Dashmain/SidebarControl.cs b/UI/Dashboards/Dashmain/SidebarControl.cs
index ffde523..00131de 100644
--- a/UI/Dashboards/Dashmain/SidebarControl.cs
+++ b/UI/Dashboards/Dashmain/SidebarControl.cs
@@ -166,9 +166,9 @@ namespace UI
// ── FINANCEIRO ────────────────────────────────────────────────────
_subMenuFinanceiro = CreateStyledMenu();
- _subMenuFinanceiro.Items.Add(CreateItem("💳 Contas"));
- _subMenuFinanceiro.Items.Add(CreateItem("📈 Contas a receber"));
- _subMenuFinanceiro.Items.Add(CreateItem("📉 Contas a pagar"));
+ _subMenuFinanceiro.Items.Add(CreateItem("💳 Contas", (s, e) => NavItemClicked?.Invoke(this, 400)));
+ _subMenuFinanceiro.Items.Add(CreateItem("📈 Contas a receber", (s, e) => NavItemClicked?.Invoke(this, 401)));
+ _subMenuFinanceiro.Items.Add(CreateItem("📉 Contas a pagar", (s, e) => NavItemClicked?.Invoke(this, 402)));
_subMenuFinanceiro.Items.Add(CreateItem("📉 Boletos/Duplicatas", (s, e) => NavItemClicked?.Invoke(this, 500)));
_subMenuFinanceiro.Items.Add(new ToolStripSeparator());
_subMenuFinanceiro.Items.Add(CreateItem("🛒 Compras"));