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

122 lines
4.0 KiB
C#

using CPM;
using MLL;
using System;
using System.Drawing;
using System.Windows.Forms;
using UI;
namespace UI
{
public partial class NotasComprasItensPanel : FormularioModelo
{
private ModeloNotasComprasItens _item = new ModeloNotasComprasItens();
private TabControl tabDetalhes;
private TabPage tpGeral, tpImpostos, tpImportacao;
public NotasComprasItensPanel()
{
this.Titulo = "Itens da Nota de Compra";
this.Size = new Size(850, 600);
MontarInterface();
}
private void MontarInterface()
{
tabDetalhes = new TabControl { Dock = DockStyle.Fill, Font = new Font("Segoe UI", 9) };
tpGeral = new TabPage("Dados Gerais");
tpImpostos = new TabPage("Impostos (ICMS/IPI/PIS)");
tpImportacao = new TabPage("Importação (DI)");
tabDetalhes.TabPages.AddRange(new[] { tpGeral, tpImpostos, tpImportacao });
content.Controls.Add(tabDetalhes);
ConfigurarAbaGeral();
ConfigurarAbaImpostos();
}
private void ConfigurarAbaGeral()
{
AddInput(tpGeral, "ID ITEM", 20, 20, 80, 30, true).Name = "txtId";
AddInput(tpGeral, "DESCRIÇÃO DO PRODUTO", 110, 20, 450, 30).Name = "txtXProd";
AddInput(tpGeral, "CÓD. FORNECEDOR", 20, 80, 150, 30);
AddInput(tpGeral, "EAN / GTIN", 180, 80, 180, 30);
AddInput(tpGeral, "NCM", 370, 80, 120, 30);
AddInput(tpGeral, "QTD COMPRADA", 20, 140, 120, 30).ForeColor = Color.Blue;
AddInput(tpGeral, "UNIDADE", 150, 140, 80, 30);
AddInput(tpGeral, "VLR UNITÁRIO", 240, 140, 120, 30);
AddInput(tpGeral, "VLR TOTAL PROD", 370, 140, 150, 30).BackColor = Color.LightYellow;
}
private void ConfigurarAbaImpostos()
{
AddInput(tpImpostos, "CST ICMS", 20, 20, 80, 30);
AddInput(tpImpostos, "BASE CÁLC. ICMS", 110, 20, 120, 30);
AddInput(tpImpostos, "VLR ICMS", 240, 20, 120, 30);
AddInput(tpImpostos, "CST PIS", 20, 80, 80, 30);
AddInput(tpImpostos, "CST COFINS", 110, 80, 80, 30);
AddInput(tpImpostos, "VLR IPI", 200, 80, 120, 30);
}
// --- MÉTODOS OBRIGATÓRIOS (IMPLEMENTAÇÃO) ---
protected override void OnNovo()
{
_item = new ModeloNotasComprasItens();
LimparCampos(tpGeral);
LimparCampos(tpImpostos);
LimparCampos(tpImportacao);
MessageBox.Show("Pronto para adicionar um novo item.");
}
protected override void OnSalvar()
{
// Validação mínima
if (string.IsNullOrEmpty(_item.XPROD))
{
// Aqui você capturaria dos inputs antes de salvar
// PreencherModel();
}
MessageBox.Show("Item da nota salvo com sucesso!", "LevelOS");
}
protected override void OnAlterar()
{
if (_item.ID_NOTAS_COMP_ITENS == 0)
{
MessageBox.Show("Selecione um item na lista para alterar.");
return;
}
MessageBox.Show("Alterações no item registradas.");
}
protected override void OnExcluir()
{
if (MessageBox.Show("Remover este item da nota fiscal?", "Excluir", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
OnNovo();
}
}
protected override void OnLocalizar()
{
// Geralmente itens são listados em um Grid, mas o método é obrigatório
MessageBox.Show("Localizando itens vinculados à nota...");
}
protected override void OnCancelar()
{
}
private void LimparCampos(Control pai)
{
foreach (Control c in pai.Controls)
{
if (c is LV_TEXTBOX1 t) t.Text = "";
if (c.HasChildren) LimparCampos(c);
}
}
}
}