//PRIVATE LOGIC private void InitTransactionDbManagers() { SaleTransactionDbService = new SaleTransactionDbService(Presenter.GetStateManager().UserSession.SessionEntity); DeliveryTransactionDbService = new DeliveryTransactionDbService(Presenter.GetStateManager().UserSession.SessionEntity); }
private void OnRemoveTransactionConfirmed(bool isConfirmed) { if (isConfirmed) { try { var transaction = SaleTransactionDbService.FindById(_transactionToRemove); if (transaction == null) { Form.Log(InvalidTransactionId); return; } if (transaction.User.Id != Presenter.GetStateManager().UserSession.SessionEntity.Id) { if (!Roles.IsAdmin(Presenter.GetStateManager().UserSession.SessionEntity.Roles)) { Form.Log(TransactionDoesNotBelongToUserMsg); return; } } switch (transaction.TransactionType) { case TransactionType.DELIVERY: DeliveryTransactionDbService.RollBack(transaction); break; case TransactionType.SALE: SaleTransactionDbService.RollBack(_transactionToRemove); break; } Search(); Form.Log($"Изтрита е транзакция с номер: {_transactionToRemove}"); _transactionToRemove = -1; } catch (Exception e) { Form.Log(e.Message); } } }
public void Search() { if (!Roles.IsStandard(Presenter.GetStateManager().UserSession.SessionEntity.Roles)) { Form.Log(Messages.NotAuthorizedMsg); return; } var isRevised = Form.IsTransactionRevised; var startDate = Form.TransactionStartDate; var endDate = Form.TransactionEndtDate; var transactionType = Form.SelectedTransactionType; var transactions = SaleTransactionDbService.FindByDateTypeAndRevisionStatus(startDate, endDate, transactionType, isRevised); GridViewManager.ClearRows(); transactions.ForEach(GridViewManager.InsertTransaction); var totalSum = transactions.Sum(tr => tr.RevenueAmount); Form.Log($"Показани са {transactions.Count} транзакции. Обща сума: {totalSum:F2}."); }