Пример #1
0
        public void Save(bool modifyPurchases = false)
        {
            dbConnect dbCon     = new dbConnect();
            Int32     receiptid = this.ORNumber;

            if (dbCon.CreateReceipt(ref receiptid, this.CashierName, this.TotalAmountDue, this.CashTendered, this.SeniorDiscount, this.ItemDiscount, this.Accountid, this.TransDate) == false)
            {
                return;
            }
            if (this.ORNumber != receiptid || this.ORNumber == receiptid && modifyPurchases)
            {
                this.ORNumber = receiptid;

                dbCon.RemoveFromHistory(this._ORNumber);
                foreach (KeyValuePair <string, clsPurchasedItem> purchaseditem in _lstPurchasedItems)
                {
                    if (purchaseditem.Value.Qty > 0)
                    {
                        purchaseditem.Value.ORNumber = this.ORNumber;
                        if (dbCon.AddTransaction(purchaseditem.Value))
                        {
                            clsProductItem prod = clsProductItem.SearchProduct(purchaseditem.Value.BarCode);
                            prod.QtySold += purchaseditem.Value.Qty;
                            prod.Save();
                        }
                    }
                }
            }
            this.ORNumber = receiptid;

            dbCon.Close();
        }