From b77ec39c5be6ca511f8be89c31b437e88240e82c Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Thu, 17 Sep 2026 09:08:33 +0200 Subject: [PATCH] Add DB presence check button to import phase Lets the user spot missing components right after import instead of discovering it later in the raw-folder step, by coloring each grid row green/red based on a lookup against cad_index.db. Co-Authored-By: Claude Sonnet 5 --- CadSearchGui/Form1.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CadSearchGui/Form1.cs b/CadSearchGui/Form1.cs index 6f062f1..89011b3 100644 --- a/CadSearchGui/Form1.cs +++ b/CadSearchGui/Form1.cs @@ -10,6 +10,7 @@ public partial class Form1 : Form private readonly Button _btnCreaRaw = new(); private readonly Button _btnTrovaPrt = new(); private readonly Button _btnReport = new(); + private readonly Button _btnVerifica = new(); private readonly Button _btnCompletezza = new(); private readonly Button _btnPulisci = new(); private readonly Label _lblStatus = new(); @@ -261,6 +262,12 @@ public partial class Form1 : Form btnSfoglia.Click += (_, _) => ScegliFileDistinta(); contenuto.Controls.Add(btnSfoglia); + _btnVerifica.Text = "Verifica presenza nel DB"; + _btnVerifica.Size = new Size(220, 32); + _btnVerifica.Margin = new Padding(0, 0, 0, 8); + _btnVerifica.Click += (_, _) => VerificaCodiciNelDb(); + contenuto.Controls.Add(_btnVerifica); + _lblImportStatus.AutoSize = false; _lblImportStatus.AutoEllipsis = true; _lblImportStatus.Height = 24; @@ -488,6 +495,21 @@ public partial class Form1 : Form _tipImportStatus.SetToolTip(_lblImportStatus, testo); } + private void VerificaCodiciNelDb() + { + if (_righeCorrenti is null) + return; + + var trovati = TrovaPercorsiCad(_righeCorrenti.Select(r => r.Componente)); + foreach (DataGridViewRow riga in _gridImport.Rows) + { + string componente = (string)riga.Cells["componente"].Value!; + riga.DefaultCellStyle.BackColor = trovati.ContainsKey(componente) + ? Color.FromArgb(198, 239, 206) + : Color.FromArgb(255, 199, 206); + } + } + private void CreaCartellaRaw() { if (_percorsoInputCorrente is null || _righeCorrenti is null)