129 lines
4.8 KiB
C#
129 lines
4.8 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class ItensFabricaCadastroPanel : FormularioModelo
|
|
{
|
|
private ModeloItensFabrica _composicao = new ModeloItensFabrica();
|
|
|
|
// Controles - Identificação do Kit/Pai
|
|
private LV_TEXTBOX1 txtId, txtCodigo, txtKitCodigo, txtKitDescricao;
|
|
private Button btnBuscaKit;
|
|
|
|
// Controles - Item Componente (Filho)
|
|
private LV_TEXTBOX1 txtItemCodigo, txtBarcode, txtItemDescricao;
|
|
private Button btnBuscaItem;
|
|
|
|
// Controles - Quantidade e Valores
|
|
private LV_TEXTBOX1 txtQtd, txtCusto, txtVenda;
|
|
|
|
// Controles - Serviço Associado
|
|
private LV_TEXTBOX1 txtServico;
|
|
|
|
public ItensFabricaCadastroPanel()
|
|
{
|
|
this.Titulo = "Composição de Kits e Fabricação";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Produto Principal (O Kit ou Produto Final) ---
|
|
content.Controls.Add(CreateSectionHeader("PRODUTO PAI / KIT DE MONTAGEM", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
|
|
txtCodigo = AddInput(content, "CÓD. VÍNCULO", 100, 50, 110, 30);
|
|
|
|
txtKitCodigo = AddInput(content, "CÓD. KIT", 220, 50, 100, 30);
|
|
btnBuscaKit = CriarBotaoLupa(325, 66, OnBuscaKit);
|
|
txtKitDescricao = AddInput(content, "DESCRIÇÃO DO PRODUTO FINAL", 365, 50, 470, 30, true);
|
|
|
|
// --- SEÇÃO 2: Componente / Insumo ---
|
|
content.Controls.Add(CreateSectionHeader("COMPONENTE (ITEM DA COMPOSIÇÃO)", 115));
|
|
|
|
txtItemCodigo = AddInput(content, "CÓD. COMPONENTE", 20, 145, 130, 30);
|
|
btnBuscaItem = CriarBotaoLupa(155, 161, OnBuscaItem);
|
|
|
|
txtBarcode = AddInput(content, "BARRAS/GTIN", 200, 145, 180, 30);
|
|
txtItemDescricao = AddInput(content, "DESCRIÇÃO DO COMPONENTE", 390, 145, 445, 30, true);
|
|
|
|
// --- SEÇÃO 3: Quantidades e Financeiro do Componente ---
|
|
content.Controls.Add(CreateSectionHeader("ESTRUTURA DE CUSTOS E QTD.", 210));
|
|
|
|
txtQtd = AddInput(content, "QTD. NECESSÁRIA", 20, 240, 150, 30);
|
|
txtQtd.BackColor = Color.LightYellow; // Destaque para campo de ajuste
|
|
|
|
txtCusto = AddInput(content, "CUSTO UNIT.", 180, 240, 150, 30);
|
|
txtVenda = AddInput(content, "VENDA UNIT.", 340, 240, 150, 30);
|
|
|
|
// --- SEÇÃO 4: Mão de Obra / Serviço ---
|
|
content.Controls.Add(CreateSectionHeader("MÃO DE OBRA ASSOCIADA", 305));
|
|
txtServico = AddInput(content, "SERVIÇO DE MONTAGEM / TÉCNICO", 20, 335, 815, 30);
|
|
|
|
content.Height = 420;
|
|
}
|
|
|
|
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 OnBuscaKit(object sender, EventArgs e) => MessageBox.Show("Selecionar Produto Pai");
|
|
private void OnBuscaItem(object sender, EventArgs e) => MessageBox.Show("Selecionar Componente");
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_composicao.CODIGO = txtCodigo.Text;
|
|
_composicao.KIT_CODIGO = txtKitCodigo.Text;
|
|
_composicao.ITEM_CODIGO = txtItemCodigo.Text;
|
|
_composicao.BARCODE = txtBarcode.Text;
|
|
_composicao.DESCRICAO = txtItemDescricao.Text;
|
|
_composicao.QTD = txtQtd.Text;
|
|
_composicao.CUSTO = txtCusto.Text;
|
|
_composicao.VENDA = txtVenda.Text;
|
|
_composicao.SERVICO = txtServico.Text;
|
|
}
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_composicao = new ModeloItensFabrica();
|
|
txtKitCodigo.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
try
|
|
{
|
|
PreencherModel();
|
|
MessageBox.Show("Componente vinculado à fabricação com sucesso!", "LevelOS - Fábrica", 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(); }
|
|
}
|
|
} |