Ejemplo n.º 1
0
        private void BtnSalesAdd_Click(object sender, EventArgs e)
        {
            string name    = tbProdName.Text;
            int    stock   = Convert.ToInt32(tbProdStock.Text);
            bool   ifThere = false;

            foreach (Product p in ProductManagment.ProductsDEPOT)
            {
                if (p.Name == name && p.Stocks >= stock)
                {
                    p.Stocks -= stock;
                    managment.UPDATEprodStockDepot(name);
                    double  price    = p.Price;
                    int     sold     = 0;
                    string  category = "SALES";
                    Product pS       = new Product(name, price, stock, sold, category, 0);
                    ProductManagment.ProductsSales.Add(pS);
                    conn.AddProductToDB(pS);
                    MessageBox.Show("Done!");
                    managment.AddProductinSALES(pS);
                    ifThere = true;
                }
            }
            if (ifThere == false)
            {
                MessageBox.Show("Product not found or not enough stock!");
            }
        }