예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //write from list cashier to xml
            string name = "";
            double newCountProductSell = 0.00, newCountProduct = 0.00;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (Products.First(it => it.Name == row.Cells[0].Value.ToString()).CountMarket < Convert.ToDouble(row.Cells[2].Value.ToString()))
                {
                    MessageBox.Show("Товара " + row.Cells[0].Value.ToString() + " недостаточно в магазине", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    continue;
                }
                // ProductsSell.First(it => it.Name == row.Cells[0].Value.ToString()).CountSell+=Convert.ToDouble(row.Cells[2].Value.ToString());
                // Products.First(it => it.Name == row.Cells[0].Value.ToString()).CountMarket -= Convert.ToDouble(row.Cells[2].Value.ToString());
                name = row.Cells[0].Value.ToString();
                newCountProductSell = ProductsSell.First(it => it.Name == row.Cells[0].Value.ToString()).CountSell += Convert.ToDouble(row.Cells[2].Value.ToString());
                newCountProduct     = Products.First(it => it.Name == row.Cells[0].Value.ToString()).CountMarket -= Convert.ToDouble(row.Cells[2].Value.ToString());
                HelperProductSell.UpdateCountToSql(name, newCountProductSell);
                HelperProduct.UpdateCountToSql(name, newCountProduct);
            }
            // HelperProductSell.SaveFromFile(ProductsSell);
            // HelperProduct.SaveUsersFromFile(Products);
            Products.ForEach(UpdateProduct);
        }
예제 #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();
        }
예제 #3
0
        private void Manager_Load(object sender, EventArgs e)
        {
            var column1 = new DataGridViewColumn();

            column1.HeaderText   = "Название товара";
            column1.Width        = 100;
            column1.ReadOnly     = true;
            column1.Name         = "name";
            column1.Frozen       = true;
            column1.CellTemplate = new DataGridViewTextBoxCell();

            var column2 = new DataGridViewColumn();

            column2.HeaderText   = "Количество товара на складе";
            column2.Width        = 100;
            column2.ReadOnly     = true;
            column2.Name         = "countStore";
            column2.Frozen       = true;
            column2.CellTemplate = new DataGridViewTextBoxCell();

            var column3 = new DataGridViewColumn();

            column3.HeaderText   = "Количество товара в магазине";
            column3.Width        = 100;
            column3.ReadOnly     = true;
            column3.Name         = "countShop";
            column3.Frozen       = true;
            column3.CellTemplate = new DataGridViewTextBoxCell();

            var column4 = new DataGridViewColumn();

            column4.HeaderText   = "Цена закупки";
            column4.Width        = 100;
            column4.ReadOnly     = true;
            column4.Name         = "priceBuy";
            column4.Frozen       = true;
            column4.CellTemplate = new DataGridViewTextBoxCell();

            var column5 = new DataGridViewColumn();

            column5.HeaderText   = "Цена продажи";
            column5.Width        = 100;
            column5.ReadOnly     = true;
            column5.Name         = "priceSell";
            column5.Frozen       = true;
            column5.CellTemplate = new DataGridViewTextBoxCell();

            var column6 = new DataGridViewColumn();

            column6.HeaderText   = "Общая стоимость товара";
            column6.Width        = 100;
            column6.ReadOnly     = true;
            column6.Name         = "totalCost";
            column6.Frozen       = true;
            column6.CellTemplate = new DataGridViewTextBoxCell();

            var column7 = new DataGridViewColumn();

            column7.HeaderText   = "Плановая маржа";
            column7.Width        = 100;
            column7.ReadOnly     = true;
            column7.Name         = "profitPlan";
            column7.Frozen       = true;
            column7.CellTemplate = new DataGridViewTextBoxCell();

            dataGridView1.Columns.Add(column1);
            dataGridView1.Columns.Add(column2);
            dataGridView1.Columns.Add(column3);
            dataGridView1.Columns.Add(column4);
            dataGridView1.Columns.Add(column5);
            dataGridView1.Columns.Add(column6);
            dataGridView1.Columns.Add(column7);

            // var row = new DataGridViewRow();
            // var cell = new DataGridView();
            dataGridView1ReLoad();

            double totalCost2   = 0;
            double totalProfit2 = 0;

            // ProductsSell = HelperProductSell.LoadFromFile();
            ProductsSell = HelperProductSell.LoadFromSql();
            foreach (var item in ProductsSell)
            {
                dataGridView2.Rows.Add(item.setGridView2());
                totalCost2   += item.SumSell;
                totalProfit2 += item.ProfitSell;
            }
            textBox1.Text = totalCost2.ToString() + " " + "руб.";
            textBox2.Text = totalProfit2.ToString() + " " + "руб.";

            UsersViewReload();
            comboBox3.Items.Add(UserRole.Cashier);
            comboBox3.Items.Add(UserRole.Manager);

            comboBox1.Items.Add(UoM.Piece);
            comboBox1.Items.Add(UoM.Kg);
            comboBox1.Items.Add(UoM.Liter);
            comboBox1.Items.Add(UoM.Cans);

            comboBox2.Items.Add("Shop");
            comboBox2.Items.Add("Warehouse");
        }