118 lines
4.0 KiB
C#
118 lines
4.0 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class NotasConsumidorPanel : FormularioModelo
|
|
{
|
|
private ModeloNotasFiscaisConsumidor _nfce = new ModeloNotasFiscaisConsumidor();
|
|
|
|
// Controles de destaque para o PDV
|
|
private LV_TEXTBOX1 txtTotalNF, txtStatus, txtChave, txtCpfDest;
|
|
|
|
public NotasConsumidorPanel()
|
|
{
|
|
this.Titulo = "Emissão de Cupom Fiscal (NFC-e)";
|
|
this.Size = new Size(900, 600);
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- Cabeçalho de Venda ---
|
|
AddInput(content, "ID", 20, 30, 60, 30, true);
|
|
AddInput(content, "SÉRIE", 90, 30, 60, 30).Text = "1";
|
|
AddInput(content, "NATUREZA", 160, 30, 250, 30).Text = "VENDA CONSUMIDOR";
|
|
|
|
txtStatus = AddInput(content, "SITUAÇÃO", 420, 30, 150, 30, true);
|
|
txtStatus.BackColor = Color.Gold;
|
|
|
|
// --- Dados do Consumidor (Muitas vezes em branco para "Consumidor não identificado") ---
|
|
content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO DO CONSUMIDOR", 80));
|
|
txtCpfDest = AddInput(content, "CPF / CNPJ", 20, 110, 180, 30);
|
|
AddInput(content, "NOME (OPCIONAL)", 210, 110, 350, 30);
|
|
|
|
// --- Totais (O que importa no balcão) ---
|
|
content.Controls.Add(CreateSectionHeader("TOTAIS DO CUPOM", 160));
|
|
|
|
var vProd = AddInput(content, "VALOR PRODUTOS", 20, 190, 150, 30);
|
|
var vDesc = AddInput(content, "DESCONTO", 180, 190, 100, 30);
|
|
|
|
txtTotalNF = AddInput(content, "TOTAL A PAGAR", 290, 190, 200, 40);
|
|
txtTotalNF.Font = new Font("Segoe UI", 14, FontStyle.Bold);
|
|
txtTotalNF.ForeColor = Color.DarkGreen;
|
|
|
|
// --- Dados Fiscais / SEFAZ ---
|
|
content.Controls.Add(CreateSectionHeader("COMUNICAÇÃO SEFAZ", 260));
|
|
txtChave = AddInput(content, "CHAVE DE ACESSO", 20, 290, 500, 30, true);
|
|
AddInput(content, "PROTOCOLO", 20, 340, 250, 30, true);
|
|
|
|
content.Height = 400;
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_nfce = new ModeloNotasFiscaisConsumidor();
|
|
LimparFormulario();
|
|
txtStatus.Text = "PENDENTE";
|
|
txtCpfDest.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
// Lógica: Em NFC-e, "Salvar" geralmente significa "Transmitir"
|
|
if (string.IsNullOrWhiteSpace(txtTotalNF.Text))
|
|
{
|
|
MessageBox.Show("Não é possível emitir cupom sem valor total.");
|
|
return;
|
|
}
|
|
|
|
MessageBox.Show("Transmitindo para a SEFAZ... Aguardando Protocolo.", "LevelOS PDV");
|
|
|
|
// Simulação de retorno com sucesso
|
|
txtStatus.Text = "AUTORIZADA";
|
|
txtStatus.BackColor = Color.LightGreen;
|
|
_nfce.SITUACAO = "AUTORIZADA";
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
MessageBox.Show("Cupom fiscal não permite alteração após emitido. Use o Cancelamento.");
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Deseja CANCELAR este cupom fiscal?", "Fiscal", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
_nfce.SITUACAO = "CANCELADA";
|
|
txtStatus.Text = "CANCELADA";
|
|
txtStatus.BackColor = Color.Salmon;
|
|
MessageBox.Show("Cupom cancelado com sucesso.");
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
MessageBox.Show("Pesquisando cupons emitidos por data ou terminal...");
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
|
|
}
|
|
|
|
private void LimparFormulario()
|
|
{
|
|
foreach (Control c in content.Controls)
|
|
{
|
|
if (c is LV_TEXTBOX1 t) t.Text = "";
|
|
}
|
|
}
|
|
}
|
|
} |