124 lines
4.0 KiB
C#
124 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 NotasComprasCorelPanel : FormularioModelo
|
|
{
|
|
private ModeloNotasComprasCorel _corel = new ModeloNotasComprasCorel();
|
|
|
|
// Controles
|
|
private LV_TEXTBOX1 txtId, txtCnpjFornecedor, txtCodFornecedor, txtMeuCodigo;
|
|
private Label lblPreviewRelacao;
|
|
|
|
public NotasComprasCorelPanel()
|
|
{
|
|
this.Titulo = "Correlação de Produtos (De/Para Fornecedor)";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Origem (O que vem na Nota) ---
|
|
content.Controls.Add(CreateSectionHeader("DADOS DO FORNECEDOR", 20));
|
|
|
|
txtCnpjFornecedor = AddInput(content, "CNPJ DO FORNECEDOR", 20, 50, 250, 30);
|
|
txtCodFornecedor = AddInput(content, "CÓD. PRODUTO NO FORNECEDOR", 280, 50, 250, 30);
|
|
|
|
// --- SEÇÃO 2: Destino (Como está no seu Sistema) ---
|
|
content.Controls.Add(CreateSectionHeader("MEU CADASTRO INTERNO", 115));
|
|
|
|
txtMeuCodigo = AddInput(content, "MEU CÓDIGO DE ESTOQUE (SKU)", 20, 145, 250, 30);
|
|
|
|
// Preview Visual
|
|
lblPreviewRelacao = new Label
|
|
{
|
|
Text = "Vínculo: [Produto Fornecedor] ➔ [Meu Estoque]",
|
|
Location = new Point(20, 195),
|
|
Size = new Size(500, 20),
|
|
ForeColor = Color.DimGray,
|
|
Font = new Font("Segoe UI", 9, FontStyle.Italic)
|
|
};
|
|
content.Controls.Add(lblPreviewRelacao);
|
|
|
|
// Botão auxiliar para busca
|
|
Button btnBuscarProduto = new Button
|
|
{
|
|
Text = "🔍 Buscar no Meu Estoque",
|
|
Location = new Point(280, 142),
|
|
Size = new Size(180, 35),
|
|
FlatStyle = FlatStyle.Flat
|
|
};
|
|
content.Controls.Add(btnBuscarProduto);
|
|
|
|
content.Height = 240;
|
|
}
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_corel.FORNEC_CNPJ = txtCnpjFornecedor.Text;
|
|
_corel.FORNEC_cProd = txtCodFornecedor.Text;
|
|
_corel.MEU_cProd = txtMeuCodigo.Text;
|
|
}
|
|
|
|
// --- IMPLEMENTAÇÃO DOS MEMBROS OBRIGATÓRIOS ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_corel = new ModeloNotasComprasCorel();
|
|
txtId.Text = "0";
|
|
txtCnpjFornecedor.Text = "";
|
|
txtCodFornecedor.Text = "";
|
|
txtMeuCodigo.Text = "";
|
|
txtCnpjFornecedor.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(txtCnpjFornecedor.Text)) return;
|
|
|
|
PreencherModel();
|
|
// Lógica de persistência no Banco de Dados viria aqui
|
|
MessageBox.Show("Vínculo de produto salvo com sucesso!", "LevelOS");
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
if (_corel.ID_NOTAS_COMP_COREL == 0)
|
|
{
|
|
MessageBox.Show("Selecione um registro primeiro para alterar.", "Aviso");
|
|
return;
|
|
}
|
|
PreencherModel();
|
|
MessageBox.Show("Registro atualizado!", "LevelOS");
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Deseja realmente excluir este vínculo?", "Confirmar", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
OnNovo();
|
|
MessageBox.Show("Vínculo removido.");
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// Aqui você abriria o seu formulário de busca padrão (Grid)
|
|
// Exemplo hipotético:
|
|
// var busca = new FormBuscaGenerica("NotasComprasCorel");
|
|
// if (busca.ShowDialog() == DialogResult.OK) { MapModelParaTela(busca.ObjetoSelecionado); }
|
|
|
|
MessageBox.Show("Abrindo tela de consulta de correlações...");
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |