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

148 lines
5.6 KiB
C#

using CPM;
using MLL;
using System;
using System.Drawing;
using System.Windows.Forms;
using UI;
namespace UI
{
public partial class ItensPedidoCadastroPanel : FormularioModelo
{
private ModeloItensPedido _itemPedido = new ModeloItensPedido();
// Controles - Vínculos e Cabeçalho
private LV_TEXTBOX1 txtId, txtCodigo, txtPedido, txtItemSequencial;
// Controles - Dados do Produto
private LV_TEXTBOX1 txtCodItem, txtCodFab, txtNome, txtUn;
private Button btnBuscaItem;
// Controles - Quantidades e Valores Base
private LV_TEXTBOX1 txtQtd, txtVlrUnitario, txtValorTotal;
// Controles - Impostos e Rateios (Logística)
private LV_TEXTBOX1 txtIpi, txtIcms, txtVFrete, txtVSeguro, txtVDesconto, txtVOutros;
// Controles - Rastreabilidade
private LV_TEXTBOX1 txtSeriais;
public ItensPedidoCadastroPanel()
{
this.Titulo = "Gestão de Itens do Pedido";
MontarInterface();
}
private void MontarInterface()
{
// --- SEÇÃO 1: Referências do Pedido ---
content.Controls.Add(CreateSectionHeader("VÍNCULO DO PEDIDO", 20));
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
txtCodigo = AddInput(content, "CÓD. INTERNO", 100, 50, 110, 30);
txtPedido = AddInput(content, "Nº PEDIDO", 220, 50, 150, 30);
txtItemSequencial = AddInput(content, "ITEM Nº", 380, 50, 80, 30);
// --- SEÇÃO 2: Dados do Produto ---
content.Controls.Add(CreateSectionHeader("PRODUTO E REFERÊNCIA DE FÁBRICA", 115));
txtCodItem = AddInput(content, "CÓD. ITEM", 20, 145, 110, 30);
btnBuscaItem = CriarBotaoLupa(135, 161, OnBuscaItem);
txtCodFab = AddInput(content, "REF. FABRICANTE", 175, 145, 150, 30);
txtNome = AddInput(content, "DESCRIÇÃO DO PRODUTO", 335, 145, 410, 30);
txtUn = AddInput(content, "UN", 755, 145, 60, 30);
// --- SEÇÃO 3: Valores, Impostos e Rateios ---
content.Controls.Add(CreateSectionHeader("FINANCEIRO E COMPOSIÇÃO DE CUSTO", 210));
txtQtd = AddInput(content, "QUANTIDADE", 20, 240, 110, 30);
txtVlrUnitario = AddInput(content, "VLR. UNITÁRIO", 140, 240, 130, 30);
txtIpi = AddInput(content, "IPI (%)", 280, 240, 80, 30);
txtIcms = AddInput(content, "ICMS (%)", 370, 240, 80, 30);
txtVDesconto = AddInput(content, "(-) DESCONTO", 460, 240, 120, 30);
txtVDesconto.ForeColor = Color.Red;
txtValorTotal = AddInput(content, "TOTAL LÍQUIDO", 590, 240, 225, 30, true);
txtValorTotal.BackColor = Color.FromArgb(240, 248, 255);
// Linha de custos logísticos
txtVFrete = AddInput(content, "(+) FRETE", 20, 295, 120, 30);
txtVSeguro = AddInput(content, "(+) SEGURO", 150, 295, 120, 30);
txtVOutros = AddInput(content, "(+) OUTROS", 280, 295, 120, 30);
// --- SEÇÃO 4: Rastreabilidade (Seriais) ---
content.Controls.Add(CreateSectionHeader("CONTROLE DE SERIAIS / GARANTIA", 365));
txtSeriais = AddInput(content, "NÚMEROS DE SÉRIE (SEPARE POR VÍRGULA OU SCANNER)", 20, 395, 795, 50);
content.Height = 480;
}
private Button CriarBotaoLupa(int x, int y, EventHandler clickEvent)
{
var btn = new Button
{
Text = "🔍",
Location = new Point(x, y),
Size = new Size(32, 30),
BackColor = AccentBlue,
ForeColor = Color.White,
FlatStyle = FlatStyle.Flat,
Cursor = Cursors.Hand
};
btn.FlatAppearance.BorderSize = 0;
btn.Click += clickEvent;
content.Controls.Add(btn);
return btn;
}
private void OnBuscaItem(object sender, EventArgs e) => MessageBox.Show("Busca de Itens");
private void PreencherModel()
{
_itemPedido.CODIGO = txtCodigo.Text;
_itemPedido.ITEM = txtItemSequencial.Text;
_itemPedido.PEDIDO = txtPedido.Text;
_itemPedido.COD_ITEM = txtCodItem.Text;
_itemPedido.NOME = txtNome.Text;
_itemPedido.UN = txtUn.Text;
_itemPedido.QTD = txtQtd.Text;
_itemPedido.VLR = txtVlrUnitario.Text;
_itemPedido.IPI = txtIpi.Text;
_itemPedido.ICMS = txtIcms.Text;
_itemPedido.VALOR = txtValorTotal.Text;
_itemPedido.COD_FAB = txtCodFab.Text;
_itemPedido.VFrete = txtVFrete.Text;
_itemPedido.VSeguro = txtVSeguro.Text;
_itemPedido.VDesconto = txtVDesconto.Text;
_itemPedido.VOutros = txtVOutros.Text;
_itemPedido.SERIAIS_IN = txtSeriais.Text;
}
protected override void OnNovo()
{
_itemPedido = new ModeloItensPedido();
txtCodItem.Focus();
}
protected override void OnSalvar()
{
try
{
PreencherModel();
MessageBox.Show("Item do pedido processado!", "LevelOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Erro: " + ex.Message);
}
}
protected override void OnAlterar() { }
protected override void OnExcluir() { }
protected override void OnLocalizar() { }
protected override void OnCancelar() { OnNovo(); }
}
}