/// <summary> /// The delete transaction click, from Transaction View will delete the row of transaction with a message box before it goes through /// </summary> /// <param name="sender"> /// The sender is the parent object of the button, which is the Data Grid /// </param> /// <param name="e"> /// The e is the event arguments if applicable /// </param> private void DeleteTransClick(object sender, RoutedEventArgs e) { var transView = ((FrameworkElement)sender).DataContext as TransactionView; if (MessageBox.Show("Are you want to Delete - " + transView.RefNo + "?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { foreach (var trans in transView.Transactions) { var prod = Product.GetProduct(trans.Product.Id); if (transView.TransactionType == "Purchased") { Product.BalanceCasePackPiece(trans, prod, "Sales"); } else { Product.BalanceCasePackPiece(trans, prod, "Purchased"); } Product.EditProduct(prod); } TransactionOrder.DeleteTransaction(transView.Id); } this.InitializeTransView(); this.InitializeProductsFilter(this.locationFilterProduct, this.principalFilterProduct, this.categoryFilterProduct); }
public void GetTransactionTest() { var actualResult = new TransactionOrder { TransactionType = "Sales", DateTransaction = DateTime.Now, RefNo = "TestRef" }; actualResult = TransactionOrder.CreateTransaction(actualResult); var expectedResult = TransactionOrder.GetTransaction(actualResult.Id); UnitTestingHelper.AssertPublicPropertiesEqual(actualResult, expectedResult); if (TransactionOrder.GetTransaction("DoesNotExist") != null) { Assert.Fail("Transaction Order should not exist and must return null"); } if (TransactionOrder.GetTransaction(actualResult.Id + " ") != null) { Assert.Fail("Transaction Order must return null since the id is modified"); } TransactionOrder.DeleteTransaction(actualResult.Id); }
public void CreateTransactionTest() { var actualResult = new TransactionOrder { TransactionType = "Sales", DateTransaction = DateTime.Now, RefNo = "TestRef" }; actualResult = TransactionOrder.CreateTransaction(actualResult); var expectedResult = TransactionOrder.GetTransaction(actualResult.Id); UnitTestingHelper.AssertPublicPropertiesEqual(actualResult, expectedResult); TransactionOrder.DeleteTransaction(actualResult.Id); }
public void DeleteTransactionTest() { var actualResult = new TransactionOrder { TransactionType = "Sales", DateTransaction = DateTime.Now, RefNo = "TestRef" }; actualResult = TransactionOrder.CreateTransaction(actualResult); TransactionOrder.DeleteTransaction(actualResult.Id); var expectedResult = TransactionOrder.GetTransaction(actualResult.Id); Assert.IsNull(expectedResult); }
public void EditTransactionTest() { var actualResult = new TransactionOrder { TransactionType = "Sales", DateTransaction = DateTime.Now, RefNo = "TestRef" }; actualResult = TransactionOrder.CreateTransaction(actualResult); actualResult.RefNo = "Change Ref No"; TransactionOrder.EditTransaction(actualResult); var expectedResult = TransactionOrder.GetTransaction(actualResult.Id); Assert.AreEqual(actualResult.RefNo, expectedResult.RefNo); TransactionOrder.DeleteTransaction(actualResult.Id); }
public void GetAllTransactionsTest() { for (var i = 0; i < 5; i++) { var actualResult = new TransactionOrder { TransactionType = "Sales", DateTransaction = DateTime.Now, RefNo = "TestRef" }; TransactionOrder.CreateTransaction(actualResult); } var trans = TransactionOrder.GetAllTransactions(); var expectedResult = 5; Assert.AreEqual(expectedResult, trans.Count); foreach (var temp in trans) { TransactionOrder.DeleteTransaction(temp.Id); } }