Example #1
0
 public void Init()
 {
     Mysql.UseMockDatabase();
     Mysql.CheckDatabaseConnection();
     SC = new StorageController();
     SC.GetAll();
     SC.LoadAllProductsDictionary();
     SaleTransaction.SetStorageController(SC);
     SaleTransaction.HideMessageBox = true;
     POS = new POSController(SC);
     Utils.GetIceCreamID();
 }
Example #2
0
        public string CompletePurchase(PaymentMethod_Enum PaymentMethod, TextBox PayWithAmount, ListView ReceiptListView, out bool CompletedPurchase)
        {
            CompletedPurchase = false;
            if (ReceiptListView.HasItems)
            {
                if (TotalPriceToPay == -1m)
                {
                    TotalPriceToPay = PlacerholderReceipt.TotalPrice;
                }

                decimal PaymentAmount;
                if (PayWithAmount.Text.Length == 0)
                {
                    PaymentAmount = TotalPriceToPay;
                }
                else
                {
                    PaymentAmount = Convert.ToDecimal(PayWithAmount.Text);
                }

                if (ReceiptID == 0)
                {
                    ReceiptID = Receipt.GetNextID();
                }

                Payment NewPayment = new Payment(ReceiptID, PaymentAmount, PaymentMethod);
                PlacerholderReceipt.Payments.Add(NewPayment);

                PayWithAmount.Text = string.Empty;
                TotalPriceToPay   -= NewPayment.Amount;
                if (PlacerholderReceipt.PaidPrice >= PlacerholderReceipt.TotalPrice)
                {
                    CompletedPurchase = true;
                    SaleTransaction.SetStorageController(_storageController);

                    Thread NewThread = new Thread(new ThreadStart(ExecuteReceipt));
                    NewThread.Name = "ExecuteReceipt Thread";
                    NewThread.Start();
                    _storageController.TempProductToDictionary();
                    ReceiptListView.Items.Clear();

                    TotalPriceToPay = -1m;
                    ReceiptID       = 0;
                    if (PlacerholderReceipt.PaidPrice > PlacerholderReceipt.TotalPrice)
                    {
                        return("Retur: " + Math.Round((PlacerholderReceipt.PaidPrice - PlacerholderReceipt.TotalPrice), 2).ToString().Replace('.', ','));
                    }
                    else
                    {
                        return("");
                    }
                }
                if (TotalPriceToPay != -1m)
                {
                    if (TotalPriceToPay == 0)
                    {
                        PlacerholderReceipt.Payments.Clear();
                        PlacerholderReceipt.TotalPrice = 0;
                        CompletedPurchase = true;
                        return(string.Empty);
                    }
                    return(Math.Round(TotalPriceToPay, 2).ToString().Replace('.', ','));
                }
            }
            return(string.Empty);
        }