Beispiel #1
0
        private void cmbLettori_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbLettori.SelectedIndex != -1 && cmbLettori.ValueMember != "" && selezionaLettore)
            {
                clsLettore l = new clsLettore("Biblioteca.mdf");

                l.codice = Convert.ToInt32(cmbLettori.SelectedValue);
                l.getDati();

                txtNome.Text    = l.nome;
                txtTessera.Text = l.nTessera.Substring(7);
                txtCognome.Text = l.cognome;
                txtMail.Text    = l.mail;
                if (l.validita == 'A')
                {
                    chkAnnullaValditita.Checked = true;
                }

                lblCodice.Text = "Codice: " + l.codice.ToString();

                l.dispose();

                grpElenco.Enabled   = false;
                grpGestione.Enabled = true;
                btnConferma.Text    = "Modifica";

                chkAnnullaValditita.Enabled = true;
            }
        }
Beispiel #2
0
        private string creaStringa()
        {
            string s = string.Empty;

            clsLettore lettore = new clsLettore("Biblioteca.mdf");

            lettore.codice = Convert.ToInt32(cmbLettori.SelectedValue);
            lettore.getDati();

            s = "Scheda richiesta da: " + lettore.cognome + " " + lettore.nome + "\n";


            lettore.dispose();

            s += "Titolo: " + lblTitolo.Text +
                 "\nAutore: " + lblAutore.Text +
                 "\nGenere: " + lblGenere.Text;

            return(s);
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (cmbLettori.SelectedIndex != -1)
            {
                string dati = creaStringa();

                clsLettore l = new clsLettore("Biblioteca.mdf");

                l.codice = Convert.ToInt32(cmbLettori.SelectedValue);
                l.getDati();

                Percorso = System.Windows.Forms.Application.StartupPath;
                //MessageBox.Show(Percorso);
                FileDOC = Percorso + "/" + "PDF\\" + lblTitolo.Text + "_" + l.cognome + l.nome + ".docx";
                FilePDF = Percorso + "/" + "PDF\\" + lblTitolo.Text + "_" + l.cognome + l.nome + ".pdf";

                l.dispose();
                // Creo una NUOVA istanza di WORD Application
                myWord = new Microsoft.Office.Interop.Word.Application();

                // Rendo visibile la nuova Word Application
                //myWord.Visible = false;
                myWord.Visible = false;

                //Aggiungo un NUOVO Documento
                myDoc = new Document();
                myDoc = myWord.Documents.Add();

                start   = myDoc.Sentences[myDoc.Sentences.Count].End - 1;
                end     = myDoc.Sentences[myDoc.Sentences.Count].End;
                myRange = myDoc.Range(ref start, ref end);

                // Aggiungo il Testo
                myRange.Text = dati + "\n";

                myDoc.SaveAs2(FileDOC);

                // Chiudo il Documento
                myDoc.Close();

                // Chiudo il Word Application
                myWord.Quit();

                this.Cursor = Cursors.WaitCursor;

                myWord = new Microsoft.Office.Interop.Word.Application();

                myWord.Visible = false;

                myDoc = new Document();

                myDoc = myWord.Documents.Open(@FileDOC);

                myDoc.ExportAsFixedFormat(@FilePDF, WdExportFormat.wdExportFormatPDF);

                myDoc.Close();

                myWord.Quit();

                this.Cursor = Cursors.Default;

                MessageBox.Show("PDF creato con successo");

                File.Delete(@FileDOC);

                cmbLettori.SelectedIndex = -1;
                cmbLettori.SelectedIndex = -1;
            }
            else
            {
                MessageBox.Show("Seleziona il lettore");
            }
        }