733 lines
36 KiB
C#
733 lines
36 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|