コード例 #1
0
        //Fill textboxes with info from selected debiteur
        private void FillTextBoxes(string id)
        {
            int                  ID     = int.Parse(id);
            facturen             fact   = db.facturen.Find(ID);
            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>();

            for (int i = 0; i < fiList.Count; i++)
            {
                int pid = fiList[i].ProductID;

                pidList.Add(pid);
            }

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

                productList.Add(p);
            }

            datumBox.Text  = String.Format("{0:dd-MM-yyyy}", fact.Factuurdatum);
            totaalBox.Text = String.Format("{0:C}", fact.Totaalbedrag);
        }
コード例 #2
0
        private void FillTotal(List <producten> products, facturen factuur)
        {
            for (int i = 0; i < products.Count; i++)
            {
                producten pr = products[i];

                decimal?subtotal = (decimal?)(factuur.Totaalbedrag * 100) / (100 + pr.BTW);
                SubtotaalLabel.Text = String.Format("{0:C}", subtotal);
                BTWLabel.Text       = pr.BTW + "%";
                TotaalLabel.Text    = String.Format("{0:C}", factuur.Totaalbedrag);
            }
        }
コード例 #3
0
ファイル: Product.aspx.cs プロジェクト: JHNBOS/FactuurWebsite
        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
                {
                    producten            prod        = db.producten.Where(d => d.ID == ID).SingleOrDefault();
                    List <factuur_items> fiList      = db.factuur_items.Where(f => f.ProductID == prod.ID).ToList();
                    List <facturen>      factuurList = new List <facturen>();
                    List <toewijzen>     toewijsList = db.toewijzen.Where(t => t.ProductID == ID).ToList();

                    for (int i = 0; i < fiList.Count; i++)
                    {
                        int fid = fiList[i].FactuurID;

                        facturen fact = db.facturen.Find(fid);
                        factuurList.Add(fact);
                    }

                    db.factuur_items.RemoveRange(fiList);
                    db.facturen.RemoveRange(factuurList);
                    db.toewijzen.RemoveRange(toewijsList);
                    db.producten.Remove(prod);
                    db.SaveChanges();

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

                    Response.Redirect(Request.RawUrl);
                }
                catch (Exception ex)
                {
                    Message m = new Message();
                    m.Show("Product kon niet worden verwijderd!");
                    System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                }
            }
            else
            {
                Response.Redirect(Request.RawUrl);
            }
        }
コード例 #4
0
ファイル: Factuur.aspx.cs プロジェクト: JHNBOS/FactuurWebsite
        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
                {
                    facturen fact = db.facturen.Where(d => d.Factuurnummer == ID).SingleOrDefault();

                    List <factuur_items> itemList = db.factuur_items.Where(f => f.FactuurID == ID).ToList();

                    db.factuur_items.RemoveRange(itemList);
                    db.facturen.Remove(fact);
                    db.SaveChanges();

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

                    Response.Redirect(Request.RawUrl);
                }
                catch (Exception ex)
                {
                    Message m = new Message();
                    m.Show("Factuur kon niet worden verwijderd!");
                    System.Diagnostics.Debug.WriteLine(ex.StackTrace);
                }
            }
            else
            {
                Response.Redirect(Request.RawUrl);
            }
        }
コード例 #5
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");
        }
コード例 #6
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);
        }
コード例 #7
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);
                }
            }
        }
コード例 #8
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);
        }