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

130 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 ItensSaidaCadastroPanel : FormularioModelo
{
private ModeloItensSaida _saida = new ModeloItensSaida();
// Controles - Identificação e Item
private LV_TEXTBOX1 txtId, txtCodigo, txtCodItem, txtDescricaoItem;
private Button btnBuscaItem;
// Controles - Quantidade e Responsável
private LV_TEXTBOX1 txtQtdSai, txtDataSaida, txtFuncionario;
// Controles - Origem e Documentação (OS, OP, OV, NOTA)
private LV_TEXTBOX1 txtOs, txtOp, txtOv, txtNota, txtNatureza;
// Controles - Notas
private LV_TEXTBOX1 txtObs;
public ItensSaidaCadastroPanel()
{
this.Titulo = "Lançamento de Saída / Baixa de Estoque";
MontarInterface();
}
private void MontarInterface()
{
// --- SEÇÃO 1: Item Selecionado ---
content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO DO PRODUTO", 20));
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
txtCodigo = AddInput(content, "CÓD. MOV.", 100, 50, 110, 30);
txtCodItem = AddInput(content, "CÓD. ITEM", 220, 50, 100, 30);
btnBuscaItem = CriarBotaoLupa(325, 66, OnBuscaItem);
txtDescricaoItem = AddInput(content, "DESCRIÇÃO DO PRODUTO", 365, 50, 470, 30, true);
// --- SEÇÃO 2: Dados da Movimentação ---
content.Controls.Add(CreateSectionHeader("DADOS DA BAIXA", 115));
txtQtdSai = AddInput(content, "QTD. SAÍDA", 20, 145, 130, 30);
txtQtdSai.BackColor = Color.FromArgb(255, 240, 240); // Tom avermelhado para indicar saída/baixa
txtDataSaida = AddInput(content, "DATA SAÍDA", 160, 145, 130, 30);
txtFuncionario = AddInput(content, "RESPONSÁVEL PELA BAIXA", 300, 145, 330, 30);
txtNatureza = AddInput(content, "NATUREZA (EX: VENDA/AVARIA)", 640, 145, 195, 30);
// --- SEÇÃO 3: Vínculos e Documentos (OS, OP, OV, NOTA) ---
content.Controls.Add(CreateSectionHeader("DOCUMENTOS DE ORIGEM", 210));
txtOs = AddInput(content, "ORDEM SERV. (OS)", 20, 240, 150, 30);
txtOp = AddInput(content, "ORDEM PROD. (OP)", 180, 240, 150, 30);
txtOv = AddInput(content, "ORDEM VENDA (OV)", 340, 240, 150, 30);
txtNota = AddInput(content, "NOTA FISCAL", 500, 240, 180, 30);
// --- SEÇÃO 4: Observações ---
content.Controls.Add(CreateSectionHeader("OBSERVAÇÕES GERAIS", 305));
txtObs = AddInput(content, "MOTIVO DETALHADO DA SAÍDA", 20, 335, 815, 60);
content.Height = 430;
}
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()
{
_saida.CODIGO = txtCodigo.Text;
_saida.COD_ITEM = txtCodItem.Text;
_saida.QTD_SAI = txtQtdSai.Text;
_saida.FUNCIONARIO = txtFuncionario.Text;
_saida.NOTA = txtNota.Text;
_saida.OS = txtOs.Text;
_saida.OP = txtOp.Text;
_saida.OBSERVACAO = txtObs.Text;
_saida.DATA_SAIDA = txtDataSaida.Text;
_saida.NATUREZA = txtNatureza.Text;
_saida.OV = txtOv.Text;
}
protected override void OnNovo()
{
_saida = new ModeloItensSaida();
txtDataSaida.Text = DateTime.Now.ToString("dd/MM/yyyy");
txtCodItem.Focus();
}
protected override void OnSalvar()
{
try
{
PreencherModel();
MessageBox.Show("Baixa de estoque registrada!", "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(); }
}
}