133 lines
5.2 KiB
C#
133 lines
5.2 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class FornecedoresCadastroPanel : FormularioModelo
|
|
{
|
|
private ModeloFornecedores _fornecedor = new ModeloFornecedores();
|
|
|
|
// Controles - Identificação
|
|
private LV_TEXTBOX1 txtId, txtEmpresaId, txtNome, txtNomeFantasia, txtDocumento, txtIE, txtTipoPessoa;
|
|
|
|
// Controles - Localização
|
|
private LV_TEXTBOX1 txtCep, txtEndereco, txtNumero, txtBairro, txtCidade, txtUF, txtComplemento;
|
|
|
|
// Controles - Contato e Extras
|
|
private LV_TEXTBOX1 txtTelefone, txtCelular, txtWhatsapp, txtEmail, txtSite, txtObservacoes;
|
|
private CheckBox chkAtivo;
|
|
|
|
public FornecedoresCadastroPanel()
|
|
{
|
|
this.Titulo = "Cadastro de Fornecedores";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Identificação ---
|
|
content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO DO FORNECEDOR", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
|
|
txtEmpresaId = AddInput(content, "ID EMPRESA", 100, 50, 80, 30);
|
|
txtTipoPessoa = AddInput(content, "TIPO (PF/PJ)", 190, 50, 100, 30);
|
|
txtDocumento = AddInput(content, "CPF / CNPJ", 300, 50, 180, 30);
|
|
txtIE = AddInput(content, "INSC. ESTADUAL", 490, 50, 180, 30);
|
|
|
|
txtNome = AddInput(content, "RAZÃO SOCIAL / NOME", 20, 105, 430, 30);
|
|
txtNomeFantasia = AddInput(content, "NOME FANTASIA", 460, 105, 420, 30);
|
|
|
|
// --- SEÇÃO 2: Localização ---
|
|
content.Controls.Add(CreateSectionHeader("ENDEREÇO E LOCALIZAÇÃO", 175));
|
|
|
|
txtCep = AddInput(content, "CEP", 20, 205, 100, 30);
|
|
txtEndereco = AddInput(content, "LOGRADOURO", 130, 205, 350, 30);
|
|
txtNumero = AddInput(content, "Nº", 490, 205, 70, 30);
|
|
txtBairro = AddInput(content, "BAIRRO", 570, 205, 190, 30);
|
|
txtUF = AddInput(content, "UF", 770, 205, 50, 30);
|
|
|
|
txtCidade = AddInput(content, "CIDADE", 20, 260, 300, 30);
|
|
txtComplemento = AddInput(content, "COMPLEMENTO", 330, 260, 550, 30);
|
|
|
|
// --- SEÇÃO 3: Contato e Comunicação ---
|
|
content.Controls.Add(CreateSectionHeader("CONTATOS E DIGITAL", 330));
|
|
|
|
txtTelefone = AddInput(content, "TELEFONE", 20, 360, 150, 30);
|
|
txtCelular = AddInput(content, "CELULAR", 180, 360, 150, 30);
|
|
txtWhatsapp = AddInput(content, "WHATSAPP", 340, 360, 150, 30);
|
|
txtEmail = AddInput(content, "E-MAIL", 500, 360, 380, 30);
|
|
|
|
txtSite = AddInput(content, "WEBSITE / PORTAL", 20, 415, 430, 30);
|
|
|
|
chkAtivo = CreateCheckBox("FORNECEDOR ATIVO", 460, 433);
|
|
content.Controls.Add(chkAtivo);
|
|
|
|
// --- SEÇÃO 4: Observações ---
|
|
content.Controls.Add(CreateSectionHeader("OBSERVAÇÕES GERAIS", 485));
|
|
txtObservacoes = AddInput(content, "NOTAS INTERNAS", 20, 515, 860, 100);
|
|
txtObservacoes.Height = 100;
|
|
|
|
// Ajuste automático da área de scroll para o conteúdo caber
|
|
content.Height = 650;
|
|
}
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_fornecedor.Nome = txtNome.Text;
|
|
_fornecedor.NomeFantasia = txtNomeFantasia.Text;
|
|
_fornecedor.TipoPessoa = txtTipoPessoa.Text;
|
|
_fornecedor.Documento = txtDocumento.Text;
|
|
_fornecedor.InscricaoEstadual = txtIE.Text;
|
|
|
|
_fornecedor.Cep = txtCep.Text;
|
|
_fornecedor.Endereco = txtEndereco.Text;
|
|
_fornecedor.Bairro = txtBairro.Text;
|
|
_fornecedor.Cidade = txtCidade.Text;
|
|
_fornecedor.UF = txtUF.Text;
|
|
_fornecedor.Complemento = txtComplemento.Text;
|
|
|
|
if (int.TryParse(txtNumero.Text, out int n)) _fornecedor.Numero = n;
|
|
if (int.TryParse(txtEmpresaId.Text, out int emp)) _fornecedor.EmpresaId = emp;
|
|
|
|
_fornecedor.Telefone = txtTelefone.Text;
|
|
_fornecedor.Celular = txtCelular.Text;
|
|
_fornecedor.Whatsapp = txtWhatsapp.Text;
|
|
_fornecedor.Email = txtEmail.Text;
|
|
_fornecedor.Site = txtSite.Text;
|
|
_fornecedor.Observacoes = txtObservacoes.Text;
|
|
_fornecedor.Ativo = chkAtivo.Checked;
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_fornecedor = new ModeloFornecedores();
|
|
// Implementar lógica de limpar campos se necessário
|
|
txtNome.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
try
|
|
{
|
|
PreencherModel();
|
|
// BLLFornecedor.Salvar(_fornecedor);
|
|
MessageBox.Show("Fornecedor salvo com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Erro ao salvar: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
protected override void OnAlterar() { }
|
|
protected override void OnExcluir() { }
|
|
protected override void OnLocalizar() { }
|
|
protected override void OnCancelar() { OnNovo(); }
|
|
}
|
|
} |