示例#1
0
        /// <summary>
        /// method wich fill the product and wine objects with the new wine details
        /// and insert the new wine to data base
        /// </summary>
        private void InsertNewWine()
        {
            newProduct            = new Product();
            newProduct.Name       = txtWineName.Text + " " + dtpWineYear.Text;
            newProduct.Price      = int.Parse(nudWinePriceBottle.Value.ToString());
            newProduct.Type       = "Wine";
            newProduct.Department = "Bar";
            newProduct.Status     = true;
            db.InsertNewProduct(newProduct);

            newWine             = new Wine();
            newWine.WineID      = db.GetProductIdByName(newProduct.Name);
            newWine.Name        = txtWineName.Text;
            newWine.Year        = dtpWineYear.Text;
            newWine.PriceBottle = int.Parse(nudWinePriceBottle.Value.ToString());
            newWine.PriceGlass  = int.Parse(nudWinePriceGlass.Value.ToString());
            newWine.Status      = cbWineStatus.Checked;
            db.InsertNewWine(newWine);
            db.InsertNewProductToStockByDate(newWine.WineID, 0);
            db.InsertNewProductToStockByYear(newWine.WineID, 0, DateTime.Now.Month, DateTime.Now.Year);
        }
示例#2
0
        /// <summary>
        /// method wich fill all the fields in the form with the
        /// details of the chosen wine
        /// </summary>
        private void FillSelectedWineData()
        {
            bool flag = true;

            string[] words  = lstWineList.SelectedItem.ToString().Split();
            int      wineId = int.Parse(words[0]);

            //loop to pass on all the wine array
            for (int i = 0; i < wineArray.Length && flag; i++)
            {
                if (wineArray[i].WineID == wineId)
                {
                    wineToUpdate = wineArray[i];
                    flag         = false;
                }
            }
            txtWineName.Text         = wineToUpdate.Name.ToString();
            dtpWineYear.Text         = "01-01-" + wineToUpdate.Year;
            nudWinePriceBottle.Value = wineToUpdate.PriceBottle;
            nudWinePriceGlass.Value  = wineToUpdate.PriceGlass;
            cbWineStatus.Checked     = wineToUpdate.Status;
        }