Beispiel #1
0
        private void dataGridView1ReLoad()
        {
            double totalCost   = 0;
            double totalProfit = 0;

            // Products = HelperProduct.LoadUsersFromFile();
            Products = HelperProduct.LoadFromSql();
            dataGridView1.Rows.Clear();
            foreach (var item in Products)
            {
                dataGridView1.Rows.Add(item.setGridView1());
                totalCost   += (item.CountWarehouse + item.CountMarket) * item.Price;
                totalProfit += (item.CountWarehouse + item.CountMarket) * item.Price - (item.CountWarehouse + item.CountMarket) * item.PricePurchasing;
            }
            textBoxTotalCost.Text   = totalCost.ToString() + " " + "руб.";
            textBoxTotalProfit.Text = totalProfit.ToString() + " " + "руб.";
        }
Beispiel #2
0
        private void Cashier_Load(object sender, EventArgs e)
        {
            //Products = HelperProduct.LoadUsersFromFile();
            Products = HelperProduct.LoadFromSql();
            // for first creating file xml
            //Products.ForEach(it => { ProductSell pr = new ProductSell(); pr.Name = it.Name; pr.PriceSell = it.Price; pr.PriceBuy = it.PricePurchasing; pr.CountSell = 0; ProductsSell.Add(pr); });
            //HelperProductSell.SaveFromFile(ProductsSell);
            //ProductsSell =  HelperProductSell.LoadFromFile();
            ProductsSell = HelperProductSell.LoadFromSql();
            //int countEquals;
            foreach (Product product in Products)
            {
                // countEquals = 0;
                if (ProductsSell.Any(it => it.Name == product.Name))
                {
                    // countEquals++;
                    continue;
                }
                HelperProductSell.InsertToSql(product);

                /*foreach (ProductSell productSell in ProductsSell)
                 * {
                 *  if(product.Name == productSell.Name)
                 *  {
                 *      countEquals++;
                 *  }
                 * }*/
/*                if (countEquals == 0)
 *              {
 *                  ProductSell prSell = new ProductSell();
 *                  prSell.Name = product.Name;
 *                  prSell.PriceBuy = product.PricePurchasing;
 *                  prSell.PriceSell = product.Price;
 *                  prSell.CountSell = 0;
 *                  prSell.UoM = product.UoM;
 *                  ProductsSell.Add(prSell);
 *              }*/
            }
            //  HelperProductSell.SaveFromFile(ProductsSell);
            ProductsSell = HelperProductSell.LoadFromSql();
        }