public OrderOverviewUI(Order order, OrderHomeUI orderMenuUI) { InitializeComponent(); try { this.order = orderLogic.get_Order(order); AddItemsToListView(); } catch { MessageBox.Show("Probleem met het laden van de database. Probeer opnieuw."); this.Hide(); orderUI.Show(); } this.orderUI = orderMenuUI; }
//Goes to previous screen private void btnBack_Click(object sender, EventArgs e) { this.Hide(); orderMenuUI.Show(); this.Close(); }
private void ShowPanel(string panelName) { if (panelName == "Tip") { //open tip UI this.Hide(); CheckoutTipUI checkoutTipUI = new CheckoutTipUI(order, orderHomeUI); checkoutTipUI.ShowDialog(); } else if (panelName == "Pay") { //open pay UI this.Hide(); CheckoutPayUI checkoutUI = new CheckoutPayUI(order, orderHomeUI); checkoutUI.ShowDialog(); } else if (panelName == "Error") { //show 'no orders found' panel pnlError.Show(); pnlError.BringToFront(); //disable other buttons btnAddComment.Enabled = false; btnAddTip.Enabled = false; btnPay.Enabled = false; } else if (panelName == "Back") { //back //go back to overview this.Hide(); orderHomeUI.Show(); } else if (panelName == "Comment") { //show comment UI this.Hide(); CheckoutCommentsUI checkoutCommentsUI = new CheckoutCommentsUI(order, orderHomeUI); checkoutCommentsUI.ShowDialog(); } else if (panelName == "Overview") { //hide other panel pnlError.Hide(); //enable buttons btnAddComment.Enabled = true; btnAddTip.Enabled = true; btnPay.Enabled = true; //set title of header lblCheckoutOverviewHeader.Text = string.Format("Overzicht bestelling tafel {0}", order.Table.ID); //set labels to visible lblOrderPriceWithoutTax.Show(); lblTaxAmount.Show(); lblTotalAmount.Show(); //set label prices this.lblOrderPriceWithoutTax.Text = string.Format("{0:0.00}", order.GetTotalAmount("withoutTax")); this.lblTaxAmount.Text = string.Format("{0:0.00}", order.GetTotalAmount("Tax")); this.lblTotalAmount.Text = string.Format("{0:0.00}", order.GetTotalAmount("Total")); //check if there's given a tip //if yes, show labels if (order.tip > 0) { lblTip.Show(); lblTipAmount.Show(); lblTipEuroSign.Show(); lblTipAmount.Text = string.Format("{0:0.00}", order.tip); } //empty listview before filling it listViewOrderItems.Items.Clear(); //filling listview foreach (OrderItem item in order.orderItems) { ListViewItem li; //check if there's a comment if (string.IsNullOrWhiteSpace(item.comment)) { li = new ListViewItem(item.item.name); } else { li = new ListViewItem(string.Format("{0} ~ {1}", item.item.name, item.comment)); } li.SubItems.Add(item.amount.ToString()); li.SubItems.Add(item.GetAmount("Total").ToString("0.00")); listViewOrderItems.Items.Add(li); } } }