Exemplo n.º 1
0
 private string BuildStockMovementInsertQuery(StockItemMovement movement)
 {
     return string.Format(@"INSERT INTO StockItemMovements
     ([StockItemTypeID],
     [Quantity],
     [MovementType],
     [Description],
     [SerialNumber],
     [UnitPurchasePrice],
     [MovementReason],
     [DateRecorded])
     VALUES ({0},{1},{2},'{3}','{4}',{5},'{6}', CONVERT(DATETIME, '{7}'))",
     movement.StockItemTypeID, movement.Quantity, movement.MovementType, movement.Description,
      movement.SerialNumber, movement.UnitPurchasePrice, movement.MovementReason, movement.DateRecorded);
 }
Exemplo n.º 2
0
 public StockItemMovement AddStockItemMovement(StockItemMovement stockMovement)
 {
     _dataBaseContext.StockItemMovements.AddObject(stockMovement);
     SaveChangesToDataBase();
     return stockMovement;
 }
Exemplo n.º 3
0
        private void addSaleView_RecordButtonClicked(object sender, SaleSavingArgs e)
        {
            if (SalesTransactionType == null)
            {
                BuzzleFunctions.ShowMessage(
                    "Cannot record this sale. No transaction type set for sales. Please go to the general settings tab on the settings page and set a transaction type for sales",
                    "Cannot record sales");
                return;
            }

            (sender as AddSaleView).Close();

            //add transaction
            var saleTransaction = new Transaction(){

                TransactionTypeID = SalesTransactionType.TransactionTypeID,
                Amount = e.Sale.SaleItems.Select(item => item.Quantity * item.UnitSoldPrice).Sum(),
                Notes = "New Sale",
                RecordedByUserID = CurrentlyLoggedInUser.UserID,
                DateRecorded = DateTime.Now
            };
            _dataManager.AddTransaction(saleTransaction);

            //add movement
            foreach(var item in e.Sale.SaleItems){
                var movement = new StockItemMovement()
                {
                    StockItemTypeID = item.StockItemTypeID,
                    Quantity = item.Quantity,
                    MovementType = (int)BuzzleEnums.StockMovementTypes.Stock_Out,
                    UnitPurchasePrice = item.UnitPurchasePrice,
                    MovementReason = BuzzleEnums.StockMovementReasons.Sales.ToString(),
                    DateRecorded = DateTime.Now
                };
                _dataManager.AddStockItemMovement(movement);
            }

            //add sale
            _dataManager.AddSale(e.Sale);
            if (e.PrintCommandPassed)
            {
                _receiptPrinter.PrintSaleReceipt(e.Sale);
            }
            LoadOrReloadAllSales();
        }