private void btnCreaPDF_Click(object sender, EventArgs e) { string filename = string.Empty; string brand = ((DataCollaudo)ddlDataCollaudo.SelectedItem).Brand; try { Cursor.Current = Cursors.WaitCursor; lblMessaggio.Text = string.Empty; if (_dsServizio.Tables[tblAggregati].Rows.Count == 0) { lblMessaggio.Text = "Creare i campioni per la misura"; return; } if (_dettaglio == null) { lblMessaggio.Text = "Selezionare un collaudo"; return; } if (string.IsNullOrEmpty(txtApplicazione.Text) && CDCBrands.Gucci == brand) { lblMessaggio.Text = "Il campo applicazione è vuoto impossibile procedere"; return; } if (string.IsNullOrEmpty(txtSpessoreRichiesto.Text) && CDCBrands.Gucci == brand) { lblMessaggio.Text = "Il campo spessore richiesto è vuoto impossibile procedere"; return; } decimal IDDETTAGLIO = _dettaglio.IDDETTAGLIO; CDCDS.CDC_SPESSORERow spessore = _DS.CDC_SPESSORE.Where(x => x.RowState != DataRowState.Deleted && x.PARTE == _dettaglio.PARTE && x.COLORE == _dettaglio.COLORE && x.SEQUENZA == 0).FirstOrDefault(); if (spessore == null) { lblMessaggio.Text = "Impossibile individuare lo spessore richiesto. Impossibile procedere"; return; } if (spessore.DENOMINATORE == 0) { lblMessaggio.Text = "Denominatore a zero. Impossibile procedere"; return; } if (nMisurePerCampione.Value == 0) { lblMessaggio.Text = "Numero misure per campioni non può essere zero"; return; } CDCBLL bll = new CDCBLL(); int misurePerCampione = (int)nMisurePerCampione.Value; CDCDS.CDC_APPLICAZIONERow applicazioneRow = _DS.CDC_APPLICAZIONE.Where(x => x.PARTE == _dettaglio.PARTE && x.COLORE == _dettaglio.COLORE).FirstOrDefault(); if (applicazioneRow == null) { applicazioneRow = _DS.CDC_APPLICAZIONE.NewCDC_APPLICAZIONERow(); applicazioneRow.PARTE = _dettaglio.PARTE; applicazioneRow.COLORE = _dettaglio.COLORE; applicazioneRow.APPLICAZIONE = txtApplicazione.Text; applicazioneRow.NUMEROCAMPIONI = nMisurePerCampione.Value; applicazioneRow.SPESSORE = txtSpessoreRichiesto.Text; applicazioneRow.CERTIFICATO = tipoCertificato; _DS.CDC_APPLICAZIONE.AddCDC_APPLICAZIONERow(applicazioneRow); } else { applicazioneRow.APPLICAZIONE = txtApplicazione.Text; applicazioneRow.NUMEROCAMPIONI = nMisurePerCampione.Value; applicazioneRow.SPESSORE = txtSpessoreRichiesto.Text; } decimal IDGALVANICA = bll.InserisciCDCGalvanica(_DS, txtSpessoreRichiesto.Text, IDDETTAGLIO, txtApplicazione.Text, Contesto.StrumentoSpessore, misurePerCampione, Contesto.Utente.FULLNAMEUSER, tipoCertificato); List <CDCDS.CDC_MISURERow> idMisuraDaCancellare = _DS.CDC_MISURE.Where(x => x.RowState != DataRowState.Deleted && x.IDGALVANICA == IDGALVANICA).ToList(); foreach (CDCDS.CDC_MISURERow misura in idMisuraDaCancellare) { misura.Delete(); } foreach (DataRow riga in _dsServizio.Tables[tblMisure].Rows) { for (int j = 0; j < _dsServizio.Tables[tblMisure].Columns.Count - 3; j++) { CDCDS.CDC_MISURERow misura = _DS.CDC_MISURE.NewCDC_MISURERow(); int nMisura = (int)riga[2]; misura.NMISURA = nMisura; misura.DATAMISURA = DateTime.Today; misura.IDGALVANICA = IDGALVANICA; string tipo = _dsServizio.Tables[tblMisure].Columns[j + 3].ColumnName; string valore = (riga[3 + j]).ToString(); misura.NCOLONNA = j; misura.TIPOMISURA = tipo; misura.VALORE = valore; _DS.CDC_MISURE.AddCDC_MISURERow(misura); } } bll.SalvaTabelleSpessori(_DS); _DS.AcceptChanges(); Bitmap logoSpessori = Properties.Resources.logo_spessori_v2; ImageConverter converter = new ImageConverter(); byte[] iLogo = (byte[])converter.ConvertTo(logoSpessori, typeof(byte[])); Bitmap bowman = Properties.Resources.Bowman; converter = new ImageConverter(); byte[] iBowman = (byte[])converter.ConvertTo(bowman, typeof(byte[])); List <string> medie = new List <string>(); List <string> Std = new List <string>(); List <string> Pct = new List <string>(); List <string> range = new List <string>(); List <string> minimo = new List <string>(); List <string> massimo = new List <string>(); DataRow rigaMedie = _dsServizio.Tables[tblAggregati].Rows[0]; DataRow rigaStd = _dsServizio.Tables[tblAggregati].Rows[1]; DataRow rigaPct = _dsServizio.Tables[tblAggregati].Rows[2]; DataRow rigarange = _dsServizio.Tables[tblAggregati].Rows[3]; DataRow rigaMinimo = _dsServizio.Tables[tblAggregati].Rows[4]; DataRow rigaMassimo = _dsServizio.Tables[tblAggregati].Rows[5]; for (int ncol = 0; ncol < _dsServizio.Tables[tblAggregati].Columns.Count; ncol++) { medie.Add(rigaMedie[ncol].ToString()); Std.Add(rigaStd[ncol].ToString()); Pct.Add(rigaPct[ncol].ToString()); range.Add(rigarange[ncol].ToString()); minimo.Add(rigaMinimo[ncol].ToString()); massimo.Add(rigaMassimo[ncol].ToString()); } filename = bll.CreaPDFSpessore(IDDETTAGLIO, tipoCertificato, _DS, Contesto.PathCollaudo, iLogo, iBowman, chkCopiaReferto.Checked, Contesto.GetPathRefertiLaboratorio(brand), medie, Std, Pct, range, minimo, massimo, brand, txtNumeroCampioni.Text); if (chkApriPDF.Checked) { Process.Start(filename); } evidenziaPDFFatti(); } catch (Exception ex) { MostraEccezione(ex, "Errore in crea PDF"); } finally { Cursor.Current = Cursors.Default; } }