using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class ItensVendaCadastroPanel : FormularioModelo { private ModeloItensVenda _itemVenda = new ModeloItensVenda(); // Controles - Vínculos e Identificação private LV_TEXTBOX1 txtId, txtCodigo, txtItemCodigo, txtBarcode, txtDescricao; private Button btnBuscaItem; // Controles - Comercial (Valores e Lucro) private LV_TEXTBOX1 txtQtd, txtVlrUn, txtDesconto, txtVlrTotal, txtVendaTabela, txtCusto; // Controles - Rastreabilidade e Fiscal private LV_TEXTBOX1 txtSeriais, txtLotes, txtXped, txtNitemped, txtInfAdic; // Auxiliares private LV_TEXTBOX1 txtUn, txtServico, txtDia; public ItensVendaCadastroPanel() { this.Titulo = "Detalhamento do Item da Venda"; MontarInterface(); } private void MontarInterface() { // --- SEÇÃO 1: Dados do Produto --- content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO DO ITEM", 20)); txtId = AddInput(content, "ID", 20, 50, 70, 30, true); txtCodigo = AddInput(content, "CÓD. VENDA", 100, 50, 100, 30); txtItemCodigo = AddInput(content, "CÓD. ITEM", 210, 50, 100, 30); btnBuscaItem = CriarBotaoLupa(315, 66, OnBuscaItem); txtBarcode = AddInput(content, "BARCODE", 355, 50, 160, 30); txtDescricao = AddInput(content, "DESCRIÇÃO DO ITEM", 20, 105, 495, 30); txtUn = AddInput(content, "UN", 525, 105, 60, 30); txtServico = AddInput(content, "S/P", 595, 105, 60, 30); // Serviço ou Produto // --- SEÇÃO 2: Financeiro e Precificação --- content.Controls.Add(CreateSectionHeader("VALORES E NEGOCIAÇÃO", 175)); txtCusto = AddInput(content, "CUSTO UNIT. (REF)", 20, 205, 130, 30, true); txtVendaTabela = AddInput(content, "PREÇO TABELA", 160, 205, 130, 30, true); txtQtd = AddInput(content, "QUANTIDADE", 300, 205, 100, 30); txtVlrUn = AddInput(content, "PREÇO PRATICADO", 410, 205, 130, 30); txtVlrUn.BackColor = Color.LightCyan; txtDesconto = AddInput(content, "DESCONTO UNIT.", 550, 205, 105, 30); txtVlrTotal = AddInput(content, "TOTAL LÍQUIDO", 665, 205, 170, 30, true); txtVlrTotal.BackColor = Color.FromArgb(235, 255, 235); txtVlrTotal.Font = new Font("Segoe UI", 11, FontStyle.Bold); // --- SEÇÃO 3: Rastreabilidade (Seriais e Lotes) --- content.Controls.Add(CreateSectionHeader("CONTROLE DE ESTOQUE ESPECÍFICO", 275)); txtSeriais = AddInput(content, "NÚMEROS DE SÉRIE (GARANTIA)", 20, 305, 400, 40); txtLotes = AddInput(content, "IDENTIFICAÇÃO DE LOTES", 430, 305, 405, 40); // --- SEÇÃO 4: Dados Fiscais e Pedido Externo --- content.Controls.Add(CreateSectionHeader("REFERÊNCIAS FISCAIS (NF-e)", 375)); txtXped = AddInput(content, "PEDIDO COMPRA CLIENTE (xPed)", 20, 405, 200, 30); txtNitemped = AddInput(content, "ITEM DO PEDIDO (nItemPed)", 230, 405, 150, 30); txtDia = AddInput(content, "DIA", 390, 405, 60, 30); txtInfAdic = AddInput(content, "INFORMAÇÕES ADICIONAIS DO ITEM", 460, 405, 375, 40); content.Height = 480; } 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("Selecionar Item para Venda"); private void PreencherModel() { _itemVenda.CODIGO = txtCodigo.Text; _itemVenda.ITEM_CODIGO = txtItemCodigo.Text; _itemVenda.BARCODE = txtBarcode.Text; _itemVenda.DESCRICAO = txtDescricao.Text; _itemVenda.SERVICO = txtServico.Text; _itemVenda.QTD = txtQtd.Text; _itemVenda.VRL_UN = txtVlrUn.Text; _itemVenda.DESCONTO = txtDesconto.Text; _itemVenda.VLR_TOTAL = txtVlrTotal.Text; _itemVenda.UN = txtUn.Text; _itemVenda.VENDA = txtVendaTabela.Text; _itemVenda.DIA = txtDia.Text; _itemVenda.SERIAIS_IN = txtSeriais.Text; _itemVenda.XPED = txtXped.Text; _itemVenda.NITEMPED = txtNitemped.Text; _itemVenda.CUSTO = txtCusto.Text; _itemVenda.VINF_ADIC = txtInfAdic.Text; _itemVenda.LOTES = txtLotes.Text; } protected override void OnNovo() { _itemVenda = new ModeloItensVenda(); txtBarcode.Focus(); } protected override void OnSalvar() { try { PreencherModel(); MessageBox.Show("Item adicionado à venda!", "LevelOS PDV", 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(); } } }