示例#1
0
        private void CreateDeb()
        {
            debiteuren deb = new debiteuren();

            deb.Voornaam   = voornaamBox.Text;
            deb.Achternaam = achternaamBox.Text;
            deb.Email      = emailBox.Text;
            deb.Telefoon   = telefoonBox.Text;
            deb.Adres      = adresBox.Text;
            deb.Postcode   = postcodeBox.Text;
            deb.Plaats     = plaatsBox.Text;
            deb.Land       = landBox.Text;

            try
            {
                db.debiteuren.Add(deb);
                db.SaveChanges();

                Message m = new Message();
                m.Show("Debiteur is aangemaakt!");
            }
            catch (Exception ex)
            {
                Message m = new Message();
                m.Show("Debiteur kon niet worden aangemaakt!");
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
示例#2
0
        //Save button to update debiteur
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string id = Session["EditID"].ToString();
            int    ID = int.Parse(id);

            debiteuren deb    = db.debiteuren.Find(ID);
            debiteuren newDeb = new debiteuren();

            if (deb != null)
            {
                newDeb.ID         = ID;
                newDeb.Voornaam   = voornaamBox.Text;
                newDeb.Achternaam = achternaamBox.Text;
                newDeb.Email      = emailBox.Text;
                newDeb.Telefoon   = telefoonBox.Text;
                newDeb.Adres      = adresBox.Text;
                newDeb.Postcode   = postcodeBox.Text;
                newDeb.Plaats     = plaatsBox.Text;
                newDeb.Land       = landBox.Text;
            }

            db.Entry(deb).CurrentValues.SetValues(newDeb);
            db.SaveChanges();

            Response.Redirect("Debiteur.aspx");
        }
示例#3
0
        private void CreateProduct()
        {
            producten product = new producten();

            product.Naam    = naamBox.Text;
            product.Prijs   = decimal.Parse(prijsBox.Text);
            product.BTW     = int.Parse(btwBox.Text);
            product.Korting = int.Parse(kortingBox.Text);

            try
            {
                db.producten.Add(product);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

            string debiteur = DebDDL.SelectedValue;

            if (DebDDL.SelectedValue != "")
            {
                string[] name  = debiteur.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                string   fname = name[0];
                string   lname = "";

                for (int i = 1; i < name.Length; i++)
                {
                    lname += name[i] + " ";
                }

                debiteuren deb = db.debiteuren.Where(d => d.Voornaam == fname && d.Achternaam == lname).SingleOrDefault();

                toewijzen toewijzing = new toewijzen();
                producten prod       = db.producten.Where(p => p.Naam == naamBox.Text).SingleOrDefault();
                toewijzing.ProductID  = prod.ID;
                toewijzing.DebiteurID = deb.ID;

                try
                {
                    db.toewijzen.Add(toewijzing);
                    db.SaveChanges();

                    Message m = new Message();
                    m.Show("Product is aangemaakt!");
                }
                catch (Exception ex)
                {
                    Message m = new Message();
                    m.Show("Product kon niet worden aangemaakt!");
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            }
            else
            {
                Message m = new Message();
                m.Show("Product is aangemaakt!");
            }
        }
示例#4
0
        //Fill textboxes with info from selected debiteur
        private void FillTextBoxes(string id)
        {
            int        ID  = int.Parse(id);
            debiteuren deb = db.debiteuren.Find(ID);

            voornaamBox.Text   = deb.Voornaam;
            achternaamBox.Text = deb.Achternaam;
            emailBox.Text      = deb.Email;
            telefoonBox.Text   = deb.Telefoon;
            adresBox.Text      = deb.Adres;
            postcodeBox.Text   = deb.Postcode;
            plaatsBox.Text     = deb.Plaats;
            landBox.Text       = deb.Land;
        }
示例#5
0
        //Delete button in table
        private void Del_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            string id  = btn.ID;

            string[] split = id.Split('_');
            int      ID    = int.Parse(split[1]);

            string confirmValue = Request.Form["confirm_value"];

            if (confirmValue == "Ja")
            {
                try
                {
                    debiteuren           deb    = db.debiteuren.Where(d => d.ID == ID).SingleOrDefault();
                    List <facturen>      fList  = db.facturen.Where(fa => fa.DebiteurID == ID).ToList();
                    List <factuur_items> fiList = db.factuur_items.Where(f => f.facturen.DebiteurID == ID).ToList();

                    db.factuur_items.RemoveRange(fiList);
                    db.facturen.RemoveRange(fList);
                    db.debiteuren.Remove(deb);
                    db.SaveChanges();

                    Message m = new Message();
                    m.Show("Debiteur is verwijderd!");

                    Response.Redirect(Request.RawUrl);
                }
                catch (Exception ex)
                {
                    Message m = new Message();
                    m.Show("Debiteur kon niet worden verwijderd!");
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            }
            else
            {
                Response.Redirect(Request.RawUrl);
            }
        }
示例#6
0
        //Save button to update factuur
        private void SaveButton_Click(object sender, EventArgs e)
        {
            string id = Session["EditID3"].ToString();
            int    ID = int.Parse(id);

            facturen fact    = db.facturen.Find(ID);
            facturen newFact = new facturen();

            if (fact != null)
            {
                //Factuur

                newFact.Factuurnummer = ID;
                newFact.Factuurdatum  = DateTime.Parse(datumBox.Text);
                newFact.Totaalbedrag  = decimal.Parse(totaalBox.Text);

                //----------------------------------------------------
                //Debiteur

                string   debiteur = debDDL.SelectedValue;
                string[] name     = debiteur.Split(' ');
                string   fname    = name[0];
                string   lname    = name[1];

                debiteuren deb = db.debiteuren.Where(d => d.Voornaam == fname && d.Achternaam == lname).SingleOrDefault();

                fact.DebiteurID = deb.ID;

                //----------------------------------------------------
                //Product

                List <producten> proList = new List <producten>();
                List <string>    values  = new List <string>();

                foreach (ListItem Item in productCheckBoxList.Items)
                {
                    if (Item.Selected)
                    {
                        values.Add(Item.Value);
                    }
                }

                for (int i = 0; i < values.Count; i++)
                {
                    string    j = values[i];
                    producten p = db.producten.Where(pr => pr.Naam == j).SingleOrDefault();
                    proList.Add(p);
                }

                string products = "";

                for (int i = 0; i < proList.Count; i++)
                {
                    string pname = proList[i].Naam;

                    products += pname + "\n";
                }

                //--------------------------------------
                //Save factuur to database

                try
                {
                    db.facturen.Add(fact);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }

                //--------------------------------------
            }

            db.Entry(fact).CurrentValues.SetValues(newFact);
            db.SaveChanges();

            Response.Redirect("Factuur.aspx");
        }
示例#7
0
        //Fill textboxes with info from selected debiteur
        private void ShowInfo(string id)
        {
            int ID = int.Parse(id);

            facturen factuur = db.facturen.Find(ID);

            int        debID = factuur.DebiteurID;
            debiteuren deb   = db.debiteuren.Find(debID);

            List <factuur_items> fiList      = db.factuur_items.Where(f => f.FactuurID == ID).ToList();
            List <producten>     productList = new List <producten>();
            List <int>           pidList     = new List <int>();
            List <int>           aantalList  = new List <int>();

            for (int i = 0; i < fiList.Count; i++)
            {
                int productID = fiList[i].ProductID;
                pidList.Add(productID);
            }

            for (int i = 0; i < fiList.Count; i++)
            {
                int aantal = fiList[i].Aantal;
                aantalList.Add(aantal);
            }

            for (int i = 0; i < pidList.Count; i++)
            {
                int       pid = pidList[i];
                producten p   = db.producten.Find(pid);

                productList.Add(p);
            }

            TableCell cell  = new TableCell();
            TableCell cell1 = new TableCell();
            TableCell cell2 = new TableCell();
            TableCell cell3 = new TableCell();
            TableCell cell4 = new TableCell();
            TableCell cell5 = new TableCell();

            cell.Text  = factuur.Factuurnummer.ToString();
            cell1.Text = String.Format("{0:dd-MM-yyyy}", factuur.Factuurdatum);
            cell2.Text = String.Format("{0:C}", factuur.Totaalbedrag);
            cell3.Text = deb.Voornaam + " " + deb.Achternaam;

            string products = "";

            for (int i = 0; i < productList.Count; i++)
            {
                products += productList[i].Naam + "<br />";
            }

            string aantallen = "";

            for (int i = 0; i < aantalList.Count; i++)
            {
                aantallen += aantalList[i] + "<br />";
            }

            cell4.Text = products;
            cell5.Text = aantallen;

            TableRow row = new TableRow();

            row.Cells.Add(cell);
            row.Cells.Add(cell1);
            row.Cells.Add(cell2);
            row.Cells.Add(cell3);
            row.Cells.Add(cell4);
            row.Cells.Add(cell5);


            factuurTable.Rows.Add(row);
        }
示例#8
0
        private void CreateFactuur()
        {
            List <int> aantalList = new List <int>();
            facturen   factuur    = new facturen();

            factuur.Factuurdatum = DateTime.Parse(datumBox.Text);

            //---------------------------------
            //Debiteur
            string debiteur = debDDL.SelectedValue;

            string[] name = debiteur.Split(' ');
            System.Diagnostics.Debug.WriteLine("fname: " + name[0]);
            System.Diagnostics.Debug.WriteLine("lname: " + name[1]);

            string fname = name[0];
            string lname = name[1];

            /*
             * for (int i = 1; i < name.Length; i++)
             * {
             *  lname += name[i] + " ";
             * }
             */

            debiteuren deb = db.debiteuren.Where(d => d.Voornaam == fname && d.Achternaam == lname).SingleOrDefault();

            factuur.DebiteurID = deb.ID;

            //---------------------------------
            //Product
            List <producten> proList = new List <producten>();
            List <string>    values  = new List <string>();

            foreach (var tr in SelectTable.Controls.OfType <TableRow>())
            {
                foreach (var td in tr.Controls.OfType <TableCell>())
                {
                    foreach (var chk in td.Controls.OfType <CheckBox>())
                    {
                        if (chk.Checked)
                        {
                            values.Add(chk.Text);
                        }
                    }
                }
            }

            string product = "";

            for (int i = 0; i < values.Count; i++)
            {
                string j = values[i];
                product = j;


                producten p = db.producten.Where(pr => pr.Naam == j).SingleOrDefault();
                proList.Add(p);
            }

            System.Diagnostics.Debug.WriteLine("size proList: " + proList.Count);


            //Totaalbedrag factuur
            string totalString = totaalBox.Text;
            string str         = totalString.Replace("€", string.Empty);

            decimal total = decimal.Parse(str);

            factuur.Totaalbedrag = total;


            //--------------------------------------
            //Save factuur to database

            try
            {
                db.facturen.Add(factuur);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

            //--------------------------------------

            List <factuur_items> fiList = new List <factuur_items>();

            TextBox txtBox = null;

            foreach (var tr in SelectTable.Controls.OfType <TableRow>())
            {
                foreach (var td in tr.Controls.OfType <TableCell>())
                {
                    foreach (var txt in td.Controls.OfType <TextBox>())
                    {
                        if (txt.ID.Contains(product))
                        {
                            txtBox = txt;
                        }
                    }
                }
            }



            if (proList.Count == 1)
            {
                System.Diagnostics.Debug.WriteLine("Only one item in list");

                factuur_items fi = new factuur_items();
                fi.FactuurID = factuur.Factuurnummer;
                fi.Aantal    = int.Parse(txtBox.Text);
                fi.ProductID = proList[0].ID;

                try
                {
                    db.factuur_items.Add(fi);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            }
            else if (proList.Count > 1)
            {
                System.Diagnostics.Debug.WriteLine("More than one item in list");

                for (int i = 0; i < proList.Count; i++)
                {
                    factuur_items sfi = new factuur_items();
                    sfi.FactuurID = factuur.Factuurnummer;
                    sfi.Aantal    = int.Parse(txtBox.Text);

                    sfi.ProductID = proList[i].ID;
                    fiList.Add(sfi);
                }

                try
                {
                    db.factuur_items.AddRange(fiList);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            }
        }
示例#9
0
        //Fill textboxes with info from selected debiteur
        private void ShowInfo(string id)
        {
            int ID = int.Parse(id);

            facturen factuur = db.facturen.Find(ID);

            int        debID = factuur.DebiteurID;
            debiteuren deb   = db.debiteuren.Find(debID);

            List <factuur_items> fiList      = db.factuur_items.Where(f => f.FactuurID == ID).ToList();
            List <producten>     productList = new List <producten>();
            List <int>           pidList     = new List <int>();
            List <int>           aantalList  = new List <int>();

            for (int i = 0; i < fiList.Count; i++)
            {
                int productID = fiList[i].ProductID;
                pidList.Add(productID);
            }

            for (int i = 0; i < fiList.Count; i++)
            {
                int aantal = fiList[i].Aantal;
                aantalList.Add(aantal);
            }

            for (int i = 0; i < pidList.Count; i++)
            {
                int       pid = pidList[i];
                producten p   = db.producten.Find(pid);

                productList.Add(p);
            }

            //Table cells
            TableCell cell  = new TableCell();
            TableCell cell1 = new TableCell();
            TableCell cell2 = new TableCell();
            TableCell cell3 = new TableCell();
            TableCell cell4 = new TableCell();
            TableCell cell5 = new TableCell();

            //Set debiteur naam and address label
            DebiteurNaamLabel.Text  = deb.Voornaam + " " + deb.Achternaam;
            DebiteurAdresLabel.Text = deb.Adres;

            if (deb.Land == "Nederland")
            {
                DebiteurPostcodeLabel.Text = deb.Postcode + " " + deb.Plaats;
            }
            else
            {
                DebiteurPostcodeLabel.Text = deb.Postcode + " " + deb.Plaats + " " + deb.Land;
            }

            //Set factuurnummer and date label
            FactuurNummerLabel.Text = factuur.Factuurnummer.ToString();
            FactuurDatumLabel.Text  = String.Format("{0:dd-MM-yyyy}", factuur.Factuurdatum);

            //Set cell text
            for (int i = 0; i < productList.Count; i++)
            {
                producten pr = productList[i];

                string aantallen = "";

                for (int j = 0; j < aantalList.Count; j++)
                {
                    aantallen += aantalList[j] + "<br />";
                }

                cell.Text  = pr.Naam;
                cell1.Text = String.Format("{0:C}", pr.Prijs);
                cell2.Text = pr.BTW + "%";
                cell3.Text = pr.Korting + "%";
                cell4.Text = aantallen;
                cell5.Text = String.Format("{0:C}", factuur.Totaalbedrag);

                TableRow row = new TableRow();

                row.Cells.Add(cell);
                row.Cells.Add(cell1);
                row.Cells.Add(cell2);
                row.Cells.Add(cell3);
                row.Cells.Add(cell4);
                row.Cells.Add(cell5);

                FactuurTable.Rows.Add(row);
            }

            FillTotal(productList, factuur);
        }
示例#10
0
        //Fill GridView of listed debiteuren.
        private void FillGridView()
        {
            try
            {
                List <facturen> factuurlist = db.facturen.ToList();

                for (int i = 0; i < factuurlist.Count; i++)
                {
                    string fnummer = factuurlist[i].Factuurnummer.ToString();
                    string fdatum  = String.Format("{0:dd-MM-yyyy}", factuurlist[i].Factuurdatum);
                    string totaal  = String.Format("{0:C}", factuurlist[i].Totaalbedrag);

                    debiteuren deb = db.debiteuren.Find(factuurlist[i].DebiteurID);

                    string debiteur = deb.Voornaam + " " + deb.Achternaam;

                    Button del = new Button();
                    del.ID            = "del_" + factuurlist[i].Factuurnummer.ToString();
                    del.Text          = "Verwijder";
                    del.CssClass      = "btn btn-warning btn-sm";
                    del.Click        += Del_Click;
                    del.OnClientClick = "Confirm()";


                    /*
                     * Button edit = new Button();
                     * edit.ID = "edit_" + factuurlist[i].Factuurnummer.ToString();
                     * edit.Text = "Wijzigen";
                     * edit.CssClass = "btn btn-success btn-sm";
                     * edit.Click += Edit_Click;
                     */

                    Button export = new Button();
                    export.ID       = "export_" + factuurlist[i].Factuurnummer.ToString();
                    export.Text     = "Exporteer";
                    export.CssClass = "btn btn-info btn-sm";
                    export.Click   += Export_Click;

                    Button show = new Button();
                    show.ID       = "show_" + factuurlist[i].Factuurnummer.ToString();
                    show.Text     = "Inzien";
                    show.CssClass = "btn btn-info btn-sm";
                    show.Click   += Show_Click;

                    TableCell cell  = new TableCell();
                    TableCell cell1 = new TableCell();
                    TableCell cell2 = new TableCell();
                    TableCell cell3 = new TableCell();
                    TableCell cell4 = new TableCell();
                    TableCell cell5 = new TableCell();
                    TableCell cell6 = new TableCell();

                    cell.Text  = fnummer;
                    cell1.Text = fdatum;
                    cell2.Text = totaal;
                    cell3.Text = debiteur;
                    cell4.Controls.Add(show);
                    cell5.Controls.Add(export);
                    cell6.Controls.Add(del);

                    TableRow row = new TableRow();

                    row.Cells.Add(cell);
                    row.Cells.Add(cell1);
                    row.Cells.Add(cell2);
                    row.Cells.Add(cell3);
                    row.Cells.Add(cell4);
                    row.Cells.Add(cell5);
                    row.Cells.Add(cell6);

                    factuurTable.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
            }
        }
示例#11
0
        //Fill table with products.
        private void FillGridView()
        {
            try
            {
                List <producten> prodlist      = db.producten.ToList();
                List <toewijzen> toewijzenList = db.toewijzen.ToList();

                for (int i = 0; i < prodlist.Count; i++)
                {
                    string  naam    = prodlist[i].Naam;
                    decimal prijs   = (decimal)prodlist[i].Prijs;
                    int     btw     = (int)prodlist[i].BTW;
                    int     korting = (int)prodlist[i].Korting;

                    Button del = new Button();
                    del.ID            = "del_" + prodlist[i].ID.ToString();
                    del.Text          = "Verwijder";
                    del.CssClass      = "btn btn-warning btn-sm";
                    del.Click        += Del_Click;
                    del.OnClientClick = "Confirm()";

                    Button edit = new Button();
                    edit.ID       = "edit_" + prodlist[i].ID.ToString();
                    edit.Text     = "Wijzigen";
                    edit.CssClass = "btn btn-success btn-sm";
                    edit.Click   += Edit_Click;

                    TableCell cell  = new TableCell();
                    TableCell cell1 = new TableCell();
                    TableCell cell2 = new TableCell();
                    TableCell cell3 = new TableCell();
                    TableCell cell4 = new TableCell();
                    TableCell cell5 = new TableCell();
                    TableCell cell6 = new TableCell();

                    int pid = prodlist[i].ID;

                    toewijzen tw = toewijzenList.Where(t => t.ProductID == pid).SingleOrDefault();

                    if (tw != null)
                    {
                        int        id  = tw.DebiteurID;
                        debiteuren deb = db.debiteuren.Find(id);

                        cell4.Text = deb.Voornaam + " " + deb.Achternaam;
                    }
                    else
                    {
                        cell4.Text = "";
                    }

                    cell.Text  = naam;
                    cell1.Text = String.Format("{0:C}", prijs);
                    cell2.Text = String.Format("{0}%", btw);
                    cell3.Text = String.Format("{0}%", korting);
                    cell5.Controls.Add(edit);
                    cell6.Controls.Add(del);

                    TableRow row = new TableRow();

                    row.Cells.Add(cell);
                    row.Cells.Add(cell1);
                    row.Cells.Add(cell2);
                    row.Cells.Add(cell3);
                    row.Cells.Add(cell4);
                    row.Cells.Add(cell5);
                    row.Cells.Add(cell6);

                    productTable.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
            }
        }