public void Create(TareChange tareChange) { if (tareChange != null) { db.InsertTareChange(tareChange); } }
public void Delete(TareChange tareChange) { TareChange curTareChange = this.FindById(tareChange.Id); if (curTareChange != null) { db.DropTareChange(tareChange); db.TareChanges.Remove(curTareChange); } }
public void Update(TareChange tareChange) { if (tareChange != null) { for (int i = 0; i < this.GetAll().Count; i++) { if (db.Sellers[i].Id == tareChange.Id) { db.TareChanges[i].Name = tareChange.Name; } } db.UpdateTareChange(tareChange); } }
public void DropTareChange(TareChange tareChange) { try { this.OpenConnection(); string comand = "delete from TareChanges where id = '" + tareChange.Id.ToString() + "'"; SqlCommand sqlCom = new SqlCommand(comand, con); sqlCom.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Cannot delete the tare-change!", ex); } finally { this.Dispose(); } }
public List <TareChange> Run() { List <TareChange> tareChanges = new List <TareChange>(); tareChangeRepository.GetNewAll(); foreach (TareChange curTareChange in tareChangeRepository.GetAll()) { TareChange tareChange = new TareChange() { Id = curTareChange.Id, Name = curTareChange.Name }; tareChanges.Add(tareChange); } return(tareChanges); }
public void InsertTareChange(TareChange tareChange) { try { this.OpenConnection(); string comand = "Insert Into TareChanges(tare_change) Values(@tare_change)"; SqlCommand sqlCom = new SqlCommand(comand, con); sqlCom.Parameters.AddWithValue("@tare_change", tareChange.Name); sqlCom.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Cannot add the tare-change!", ex); } finally { this.Dispose(); } }
public void UpdateTareChange(TareChange tareChange) { try { this.OpenConnection(); string comand = "Update TareChanges Set tare_change=@tare_change Where Id=@Id"; SqlCommand sqlCom = new SqlCommand(comand, con); sqlCom.Parameters.AddWithValue("@Id", tareChange.Id); sqlCom.Parameters.AddWithValue("@tare_change", tareChange.Name); sqlCom.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Cannot update tare-change data!", ex); } finally { this.Dispose(); } }
public AddProductGoodsRequest(string unit, TareChange tareChange, string count, Provider provider, string dateTime, Category category, Class class_, string expirationDate, string allPurchasePrice, string allSalesPrice, Department department, Seller seller, bool returned, string returnedDate, bool writenOff) { 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.AllPurchasePrice = allPurchasePrice; this.AllSalesPrice = allSalesPrice; this.Department = department; this.Seller = seller; this.Returned = returned; this.ReturnedDate = returnedDate; this.WritenOff = writenOff; }
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 void ShowProductGoods() { try { if (this.id > 0) { if (this.product != null) { Provider provider = this.product.ArrivedGoods.Provider; TareChange tareChange = this.product.TareChange; Category category = this.product.Category; Class class_ = this.product.Class; this.viewProduct.UnitTxt = this.product.Unit; this.viewProduct.TareChangeList.SelectedIndex = SetSelectedIndex(this.product.TareChange); this.viewProduct.CountTxt = this.product.ArrivedGoods.Count.ToString(); this.viewProduct.ProviderList.SelectedIndex = SetSelectedIndex(this.product.ArrivedGoods.Provider); this.viewProduct.DatetimePick.Text = this.product.ArrivedGoods.DateTime.ToString(); this.viewProduct.CategoryList.SelectedIndex = SetSelectedIndex(this.product.Category); this.viewProduct.ClassList.SelectedIndex = SetSelectedIndex(this.product.Class); this.viewProduct.ExpirationDatePick.Text = this.product.ExpirationDate.ToString(); this.viewProduct.AllPurchasePriceTxt = this.product.ArrivedGoods.AllPurchasePrice.ToString(); this.viewProduct.AllSalesPriceTxt = this.product.ArrivedGoods.AllSalesPrice.ToString(); this.viewProduct.DepartmentTxt = this.product.ArrivedGoods.Department.Number.ToString(); this.viewProduct.SellerTxt = this.product.ArrivedGoods.Seller.Surname; this.viewProduct.ReturnedChecked = this.product.Returned; this.viewProduct.ReturnedDatePick.Text = this.product.ReturnedDate.ToString(); this.viewProduct.WritenOffChecked = this.product.WritenOff; } } } catch (Exception ex) { this.viewProduct.ShowError(ex.InnerException.Message); } }
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); } }