185 lines
8.1 KiB
C#
185 lines
8.1 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace UI
|
|
{
|
|
public class PedidosPanel : FormularioModelo
|
|
{
|
|
// Mapeamento absoluto de todas as propriedades do ModeloPedidos
|
|
private LV_TEXTBOX1 txtIdPedidos;
|
|
private LV_TEXTBOX1 txtCodigo;
|
|
private LV_TEXTBOX1 txtTipo;
|
|
private LV_TEXTBOX1 txtDataPedido;
|
|
private LV_TEXTBOX1 txtFormaPgto;
|
|
private LV_TEXTBOX1 txtEntregaDia;
|
|
private LV_TEXTBOX1 txtEntregaContato;
|
|
private LV_TEXTBOX1 txtEntregaEndereco;
|
|
private LV_TEXTBOX1 txtEntregaCidade;
|
|
private LV_TEXTBOX1 txtEntregaUf;
|
|
private LV_TEXTBOX1 txtEntregaCep;
|
|
private LV_TEXTBOX1 txtEntregaTelefone;
|
|
private LV_TEXTBOX1 txtDataEnvio;
|
|
private LV_TEXTBOX1 txtObservacoes;
|
|
private LV_TEXTBOX1 txtFornecedor;
|
|
private LV_TEXTBOX1 txtTransportador;
|
|
private LV_TEXTBOX1 txtVendedor;
|
|
private LV_TEXTBOX1 txtValor;
|
|
private LV_TEXTBOX1 txtSituacao;
|
|
private LV_TEXTBOX1 txtDesconto;
|
|
private LV_TEXTBOX1 txtNumNfPed;
|
|
private LV_TEXTBOX1 txtVFrete;
|
|
private LV_TEXTBOX1 txtVSeguro;
|
|
private LV_TEXTBOX1 txtVOutros;
|
|
private LV_TEXTBOX1 txtPedPrazo;
|
|
private LV_TEXTBOX1 txtPedForma;
|
|
private LV_TEXTBOX1 txtPedObs;
|
|
private LV_TEXTBOX1 txtChaveNfeCompra;
|
|
private LV_TEXTBOX1 txtPagamentoPedido;
|
|
private LV_TEXTBOX1 txtPagamentoFrete;
|
|
private LV_TEXTBOX1 txtRastreioFrete;
|
|
|
|
public PedidosPanel()
|
|
{
|
|
this.Titulo = "CENTRAL DE COMPRAS E PEDIDOS";
|
|
MontarInterfaceCompleta();
|
|
}
|
|
|
|
private void MontarInterfaceCompleta()
|
|
{
|
|
// --- SEÇÃO 1: DADOS BÁSICOS E ENVOLVIDOS ---
|
|
content.Controls.Add(CreateSectionHeader("Identificação Básica e Fluxo", 15));
|
|
|
|
txtIdPedidos = AddInput(content, "ID PEDIDO", 20, 45, 100, 28, true);
|
|
txtCodigo = AddInput(content, "CÓDIGO INT.", 135, 45, 110, 28);
|
|
txtTipo = AddInput(content, "TIPO (COMPRA/VENDA)", 260, 45, 160, 28);
|
|
txtDataPedido = AddInput(content, "DATA PEDIDO", 435, 45, 130, 28);
|
|
txtSituacao = AddInput(content, "SITUAÇÃO/STATUS", 580, 45, 150, 28);
|
|
|
|
txtVendedor = AddInput(content, "VENDEDOR", 20, 100, 225, 28);
|
|
txtFornecedor = AddInput(content, "FORNECEDOR / PARCEIRO", 260, 100, 310, 28);
|
|
txtTransportador = AddInput(content, "TRANSPORTADORA", 585, 100, 280, 28);
|
|
|
|
// --- SEÇÃO 2: LOGÍSTICA E ENTREGA ---
|
|
content.Controls.Add(CreateSectionHeader("Logística e Local de Entrega", 155));
|
|
|
|
txtEntregaContato = AddInput(content, "CONTATO P/ ENTREGA", 20, 185, 225, 28);
|
|
txtEntregaTelefone = AddInput(content, "TEL. ENTREGA", 260, 185, 150, 28);
|
|
txtEntregaDia = AddInput(content, "DATA PROMETIDA", 425, 185, 140, 28);
|
|
txtDataEnvio = AddInput(content, "DATA DE ENVIO", 580, 185, 140, 28);
|
|
txtRastreioFrete = AddInput(content, "CÓD. RASTREIO FRETE", 735, 185, 220, 28);
|
|
|
|
txtEntregaEndereco = AddInput(content, "ENDEREÇO DE ENTREGA", 20, 240, 400, 28);
|
|
txtEntregaCidade = AddInput(content, "CIDADE", 435, 240, 200, 28);
|
|
txtEntregaUf = AddInput(content, "UF", 650, 240, 60, 28);
|
|
txtEntregaCep = AddInput(content, "CEP", 725, 240, 110, 28);
|
|
|
|
// --- SEÇÃO 3: VALORES E FINANCEIRO ---
|
|
content.Controls.Add(CreateSectionHeader("Valores, Custos e Condições Financeiras", 295));
|
|
|
|
txtValor = AddInput(content, "VALOR PRODUTOS (R$)", 20, 325, 150, 28);
|
|
txtDesconto = AddInput(content, "DESCONTO (R$)", 185, 325, 120, 28);
|
|
txtVFrete = AddInput(content, "VALOR FRETE (R$)", 320, 325, 120, 28);
|
|
txtVSeguro = AddInput(content, "VALOR SEGURO (R$)", 455, 325, 120, 28);
|
|
txtVOutros = AddInput(content, "OUTRAS DESPESAS (R$)", 590, 325, 140, 28);
|
|
|
|
txtFormaPgto = AddInput(content, "FORMA PGTO PRINCIPAL", 20, 380, 180, 28);
|
|
txtPedForma = AddInput(content, "FORMA DETALHADA", 215, 380, 180, 28);
|
|
txtPedPrazo = AddInput(content, "CONDIÇÃO DE PRAZO", 410, 380, 165, 28);
|
|
txtPagamentoPedido = AddInput(content, "STATUS PGTO PEDIDO", 590, 380, 160, 28);
|
|
txtPagamentoFrete = AddInput(content, "STATUS PGTO FRETE", 765, 380, 160, 28);
|
|
|
|
// --- SEÇÃO 4: DADOS FISCAIS E OBSERVAÇÕES ---
|
|
content.Controls.Add(CreateSectionHeader("Documentação Fiscal e Informações de Fechamento", 435));
|
|
|
|
txtNumNfPed = AddInput(content, "Nº NF-E / DOCUMENTO", 20, 465, 180, 28);
|
|
txtChaveNfeCompra = AddInput(content, "CHAVE DE ACESSO DA NF-E (44 DÍGITOS)", 215, 465, 415, 28);
|
|
|
|
txtObservacoes = AddInput(content, "OBSERVAÇÕES GERAIS", 20, 520, 465, 28);
|
|
txtPedObs = AddInput(content, "OBS. INTERNAS / FINANCEIRAS", 500, 520, 455, 28);
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS DO FORMULÁRIO MODELO ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
// Limpa de forma segura todos os inputs dinâmicos do formulário
|
|
foreach (Control c in content.Controls)
|
|
{
|
|
if (c is LV_TEXTBOX1 txt && !txt.ReadOnly)
|
|
{
|
|
txt.Text = string.Empty;
|
|
}
|
|
}
|
|
txtCodigo.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
// Mapeamento cirúrgico e sem omissões de todas as 31 propriedades
|
|
var pedido = new ModeloPedidos
|
|
{
|
|
ID_PEDIDOS = string.IsNullOrEmpty(txtIdPedidos.Text) ? 0 : Convert.ToInt32(txtIdPedidos.Text),
|
|
CODIGO = txtCodigo.Text,
|
|
TIPO = txtTipo.Text,
|
|
DATA_PEDIDO = txtDataPedido.Text,
|
|
FORMA_PGTO = txtFormaPgto.Text,
|
|
ENTREGA_DIA = txtEntregaDia.Text,
|
|
ENTREGA_CONTATO = txtEntregaContato.Text,
|
|
ENTREGA_ENDERECO = txtEntregaEndereco.Text,
|
|
ENTREGA_CIDADE = txtEntregaCidade.Text,
|
|
ENTREGA_UF = txtEntregaUf.Text,
|
|
ENTREGA_CEP = txtEntregaCep.Text,
|
|
ENTREGA_TELEFONE = txtEntregaTelefone.Text,
|
|
DATA_ENVIO = txtDataEnvio.Text,
|
|
OBSERVACOES = txtObservacoes.Text,
|
|
FORNECEDOR = txtFornecedor.Text,
|
|
TRANSPORTADOR = txtTransportador.Text,
|
|
VENDEDOR = txtVendedor.Text,
|
|
VALOR = txtValor.Text,
|
|
SITUACAO = txtSituacao.Text,
|
|
DESCONTO = txtDesconto.Text,
|
|
NUM_NF_PED = txtNumNfPed.Text,
|
|
V_FRETE = txtVFrete.Text,
|
|
V_SEGURO = txtVSeguro.Text,
|
|
V_OUTROS = txtVOutros.Text,
|
|
PED_PRAZO = txtPedPrazo.Text,
|
|
PED_FORMA = txtPedForma.Text,
|
|
PED_OBS = txtPedObs.Text,
|
|
CHAVE_NFE_COMPRA = txtChaveNfeCompra.Text,
|
|
PAGAMENTO_PEDIDO = txtPagamentoPedido.Text,
|
|
PAGAMENTO_FRETE = txtPagamentoFrete.Text,
|
|
RASTREIO_FRETE = txtRastreioFrete.Text
|
|
};
|
|
|
|
// Comunicação direta com sua BLL/DAL para persistir no banco SQL Server
|
|
MessageBox.Show("Pedido registrado e integrado com sucesso!", "LevelOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
txtSituacao.Focus();
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Atenção! A exclusão deste pedido pode afetar o fluxo financeiro e o estoque. Confirmar?", "LevelOS", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
|
{
|
|
// Comando de deleção...
|
|
OnNovo();
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// Aciona sua tela de consulta/Grid de pedidos
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
OnNovo();
|
|
}
|
|
}
|
|
} |