135 lines
4.8 KiB
C#
135 lines
4.8 KiB
C#
using CPM;
|
|
using MLL;
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
using UI;
|
|
|
|
namespace UI
|
|
{
|
|
public partial class ItensOrcamentoCadastroPanel : FormularioModelo
|
|
{
|
|
private ModeloItensOrca _itemOrca = new ModeloItensOrca();
|
|
|
|
// Controles - Referências e Identificação
|
|
private LV_TEXTBOX1 txtId, txtCodigo, txtBarcode;
|
|
private Button btnBuscaItem;
|
|
|
|
// Controles - Descrição e Tipo
|
|
private LV_TEXTBOX1 txtDescricao, txtUn, txtServico;
|
|
|
|
// Controles - Valores e Negociação
|
|
private LV_TEXTBOX1 txtQtd, txtVlrUn, txtVendaOriginal, txtDesconto, txtVlrTotal;
|
|
|
|
public ItensOrcamentoCadastroPanel()
|
|
{
|
|
this.Titulo = "Item do Orçamento / Cotação";
|
|
MontarInterface();
|
|
}
|
|
|
|
private void MontarInterface()
|
|
{
|
|
// --- SEÇÃO 1: Identificação do Item ---
|
|
content.Controls.Add(CreateSectionHeader("REFERÊNCIA DO ITEM", 20));
|
|
|
|
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
|
|
txtCodigo = AddInput(content, "CÓD. ORÇAMENTO", 100, 50, 130, 30);
|
|
txtBarcode = AddInput(content, "BARRAS / GTIN", 240, 50, 180, 30);
|
|
|
|
btnBuscaItem = CriarBotaoLupa(425, 66, OnBuscaItem);
|
|
|
|
// --- SEÇÃO 2: Detalhes do Produto/Serviço ---
|
|
content.Controls.Add(CreateSectionHeader("DESCRIÇÃO E CLASSIFICAÇÃO", 115));
|
|
|
|
txtDescricao = AddInput(content, "DESCRIÇÃO DO ITEM NO ORÇAMENTO", 20, 145, 500, 30);
|
|
txtUn = AddInput(content, "UN", 530, 145, 60, 30);
|
|
txtServico = AddInput(content, "TIPO/SERVIÇO", 600, 145, 215, 30);
|
|
|
|
// --- SEÇÃO 3: Comercial e Negociação ---
|
|
content.Controls.Add(CreateSectionHeader("CÁLCULO DE VALORES", 210));
|
|
|
|
txtQtd = AddInput(content, "QUANTIDADE", 20, 240, 120, 30);
|
|
txtVendaOriginal = AddInput(content, "PREÇO TABELA (R$)", 150, 240, 140, 30, true); // Campo VENDA
|
|
|
|
txtVlrUn = AddInput(content, "PREÇO PRATICADO", 300, 240, 140, 30);
|
|
txtVlrUn.BackColor = Color.LightYellow;
|
|
|
|
txtDesconto = AddInput(content, "DESCONTO UNIT.", 450, 240, 130, 30);
|
|
|
|
txtVlrTotal = AddInput(content, "TOTAL DO ITEM", 590, 240, 225, 30, true);
|
|
txtVlrTotal.BackColor = Color.FromArgb(230, 245, 230); // Verde suave para o total
|
|
txtVlrTotal.Font = new Font("Segoe UI", 10, FontStyle.Bold);
|
|
|
|
// Informativo de rodapé
|
|
Label lblAviso = new Label
|
|
{
|
|
Text = "* Alterações nestes valores afetam apenas este orçamento específico.",
|
|
Location = new Point(20, 290),
|
|
AutoSize = true,
|
|
ForeColor = Color.DimGray,
|
|
Font = new Font("Segoe UI", 8, FontStyle.Italic)
|
|
};
|
|
content.Controls.Add(lblAviso);
|
|
|
|
content.Height = 350;
|
|
}
|
|
|
|
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/Serviços");
|
|
|
|
private void PreencherModel()
|
|
{
|
|
_itemOrca.CODIGO = txtCodigo.Text;
|
|
_itemOrca.BARCODE = txtBarcode.Text;
|
|
_itemOrca.DESCRICAO = txtDescricao.Text;
|
|
_itemOrca.SERVICO = txtServico.Text;
|
|
_itemOrca.QTD = txtQtd.Text;
|
|
_itemOrca.VRL_UN = txtVlrUn.Text;
|
|
_itemOrca.VENDA = txtVendaOriginal.Text;
|
|
_itemOrca.DESCONTO = txtDesconto.Text;
|
|
_itemOrca.VLR_TOTAL = txtVlrTotal.Text;
|
|
_itemOrca.UN = txtUn.Text;
|
|
}
|
|
|
|
protected override void OnNovo()
|
|
{
|
|
_itemOrca = new ModeloItensOrca();
|
|
txtBarcode.Focus();
|
|
}
|
|
|
|
protected override void OnSalvar()
|
|
{
|
|
try
|
|
{
|
|
PreencherModel();
|
|
MessageBox.Show("Item adicionado ao orçamento!", "LevelOS", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Erro: " + ex.Message);
|
|
}
|
|
}
|
|
|
|
protected override void OnAlterar() { }
|
|
protected override void OnExcluir() { }
|
|
protected override void OnLocalizar() { }
|
|
protected override void OnCancelar() { OnNovo(); }
|
|
}
|
|
} |