Exemple #1
0
        private clsPrestito acquisisciDati()
        {
            clsPrestito p = new clsPrestito("Biblioteca.mdf");

            p.dataPrestito = Convert.ToDateTime(dtpPrestito.Value);
            p.codLettore   = Convert.ToInt32(cmbLettore.SelectedValue);
            p.codLibro     = Convert.ToInt32(cmbLibro.SelectedValue);
            p.codice       = Convert.ToInt32(lblCodice.Text.Substring(8));

            if (chkRestituito.Checked == true)
            {
                p.dataRest = dtpRestituzione.Value;
            }

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

            return(p);
        }
Exemple #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();
        }
Exemple #3
0
        private void cmbPrestiti_SelectedIndexChanged(object sender, EventArgs e)
        {
            //MessageBox.Show(tabellaPrestiti.Rows.ToString());
            if (selezionaPrestito && cmbPrestiti.SelectedIndex != -1 && cmbPrestiti.ValueMember != "")
            {
                grpElenco.Enabled   = false;
                grpGestione.Enabled = true;

                selezionaLibro = true;

                btnConferma.Text = "Modifica";

                chkAnnullaValditita.Enabled = true;

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


                p.codice = Convert.ToInt32(cmbPrestiti.SelectedValue);
                p.getDati();

                caricaComboBox('k');

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

                dtpPrestito.Value        = p.dataPrestito;
                cmbLettore.SelectedValue = p.codLettore;
                cmbLibro.SelectedValue   = p.codLibro;
                lblCodice.Text           = "Codice: " + p.codice;

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

                l.codice = p.codLibro;
                l.getDati();
                pctCopertina.ImageLocation = @"IMG\\" + l.immagine;

                l.dispose();

                if (p.dataRest != DateTime.MinValue)
                {
                    dtpRestituzione.Value   = p.dataRest;
                    chkRestituito.Checked   = true;
                    dtpRestituzione.Enabled = true;
                }
                else
                {
                    chkRestituito.Checked = false;
                    chkRestituito.Enabled = true;
                }
                p.dispose();
            }
        }
Exemple #4
0
        private void elencoPrestiti(char from)
        {
            clsPrestito p = new clsPrestito("Biblioteca.mdf");



            if (from == 'L')
            {
                if (chkSoloNonRestituiti.Checked == true)
                {
                    tabellaPrestiti = p.lista(' ', true, Convert.ToInt32(cmbGenere.SelectedIndex + 1));
                }
                else
                {
                    tabellaPrestiti = p.lista(' ', false, Convert.ToInt32(cmbGenere.SelectedIndex + 1));
                }
            }
            else
            {
                if (chkAggiungiAnnullati.Checked == true)
                {
                    if (chkSoloNonRestituiti.Checked == true)
                    {
                        tabellaPrestiti = p.lista('A', true, Convert.ToInt32(cmbGenere.SelectedIndex + 1));
                    }
                    else
                    {
                        tabellaPrestiti = p.lista('A', false, Convert.ToInt32(cmbGenere.SelectedIndex + 1));
                    }
                }
                else if (chkSoloNonRestituiti.Checked == true)
                {
                    tabellaPrestiti = p.lista(' ', true, Convert.ToInt32(cmbGenere.SelectedIndex + 1));
                }
                else
                {
                    tabellaPrestiti = p.lista(' ', false, Convert.ToInt32(cmbGenere.SelectedIndex + 1));
                }
            }

            p.dispose();

            dgvElenco.DataSource = tabellaPrestiti;

            cmbPrestiti.DataSource    = tabellaPrestiti;
            cmbPrestiti.ValueMember   = "CodPrestito";
            cmbPrestiti.SelectedIndex = -1;

            annulla();
        }
Exemple #5
0
        private void btnConferma_Click_1(object sender, EventArgs e)
        {
            if (controllo())
            {
                clsPrestito p = acquisisciDati();
                clsLibro    l = new clsLibro("Biblioteca.mdf");
                l.codice = Convert.ToInt32(cmbLibro.SelectedValue);
                if (btnConferma.Text == "Aggiungi")
                {
                    if (p.aggiungi())
                    {
                        l.aggiornaPrestito('P');
                        selezionaPrestito = false;
                        elencoPrestiti('L');
                        selezionaPrestito = false;
                    }
                }
                else
                {
                    if (p.modifica())
                    {
                        if (chkRestituito.Checked == true)
                        {
                            l.aggiornaPrestito(' ');
                        }
                        else
                        {
                            l.aggiornaPrestito('P');
                        }

                        selezionaPrestito = false;
                        elencoPrestiti('K');
                        selezionaPrestito = false;
                    }
                }

                p.dispose();
                l.dispose();
                annulla();
                prestitiRecenti();
            }
        }
Exemple #6
0
        private void cmbPrestatiNONVISIBILE_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbPrestatiNONVISIBILE.SelectedIndex != -1 && !firstRun)
            {
                clsLibro libro = new clsLibro("Biblioteca.mdf");

                libro.codice = Convert.ToInt32(cmbPrestatiNONVISIBILE.SelectedValue);

                libro.getDati();

                lblAutore.Text = libro.autore;
                lblGenere.Text = libro.codGenere.ToString();
                lblTitolo.Text = libro.titolo;

                clsGenere g = new clsGenere("Biblioteca.mdf");

                g.codice = libro.codGenere;
                g.getDati();
                lblGenere.Text = g.nome;

                g.dispose();

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

                p.codLibro = libro.codice;
                p.getPrestitoFromLibro();
                lblDataPrestito.Text = p.dataPrestito.ToShortDateString();

                p.dispose();


                ptbCopertina.ImageLocation = @"IMG\\" + libro.immagine;

                libro.dispose();
            }
        }