// Methods public Receipt(int invoiceID) { this.selectedBill = null; this.totalReceive = 0.0; this.paymentMethod = null; this.paymentMethodList = new ArrayList(); this.payValueList = new ArrayList(); this.coupon = null; this.giftVoucher = null; this.useDiscount = new ArrayList(); this.invoiceID = invoiceID; this.invoiceNote = string.Empty; this.LoadInvoice(); }
private void LoadInvoice() { Invoice invoiceByID; smartRestaurant.CheckBillService.CheckBillService service = new smartRestaurant.CheckBillService.CheckBillService(); if (this.invoiceID == 0) { invoiceByID = service.GetInvoice(this.selectedBill.OrderBillID); } else { invoiceByID = service.GetInvoiceByID(this.invoiceID); } if (invoiceByID == null) { this.SendInvoice(false, false); } else if (invoiceByID.invoiceID == 0) { MessageBox.Show("Can't load invoice data"); } else { this.invoiceID = invoiceByID.invoiceID; this.invoiceNote = invoiceByID.invoiceNote; this.paymentMethod = null; if (PaymentMethods != null) { for (int i = 0; i < PaymentMethods.Length; i++) { if (PaymentMethods[i].paymentMethodID == invoiceByID.paymentMethodID) { this.paymentMethod = PaymentMethods[i]; break; } } } if (this.selectedBill == null) { this.employeeID = invoiceByID.employeeID; this.orderBillID = invoiceByID.orderBillID; } this.amountDue = invoiceByID.totalPrice; this.pointAmount = invoiceByID.point; this.tax1 = invoiceByID.tax1; this.tax2 = invoiceByID.tax2; this.totalDiscount = invoiceByID.totalDiscount; this.totalReceive = invoiceByID.totalReceive; this.totalDue = ((this.amountDue + this.tax1) + this.tax2) - this.totalDiscount; this.useDiscount.Clear(); if (invoiceByID.discounts != null) { for (int j = 0; j < invoiceByID.discounts.Length; j++) { for (int k = 0; k < Discounts.Length; k++) { if (Discounts[k].promotionID == invoiceByID.discounts[j].promotionID) { this.useDiscount.Add(Discounts[k]); break; } } } } this.paymentMethodList.Clear(); this.payValueList.Clear(); if (invoiceByID.payments != null) { for (int m = 0; m < invoiceByID.payments.Length; m++) { for (int n = 0; n < PaymentMethods.Length; n++) { if (PaymentMethods[n].paymentMethodID == invoiceByID.payments[m].paymentMethodID) { this.paymentMethodList.Add(PaymentMethods[n]); this.payValueList.Add(invoiceByID.payments[m].receive); break; } } } } } }
public void SetPaymentMethod(PaymentMethod method, double val) { if (method == null) { this.paymentMethodList.Clear(); this.payValueList.Clear(); } else { int index = this.paymentMethodList.IndexOf(method); if (val != 0.0) { if (index >= 0) { this.payValueList[index] = val; } else { this.paymentMethodList.Add(method); this.payValueList.Add(val); } } else if (index >= 0) { this.paymentMethodList.RemoveAt(index); this.payValueList.RemoveAt(index); } } this.payValue = 0.0; for (int i = 0; i < this.payValueList.Count; i++) { this.payValue += (double) this.payValueList[i]; } this.totalReceive = this.payValue; this.paymentMethod = null; }