122 lines
3.9 KiB
C#
122 lines
3.9 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class NotasContadorPanel : FormularioModelo
|
|
{
|
|
private ModeloNotasContador _contador = new ModeloNotasContador();
|
|
|
|
// Controles de UI
|
|
private LV_TEXTBOX1 txtId, txtCnpjCpf, txtNome, txtEmail, txtTelefone, txtContadorId;
|
|
|
|
public NotasContadorPanel()
|
|
{
|
|
this.Titulo = "Cadastro de Contador Responsável";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- Identificação ---
|
|
txtId = AddInput(content, "ID", 20, 30, 60, 30, true);
|
|
txtContadorId = AddInput(content, "CÓD. CONTADOR (CRC)", 90, 30, 150, 30);
|
|
|
|
// --- Dados Principais ---
|
|
content.Controls.Add(CreateSectionHeader("DADOS PROFISSIONAIS", 85));
|
|
|
|
txtCnpjCpf = AddInput(content, "CNPJ / CPF", 20, 115, 200, 30);
|
|
txtNome = AddInput(content, "NOME DO CONTADOR / ESCRITÓRIO", 230, 115, 410, 30);
|
|
|
|
// --- Contato ---
|
|
content.Controls.Add(CreateSectionHeader("CONTATO E COMUNICAÇÃO", 180));
|
|
|
|
txtEmail = AddInput(content, "E-MAIL (PARA ENVIO DE XMLS)", 20, 210, 350, 30);
|
|
txtTelefone = AddInput(content, "TELEFONE", 380, 210, 200, 30);
|
|
|
|
content.Height = 280;
|
|
}
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_contador.CNPJ_CPF = txtCnpjCpf.Text;
|
|
_contador.NOME = txtNome.Text;
|
|
_contador.EMAIL = txtEmail.Text;
|
|
_contador.TELEFONE = txtTelefone.Text;
|
|
_contador.CONTADOR_ID = txtContadorId.Text;
|
|
_contador.DATA_CADASTRO = DateTime.Now.ToString("dd/MM/yyyy HH:mm");
|
|
}
|
|
|
|
private void MapModelParaTela(ModeloNotasContador model)
|
|
{
|
|
txtId.Text = model.ID_NOTAS_CONTADOR.ToString();
|
|
txtCnpjCpf.Text = model.CNPJ_CPF;
|
|
txtNome.Text = model.NOME;
|
|
txtEmail.Text = model.EMAIL;
|
|
txtTelefone.Text = model.TELEFONE;
|
|
txtContadorId.Text = model.CONTADOR_ID;
|
|
}
|
|
|
|
// --- IMPLEMENTAÇÃO OBRIGATÓRIA DOS MÉTODOS ABSTRATOS ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_contador = new ModeloNotasContador();
|
|
txtId.Text = "0";
|
|
txtCnpjCpf.Text = "";
|
|
txtNome.Text = "";
|
|
txtEmail.Text = "";
|
|
txtTelefone.Text = "";
|
|
txtContadorId.Text = "";
|
|
txtCnpjCpf.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(txtNome.Text))
|
|
{
|
|
MessageBox.Show("O nome do contador é obrigatório para fins fiscais.", "LevelOS Cloud");
|
|
return;
|
|
}
|
|
|
|
PreencherModel();
|
|
// Lógica de Salvamento no Banco (DAO/BLL)
|
|
MessageBox.Show("Dados do contador salvos! O envio automático de XML agora está ativo.", "Sucesso");
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
if (txtId.Text == "0")
|
|
{
|
|
MessageBox.Show("Selecione um contador para alterar.", "Aviso");
|
|
return;
|
|
}
|
|
PreencherModel();
|
|
MessageBox.Show("Cadastro de contador atualizado.");
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Deseja remover este contador do sistema?", "Confirmar Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
|
{
|
|
OnNovo();
|
|
MessageBox.Show("Contador removido.");
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// Chamada para a tela de busca ou consulta no banco
|
|
MessageBox.Show("Pesquisando contadores cadastrados...");
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |