using CPM; using MLL; using System; using System.Drawing; using System.Windows.Forms; using UI; namespace UI { public partial class EsquemasTecnicosCadastroPanel : FormularioModelo { private ModeloEsquemas _esquema = new ModeloEsquemas(); // Controles - Identificação private LV_TEXTBOX1 txtId, txtCodigo, txtMarca, txtNome; // Controles - Localização do Arquivo private LV_TEXTBOX1 txtLocalFisico, txtCaminhoArquivo; private Button btnSelecionarArquivo; // Controles - Observações private LV_TEXTBOX1 txtObs; public EsquemasTecnicosCadastroPanel() { this.Titulo = "Biblioteca de Esquemas e Manuais"; MontarInterface(); } private void MontarInterface() { // --- SEÇÃO 1: Identificação Técnica --- content.Controls.Add(CreateSectionHeader("IDENTIFICAÇÃO DO ESQUEMA", 20)); txtId = AddInput(content, "ID", 20, 50, 70, 30, true); txtCodigo = AddInput(content, "CÓD. INTERNO", 100, 50, 110, 30); txtMarca = AddInput(content, "MARCA / FABRICANTE", 220, 50, 250, 30); txtNome = AddInput(content, "NOME DO DIAGRAMA / MODELO", 20, 105, 860, 30); // --- SEÇÃO 2: Localização (Digital e Física) --- content.Controls.Add(CreateSectionHeader("LOCALIZAÇÃO DO DOCUMENTO", 175)); // LOCAL: Pode ser "Gaveta 02", "Prateleira A", ou "Servidor Nuvem" txtLocalFisico = AddInput(content, "LOCALIZAÇÃO FÍSICA / ARQUIVAMENTO", 20, 205, 400, 30); // FPATH: Caminho do arquivo no PC ou Rede txtCaminhoArquivo = AddInput(content, "CAMINHO DO ARQUIVO DIGITAL (PDF/IMG)", 20, 260, 780, 30); btnSelecionarArquivo = new Button { Text = "📁", Location = new Point(810, 276), // Alinhado ao txtCaminhoArquivo Size = new Size(70, 30), BackColor = AccentBlue, ForeColor = Color.White, FlatStyle = FlatStyle.Flat, Cursor = Cursors.Hand }; btnSelecionarArquivo.FlatAppearance.BorderSize = 0; btnSelecionarArquivo.Click += OnSelecionarArquivo; content.Controls.Add(btnSelecionarArquivo); // --- SEÇÃO 3: Observações --- content.Controls.Add(CreateSectionHeader("OBSERVAÇÕES TÉCNICAS", 325)); txtObs = AddInput(content, "DETALHES ADICIONAIS", 20, 355, 860, 60); content.Height = 450; } private void OnSelecionarArquivo(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Filter = "Arquivos PDF|*.pdf|Imagens|*.jpg;*.png;*.bmp|Todos os Arquivos|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { txtCaminhoArquivo.Text = ofd.FileName; } } } private void PreencherModel() { _esquema.CODIGO = txtCodigo.Text; _esquema.MARCA = txtMarca.Text; _esquema.NOME = txtNome.Text; _esquema.LOCAL = txtLocalFisico.Text; _esquema.FPATH = txtCaminhoArquivo.Text; _esquema.OBS = txtObs.Text; } protected override void OnNovo() { _esquema = new ModeloEsquemas(); txtMarca.Focus(); } protected override void OnSalvar() { try { PreencherModel(); // BLL.Salvar(_esquema); MessageBox.Show("Esquema técnico registrado com sucesso!"); } catch (Exception ex) { MessageBox.Show("Erro ao salvar: " + ex.Message); } } protected override void OnAlterar() { } protected override void OnExcluir() { } protected override void OnLocalizar() { } protected override void OnCancelar() { OnNovo(); } } }