LevelOS-Core/UI/Dashboards/Cadastros/NotasCceCadastroPanel.cs

93 lines
3.2 KiB
C#

using CPM;
using MLL;
using System;
using System.Drawing;
using System.Windows.Forms;
using UI;
namespace UI
{
public partial class NotasCceCadastroPanel : FormularioModelo
{
private ModeloNotasCCE _cce = new ModeloNotasCCE();
// Controles - Rastreio
private LV_TEXTBOX1 txtId, txtChaveNfe, txtProtocolo, txtDataHora, txtSequencia;
// Controles - Conteúdo
private LV_TEXTBOX1 txtCorrecao, txtRetorno;
public NotasCceCadastroPanel()
{
this.Titulo = "Carta de Correção Eletrônica (CC-e)";
MontarInterface();
}
private void MontarInterface()
{
// --- SEÇÃO 1: Dados do Evento ---
content.Controls.Add(CreateSectionHeader("VÍNCULO COM A NF-e", 20));
txtId = AddInput(content, "ID INTERNO", 20, 50, 80, 30, true);
txtChaveNfe = AddInput(content, "CHAVE DE ACESSO NF-e", 110, 50, 380, 30);
txtProtocolo = AddInput(content, "PROTOCOLO EVENTO", 500, 50, 220, 30, true);
txtDataHora = AddInput(content, "DATA/HORA ENVIO", 20, 105, 180, 30, true);
txtSequencia = AddInput(content, "Nº SEQUENCIAL (EVENTO)", 210, 105, 150, 30);
// --- SEÇÃO 2: Texto da Correção ---
content.Controls.Add(CreateSectionHeader("DETALHAMENTO DA CORREÇÃO", 165));
txtCorrecao = AddInput(content, "TEXTO DA CORREÇÃO (MÍNIMO 15 CARACTERES)", 20, 195, 700, 100);
txtCorrecao.Multiline = true;
//txtCorrecao.ScrollBars = ScrollBars.Vertical;
txtCorrecao.Height = 120;
// --- SEÇÃO 3: Retorno SEFAZ ---
content.Controls.Add(CreateSectionHeader("RETORNO DO PROCESSAMENTO", 325));
txtRetorno = AddInput(content, "STATUS / MENSAGEM DA SEFAZ", 20, 355, 700, 60, true);
txtRetorno.Multiline = true;
content.Height = 450;
}
private void PreencherModel()
{
_cce.COD_NFE = txtChaveNfe.Text;
_cce.CORRECAO = txtCorrecao.Text;
_cce.EVENTO = txtSequencia.Text;
_cce.DATA_HORA = txtDataHora.Text;
// TZD (Time Zone Designator) geralmente é capturado automaticamente pelo motor fiscal
_cce.TZD = "-03:00";
}
protected override void OnNovo()
{
_cce = new ModeloNotasCCE();
txtDataHora.Text = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
txtSequencia.Text = "1"; // Se for a primeira correção para esta nota
txtChaveNfe.Focus();
}
protected override void OnSalvar()
{
if (txtCorrecao.Text.Length < 15)
{
MessageBox.Show("A carta de correção deve ter no mínimo 15 caracteres.", "Regra Fiscal");
return;
}
PreencherModel();
MessageBox.Show("Solicitação de Carta de Correção gerada!", "LevelOS Fiscal");
}
protected override void OnCancelar() { }
protected override void OnExcluir() { }
protected override void OnAlterar() { }
protected override void OnLocalizar()
{
}
}
}