135 lines
4.7 KiB
C#
135 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 NotasEnderecosPanel : FormularioModelo
|
|
{
|
|
private ModeloNotasEnderecos _endereco = new ModeloNotasEnderecos();
|
|
|
|
// Controles de UI
|
|
private LV_TEXTBOX1 txtId, txtCodNota, txtCnpj, txtLogradouro, txtNumero, txtBairro, txtCep, txtCidade, txtUf, txtIe;
|
|
private ComboBox cbTipoEndereco;
|
|
|
|
public NotasEnderecosPanel()
|
|
{
|
|
this.Titulo = "Gestão de Endereços da Nota Fiscal";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- Vínculo e Tipo ---
|
|
txtId = AddInput(content, "ID", 20, 30, 60, 30, true);
|
|
txtCodNota = AddInput(content, "CÓD. DA NOTA", 90, 30, 150, 30);
|
|
|
|
content.Controls.Add(new Label { Text = "TIPO DE ENDEREÇO:", Location = new Point(260, 10), AutoSize = true });
|
|
cbTipoEndereco = new ComboBox
|
|
{
|
|
Location = new Point(260, 30),
|
|
Size = new Size(200, 30),
|
|
DropDownStyle = ComboBoxStyle.DropDownList
|
|
};
|
|
cbTipoEndereco.Items.AddRange(new object[] { "EMITENTE", "DESTINATÁRIO", "ENTREGA", "RETIRADA" });
|
|
content.Controls.Add(cbTipoEndereco);
|
|
|
|
// --- Dados de Identificação ---
|
|
content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO", 75));
|
|
txtCnpj = AddInput(content, "CNPJ / CPF", 20, 105, 200, 30);
|
|
txtIe = AddInput(content, "INSCRIÇÃO ESTADUAL", 230, 105, 200, 30);
|
|
|
|
// --- Localização ---
|
|
content.Controls.Add(CreateSectionHeader("LOCALIZAÇÃO", 160));
|
|
txtCep = AddInput(content, "CEP", 20, 190, 120, 30);
|
|
txtLogradouro = AddInput(content, "LOGRADOURO (RUA, AV...)", 150, 190, 350, 30);
|
|
txtNumero = AddInput(content, "Nº", 510, 190, 80, 30);
|
|
|
|
txtBairro = AddInput(content, "BAIRRO", 20, 250, 200, 30);
|
|
txtCidade = AddInput(content, "MUNICÍPIO", 230, 250, 250, 30);
|
|
txtUf = AddInput(content, "UF", 490, 250, 60, 30);
|
|
|
|
content.Height = 330;
|
|
}
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_endereco.COD_NOTA = txtCodNota.Text;
|
|
_endereco.CNPJ_CPF = txtCnpj.Text;
|
|
_endereco.IE = txtIe.Text;
|
|
_endereco.CEP = txtCep.Text;
|
|
_endereco.XLgr = txtLogradouro.Text;
|
|
_endereco.Nro = txtNumero.Text;
|
|
_endereco.XBairro = txtBairro.Text;
|
|
_endereco.XMun = txtCidade.Text;
|
|
_endereco.UF = txtUf.Text;
|
|
_endereco.TIPO = cbTipoEndereco.Text;
|
|
_endereco.DATA_CADASTRO = DateTime.Now.ToString("dd/MM/yyyy HH:mm");
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS DA CLASSE FormularioModelo ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_endereco = new ModeloNotasEnderecos();
|
|
txtId.Text = "0";
|
|
txtCodNota.Text = "";
|
|
txtCnpj.Text = "";
|
|
txtIe.Text = "";
|
|
txtCep.Text = "";
|
|
txtLogradouro.Text = "";
|
|
txtNumero.Text = "";
|
|
txtBairro.Text = "";
|
|
txtCidade.Text = "";
|
|
txtUf.Text = "";
|
|
cbTipoEndereco.SelectedIndex = -1;
|
|
txtCodNota.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(txtLogradouro.Text) || cbTipoEndereco.SelectedIndex == -1)
|
|
{
|
|
MessageBox.Show("Preencha o tipo de endereço e o logradouro.", "Aviso LevelOS");
|
|
return;
|
|
}
|
|
|
|
PreencherModel();
|
|
// Aqui você chamaria o seu controlador de banco de dados
|
|
MessageBox.Show($"Endereço de {cbTipoEndereco.Text} salvo com sucesso!");
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
if (txtId.Text == "0")
|
|
{
|
|
MessageBox.Show("Selecione um endereço para alterar.");
|
|
return;
|
|
}
|
|
PreencherModel();
|
|
MessageBox.Show("Alterações gravadas.");
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Remover este endereço da nota?", "Confirmação", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
OnNovo();
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// Simulação de busca na tabela de endereços
|
|
MessageBox.Show("Abrindo lista de endereços da nota...");
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
//this.Close();
|
|
}
|
|
}
|
|
} |