예제 #1
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);
        }
예제 #2
0
        //bestelling laten zien
        public BestelScherm(Overzicht_groot submain, Klant klant, Bestelling bestelling)
        {
            InitializeComponent();
            this.submain    = submain;
            this.bestelling = bestelling;
            this.klant      = klant;

            foreach (Control c in this.Controls)
            {
                if (c.GetType().FullName == "System.Windows.Forms.Label" && c.Name != "lblError" && c.Name != "lblGegStatusExtra" && c.Name != "lblZoek")
                {
                    c.Visible = true;
                }
            }

            btnKlaar.Visible   = false;
            btnFactuur.Visible = true;
            btnPrinten.Visible = true;

            lblGegBesteldatum.Text = bestelling.besteldatum.ToString().Substring(0, bestelling.besteldatum.ToString().Length - 3);
            lblGegLeverdatum.Text  = bestelling.leverdatum.ToString().Substring(0, bestelling.leverdatum.ToString().Length - 8);

            lblGegStatus.Text = bestelling.status.ToString();

            if (bestelling.status == "Boek is gedrukt.")
            {
                lblGegStatusExtra.Text    = "klik op het icoontje om de klant een mail te sturen";
                lblGegStatusExtra.Visible = true;
            }

            if (bestelling.status == "Wachten op klant.")
            {
                lblGegStatusExtra.Text    = "klik op het icoontje om de bevestiging te voltooien";
                lblGegStatusExtra.Visible = true;
            }


            checkStatus();

            bestellingregel.bestelling_id = bestelling.id;
            DataTable dt = new DataTable();


            dt = BestellingregelDB.overzicht(bestellingregel);

            foreach (DataRow drow in dt.Rows)
            {
                bestellingregel.boek_isbn_nummer = Convert.ToString(drow["boek_isbn_nummer"]);
                dt = BestellingregelDB.overzichtBestelling(bestellingregel);
            }

            BindingSource bindingSource = new BindingSource();

            bindingSource.DataSource = dt;
            dgvBoeken.DataSource     = bindingSource;

            dgvBoeken.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;

            if (dgvBoeken.SelectedRows.Count > 0)
            {
                dgvBoeken.Rows[0].Selected = false;
            }

            dgvBoeken.Columns["Toevoegen"].DisplayIndex = 0;
            dgvBoeken.Columns["Aantal"].DisplayIndex    = 1;
            dgvBoeken.Columns["Prijs"].DisplayIndex     = 2;

            dgvBoeken.Columns[1].Visible = false;
        }
예제 #3
0
        private void btnVerwijderen_Click(object sender, EventArgs e)
        {
            if (scherm == "Bestelscherm")
            {
                if (selectieId != "")
                {
                    foreach (DataGridViewRow Row in dgvOverzicht.SelectedRows)
                    {
                        bestelling.id          = (int)Row.Cells[0].Value;
                        bestelling.besteldatum = (DateTime)Row.Cells[2].Value;
                    }

                    DialogResult dialogResult = MessageBox.Show("Weet u zeker dat u wilt verwijderen: \r\n\r\n Bestelnummer: " + bestelling.id + ". \r\n " + bestelling.besteldatum.ToString().Substring(0, bestelling.besteldatum.ToString().Length - 3), "BESTELLING VERWIJDEREN", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (dialogResult == DialogResult.Yes)
                    {
                        bestellingregel.bestelling_id = bestelling.id;
                        BestellingregelDB.verwijderen(bestellingregel);
                        BestellingDb.verwijderen(bestelling);
                        vulDgOverzicht();
                        if (dgvOverzicht.Rows.Count > 0)
                        {
                            dgvOverzicht.Rows[0].Selected = true;
                        }
                        dgvOverzichtClick();
                        main.pnlSubGegevens.Controls.Clear();

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

                        LoggingDb.aanmaken(logging);
                    }
                    else
                    {
                        dgvOverzichtClick(true);
                    }
                }
                else
                {
                    MessageBox.Show("U moet een Bestelling selecteren om deze te kunnen verwijderen.", "BESTELLING VERWIJDEREN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }



            if (scherm == "Boekscherm")
            {
                if (selectieId != "")
                {
                    foreach (DataGridViewRow Row in dgvOverzicht.SelectedRows)
                    {
                        boek.isbn_nummer = (string)Row.Cells[0].Value;
                        boek             = BoekDb.ophalen(boek);
                    }

                    DialogResult dialogResult = MessageBox.Show("Weet u zeker dat u wilt verwijderen: \r\n\r\n " + boek.isbn_nummer + ". \r\n " + boek.titel, "BOEK VERWIJDEREN", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (dialogResult == DialogResult.Yes)
                    {
                        BoekDb.verwijderen(boek);
                        vulDgOverzicht();
                        main.pnlSubGegevens.Controls.Clear();

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

                        LoggingDb.aanmaken(logging);
                    }
                    else
                    {
                        dgvOverzichtClick(true);
                    }
                }
                else
                {
                    MessageBox.Show("U moet een boek selecteren om deze te kunnen verwijderen.", "BOEK VERWIJDEREN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }