121 lines
4.4 KiB
C#
121 lines
4.4 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace UI
|
|
{
|
|
public class ParametrosPanel : FormularioModelo
|
|
{
|
|
// Mapeamento absoluto de todas as propriedades do ModeloParametros
|
|
private LV_TEXTBOX1 txtIdParametros;
|
|
private LV_TEXTBOX1 txtCodigo;
|
|
private LV_TEXTBOX1 txtNomePar;
|
|
private LV_TEXTBOX1 txtDescricao;
|
|
private LV_TEXTBOX1 txtPx;
|
|
private LV_TEXTBOX1 txtPy;
|
|
private LV_TEXTBOX1 txtCampo;
|
|
private CheckBox chkAtivo;
|
|
|
|
public ParametrosPanel()
|
|
{
|
|
this.Titulo = "CADASTRO E POSICIONAMENTO DE PARAMETROS";
|
|
MontarInterfaceCompleta();
|
|
}
|
|
|
|
private void MontarInterfaceCompleta()
|
|
{
|
|
// --- SEÇÃO 1: IDENTIFICAÇÃO E CHAVES ---
|
|
content.Controls.Add(CreateSectionHeader("Identificação do Parâmetro", 20));
|
|
|
|
txtIdParametros = AddInput(content, "ID REGISTRO", 20, 55, 100, 28, true);
|
|
txtCodigo = AddInput(content, "CÓDIGO INTERNO", 130, 55, 120, 28);
|
|
txtNomePar = AddInput(content, "NOME DO PARÂMETRO (CHAVE)", 260, 55, 300, 28);
|
|
|
|
// Status Ativo/Inativo usando o posicionamento padrão
|
|
chkAtivo = new CheckBox
|
|
{
|
|
Text = "Parâmetro Ativo no Sistema",
|
|
Location = new Point(580, 71),
|
|
AutoSize = true,
|
|
Font = new Font("Segoe UI", 10F, FontStyle.Bold),
|
|
ForeColor = Color.FromArgb(64, 64, 64),
|
|
Checked = true
|
|
};
|
|
content.Controls.Add(chkAtivo);
|
|
|
|
// --- SEÇÃO 2: MAPEAMENTO DE COORDENADAS E INTERFACE ---
|
|
content.Controls.Add(CreateSectionHeader("Posicionamento e Mapeamento de Tela / Relatório", 115));
|
|
|
|
txtCampo = AddInput(content, "CAMPO DA TABELA / CONTROLE ALVO", 20, 150, 350, 28);
|
|
txtPx = AddInput(content, "COORDENADA X (PIXELS / COLUNA)", 390, 150, 200, 28);
|
|
txtPy = AddInput(content, "COORDENADA Y (PIXELS / LINHA)", 600, 150, 200, 28);
|
|
|
|
// --- SEÇÃO 3: DETALHAMENTO ---
|
|
content.Controls.Add(CreateSectionHeader("Documentação e Regras", 210));
|
|
|
|
txtDescricao = AddInput(content, "DESCRIÇÃO DA FUNÇÃO DO PARÂMETRO", 20, 245, 780, 28);
|
|
}
|
|
|
|
// --- MÉTODOS OBRIGATÓRIOS DO FORMULÁRIO MODELO ---
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
// Limpa todos os controles de texto dentro do content
|
|
foreach (Control c in content.Controls)
|
|
{
|
|
if (c is LV_TEXTBOX1 txt && !txt.ReadOnly)
|
|
{
|
|
txt.Text = string.Empty;
|
|
}
|
|
}
|
|
|
|
chkAtivo.Checked = true;
|
|
txtCodigo.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
// Mapeamento absoluto e fiel de cada campo para o objeto MLL
|
|
var parametro = new ModeloParametros
|
|
{
|
|
ID_PARAMETROS = string.IsNullOrEmpty(txtIdParametros.Text) ? 0 : Convert.ToInt32(txtIdParametros.Text),
|
|
CODIGO = txtCodigo.Text,
|
|
NOME_PAR = txtNomePar.Text,
|
|
DESCRICAO = txtDescricao.Text,
|
|
PX = txtPx.Text,
|
|
PY = txtPy.Text,
|
|
CAMPO = txtCampo.Text,
|
|
ATIVO = chkAtivo.Checked ? "S" : "N" // Conversão limpa para persistência string do seu banco
|
|
};
|
|
|
|
// Envio direto do objeto populado para as suas camadas de persistência (BLL/DAL)
|
|
MessageBox.Show("Configuração de parâmetro salva com sucesso!", "LevelOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
|
|
protected override void OnAlterar()
|
|
{
|
|
txtNomePar.Focus();
|
|
}
|
|
|
|
protected override void OnExcluir()
|
|
{
|
|
if (MessageBox.Show("Deseja realmente excluir este parâmetro? Isso pode afetar o layout de telas ou relatórios.", "LevelOS", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
|
|
{
|
|
// Processa a exclusão...
|
|
OnNovo();
|
|
}
|
|
}
|
|
|
|
protected override void OnLocalizar()
|
|
{
|
|
// Vincula a abertura da sua Grid de pesquisa de parâmetros
|
|
}
|
|
|
|
protected override void OnCancelar()
|
|
{
|
|
OnNovo();
|
|
}
|
|
}
|
|
} |