/// <summary> /// Decrements the bin inventory. /// </summary> /// <param name="bin">The bin.</param> /// <returns></returns> public static int DecrementBinInventory(BinProduct bin) { List <BinProduct> binVends = new List <BinProduct>(); SqlParameter[] paramenters = new SqlParameter[2]; paramenters[0] = new SqlParameter("@BinID", bin.BinId); paramenters[1] = new SqlParameter("@Quantity", bin.Quantity); int result = SqlHelper.ExecuteNonQuery(BaseController.ConnectionString, "DecrementBinInventory", paramenters); return(result); }
/// <summary> /// Gets the total quantityby product. /// </summary> /// <param name="productType">Type of the product.</param> /// <returns></returns> public static BinProduct GetInventorybyBin(int BinID) { BinProduct binProduct = new BinProduct(); SqlParameter[] paramenters = new SqlParameter[1]; paramenters[0] = new SqlParameter("@BinID", BinID); SqlDataReader reader = SqlHelper.ExecuteReader(BaseController.ConnectionString, "GetInventorybyBin", paramenters); while (reader.Read()) { binProduct.Quantity = int.Parse(reader["PackageQuantity"].ToString()); binProduct.ProductID = int.Parse(reader["ProductID"].ToString()); binProduct.Enabled = bool.Parse(reader["Enabled"].ToString()); } return(binProduct); }
/// <summary> /// Gets the binsby product. /// </summary> /// <param name="productType">Type of the product.</param> /// <returns></returns> public static List <BinProduct> GetBinsbyProduct(ProductTypes productType) { List <BinProduct> binVends = new List <BinProduct>(); SqlParameter[] paramenters = new SqlParameter[1]; paramenters[0] = new SqlParameter("@Product", productType.ToString()); SqlDataReader reader = SqlHelper.ExecuteReader(BaseController.ConnectionString, "GetBinsbyProduct", paramenters); while (reader.Read()) { BinProduct bin = new BinProduct(); bin.BinId = SqlHelper.ToInt32(reader, "BinID"); bin.Quantity = SqlHelper.ToInt32(reader, "PackageQuantity"); binVends.Add(bin); } return(binVends); }
/// <summary> /// Vends the empty case. /// </summary> /// <param name="totalEmptyCases">The total empty cases.</param> public static void VendEmptyCase(int totalEmptyCases) { var totalBins = BaseDAL.GetTotalQuantitybyProduct(ProductTypes.Cartridge); bool isVendBinSuccess = false; int vendedFreeCases = 0; if (totalBins > 0) { VendEventArgs vendEventArgs = new VendEventArgs(totalEmptyCases); try { List <BinProduct> cartridgeBins = BaseDAL.GetBinsbyProduct(ProductTypes.Cartridge); foreach (BinProduct bin in cartridgeBins) { if (totalEmptyCases == 0) { break; } if (bin.Quantity > 0) { BinProduct decrementBin = new BinProduct { BinId = bin.BinId, Quantity = 0 }; for (int i = 0; i < bin.Quantity; i++) { if (totalEmptyCases == 0) { break; } isVendBinSuccess = BaseController.SendCommandToSerialPort(bin.BinId); if (isVendBinSuccess) { totalEmptyCases--; vendedFreeCases++; decrementBin.Quantity++; if (OnVending != null) { vendEventArgs.VendedEmptyCases = vendedFreeCases; OnVendingCase.Invoke(vendEventArgs); } } else { BaseDAL.DisableBin(bin.BinId); AlertController.TransactionFailureAlert("Bin " + bin.BinId.ToString() + " Disabled"); // Don't continue iterating through bin break; } } if (isVendBinSuccess && decrementBin.Quantity > 0) { BaseDAL.DecrementBinInventory(decrementBin); } isVendBinSuccess = false; } } using (KioskServiceClient proxy = new KioskServiceClient()) { // Update the members remaining free cases. proxy.EmptyCaseVend(BaseController.LoggedOnUser.MemberId, vendedFreeCases); proxy.Close(); } } catch (Exception ex) { Logger.Log(EventLogEntryType.Error, ex, BaseController.StationId); AlertController.TransactionFailureAlert(ex.Message); BaseController.RaiseOnThrowExceptionEvent(); } } }
public void Load() { #region Load Bins BinProduct binProduct = new BinProduct(); binProduct = BaseDAL.GetInventorybyBin(16); Bin16.Text = binProduct.Quantity.ToString(); Bin16Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin16.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(17); Bin17.Text = binProduct.Quantity.ToString(); Bin17Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin17.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(18); Bin18.Text = binProduct.Quantity.ToString(); Bin18Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin18.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(20); Bin20.Text = binProduct.Quantity.ToString(); Bin20Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin20.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(21); Bin21.Text = binProduct.Quantity.ToString(); Bin21Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin21.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(22); Bin22.Text = binProduct.Quantity.ToString(); Bin22Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin22.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(23); Bin23.Text = binProduct.Quantity.ToString(); Bin23Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin23.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(24); Bin24.Text = binProduct.Quantity.ToString(); Bin24Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin24.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(25); Bin25.Text = binProduct.Quantity.ToString(); Bin25Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin25.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(26); Bin26.Text = binProduct.Quantity.ToString(); Bin26Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin26.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(27); Bin27.Text = binProduct.Quantity.ToString(); Bin27Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin27.Foreground = Brushes.Red; } binProduct = BaseDAL.GetInventorybyBin(28); Bin28.Text = binProduct.Quantity.ToString(); Bin28Type.Content = GetProductType(binProduct.ProductID); if (!binProduct.Enabled) { Bin28.Foreground = Brushes.Red; } #endregion Bin16.DelayedFocus(); }