/// <summary> /// Het afrekenscherm /// </summary> public Afrekenen(int tafelId) { InitializeComponent(); this.tafelId = tafelId; this.bestellingDao = DataHelper.BestellingDao; this.productDao = DataHelper.ProductDao; bestelId = bestellingDao.GetBestelIdFromTafel(tafelId); List <BestelRegel> rekeningRegels = bestellingDao.GetRekening(bestelId); label1.Text = "Tafel " + tafelId; decimal totaalPrijs = 0; decimal totaalBtw = 0; foreach (BestelRegel rekeningRegel in rekeningRegels) { Product product = productDao.GetProductById(rekeningRegel.ProductId); int aantal = rekeningRegel.Aantal; decimal prijs = product.Prijs; decimal regelPrijs = aantal * prijs; listBox1.Items.Add(product.Naam); listBox2.Items.Add(aantal.ToString()); listBox3.Items.Add(regelPrijs.ToString()); totaalPrijs += regelPrijs; decimal btw = Math.Ceiling(product.BerekenBTW * 100) / 100; totaalBtw += (btw * aantal); } // ----- Form changes ----- // totaalTxt.Text = "Totaal: " + totaalPrijs; btwTxt.Text = "BTW: " + totaalBtw.ToString("0.00"); listBox1.Height = listBox1.PreferredHeight; listBox2.Height = listBox2.PreferredHeight; listBox3.Height = listBox3.PreferredHeight; //set panel height Listbox + BTW and Totaal labels(50px) panel1.Height = listBox1.Height + 50; //set max panel Height if (panel1.Height > 330) { panel1.Height = 330; //set other padding for labels because of the vertical scrollbar totaalTxt.Padding = new Padding(0, 0, 8, 0); btwTxt.Padding = new Padding(0, 9, 8, 0); //9top for space between listbox and label } }
/// <summary> /// De bestelling wordt afgerond en geupdate in de database /// </summary> private void afrondButton_Click(object sender, EventArgs e) { this.bestellingDao = DataHelper.BestellingDao; string commentaar = commentaarBox.Text; bestellingDao.AfrondingBestelling(bestelId, betaalMethode, commentaar); Form tafelOverzicht = new TafelOverzicht(); tafelOverzicht.Show(); this.Close(); }
/// <summary> /// refresh /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["MayaMayaConnection"].ConnectionString; SqlConnection dbConnection = new SqlConnection(connString); BestellingDAO bestellingDAO = new BestellingDAO(dbConnection); listView1.Items.Clear(); listView2.Items.Clear(); foreach (Button b in button) { b.Dispose(); } BarScherm_Huidig_load(); BarScherm_Geschiedenis_load(); ActiveForm.Refresh(); }
/// <summary> /// Wanneer een button wordt geclickt, wordt de bestelling gemarkeerd en de button verwijderd. Ook refresht het scherm. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void button_Click(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["MayaMayaConnection"].ConnectionString; SqlConnection dbConnection = new SqlConnection(connString); BestellingDAO bestellingDAO = new BestellingDAO(dbConnection); Button btn = (Button)sender; BestelRegel regel = (BestelRegel)btn.Tag; bestellingDAO.MarkeerBestelRegel(regel.Id, regel.Status); listView1.Items.Clear(); listView2.Items.Clear(); foreach (Button b in button) { b.Dispose(); } BarScherm_Huidig_load(); BarScherm_Geschiedenis_load(); ActiveForm.Refresh(); }
/// <summary> /// Huidige bestellingen laden en buttons aanmaken /// </summary> private void BarScherm_Huidig_load() { string connString = ConfigurationManager.ConnectionStrings["MayaMayaConnection"].ConnectionString; SqlConnection dbConnection = new SqlConnection(connString); BestellingDAO bestellingDAO = new BestellingDAO(dbConnection); ProductDAO p = new ProductDAO(dbConnection); listView1.View = View.Details; int status = 1; int afdeling = 3; List <BestelRegel> bestelregel = bestellingDAO.GetAllByStatus(status, afdeling); int top = 25; int left = 380; foreach (var Bestelregel in bestelregel) { ListViewItem lvi = new ListViewItem(Bestelregel.TafelId.ToString()); Product prod = p.GetProductById(Bestelregel.ProductId); lvi.SubItems.Add(prod.Naam); lvi.SubItems.Add(Bestelregel.Comment.ToString()); lvi.SubItems.Add(Bestelregel.Aantal.ToString()); listView1.Items.AddRange(new ListViewItem[] { lvi }); //create buttons Button btn = new Button(); btn.Left = left; btn.Top = top; btn.Size = new Size(55, 15); btn.Text = "Klaar"; btn.Tag = Bestelregel; btn.Font = new Font("Arial", 5); btn.Click += button_Click; tabPage1.Controls.Add(btn); button.Add(btn); top += btn.Height + 2; } }
/// <summary> /// Tovert 't BestelScherm in beeld /// </summary> /// <param name="tafelId">De tafel waarvoor besteld wordt</param> public BestelScherm(int tafelId) { InitializeComponent(); DateTime t1 = DateTime.Now; DateTime t2 = Convert.ToDateTime("18:00:00"); if (DateTime.Compare(t1, t2) >= 0) { tabControl.SelectedTab = tabPageDiner; } this.productDAO = DataHelper.ProductDao; this.bestellingDAO = DataHelper.BestellingDao; //this.personeelId = personeelId; personeelId = PersoneelDAO.personeelId; this.tafelId = tafelId; InitBestelId(); Debug.WriteLine(bestelId); DrawButtons(); }