136 lines
4.7 KiB
C#
136 lines
4.7 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class NotasFiscaisPanel : FormularioModelo
|
|
{
|
|
private ModeloNotasFiscais _nfe = new ModeloNotasFiscais();
|
|
private TabControl tabNfe;
|
|
private TabPage tpGeral, tpDestinatario, tpTotais, tpTransporte, tpSefaz;
|
|
|
|
public NotasFiscaisPanel()
|
|
{
|
|
this.Titulo = "Emissão de Nota Fiscal Eletrônica (NF-e)";
|
|
this.Size = new Size(1000, 750);
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
tabNfe = new TabControl { Dock = DockStyle.Fill, Font = new Font("Segoe UI", 9) };
|
|
|
|
tpGeral = new TabPage("1. Dados Gerais");
|
|
tpDestinatario = new TabPage("2. Destinatário");
|
|
tpTotais = new TabPage("3. Totais e Impostos");
|
|
tpTransporte = new TabPage("4. Transporte");
|
|
tpSefaz = new TabPage("5. Histórico SEFAZ");
|
|
|
|
tabNfe.TabPages.AddRange(new[] { tpGeral, tpDestinatario, tpTotais, tpTransporte, tpSefaz });
|
|
content.Controls.Add(tabNfe);
|
|
|
|
ConfigurarAbaGeral();
|
|
ConfigurarAbaDestinatario();
|
|
ConfigurarAbaTotais();
|
|
}
|
|
|
|
private void ConfigurarAbaGeral()
|
|
{
|
|
AddInput(tpGeral, "ID SISTEMA", 20, 20, 80, 30, true);
|
|
AddInput(tpGeral, "SÉRIE", 110, 20, 60, 30);
|
|
AddInput(tpGeral, "NATUREZA OPERAÇÃO", 180, 20, 350, 30);
|
|
AddInput(tpGeral, "CFOP", 540, 20, 100, 30);
|
|
|
|
var txtObs = AddInput(tpGeral, "OBSERVAÇÕES", 20, 80, 620, 100);
|
|
txtObs.Multiline = true;
|
|
txtObs.Height = 100;
|
|
}
|
|
|
|
private void ConfigurarAbaDestinatario()
|
|
{
|
|
AddInput(tpDestinatario, "NOME / RAZÃO SOCIAL", 20, 20, 400, 30);
|
|
AddInput(tpDestinatario, "CNPJ / CPF", 430, 20, 210, 30);
|
|
AddInput(tpDestinatario, "INSCRIÇÃO ESTADUAL", 20, 80, 200, 30);
|
|
AddInput(tpDestinatario, "LOGRADOURO", 20, 140, 400, 30);
|
|
AddInput(tpDestinatario, "CIDADE", 430, 140, 210, 30);
|
|
}
|
|
|
|
private void ConfigurarAbaTotais()
|
|
{
|
|
// Totais destacados
|
|
var tProd = AddInput(tpTotais, "TOTAL PRODUTOS", 20, 20, 150, 30);
|
|
tProd.BackColor = Color.LightYellow;
|
|
|
|
var tNota = AddInput(tpTotais, "TOTAL DA NOTA", 180, 20, 150, 30);
|
|
tNota.BackColor = Color.LightGreen;
|
|
tNota.Font = new Font("Segoe UI", 10, FontStyle.Bold);
|
|
|
|
content.Controls.Add(CreateSectionHeader("DETALHAMENTO DE IMPOSTOS", 80));
|
|
AddInput(tpTotais, "BASE ICMS", 20, 110, 120, 30);
|
|
AddInput(tpTotais, "VALOR ICMS", 150, 110, 120, 30);
|
|
AddInput(tpTotais, "V. ICMS ST", 280, 110, 120, 30);
|
|
AddInput(tpTotais, "VALOR IPI", 410, 110, 120, 30);
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS DO FORMULÁRIO MODELO ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_nfe = new ModeloNotasFiscais();
|
|
LimparCamposRecursivo(tabNfe);
|
|
tabNfe.SelectedTab = tpGeral;
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
// Simulação de validação da Chave de Acesso
|
|
if (string.IsNullOrEmpty(_nfe.NFE_ID_CHAVE))
|
|
{
|
|
MessageBox.Show("A nota será salva como rascunho até a transmissão.", "Aviso LevelOS");
|
|
}
|
|
|
|
MessageBox.Show("NF-e Salva com sucesso no banco de dados.");
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
if (_nfe.NFE_ENVIADA == "S")
|
|
{
|
|
MessageBox.Show("Notas já autorizadas pela SEFAZ não podem ser alteradas. Tente uma Carta de Correção.", "Bloqueio Fiscal");
|
|
return;
|
|
}
|
|
MessageBox.Show("Rascunho da nota atualizado.");
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Deseja cancelar esta nota fiscal?", "SEFAZ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
|
{
|
|
MessageBox.Show("Evento de cancelamento enviado para processamento.");
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
MessageBox.Show("Abrindo monitor de NF-e...");
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
|
|
}
|
|
|
|
private void LimparCamposRecursivo(Control container)
|
|
{
|
|
foreach (Control c in container.Controls)
|
|
{
|
|
if (c is LV_TEXTBOX1 t) t.Text = "";
|
|
if (c.HasChildren) LimparCamposRecursivo(c);
|
|
}
|
|
}
|
|
}
|
|
} |