static void Main(string[] args) { string pathTemporaneo = @"c:\temp\piombo\"; string filename = @"C:\VSProgetti\CDCMetal\CDCMetal\CDCMetal\Resources\logo_tf_autodichiarazione.png"; Bitmap firma = (Bitmap)Bitmap.FromFile(filename); // Bitmap firma = Properties.Resources.logo_tf_autodichiarazione; ImageConverter converter = new ImageConverter(); byte[] image = (byte[])converter.ConvertTo(firma, typeof(byte[])); CDCBLL bll = new CDCBLL(); CDCDS ds = new CDCDS(); bll.FillCDC_CERTIFICATIPIOMBO(ds); StringBuilder files = new StringBuilder(); foreach (CDCDS.CDC_CERTIFICATIPIOMBORow riga in ds.CDC_CERTIFICATIPIOMBO) { decimal nPd = riga.PBPPM; Color colore; bll.CalcolaEsitoAnalisiPiombo(nPd, out colore); string spessore = string.Empty; string lunghezza = string.Empty; string larghezza = string.Empty; string elemento = string.Empty; if (!riga.IsELEMENTONull()) { elemento = riga.ELEMENTO.ToString(); } if (!riga.IsLUNGHEZZANull()) { lunghezza = riga.LUNGHEZZA.ToString(); } if (!riga.IsLARGHEZZANull()) { larghezza = riga.LARGHEZZA.ToString(); } if (!riga.IsSPESSORENull()) { spessore = riga.SPESSORE.ToString(); } string path = bll.CreaPDFCertificatoPiombo(elemento, lunghezza, larghezza, spessore.ToString(), riga.CODICE, riga.LOTTO, riga.ESITO, colore, riga.METODO, riga.DATACERTIFICATO, riga.PBPPM, riga.CDPPM, pathTemporaneo, image); files.AppendLine(path); } }
private void btnCreaPdf_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; foreach (CDCDS.CDC_CERTIFICATIPIOMBORow riga in _DS.CDC_CERTIFICATIPIOMBO) { if (string.IsNullOrEmpty(riga.LOTTO)) { MessageBox.Show("La colonna LOTTO deve essere valorizzata", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Bitmap firma = Properties.Resources.logo_tf_autodichiarazione; ImageConverter converter = new ImageConverter(); byte[] image = (byte[])converter.ConvertTo(firma, typeof(byte[])); CDCBLL bll = new CDCBLL(); StringBuilder files = new StringBuilder(); foreach (CDCDS.CDC_CERTIFICATIPIOMBORow riga in _DS.CDC_CERTIFICATIPIOMBO) { decimal nPd = riga.PBPPM; Color colore; bll.CalcolaEsitoAnalisiPiombo(nPd, out colore); string spessore = string.Empty; string lunghezza = string.Empty; string larghezza = string.Empty; string elemento = string.Empty; if (!riga.IsELEMENTONull()) { elemento = riga.ELEMENTO.ToString(); } if (!riga.IsLUNGHEZZANull()) { lunghezza = riga.LUNGHEZZA.ToString(); } if (!riga.IsLARGHEZZANull()) { larghezza = riga.LARGHEZZA.ToString(); } if (!riga.IsSPESSORENull()) { spessore = riga.SPESSORE.ToString(); } string path = bll.CreaPDFCertificatoPiombo(elemento, lunghezza, larghezza, spessore.ToString(), riga.CODICE, riga.LOTTO, riga.ESITO, colore, riga.METODO, riga.DATACERTIFICATO, riga.PBPPM, riga.CDPPM, Contesto.PathAnalisiPiombo, image); files.AppendLine(path); riga.PATHFILE = path.Length > 300 ? path.Substring(0, 300) : path; } //List<CDCDS.CDC_CERTIFICATIPIOMBORow> certificati = _DS.CDC_CERTIFICATIPIOMBO.Where(x => x.IsLUNGHEZZANull()).ToList(); //foreach (CDCDS.CDC_CERTIFICATIPIOMBORow certificato in certificati) // certificato.Delete(); bll.SalvaCertificatiPiombo(_DS); MessageBox.Show("Operazionbe eseguita con successo", "INFORMAZIONE", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MainForm.LogScriviErrore("ERRORE IN CREA PDF", ex); ExceptionFrm frm = new ExceptionFrm(ex); frm.ShowDialog(); } finally { Cursor.Current = Cursors.Default; } }
private void btnCreaPDF_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); bool esito = true; if (ddlElemento.SelectedIndex == -1) { esito = false; sb.AppendLine("Indicare l'elemento da analizzare"); } if (string.IsNullOrEmpty(txtCodice.Text)) { esito = false; sb.AppendLine("Indicare il codice campione"); } if (ddlMateriale.SelectedIndex == -1) { esito = false; sb.AppendLine("Indicare il materiale"); } if (string.IsNullOrEmpty(txtLotto.Text)) { esito = false; sb.AppendLine("Indicare il lotto"); } if (nLunghezza.Value == 0) { esito = false; sb.AppendLine("Indicare la lunghezza"); } if (ddlElemento.SelectedItem as string == barraTonda && nLarghezza.Value == 0) { esito = false; sb.AppendLine("Indicare il diametro"); } if (ddlElemento.SelectedItem as string != barraTonda && nLarghezza.Value == 0) { esito = false; sb.AppendLine("Indicare la larghezza"); } if (ddlElemento.SelectedItem as string != barraTonda && nSpessore.Value == 0) { esito = false; sb.AppendLine("Indicare lo spessore"); } try { SalvaCertificatoPiombo(); Bitmap firma = Properties.Resources.logo_tf_autodichiarazione; ImageConverter converter = new ImageConverter(); byte[] image = (byte[])converter.ConvertTo(firma, typeof(byte[])); CDCBLL bll = new CDCBLL(); string path = bll.CreaPDFCertificatoPiombo(ddlElemento.SelectedItem as string, nLunghezza.Value.ToString(), nLarghezza.Value.ToString(), nSpessore.Value.ToString(), txtCodice.Text, txtLotto.Text, txtEsito.Text, txtEsito.BackColor, txtMetodo.Text, dtDataCertificato.Value, nPd.Value, nCd.Value, Contesto.PathAnalisiPiombo, image); string messaggio = string.Format("Il file {0} è stato creato", path); MessageBox.Show(messaggio, "ATTENZIONE", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MainForm.LogScriviErrore("ERRORE IN CREA PDF", ex); ExceptionFrm frm = new ExceptionFrm(ex); frm.ShowDialog(); } }