public void Run(int id, Provider provider, int count, DateTime dateTime, float allPurchasePrice, float allSalesPrice, Department department, Seller seller) { ArrivedGoods arrivedGoods = null; arrivedGoodsRepository.GetNewAll(); foreach (ArrivedGoods curArrivedGoods in arrivedGoodsRepository.GetAll()) { if (id.Equals(curArrivedGoods.Id)) { arrivedGoods = new ArrivedGoods() { Id = id, Provider = provider, Count = count, DateTime = dateTime, AllPurchasePrice = allPurchasePrice, AllSalesPrice = allPurchasePrice, Department = department, Seller = seller }; arrivedGoodsRepository.Update(arrivedGoods); break; } } if (arrivedGoods == null) { throw new Exception("The product is not updated and not found!"); } ; }
public void Create(ArrivedGoods arrivedGoods) { if (arrivedGoods != null) { db.InsertArrivedGoods(arrivedGoods); } }
public void UpdateArrivedGoods(ArrivedGoods arrivedGoods) { try { this.OpenConnection(); string comand = "Update ArrivedGoods Set idproviders=@idproviders, count=@count, datetime=@datetime, purchase_price=@purchase_price, sales_price=@sales_price, iddepartments=@iddepartments, idsellers=@idsellers Where Id=@Id"; SqlCommand sqlCom = new SqlCommand(comand, con); sqlCom.Parameters.AddWithValue("@Id", arrivedGoods.Id); sqlCom.Parameters.AddWithValue("@idproviders", arrivedGoods.Provider.Id); sqlCom.Parameters.AddWithValue("@count", arrivedGoods.Count); sqlCom.Parameters.AddWithValue("@datetime", arrivedGoods.DateTime); sqlCom.Parameters.AddWithValue("@purchase_price", arrivedGoods.AllPurchasePrice); sqlCom.Parameters.AddWithValue("@sales_price", arrivedGoods.AllSalesPrice); sqlCom.Parameters.AddWithValue("@iddepartments", arrivedGoods.Department.Id); sqlCom.Parameters.AddWithValue("@idsellers", arrivedGoods.Seller.Id); sqlCom.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Cannot update product data!", ex); } finally { this.Dispose(); } }
public void InsertArrivedGoods(ArrivedGoods arrivedGoods) { try { this.OpenConnection(); string comand = "Insert Into ArrivedGoods(idproviders, count, datetime, purchase_price, sales_price, iddepartments, idsellers) Values(@idproviders, @count, @datetime, @purchase_price, @sales_price, @iddepartments, @idsellers)"; SqlCommand sqlCom = new SqlCommand(comand, con); sqlCom.Parameters.AddWithValue("@idproviders", arrivedGoods.Provider.Id); sqlCom.Parameters.AddWithValue("@count", arrivedGoods.Count); sqlCom.Parameters.AddWithValue("@datetime", arrivedGoods.DateTime); sqlCom.Parameters.AddWithValue("@purchase_price", arrivedGoods.AllPurchasePrice); sqlCom.Parameters.AddWithValue("@sales_price", arrivedGoods.AllSalesPrice); sqlCom.Parameters.AddWithValue("@iddepartments", arrivedGoods.Department.Id); sqlCom.Parameters.AddWithValue("@idsellers", arrivedGoods.Seller.Id); sqlCom.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Cannot add the product!", ex); } finally { this.Dispose(); } }
public List <ArrivedGoods> Run(Department department) { List <ArrivedGoods> arrivedGoodses = new List <ArrivedGoods>(); arrivedGoodsRepository.GetNewAll(); foreach (ArrivedGoods curArrivedGoods in arrivedGoodsRepository.GetAll()) { if (department.Id.Equals(curArrivedGoods.Department.Id)) { ArrivedGoods arrivedGoods = new ArrivedGoods() { Id = curArrivedGoods.Id, Provider = curArrivedGoods.Provider, Count = curArrivedGoods.Count, DateTime = curArrivedGoods.DateTime, AllPurchasePrice = curArrivedGoods.AllPurchasePrice, AllSalesPrice = curArrivedGoods.AllSalesPrice, Department = curArrivedGoods.Department, Seller = curArrivedGoods.Seller }; arrivedGoodses.Add(arrivedGoods); } } return(arrivedGoodses); }
public void Delete(ArrivedGoods arrivedGoods) { ArrivedGoods curArrivedGoods = this.FindById(arrivedGoods.Id); if (curArrivedGoods != null) { db.DropArrivedGoods(arrivedGoods); db.ArrivedGoods.Remove(curArrivedGoods); } }
public void LoadProduct(int id, User user, ArrivedGoods arrivedGoods, Product product, Seller seller, IFrontServiceClient frontServiceClient) { this.mainWindow.Dispatcher.Invoke(() => { this.mainWindow.WindowState = WindowState.Normal; this.mainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen; }); this.SetElement(mainWindow, (UIElement)viewFactory.CreateViewProduct(id, arrivedGoods, product, seller, user, frontServiceClient)); }
public async Task AddProductGoods(Product product, ArrivedGoods arrivedGoods) { try { operationStatusInfo = await this.frontServiceClient.AddProductGoodsAsync(product, arrivedGoods); } catch (Exception ex) { this.ex = ex; } }
public void Run(Provider provider, int count, DateTime dateTime, float allPurchasePrice, float allSalesPrice, Department department, Seller seller) { ArrivedGoods newArrivedGoods = new ArrivedGoods() { Provider = provider, Count = count, DateTime = dateTime, AllPurchasePrice = allPurchasePrice, AllSalesPrice = allPurchasePrice, Department = department, Seller = seller }; arrivedGoodsRepository.Create(newArrivedGoods); }
public void DropArrivedGoods(ArrivedGoods arrivedGoods) { try { this.OpenConnection(); string comand = "delete from ArrivedGoods where id = '" + arrivedGoods.Id.ToString() + "'"; SqlCommand sqlCom = new SqlCommand(comand, con); sqlCom.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Cannot delete the product!", ex); } finally { this.Dispose(); } }
public ViewModelProduct(IArrivedGoodsValidationRule arrivedGoodsValidationRule, IProductValidationRule productValidationRule, IMainWindowController mainWindowController, IFrontServiceClient frontServiceClient, ArrivedGoods arrivedGoods, Product product, Seller seller, User user, int id) { this.validatablePropertyCollection.Add("Unit"); this.validatablePropertyCollection.Add("Count"); this.validatablePropertyCollection.Add("Datetime"); this.validatablePropertyCollection.Add("ExpirationDate"); this.validatablePropertyCollection.Add("PurchasePrice"); this.validatablePropertyCollection.Add("SalesPrice"); this.validatablePropertyCollection.Add("ReturnedDate"); this.arrivedGoodsValidationRule = arrivedGoodsValidationRule; this.productValidationRule = productValidationRule; this.mainWindowController = mainWindowController; this.frontServiceClient = frontServiceClient; this.seller = seller; this.product = product; this.arrivedGoods = arrivedGoods; this.user = user; this.id = id; }
public void Update(ArrivedGoods arrivedGoods) { if (arrivedGoods != null) { for (int i = 0; i < this.GetAll().Count; i++) { if (db.ArrivedGoods[i].Id == arrivedGoods.Id) { db.ArrivedGoods[i].Provider = arrivedGoods.Provider; db.ArrivedGoods[i].Count = arrivedGoods.Count; db.ArrivedGoods[i].DateTime = arrivedGoods.DateTime; db.ArrivedGoods[i].AllPurchasePrice = arrivedGoods.AllPurchasePrice; db.ArrivedGoods[i].AllSalesPrice = arrivedGoods.AllSalesPrice; db.ArrivedGoods[i].Department = arrivedGoods.Department; db.ArrivedGoods[i].Seller = arrivedGoods.Seller; } } db.UpdateArrivedGoods(arrivedGoods); } }
public async Task <OperationStatusInfo> AddProductGoods(object addedProduct, object addedArrivedGoods) { return(await Task.Run(() => { Dictionary <Type, object> collection = new Dictionary <Type, object>(); OperationStatusInfo operationStatusInfo = new OperationStatusInfo(operationStatus: OperationStatus.Done); string attachedProductObjectText = addedProduct.ToString(); string attachedArrivedGoodsObjectText = addedArrivedGoods.ToString(); Product newProduct = JsonConvert.DeserializeObject <Product>(attachedProductObjectText); ArrivedGoods newArrivedGoods = JsonConvert.DeserializeObject <ArrivedGoods>(attachedArrivedGoodsObjectText); AddProductGoodsRequest addProductGoodsRequest = new AddProductGoodsRequest(newProduct.Unit, newProduct.TareChange, newArrivedGoods.Count.ToString(), newArrivedGoods.Provider, newArrivedGoods.DateTime.ToString(), newProduct.Category, newProduct.Class, newProduct.ExpirationDate.ToString(), newArrivedGoods.AllPurchasePrice.ToString(), newArrivedGoods.AllSalesPrice.ToString(), newArrivedGoods.Department, newArrivedGoods.Seller, newProduct.Returned, newProduct.ReturnedDate.ToString(), newProduct.WritenOff); try { AddProductGoodsResponse addProductGoodsResponse = hubEnvironment.UseCaseFactory .Create <IUseCase <AddProductGoodsRequest, AddProductGoodsResponse> >() .Execute(addProductGoodsRequest); collection.Add(typeof(List <ArrivedGoods>), addProductGoodsResponse.ArrivedGoods); collection.Add(typeof(List <Product>), addProductGoodsResponse.Products); operationStatusInfo.AttachedObject = collection; operationStatusInfo.AttachedInfo = "Product is added!"; } catch (Exception ex) { Console.WriteLine(ex.Message); operationStatusInfo.OperationStatus = OperationStatus.Cancelled; operationStatusInfo.AttachedInfo = ex.Message; } return operationStatusInfo; })); }
public void Run(int id, string unit, Category category, Class class_, TareChange tareChange, int count, DateTime expirationDate, ArrivedGoods arrivedGoods, float purchasePrice, float salesPrice, bool returned, DateTime?returnedDate, bool writenOff) { Product product = null; productRepository.GetNewAll(); foreach (Product curProduct in productRepository.GetAll()) { if (id.Equals(curProduct.Id)) { product = new Product() { Id = id, Unit = unit, Category = category, Class = class_, TareChange = tareChange, Count = count, ExpirationDate = expirationDate, ArrivedGoods = arrivedGoods, PurchasePrice = purchasePrice, SalesPrice = salesPrice, Returned = returned, ReturnedDate = returnedDate, WritenOff = writenOff }; productRepository.Update(product); break; } } if (product == null) { throw new Exception("The product is not updated and not found!"); } }
private void EditProduct() { try { OperationStatusInfo operationStatusInfo = null; string unit = this.viewProduct.UnitTxt; TareChange tareChange = (TareChange)this.viewProduct.TareChangeList.SelectedItem; int count = int.Parse(this.viewProduct.CountTxt); Provider provider = (Provider)this.viewProduct.ProviderList.SelectedItem; DateTime dateTime = this.viewProduct.DatetimePick.SelectedDate.Value; Category category = (Category)this.viewProduct.CategoryList.SelectedItem; Class class_ = (Class)this.viewProduct.ClassList.SelectedItem; DateTime expirationDate = this.viewProduct.ExpirationDatePick.SelectedDate.Value; float allPurchasePrice = float.Parse(this.viewProduct.AllPurchasePriceTxt); float allSalesPrice = float.Parse(this.viewProduct.AllSalesPriceTxt); Department department = this.seller.Department; Seller seller = this.seller; bool returned = this.viewProduct.ReturnedChecked.Value; DateTime? returnedDate = this.viewProduct.ReturnedDatePick.SelectedDate; bool writenOff = this.viewProduct.WritenOffChecked.Value; Task task = Task.Run(async() => { ArrivedGoods arrivedGoods = new ArrivedGoods { Id = this.arrivedGoods.Id, Provider = provider, Count = count, DateTime = dateTime, AllPurchasePrice = allPurchasePrice, AllSalesPrice = allSalesPrice, Department = department, Seller = seller }; Product product = new Product { Id = this.product.Id, Unit = unit, TareChange = tareChange, Class = class_, Category = category, Count = count, ExpirationDate = expirationDate, ArrivedGoods = arrivedGoods, PurchasePrice = 0.0f, SalesPrice = 0.0f, Returned = returned, ReturnedDate = returnedDate, WritenOff = writenOff }; operationStatusInfo = await this.frontServiceClient.EditProductGoodsAsync(product, arrivedGoods); }); task.Wait(); if (operationStatusInfo != null) { this.viewProduct.ShowMsh(operationStatusInfo.AttachedInfo); } } catch (Exception ex) { this.viewProduct.ShowError(ex.InnerException.Message); } }
public void Run(string unit, Category category, Class class_, TareChange tareChange, int count, DateTime expirationDate, ArrivedGoods arrivedGoods, float purchasePrice, float salesPrice, bool returned, DateTime?returnedDate, bool writenOff) { Product newProduct = new Product() { Unit = unit, Category = category, Class = class_, TareChange = tareChange, Count = count, ExpirationDate = expirationDate, ArrivedGoods = arrivedGoods, PurchasePrice = purchasePrice, SalesPrice = salesPrice, Returned = returned, ReturnedDate = returnedDate, WritenOff = writenOff }; productRepository.Create(newProduct); }
public IViewModelProduct CreateViewModelProduct(int id, ArrivedGoods arrivedGoods, Product product, Seller seller, User user, IFrontServiceClient frontServiceClient) { return(new ViewModelProduct(validationRuleFactory.Create <IArrivedGoodsValidationRule>(), validationRuleFactory.Create <IProductValidationRule>(), mainWindowController, frontServiceClient, arrivedGoods, product, seller, user, id)); }
public async Task <OperationStatusInfo> EditProductGoodsAsync(Product product, ArrivedGoods arrivedGoods) { return(await this.systemProductGoodsController.EditProductGoodsAsync(product, arrivedGoods)); }
public IViewProduct CreateViewProduct(int id, ArrivedGoods arrivedGoods, Product product, Seller seller, User user, IFrontServiceClient frontServiceClient) { return(new ProductView(this.viewModelFactory.CreateViewModelProduct(id, arrivedGoods, product, seller, user, frontServiceClient))); }
public EditProductGoodsRequest(int id, string unit, TareChange tareChange, string count, Provider provider, string dateTime, Category category, Class class_, string expirationDate, ArrivedGoods arrivedGoods, string allPurchasePrice, string allSalesPrice, Department department, Seller seller, bool returned, string returnedDate, bool writenOff) { this.Id = id; this.Unit = unit; this.TareChange = tareChange; this.Count = count; this.Provider = provider; this.DateTime = dateTime; this.Category = category; this.Class = class_; this.ExpirationDate = expirationDate; this.ArrivedGoods = arrivedGoods; this.AllPurchasePrice = allPurchasePrice; this.AllSalesPrice = allSalesPrice; this.Department = department; this.Seller = seller; this.Returned = returned; this.ReturnedDate = returnedDate; this.WritenOff = writenOff; }
public async Task <OperationStatusInfo> EditProductGoodsAsync(Product product, ArrivedGoods arrivedGoods) { try { OperationStatusInfo operationStatusInfo = await this.systemSettings.Connection.InvokeAsync <OperationStatusInfo>("EditProductGoods", product, arrivedGoods); if (operationStatusInfo.OperationStatus == OperationStatus.Done) { return(operationStatusInfo); } else { throw new Exception(operationStatusInfo.AttachedInfo); } } catch (InvalidOperationException ex) { throw new Exception("Editing is not executed. Reason: Connection to server is absent now. Please, reconnect later", ex); } catch (Exception ex) { throw new Exception("Editing is not executed. Reason:" + ex.Message, ex); } }