Beispiel #1
0
        private void btnKlaar_Click(object sender, EventArgs e)
        {
            List <string> input        = new List <string>();
            string        eigenschapId = null;
            string        id           = null;

            input.Add(txtIsbnNummer.Text);
            input.Add(txtTitel.Text);
            input.Add(txtAuteur.Text);
            input.Add(txtGenre.Text);
            input.Add(txtPrijs.Text);
            input.Add(txtBeschrijving.Text);

            if (is_edit)
            {
                eigenschapId = "isbn_nummer";
                id           = Convert.ToString(boek.isbn_nummer);
            }

            if (!Validatie.is_null(input))
            {
                if (Validatie.is_isbn_nummer(txtIsbnNummer.Text))
                {
                    if (Validatie.is_uniek(txtIsbnNummer.Text, "Boek", "isbn_nummer", eigenschapId, id))
                    {
                        if (Validatie.is_prijs(txtPrijs.Text))
                        {
                            if (Validatie.is_int(txtVoorraad.Text))
                            {
                                boek.isbn_nummer  = txtIsbnNummer.Text;
                                boek.titel        = txtTitel.Text;
                                boek.auteur       = txtAuteur.Text;
                                boek.genre        = txtGenre.Text;
                                boek.prijs        = Convert.ToDecimal(txtPrijs.Text);
                                boek.beschrijving = txtBeschrijving.Text;

                                boekvoorraad.aantal           = Convert.ToInt32(txtVoorraad.Text);
                                boekvoorraad.boek_isbn_nummer = boek.isbn_nummer;

                                if (is_edit)
                                {
                                    BoekDb.wijzigen(boek, boekvoorraad);
                                    submain.vulDgOverzicht();
                                    submain.dgvOverzicht.Rows[submain.selectierow].Selected = true;
                                    submain.dgvOverzichtClick(is_edit);

                                    Logging logging = new Logging();
                                    logging.onderwerp        = "Boek";
                                    logging.handeling        = "Gewijzigd";
                                    logging.datum            = DateTime.Now;
                                    logging.medewerker_id    = Account.getMedewerker().id;
                                    logging.boek_isbn_nummer = boek.isbn_nummer;

                                    LoggingDb.aanmaken(logging);
                                }
                                else
                                {
                                    boek.uitgeversector_naam = uitgever.naam;
                                    BoekDb.aanmaken(boek, boekvoorraad);
                                    submain.vulDgOverzicht();
                                    submain.dgvOverzicht.Rows[0].Selected = true;
                                    submain.dgvOverzichtClick();

                                    Logging logging = new Logging();
                                    logging.onderwerp        = "Boek";
                                    logging.handeling        = "Aangemaakt";
                                    logging.datum            = DateTime.Now;
                                    logging.medewerker_id    = Account.getMedewerker().id;
                                    logging.boek_isbn_nummer = boek.isbn_nummer;

                                    LoggingDb.aanmaken(logging);
                                }
                            }
                            else
                            {
                                Validatie.is_error("int", lblError, "Voorraad");
                            }
                        }
                        else
                        {
                            Validatie.is_error("prijs", lblError);
                        }
                    }
                    else
                    {
                        Validatie.is_error("uniek", lblError, "Isbn-nummer");
                    }
                }
                else
                {
                    Validatie.is_error("isbn", lblError);
                }
            }
            else
            {
                Validatie.is_error("null", lblError);
            }
        }
Beispiel #2
0
        //methode om bestelling aan te maken :
        private void bestellen()
        {
            Cursor.Current         = Cursors.WaitCursor;
            bestelling.besteldatum = datum;
            bestelling.klant_id    = klant.id;

            string strDatum     = "";
            string omschrijving = "";
            string aantal       = "";
            string prijs        = "";
            string totaalPrijs  = "";

            foreach (DataGridViewRow row in dgvBoeken.Rows)
            {
                DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)dgvBoeken.Rows[row.Index].Cells[1];

                if ((bool)checkbox.EditedFormattedValue)
                {
                    strDatum     += datum.AddDays(3).ToString("dd/MM/yyyy") + "\v";
                    omschrijving += row.Cells[4].Value + "\v";
                    aantal       += row.Cells[0].Value + "\v";
                    totaalPrijs  += row.Cells[2].Value + "\v";
                    prijs        += "€" + row.Cells[7].Value + "\v";
                }
            }

            BestellingDb.aanmaken(bestelling);

            bestelling.id = BestellingDb.GetLaatsteBestelling();

            Factuur factuur = new Factuur();

            bestelling.factuur = factuur.aanmaken(klant, BedrijfsinformatieDb.ophalen(), bestelling, strDatum, omschrijving, aantal, prijs, totaalPrijs, lblPrijs.Text);

            BestellingDb.wijzigen(bestelling);

            foreach (DataGridViewRow row in dgvBoeken.Rows)
            {
                DataGridViewCheckBoxCell checkbox = (DataGridViewCheckBoxCell)dgvBoeken.Rows[row.Index].Cells[1];

                if ((bool)checkbox.EditedFormattedValue)
                {
                    bestellingregel.bestelling_id    = bestelling.id;
                    bestellingregel.boek_isbn_nummer = Convert.ToString(row.Cells[3].Value);
                    bestellingregel.aantal           = Convert.ToInt32(row.Cells[0].Value);
                    BestellingregelDB.aanmaken(bestellingregel);

                    Boekvoorraad voorraad = new Boekvoorraad();
                    voorraad.boek_isbn_nummer = bestellingregel.boek_isbn_nummer;

                    if (bestellingregel.aantal > Convert.ToInt32(row.Cells[6].Value))
                    {
                        voorraad.aantal = 0;
                    }
                    else
                    {
                        voorraad.aantal = Convert.ToInt32(row.Cells[6].Value) - bestellingregel.aantal;
                    }
                    BoekvoorraadDb.wijzigen(voorraad);
                }
            }

            Mail mail = new Mail();

            mail.mailAanmaken(klant, bestelling, bestelling.factuur);

            submain.vulDgOverzicht();
            submain.dgvOverzicht.Rows[0].Selected = true;
            submain.dgvOverzichtClick();

            Logging logging = new Logging();

            logging.onderwerp        = "Bestelling";
            logging.handeling        = "Aangemaakt";
            logging.datum            = DateTime.Now;
            logging.medewerker_id    = Account.getMedewerker().id;
            logging.bestelling_id    = bestelling.id;
            logging.boek_isbn_nummer = "";

            LoggingDb.aanmaken(logging);
        }