104 lines
3.8 KiB
C#
104 lines
3.8 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class ServicosCadastroPanel : FormularioModelo
|
|
{
|
|
private ModeloServicos _servico = new ModeloServicos();
|
|
|
|
// Controles - Identificação
|
|
private LV_TEXTBOX1 txtId, txtEmpresaId, txtNome, txtDescricao;
|
|
|
|
// Controles - Financeiro e Comissão
|
|
private LV_TEXTBOX1 txtValorVenda, txtCusto, txtTipoComissao, txtValorComissao;
|
|
|
|
// Controles - Operacional
|
|
private LV_TEXTBOX1 txtTempoEstimado;
|
|
private CheckBox chkAtivo;
|
|
|
|
public ServicosCadastroPanel()
|
|
{
|
|
this.Titulo = "Cadastro de Serviços";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Definição do Serviço ---
|
|
content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO DO SERVIÇO", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
|
|
txtEmpresaId = AddInput(content, "ID EMPRESA", 100, 50, 80, 30);
|
|
txtNome = AddInput(content, "NOME DO SERVIÇO", 190, 50, 690, 30);
|
|
|
|
txtDescricao = AddInput(content, "DESCRIÇÃO DETALHADA / ESCOPO", 20, 105, 860, 50);
|
|
txtDescricao.Multiline = true;
|
|
|
|
// --- SEÇÃO 2: Financeiro e Precificação ---
|
|
content.Controls.Add(CreateSectionHeader("VALORES E CUSTOS", 175));
|
|
|
|
txtValorVenda = AddInput(content, "VALOR DE VENDA (R$)", 20, 205, 180, 30);
|
|
txtCusto = AddInput(content, "CUSTO ESTIMADO (R$)", 210, 205, 180, 30);
|
|
|
|
// --- SEÇÃO 3: Regras de Comissão e Tempo ---
|
|
content.Controls.Add(CreateSectionHeader("COMISSIONAMENTO E OPERAÇÃO", 270));
|
|
|
|
txtTipoComissao = AddInput(content, "TIPO COMISSÃO (FIXO/%)", 20, 300, 180, 30);
|
|
txtValorComissao = AddInput(content, "VALOR DA COMISSÃO", 210, 300, 180, 30);
|
|
|
|
txtTempoEstimado = AddInput(content, "TEMPO ESTIMADO (MIN)", 400, 300, 180, 30);
|
|
|
|
chkAtivo = CreateCheckBox("SERVIÇO ATIVO PARA VENDA", 600, 318);
|
|
content.Controls.Add(chkAtivo);
|
|
|
|
// Ajuste da altura do conteúdo (Serviços costumam ser telas mais curtas)
|
|
content.Height = 450;
|
|
}
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_servico.Nome = txtNome.Text;
|
|
_servico.Descricao = txtDescricao.Text;
|
|
_servico.TipoComissao = txtTipoComissao.Text;
|
|
_servico.Ativo = chkAtivo.Checked;
|
|
|
|
// Conversões Numéricas
|
|
if (int.TryParse(txtEmpresaId.Text, out int emp)) _servico.EmpresaId = emp;
|
|
if (int.TryParse(txtTempoEstimado.Text, out int tempo)) _servico.TempoEstimado = tempo;
|
|
|
|
if (decimal.TryParse(txtValorVenda.Text, out decimal valor)) _servico.ValorPadrao = valor;
|
|
if (decimal.TryParse(txtCusto.Text, out decimal custo)) _servico.Custo = custo;
|
|
if (decimal.TryParse(txtValorComissao.Text, out decimal comissao)) _servico.ValorComissao = comissao;
|
|
}
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_servico = new ModeloServicos();
|
|
txtNome.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
try
|
|
{
|
|
PreencherModel();
|
|
// BLLServicos.Salvar(_servico);
|
|
MessageBox.Show("Serviço cadastrado com sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Erro ao salvar serviço: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
protected override void OnAlterar() { }
|
|
protected override void OnExcluir() { }
|
|
protected override void OnLocalizar() { }
|
|
protected override void OnCancelar() { OnNovo(); }
|
|
}
|
|
} |