Example #1
0
        private void elencoLettori(char from)
        {
            clsLettore lett = new clsLettore("Biblioteca.mdf");

            if (from == 'L')
            {
                tabellaLettori = lett.lista(' ');
            }
            else if (chkAggiungiAnnullati.Checked == false)
            {
                tabellaLettori = lett.lista(' ');
            }
            else
            {
                tabellaLettori = lett.lista('A');
            }

            dgvElenco.DataSource     = tabellaLettori;
            cmbLettori.DataSource    = tabellaLettori;
            cmbLettori.ValueMember   = "CodLettore";
            cmbLettori.DisplayMember = "NomeLettore" + " CognomeLettore";
            annulla();



            lett.dispose();
        }
Example #2
0
        private void btnAggiungi_Click(object sender, EventArgs e)
        {
            grpElenco.Enabled   = false;
            grpGestione.Enabled = true;


            clsPrestito p = new clsPrestito("Biblioteca.mdf");

            lblCodice.Text = "Codice: " + (p.getNuovoCodice()).ToString();

            //caricaComboBox('L');

            clsLettore lett  = new clsLettore("Biblioteca.mdf");
            clsLibro   libro = new clsLibro("Biblioteca.mdf");

            libri   = libro.disponibili();
            lettori = lett.lista(' ');

            cmbLettore.DataSource    = lettori;
            cmbLettore.DisplayMember = "CognomeLettore";
            cmbLettore.ValueMember   = "CodLettore";
            cmbLettore.SelectedIndex = -1;


            cmbLibro.DataSource    = libri;
            cmbLibro.DisplayMember = "TitoloLibro";
            cmbLibro.ValueMember   = "CodLibro";
            cmbLibro.SelectedIndex = -1;

            selezionaLibro = true;

            libro.dispose();
            lett.dispose();
            p.dispose();
        }
Example #3
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;
            }
        }
Example #4
0
        private void btnConferma_Click(object sender, EventArgs e)
        {
            if (txtCognome.Text == string.Empty)
            {
                MessageBox.Show("Inserisci il cognome");
                txtCognome.Focus();
            }
            else if (txtNome.Text == string.Empty)
            {
                MessageBox.Show("Inserisci il nome");
                txtNome.Focus();
            }
            else if (txtMail.Text == string.Empty)
            {
                MessageBox.Show("Inserisci la mail");
                txtMail.Focus();
            }
            else if (!(txtMail.Text.Contains('@')))
            {
                MessageBox.Show("Inserisci la mail nel formato corretto");
                txtMail.Focus();
            }
            else if (txtTessera.Text == string.Empty)
            {
                MessageBox.Show("Inserisci il numero tessera");
                txtTessera.Focus();
            }
            else
            {
                clsLettore l = acquisciLettore();

                if (btnConferma.Text == "Aggiungi")
                {
                    l.aggiungi();
                    elencoLettori(' ');
                }
                else
                {
                    l.modifica();
                    if (chkAggiungiAnnullati.Checked == true)
                    {
                        elencoLettori('K');
                    }
                    else
                    {
                        elencoLettori('L');
                    }
                }


                l.dispose();
            }
        }
Example #5
0
        private void btnAggiungi_Click(object sender, EventArgs e)
        {
            grpGestione.Enabled = true;
            grpElenco.Enabled   = false;

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

            lblCodice.Text = "Codice: " + l.getNuovoCodice().ToString();
            //lblNTessera.Text = l.nuovaTessera();

            l.dispose();


            cmbLettori.SelectedIndex = -1;

            txtCognome.Focus();
        }
Example #6
0
        private void frmSchedaLibro_Load(object sender, EventArgs e)
        {
            selezionaLibro = false;
            elencoLibri('L');
            selezionaLibro = true;

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

            tabellaLettori = l.lista(' ');

            l.dispose();

            cmbLettori.DataSource    = tabellaLettori;
            cmbLettori.DisplayMember = "CognomeLettore";
            cmbLettori.ValueMember   = "CodLettore";
            cmbLettori.SelectedIndex = -1;
        }
Example #7
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);
        }
Example #8
0
        private clsLettore acquisciLettore()
        {
            clsLettore l = new clsLettore("Biblioteca.mdf");

            l.nTessera = lblNTessera.Text;
            l.codice   = Convert.ToInt32(lblCodice.Text.Substring(7));
            l.nome     = txtNome.Text;
            l.cognome  = txtCognome.Text;
            l.mail     = txtMail.Text;
            l.nTessera = "NT2020_" + txtTessera.Text;

            if (chkAnnullaValditita.Checked == true)
            {
                l.validita = 'A';
            }
            else
            {
                l.validita = ' ';
            }


            return(l);
        }
Example #9
0
        private void caricaComboBox(char from)
        {
            clsGenere g = new clsGenere("Biblioteca.mdf");

            generi = g.lista('A');

            cmbGenere.DataSource    = generi;
            cmbGenere.ValueMember   = "CodGenere";
            cmbGenere.DisplayMember = "NomeGenere";
            cmbGenere.SelectedIndex = -1;
            cmbGenere.Enabled       = false;

            g.dispose();

            clsLibro   libro = new clsLibro("Biblioteca.mdf");
            clsLettore lett  = new clsLettore("Biblioteca.mdf");



            libri   = libro.lista('A');
            lettori = lett.lista('A');

            cmbLibro.DataSource    = libri;
            cmbLibro.ValueMember   = "CodLibro";
            cmbLibro.DisplayMember = "TitoloLibro";
            cmbLibro.SelectedIndex = -1;

            cmbLettore.DataSource    = lettori;
            cmbLettore.ValueMember   = "CodLettore";
            cmbLettore.DisplayMember = "CognomeLettore";
            cmbLettore.SelectedIndex = -1;


            lett.dispose();
            libro.dispose();
        }
Example #10
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");
            }
        }