예제 #1
0
        private void btnCreaPDF_Click(object sender, EventArgs e)
        {
            string fileCreati = string.Empty;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                bool esito = true;
                lblMessaggio.Text = "";

                List <decimal> idPerPDF = new List <decimal>();
                foreach (DataRow riga in _dsServizio.Tables[tableName].Rows)
                {
                    decimal iddettaglio = (decimal)riga[0];
                    idPerPDF.Add(iddettaglio);
                    string fornitore = ConvertiInStringa(riga[11]);
                    fornitore = fornitore.Length > 25 ? fornitore.Substring(0, 25) : fornitore;

                    CDCDS.CDC_VERNICICOPRENTIRow vCoprenteRow = _DS.CDC_VERNICICOPRENTI.Where(x => x.IDDETTAGLIO == iddettaglio).FirstOrDefault();
                    if (vCoprenteRow == null)
                    {
                        vCoprenteRow                 = _DS.CDC_VERNICICOPRENTI.NewCDC_VERNICICOPRENTIRow();
                        vCoprenteRow.IDDETTAGLIO     = iddettaglio;
                        vCoprenteRow.UTENTE          = Contesto.Utente.FULLNAMEUSER;
                        vCoprenteRow.DATAINSERIMENTO = DateTime.Now;
                        vCoprenteRow.DATATEST        = (DateTime)riga[9];
                        vCoprenteRow.NUMEROCAMPIONI  = (Decimal)riga[10];
                        vCoprenteRow.FORNITORE       = fornitore;
                        vCoprenteRow.TURBULA         = ConvertiBoolInStringa(riga[12]);
                        vCoprenteRow.QUADRETTATURA   = ConvertiBoolInStringa(riga[13]);

                        _DS.CDC_VERNICICOPRENTI.AddCDC_VERNICICOPRENTIRow(vCoprenteRow);
                    }
                    else
                    {
                        vCoprenteRow.UTENTE          = Contesto.Utente.FULLNAMEUSER;
                        vCoprenteRow.DATAINSERIMENTO = DateTime.Now;
                        vCoprenteRow.DATATEST        = (DateTime)riga[9];
                        vCoprenteRow.NUMEROCAMPIONI  = (decimal)riga[10];
                        vCoprenteRow.FORNITORE       = fornitore;
                        vCoprenteRow.TURBULA         = ConvertiBoolInStringa(riga[12]);
                        vCoprenteRow.QUADRETTATURA   = ConvertiBoolInStringa(riga[13]);
                    }
                }

                CDCBLL bll = new CDCBLL();
                bll.SalvaDatiVerniciaturaCoprente(_DS);
                _DS.CDC_VERNICICOPRENTI.AcceptChanges();

                Bitmap         firma     = Properties.Resources.logo_spessori_v2;
                ImageConverter converter = new ImageConverter();
                byte[]         image     = (byte[])converter.ConvertTo(firma, typeof(byte[]));

                fileCreati = bll.CreaPDFVerniceCoprente(idPerPDF, _DS, Contesto.PathCollaudo, image, chkCopiaFileReferti.Checked, Contesto.GetPathRefertiLaboratorio(((DataCollaudo)ddlDataCollaudo.SelectedItem).Brand));
                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);
        }