private void btnCreaPDF_Click(object sender, EventArgs e) { string fileCreati = string.Empty; try { Cursor.Current = Cursors.WaitCursor; bool esito = true; lblMessaggio.Text = ""; foreach (DataRow riga in _dsServizio.Tables[tableName].Rows) { if (riga["SEQUENZA"].ToString() != "") { bool aux1 = (bool)riga[14]; bool aux2 = (bool)riga[15]; if (aux1 == aux2) { esito = false; } } } if (!esito) { lblMessaggio.Text = "Impossibile creare i file. La condizione Antiallergico e Nichel Free sono mutuamente esclusive."; return; } List <decimal> idPerPDF = new List <decimal>(); foreach (DataRow riga in _dsServizio.Tables[tableName].Rows) { if (riga["SEQUENZA"].ToString() != "") { decimal idnichelfree = (decimal)riga[0]; if (idnichelfree == -1) { idnichelfree = -100; } // decimal iddettaglio = (decimal)riga[1]; int sequenza = (int)riga["SEQUENZA"]; if (!idPerPDF.Contains(iddettaglio)) { idPerPDF.Add(iddettaglio); } CDCDS.CDC_ANTIALLERGICORow antiallergicoRow = _DS.CDC_ANTIALLERGICO.Where(x => x.IDNICHELFREE == idnichelfree).FirstOrDefault(); if (antiallergicoRow == null) { antiallergicoRow = _DS.CDC_ANTIALLERGICO.NewCDC_ANTIALLERGICORow(); antiallergicoRow.IDDETTAGLIO = iddettaglio; antiallergicoRow.SEQUENZA = sequenza; antiallergicoRow.DESCRIZIONE = riga["DESCRIZIONE"].ToString(); antiallergicoRow.COLORECOMPONENTE = riga["COLORECOMPONENTE"].ToString(); antiallergicoRow.DATAPRODUZIONE = (DateTime)riga["DATAPRODUZIONE"]; // riga[9]; antiallergicoRow.UTENTE = Contesto.Utente.FULLNAMEUSER; antiallergicoRow.DATAINSERIMENTO = DateTime.Now; antiallergicoRow.NICHELFREE = ConvertiBoolInStringa(riga[15]); _DS.CDC_ANTIALLERGICO.AddCDC_ANTIALLERGICORow(antiallergicoRow); } else { antiallergicoRow.IDDETTAGLIO = iddettaglio; antiallergicoRow.SEQUENZA = sequenza; antiallergicoRow.DESCRIZIONE = riga["DESCRIZIONE"].ToString(); antiallergicoRow.COLORECOMPONENTE = riga["COLORECOMPONENTE"].ToString(); antiallergicoRow.DATAPRODUZIONE = (DateTime)riga["DATAPRODUZIONE"]; // riga[9]; antiallergicoRow.UTENTE = Contesto.Utente.FULLNAMEUSER; antiallergicoRow.DATAINSERIMENTO = DateTime.Now; antiallergicoRow.NICHELFREE = ConvertiBoolInStringa(riga[15]); } } } CDCBLL bll = new CDCBLL(); bll.SalvaDatiAntiallergia(_DS); _DS.CDC_ANTIALLERGICO.AcceptChanges(); Bitmap firma = Properties.Resources.logo_tf_autodichiarazione; ImageConverter converter = new ImageConverter(); byte[] image = (byte[])converter.ConvertTo(firma, typeof(byte[])); //fileCreati = bll.CreaPDFAntiallergico(idPerPDF, _DS, Contesto.PathCollaudo, image, chkCopiaFileReferti.Checked, Contesto.GetPathRefertiLaboratorio(((DataCollaudo)ddlDataCollaudo.SelectedItem).Brand)); //fileCreati = bll.CreaPDFAntiallergico(idPerPDF, _DS, Contesto.PathCollaudo, image, chkCopiaFileReferti.Checked, Contesto.GetPathRefertiLaboratorio(ddlBrand.SelectedItem.ToString())); fileCreati = bll.CreaPDFAntiallergico(idPerPDF, _DS, Contesto.PathCollaudo, image, chkCopiaFileReferti.Checked, Contesto.GetPathRefertiLaboratorio(ddlBrand.SelectedItem.ToString())); btnLeggiDati_Click(null, null); } finally { Cursor.Current = Cursors.Default; } StringBuilder sb = new StringBuilder(); sb.AppendLine("Sono stati creati i seguenti file:"); sb.Append(fileCreati); MessageBox.Show(sb.ToString(), "FILE PDF CREATI", MessageBoxButtons.OK, MessageBoxIcon.Information); }