public ProductSection(DataGridView dataGridView, IPresenter presenter, ISearchProductView form) { ViewService = new ProductViewService(dataGridView, form); ProductDbService = new ProductDbService(); CategoryService = new CategoryDbService(); Presenter = presenter; Form = form; }
protected AbstractOperationSection(IPresenter presenter, TabPage tabPage, DataGridView dataGrid, TextBox totalSubBox, ITransactionDbService transactionDbService) { ProductDbService = new ProductDbService(); Presenter = presenter; TotalSumBox = totalSubBox; OperationsViewService = new OperationViewService(tabPage, dataGrid, presenter.Loggable, this); TransactionDbService = transactionDbService; }
//functionality public void UpdateProducts() { if (Form.SearchText == string.Empty) { ViewService.DisplayProducts(ProductDbService.FindAll()); } else { SearchProdAction(); } }
public RevisionSection(IPresenter presenter, IHomeView homeForm) { Form = homeForm; Presenter = presenter; RevisionDbService = new RevisionDbService(); ViewService = new RevisionViewService(Form.RevisionDataTable, Form, this); ProductService = new ProductDbService(); TransactionDbService = new InvariantTransactionDbService(Presenter.GetStateManager().UserSession.SessionEntity); RevenueDbService = new RevenuesDbService(); ExpenseDbService = new ExpensesDbService(); SalesRevenue = 0D; IsRevisionStarted = false; }
protected override void UpdateProductsQuantities(List <TransactionProduct> products, bool isRollBack) { foreach (var prodTrans in products) { var product = ProductDbService.FindById(prodTrans.ProductId); if (isRollBack) { product.Quantity += prodTrans.ProductQuantity; } else { product.Quantity -= prodTrans.ProductQuantity; } ProductDbService.UpdateProduct(product); } }
public void EditProductRequest() { Product product; if (!Roles.IsStandard(Presenter.GetStateManager().UserSession.SessionEntity.Roles)) { Presenter.GetStateManager() .Push(new ErrorPresenter(Presenter.GetStateManager(), Messages.NotAuthorizedMsg)); return; } try { product = ProductDbService.FindById(ViewService.GetSelectedProductId()); } catch (ArgumentException e) { Presenter.GetStateManager().Push(new ErrorPresenter(Presenter.GetStateManager(), e.Message)); return; } Presenter.GetStateManager().Push(new EditProductPresenter(Presenter.GetStateManager(), product, this)); }
protected AbstractTransactionDbService(User loggedUser) { ProductDbService = new ProductDbService(); LoggedUser = loggedUser; }
protected List <TransactionProduct> GetProductsFromDataGrid(TransactionType transactionType) { var products = new List <TransactionProduct>(); for (var i = 0; i < OperationsViewService.GetRowsCount(); i++) { //var row = this.OperationsViewService.DataGrid.Rows[i]; var transactionNumber = OperationsViewService.GetDataAtRow(i, TransactionNumber); var productId = -1; var selectedProductQuantity = 0D; Product product; try { var prodIdCell = OperationsViewService.GetDataAtRow(i, ProductId); if (prodIdCell == null) { continue; } productId = (int)prodIdCell; product = ProductDbService.FindById(productId); if (product == null) { throw new Exception(); } selectedProductQuantity = double.Parse(OperationsViewService.GetDataAtRow(i, ProductQuantity) + ""); } catch (Exception) { throw new ArgumentException($"{ThereWasAnErrorOnRow} {transactionNumber}"); } if (selectedProductQuantity <= 0D) { throw new ArgumentException($"{ChooseValidQuantity} {transactionNumber}"); } if (transactionType == TransactionType.SALE) { if (product.Quantity < selectedProductQuantity) { throw new ArgumentException($"{InsufficientAmount} {transactionNumber}"); } } var subTotal = 0.0; switch (transactionType) { case TransactionType.SALE: subTotal = product.SellPrice * selectedProductQuantity; break; case TransactionType.DELIVERY: subTotal = product.ImportPrice * selectedProductQuantity; break; } var productTransaction = new TransactionProduct { ProductId = product.Id, ProductQuantity = selectedProductQuantity, SubTotalPrice = subTotal }; products.Add(productTransaction); } return(products); }
public bool EditProductAction(Product product) { return(ProductDbService.UpdateProduct(product)); }
public bool AddNewProductAction(Product product) { return(ProductDbService.CreateProduct(product)); }
public void SearchVisibleProdAction() { var prods = ProductDbService.SearchVisible(Form.SearchText, ViewService.SearchParam); ViewService.DisplayProducts(prods); }
public void UpdateVisibleProducts() { ViewService.DisplayProducts(ProductDbService.SearchVisible("", ProductDbService.GetSearchParameters()[0])); }
public List <SearchParameter> GetSearchParameters() { return(ProductDbService.GetSearchParameters()); }