/// <summary> /// Alissa Duffy /// Updated: 2017/04/21 /// /// Initialize Manage Stock Sub Adjust Qty Window. /// Standardized method. /// </summary> /// <param name="oldProductLot"></param> public frmManageStockSubAdjustQty(ProductLot oldProductLot) { InitializeComponent(); _oldProductLot = oldProductLot; _newQuantity = oldProductLot.AvailableQuantity; SetupWindow(); }
/// <summary> /// Aaron Usher /// Updated: /// 2017/04/21 /// /// Deletes a product lot from the database. /// </summary> /// /// <remarks> /// Aaron Usher /// Updated: /// 2017/04/21 /// /// Standardized method. /// </remarks> /// /// <param name="productLot">The product lot to delete.</param> /// <returns>Rows affected.</returns> public static int DeleteProductLot(ProductLot productLot) { var rows = 0; var conn = DBConnection.GetConnection(); var cmdText = @"sp_delete_product_lot"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PRODUCT_LOT_ID", productLot.ProductLotId); try { conn.Open(); rows = cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } return(rows); }
public void PurchasePossibleCheckAmountTest() { Product apple = new Product("Яблоко"); Product banana = new Product("Банан"); Product milk = new Product("Молоко"); Shop.Shop shop1 = new Shop.Shop("Пятёрочка", "Хвостовая ул. д.239"); shop1.AddProduct(apple, new ProductStatus(25, 1836)); shop1.AddProduct(banana, new ProductStatus(34, 993)); shop1.AddProduct(milk, new ProductStatus(67, 378)); var lot = new ProductLot(new List <ProductRequest> { new ProductRequest(apple, new ProductStatus(45)), new ProductRequest(banana, new ProductStatus(103)), new ProductRequest(milk, new ProductStatus(15)), }); shop1.BuyLotOfProducts(lot); var appleAmount = shop1.Products .Where(x => x.Product.Id == apple.Id) .Select(x => x.ProductStatus.Amount) .FirstOrDefault(); Assert.AreEqual(1791, appleAmount); }
public void SomeProductsAvailableOnlyInOneShopTest() { Product apple = new Product("Яблоко"); Product banana = new Product("Банан"); Product milk = new Product("Молоко"); Shop.Shop shop1 = new Shop.Shop("Пятёрочка", "Хвостовая ул. д.239"); shop1.AddProduct(apple, new ProductStatus(25, 1836)); shop1.AddProduct(banana, new ProductStatus(34, 993)); Shop.Shop shop2 = new Shop.Shop("Перекрёсток", "Денежная ул. д.98"); shop2.AddProduct(apple, new ProductStatus(30, 832)); shop2.AddProduct(banana, new ProductStatus(41, 892)); shop2.AddProduct(milk, new ProductStatus(478)); Shop.Shop shop3 = new Shop.Shop("Дикси", "Лесной пр-кт д.9"); shop3.AddProduct(apple, new ProductStatus(19, 1938)); shop3.AddProduct(banana, new ProductStatus(41, 892)); var shopList = new List <Shop.Shop> { shop1, shop2, shop3 }; ShopList shops = new ShopList(shopList); var lot = new ProductLot(new List <ProductRequest> { new ProductRequest(apple, new ProductStatus(10)), new ProductRequest(banana, new ProductStatus(10)), new ProductRequest(milk, new ProductStatus(10)) }); var shop = shops.GetShopWithLowestSumOnLot(lot); Assert.AreEqual("Перекрёсток", shop.Name); }
public bool UpDateProductLot(ProductLot oProductLot, int nEditID) { try { SqlCommand cmd = new SqlCommand("SP_ProductLot_Update", _conn); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.Add(new SqlParameter("@LotNo", SqlDbType.VarChar)).Value = oProductLot.LotNo; //cmd.Parameters.Add(new SqlParameter("@Pro_ID", SqlDbType.Int)).Value = oProductLot.Pro_ID; //cmd.Parameters.Add(new SqlParameter("@barCode", SqlDbType.VarChar)).Value = oProductLot.barCode; cmd.Parameters.Add(new SqlParameter("@Total_Qty", SqlDbType.Decimal)).Value = oProductLot.Total_Qty; cmd.Parameters.Add(new SqlParameter("@Bag_Qty", SqlDbType.Decimal)).Value = oProductLot.Bag_Qty; cmd.Parameters.Add(new SqlParameter("@Sale_Qty", SqlDbType.Decimal)).Value = oProductLot.Sale_Qty; cmd.Parameters.Add(new SqlParameter("@Ret_Qty", SqlDbType.Decimal)).Value = oProductLot.Ret_Qty; cmd.Parameters.Add(new SqlParameter("@purchesPrice", SqlDbType.Decimal)).Value = oProductLot.purchesPrice; cmd.Parameters.Add(new SqlParameter("@salePrice", SqlDbType.Decimal)).Value = oProductLot.salePrice; cmd.Parameters.Add(new SqlParameter("@DBUUID", SqlDbType.Int)).Value = EMSGlobal._nCurrentUserID; cmd.Parameters.Add(new SqlParameter("@Lot_ID", SqlDbType.Int)).Value = nEditID; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } cmd.ExecuteNonQuery(); cmd.Dispose(); cmd.Connection.Close(); return(true); } catch (Exception e) { throw new ServiceException(e.Message, e); } }
public ProductLot GetByID(int nID) { ProductLot oProductLot = new ProductLot(); try { SqlCommand cmd = new SqlCommand("SP_ProductLot_GetByID", _conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Lot_ID", SqlDbType.Int)).Value = nID; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } IDataReader reader = cmd.ExecuteReader(); NullHandler oReader = new NullHandler(reader); if (reader.Read()) { oProductLot = CreateObject(oReader); } cmd.Dispose(); cmd.Connection.Close(); } catch (Exception e) { throw new ServiceException(e.Message, e); } return(oProductLot); }
public void SomeProductsNotAvailableTest() { Product apple = new Product("Яблоко"); Product banana = new Product("Банан"); Product milk = new Product("Молоко"); Shop.Shop shop1 = new Shop.Shop("Пятёрочка", "Хвостовая ул. д.239"); shop1.AddProduct(apple, new ProductStatus(25, 1836)); shop1.AddProduct(banana, new ProductStatus(34, 993)); Shop.Shop shop2 = new Shop.Shop("Перекрёсток", "Денежная ул. д.98"); shop2.AddProduct(apple, new ProductStatus(30, 832)); shop2.AddProduct(banana, new ProductStatus(41, 892)); Shop.Shop shop3 = new Shop.Shop("Дикси", "Лесной пр-кт д.9"); shop3.AddProduct(apple, new ProductStatus(19, 1938)); shop3.AddProduct(banana, new ProductStatus(41, 892)); var shopList = new List <Shop.Shop> { shop1, shop2, shop3 }; ShopList shops = new ShopList(shopList); var lot = new ProductLot(new List <ProductRequest> { new ProductRequest(apple, new ProductStatus(10)), new ProductRequest(banana, new ProductStatus(10)), new ProductRequest(milk, new ProductStatus(10)) }); var result = Assert.ThrowsException <ShopNotFoundException>(() => shops.GetShopWithLowestSumOnLot(lot)); Assert.AreEqual("Shop was not found!", result.Message); }
private ProductLot CreateObject(NullHandler oReader) { ProductLot oProductLot = new ProductLot(); MapObject(oProductLot, oReader); return(oProductLot); }
/// <summary> /// Alissa Duffy /// Updated: 2017/04/21 /// /// Initialize of Add Product Lot View Window. /// Standardized method. /// </summary> /// <param name="prodMgr"></param> /// <param name="prodLot"></param> public frmAddProductLot(ProductLotManager prodMgr, ProductLot prodLot) { InitializeComponent(); _productLotManager = prodMgr; _productLot = prodLot; FillProductLotDetails(_productLot); }
/// <summary> /// Christian Lopez /// 2017/03/29 /// /// Move an item from the product lot table to the invoice line table /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddToInvoice_Click(object sender, RoutedEventArgs e) { if (dgSupplierProductLots.SelectedIndex >= 0) { ProductLot productLot = (ProductLot)dgSupplierProductLots.SelectedItem; SupplierInvoiceLine invoiceLine = new SupplierInvoiceLine() { ProductLotId = (int)productLot.ProductLotId, QuantitySold = (int)productLot.Quantity }; try { invoiceLine.PriceEach = Decimal.Parse(txtPriceEach.Text); invoiceLine.ItemDiscount = Decimal.Parse(txtDiscount.Text); } catch (Exception) { MessageBox.Show("Unable to convert to decimal"); } invoiceLine.ItemTotal = (invoiceLine.PriceEach * invoiceLine.QuantitySold - invoiceLine.ItemDiscount); _invoiceLines.Add(invoiceLine); _productLots.Remove(productLot); updateDataGrids(); txtDiscount.Text = "0.00"; txtPriceEach.Text = "0.00"; invoiceSubtotalCost += invoiceLine.ItemTotal; invoiceTax = Decimal.Round(invoiceSubtotalCost * (decimal)taxRate, 2, MidpointRounding.AwayFromZero); invoiceTotalCost = invoiceSubtotalCost + invoiceTax; lblSubtotalValue.Content = invoiceSubtotalCost.ToString(); lblTaxAmount.Content = invoiceTax.ToString(); lblTotalAmount.Content = invoiceTotalCost.ToString(); } }
/// <summary> /// Robert Forbes /// 2017/02/07 /// /// Attempts to run the data access method CreatePackageLine(PackageLine proposed) to create a new package line /// </summary> /// <param name="line">The line to be added to the database</param> /// <returns>bool representing if the package line was successfully added</returns> public bool CreatePackageLine(PackageLine line) { bool result = false; try { ProductLot lot = ProductLotAccessor.RetrieveProductLot(line.ProductLotId); int?newAvailableQuantity = lot.AvailableQuantity - line.Quantity; //Trying to take the quantity in the package line out of the product lot table to update stock levels if (ProductLotAccessor.UpdateProductLotAvailableQuantity(line.ProductLotId, lot.AvailableQuantity, newAvailableQuantity) > 0) { //if the product lot quantity could be updated then create the package line if (PackageLineAccessor.CreatePackageLine(line) > 0) { result = true; } else //Trying to add the quantity back to the product lot since the package line couldn't be created { ProductLotAccessor.UpdateProductLotAvailableQuantity(line.ProductLotId, newAvailableQuantity, lot.AvailableQuantity); } } } catch (Exception) { throw; } return(result); }
/// <summary> /// Alissa Duffy /// Updated: 2017/04/21 /// /// Initialize the Split Product Lot Window. /// Standardized method. /// </summary> /// <param name="selectedItem"></param> public frmSplitProductLot(ProductLot selectedItem) { InitializeComponent(); OldQty = selectedItem.Quantity ?? 0; NewQty = 0; txtOld.Text = OldQty.ToString(); txtNew.Text = NewQty.ToString(); }
/// <summary> /// Created by Michael Takrama /// 2017/03/02 /// Updates Available Quantity of Product Lot /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdateQuantity_OnClick(object sender, RoutedEventArgs e) { if (dgProductList.SelectedItem == null) { MessageBox.Show("Kindly select a product lot"); return; } var selectedProductLot = (ManageStockViewModel)dgProductList.SelectedItem; var selectedIndex = dgProductList.SelectedIndex; var oldProductLot = _productLotList.Find(x => x.ProductLotId == selectedProductLot.ProductLotId); //Open sub form for update var valueFromSubUdateView = new frmManageStockSubAdjustQty(oldProductLot); valueFromSubUdateView.ShowDialog(); var newProductLot = new ProductLot { ProductLotId = oldProductLot.ProductLotId, WarehouseId = oldProductLot.WarehouseId, SupplierId = oldProductLot.SupplierId, LocationId = oldProductLot.LocationId, ProductId = oldProductLot.ProductId, SupplyManagerId = oldProductLot.SupplyManagerId, Quantity = oldProductLot.Quantity, AvailableQuantity = valueFromSubUdateView.getNewQuantity(), DateReceived = oldProductLot.DateReceived, ExpirationDate = oldProductLot.ExpirationDate }; if (ValidateQuantityUpdates(newProductLot, oldProductLot)) { return; } try { if (_productLotManager.UpdateProductLotAvailableQuantity(oldProductLot, newProductLot) == 1) { MessageBox.Show("Quantity Updated Successfully"); RetrieveProductLots(); ParseLotsIntoViewModel(); RefreshDgProductLot(); dgProductList.SelectedIndex = selectedIndex; } else { MessageBox.Show("Error Updating quantity. Kindly refresh and try again"); } } catch (Exception ex) { MessageBox.Show("Error occured in update." + ex.Message); } }
/// <summary> /// Created by Michael Takrama /// 3/2/2017 /// /// Updates Product Lot Available Quantity /// </summary> /// <param name="oldProductLot"></param> /// <param name="newProductLot"></param> /// <returns></returns> public int UpdateProductLotAvailableQuantity(ProductLot oldProductLot, ProductLot newProductLot) { int result = 0; result = ProductLotAccessor.UpdateProductLotAvailableQuantity(oldProductLot.ProductLotId, oldProductLot.AvailableQuantity, newProductLot.AvailableQuantity); return(result); }
/// <summary> /// Alissa Duffy /// Updated: 2017/04/21 /// /// Saves Changes to Product Lot View. /// Standardized method. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPost_Click(object sender, RoutedEventArgs e) { int quantityRead = 0; bool shouldPost = cboLocationIDVal.SelectedIndex >= 0; shouldPost = shouldPost && cboProductIDVal.SelectedIndex >= 0; shouldPost = shouldPost && cboSupplierIDVal.SelectedIndex >= 0; shouldPost = shouldPost && cboSupplyManagerIDVal.SelectedIndex >= 0; shouldPost = shouldPost && cboWarehouseIDVal.SelectedIndex >= 0; if (!Int32.TryParse(txtQuantity.Text, out quantityRead) && quantityRead >= 0) { shouldPost = false; MessageBox.Show("Quantity needs a whole number value"); } if (null == dpDateReceived.SelectedDate) { shouldPost = false; MessageBox.Show("Add a date for Date Received"); } if (null == dpExpirationDate.SelectedDate) { shouldPost = false; MessageBox.Show("Add a date for the Expiration Date"); } if (shouldPost) { ProductLot toSave = new ProductLot() { ProductId = _productList[cboProductIDVal.SelectedIndex].ProductId, LocationId = _locationList[cboLocationIDVal.SelectedIndex].LocationId, SupplierId = _supplierList[cboSupplierIDVal.SelectedIndex].SupplierID, SupplyManagerId = (int)_employeeList[cboSupplyManagerIDVal.SelectedIndex].EmployeeId, WarehouseId = _warehouseList[cboWarehouseIDVal.SelectedIndex].WarehouseID, Quantity = quantityRead, AvailableQuantity = quantityRead, DateReceived = dpDateReceived.SelectedDate, ExpirationDate = dpExpirationDate.SelectedDate }; try { _productLotManager.CreateProductLot(toSave); MessageBox.Show("Product Lot Added"); try { supplierId = _supplierList[cboSupplierIDVal.SelectedIndex].SupplierID; } catch (Exception) { throw; } this.DialogResult = true; } catch (System.Data.SqlClient.SqlException ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// Eric Walton /// Created: 2017/03/24 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void productSelected(object sender, EventArgs e) { if (cboProducts.SelectedIndex >= 0) { _currentlySelectedProductLot = _productLots[cboProducts.SelectedIndex]; txtAvailableProduct.Text = _currentlySelectedProductLot.Quantity.ToString(); lblProductGradeResult.Content = _currentlySelectedProductLot.Grade.ToString(); lblProductPrice.Content = "$" + _currentlySelectedProductLot.Price.ToString(); } }
private ProductLots CreateObjects(IDataReader oReader) { ProductLots oProductLots = new ProductLots(); NullHandler oHandler = new NullHandler(oReader); while (oReader.Read()) { ProductLot oItem = CreateObject(oHandler); oProductLots.Add(oItem); } return(oProductLots); }
/// <summary> /// Alissa Duffy /// Updated: 2017/04/24 /// /// Initialize the Add Inspection form. /// Standardized method. /// </summary> /// <param name="productLot"></param> /// <param name="gradeManager"></param> /// <param name="currentEmp"></param> /// <param name="productManager"></param> /// <param name="supplierManager"></param> /// <param name="InspectionManager"></param> /// <param name="productLotManager"></param> public frmAddInspection(ProductLot productLot, IGradeManager gradeManager, Employee currentEmp, IProductManager productManager, ISupplierManager supplierManager, IInspectionManager InspectionManager, IProductLotManager productLotManager) { _gradeManager = gradeManager; _productLot = productLot; _currentEmp = currentEmp; _productManager = productManager; _supplierManager = supplierManager; _inspectionManager = InspectionManager; _productLotManager = productLotManager; InitializeComponent(); }
/// <summary> /// William Flood /// Created: 2017/02/15 /// /// Manages the logic regarding adding a Product Lot. /// </summary> /// /// <remarks> /// Aaron Usher /// Updated 2017/04/06 /// /// Changed to work with static accessor class; standardized. /// </remarks> /// <param name="productLot">The product lot to add.</param> /// <returns>Whether or not the product lot was created successfully.</returns> public bool CreateProductLot(ProductLot productLot) { bool result = false; try { result = (1 == ProductLotAccessor.CreateProductLot(productLot)); } catch { throw; } return(result); }
public async Task <ProductLot> AlterQuantity(ProductLot productLot, AlterQuantityDelegate @delegate) { var alterProductLotQuantityRequest = GraphQLMutationManager.GetMutationRequest( GraphQLMutationManager.MutationRequest.AlterProductLotQuantity, new { ProductLotId = productLot.Id, NewQuantity = @delegate(productLot.Quantity) }); var alterProductLotQuantityResponse = await this._Client.PostAsync(alterProductLotQuantityRequest); var alterProductLotQuantityResult = alterProductLotQuantityResponse.GetDataFieldAs <InsertResult <ProductLot> >("update_ProductLot"); return(alterProductLotQuantityResult.Result.First()); }
/// <summary> /// Created by Michael Takram /// 2017/04/02 /// Validates quantities from user /// </summary> /// <param name="newProductLot"></param> /// <param name="oldProductLot"></param> /// <returns></returns> private static bool ValidateQuantityUpdates(ProductLot newProductLot, ProductLot oldProductLot) { if (newProductLot.AvailableQuantity == oldProductLot.AvailableQuantity) { MessageBox.Show("No changes mades."); return(true); } if (newProductLot.AvailableQuantity > oldProductLot.Quantity) { MessageBox.Show("New Available cannot be higher than quantity for product lot. Updates not effected"); return(true); } return(false); }
/// <summary> /// Ryan Spurgetis /// 2017/03/24 /// Sends the new price to update product lot price from inspection /// </summary> /// <param name="prodLot"></param> /// <param name="newPrice"></param> /// <returns></returns> public int UpdateProductLotPrice(ProductLot prodLot, decimal newPrice) { int result = 0; int prodLotId = (int)prodLot.ProductLotId; try { result = ProductLotAccessor.UpdateProductPrice(prodLotId, newPrice); } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// Ethan Jorgensen /// 2017/03/23 /// /// Sets a product lot inactive. /// </summary> /// <returns></returns> public bool DeleteProductLot(ProductLot lot) { bool result = false; try { result = 1 == ProductLotAccessor.DeleteProductLot(lot); } catch (Exception) { throw; } return(result); }
/// <summary> /// Robert Forbes /// Created: /// 2017/02/16 /// /// Gets a product lot object using the given id /// </summary> /// /// <remarks> /// Aaron Usher /// Updated: /// 2017/04/21 /// /// Standardized method. /// </remarks> /// /// <param name="productLotID">the id to search on</param> /// <returns>A product lot</returns> public static ProductLot RetrieveProductLot(int?productLotID) { ProductLot productLot = null; var conn = DBConnection.GetConnection(); var cmdText = @"sp_retrieve_product_lot"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PRODUCT_LOT_ID", productLotID); try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); productLot = new ProductLot() { ProductLotId = reader.GetInt32(0), WarehouseId = reader.GetInt32(1), SupplierId = reader.GetInt32(2), LocationId = reader.GetInt32(3), ProductId = reader.GetInt32(4), SupplyManagerId = reader.GetInt32(5), Quantity = reader.GetInt32(6), AvailableQuantity = reader.GetInt32(7), DateReceived = reader.GetDateTime(8), ExpirationDate = reader.GetDateTime(9) }; } } catch (Exception) { throw; } finally { conn.Close(); } return(productLot); }
/// <summary> /// Christian Lopez /// 2017/03/29 /// /// Returns a product lot associated with that id /// </summary> /// <param name="id"></param> /// <returns></returns> public ProductLot RetrieveProductLotById(int id) { try { ProductLot lot = ProductLotAccessor.RetrieveProductLotById(id); ProductManager pm = new ProductManager(); lot.ProductName = (pm.RetrieveProductById((int)lot.ProductId)).Name; return(lot); } catch (SqlException ex) { throw new ApplicationException("There was a database error.", ex); } catch (Exception ex) { throw new ApplicationException("There was an unknown error.", ex); } }
/// <summary> /// Ryan Spurgetis /// 3/24/2017 /// /// Populates the fields of product lot window based on clicked product lot /// </summary> /// <param name="_productLot"></param> public void FillProductLotDetails(ProductLot _productLot) { btnClose.Content = "Close"; try { lblSupplierVal.Content = _productLot.SupplierId; lblWarehouseIDVal.Content = _productLot.WarehouseId; lblProductVal.Content = _productLot.ProductName; lblLocationIDVal.Content = _productLot.LocationId; lblQuantityVal.Content = _productLot.Quantity; lblSupplyManagerIDVal.Content = _productLot.SupplyManagerId; dpExpirationDate.SelectedDate = _productLot.ExpirationDate; dpDateReceived.SelectedDate = _productLot.DateReceived; } catch (Exception ex) { MessageBox.Show("An error occured", ex.Message + ex.StackTrace); } }
/// <summary> /// Christian Lopez /// 2017/02/22 /// </summary> /// <param name="supplier"></param> /// <returns></returns> public ProductLot RetrieveNewestProductLotBySupplier(Supplier supplier) { ProductLot pl = null; if (null != supplier) { try { pl = ProductLotAccessor.RetrieveNewestProductLotBySupplier(supplier); } catch (SqlException ex) { throw new ApplicationException("There was a database error.", ex); } catch (Exception ex) { throw new ApplicationException("There was an unknown error.", ex); } } return(pl); }
public ID Save(ProductLot oProductLot) { try { if (oProductLot.IsNew) { SqlCommand cmd = new SqlCommand("SP_ProductLot_Insert", _conn); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.Add(new SqlParameter("@LotNo", SqlDbType.VarChar)).Value = oProductLot.LotNo; cmd.Parameters.Add(new SqlParameter("@Pro_ID", SqlDbType.Int)).Value = oProductLot.Pro_ID; //cmd.Parameters.Add(new SqlParameter("@barCode", SqlDbType.VarChar)).Value = oProductLot.barCode; cmd.Parameters.Add(new SqlParameter("@Total_Qty", SqlDbType.Decimal)).Value = oProductLot.Total_Qty; cmd.Parameters.Add(new SqlParameter("@Bag_Qty", SqlDbType.Decimal)).Value = oProductLot.Bag_Qty; //cmd.Parameters.Add(new SqlParameter("@Sale_Qty", SqlDbType.Decimal)).Value = oProductLot.Sale_Qty; //cmd.Parameters.Add(new SqlParameter("@Ret_Qty", SqlDbType.Decimal)).Value = oProductLot.Ret_Qty; cmd.Parameters.Add(new SqlParameter("@purchesPrice", SqlDbType.Decimal)).Value = oProductLot.purchesPrice; cmd.Parameters.Add(new SqlParameter("@salePrice", SqlDbType.Decimal)).Value = oProductLot.salePrice; cmd.Parameters.Add(new SqlParameter("@DBUserID", SqlDbType.Int)).Value = EMSGlobal._nCurrentUserID; if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } string NewID = (string)cmd.ExecuteScalar(); oProductLot.LotNo = NewID; cmd.Dispose(); cmd.Connection.Close(); BusinessObject.Factory.SetID(oProductLot, new ID(1)); } BusinessObject.Factory.SetObjectState(oProductLot, ObjectState.Saved); } catch (Exception e) { throw new ServiceException(e.Message, e); } return(oProductLot.ID); }
public void PurchasePossibleCheckSumTest() { Product apple = new Product("Яблоко"); Product banana = new Product("Банан"); Product milk = new Product("Молоко"); Shop.Shop shop1 = new Shop.Shop("Пятёрочка", "Хвостовая ул. д.239"); shop1.AddProduct(apple, new ProductStatus(25, 1836)); shop1.AddProduct(banana, new ProductStatus(34, 993)); shop1.AddProduct(milk, new ProductStatus(67, 378)); var lot = new ProductLot(new List <ProductRequest> { new ProductRequest(apple, new ProductStatus(45)), new ProductRequest(banana, new ProductStatus(103)), new ProductRequest(milk, new ProductStatus(15)), }); var sum = shop1.BuyLotOfProducts(lot); Assert.AreEqual(5632.0m, sum); }
public void PurchaseNotPossibleTest() { Product apple = new Product("Яблоко"); Product banana = new Product("Банан"); Product milk = new Product("Молоко"); Shop.Shop shop1 = new Shop.Shop("Пятёрочка", "Хвостовая ул. д.239"); shop1.AddProduct(apple, new ProductStatus(25, 1836)); shop1.AddProduct(banana, new ProductStatus(34, 993)); shop1.AddProduct(milk, new ProductStatus(67, 378)); var lot = new ProductLot(new List <ProductRequest> { new ProductRequest(apple, new ProductStatus(45000)), new ProductRequest(banana, new ProductStatus(103)), new ProductRequest(milk, new ProductStatus(15)), }); var result = Assert.ThrowsException <ImpossibleToBuyLotException>(() => shop1.BuyLotOfProducts(lot)); Assert.AreEqual("Impossible to buy this lot!", result.Message); }