Esempio n. 1
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            var goods           = new AddGoods();
            int indexGoodInList = -1;

            if (dgvGoods.CurrentRow != null)
            {
                goods.NameGood = dgvGoods[colNameModel.Index, dgvGoods.CurrentRow.Index].Value.ToString();
                goods.Brand    = dgvGoods[colBrend.Index, dgvGoods.CurrentRow.Index].Value.ToString();
                goods.Price    = dgvGoods[colPrice.Index, dgvGoods.CurrentRow.Index].Value.ToString();

                indexGoodInList = _storageGood.Goods.FindIndex(f => f.Name == goods.NameGood);
            }
            if (goods.ShowDialog() == DialogResult.OK)
            {
                if (dgvGoods.CurrentRow != null)
                {
                    dgvGoods[colNameModel.Index, dgvGoods.CurrentRow.Index].Value = goods.Brand;
                    dgvGoods[colBrend.Index, dgvGoods.CurrentRow.Index].Value     = goods.Brand;
                    dgvGoods[colPrice.Index, dgvGoods.CurrentRow.Index].Value     = goods.Price;

                    _storageGood.Goods[indexGoodInList].Name  = goods.NameGood;
                    _storageGood.Goods[indexGoodInList].Date  = DateTime.Now;
                    _storageGood.Goods[indexGoodInList].Brend = goods.Brand;
                    _storageGood.Goods[indexGoodInList].Price = goods.Price;
                }
            }
        }
Esempio n. 2
0
        private void AddGoodsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var goods = new AddGoods();

            if (goods.ShowDialog() == DialogResult.OK)
            {
                dgvGoods.RowCount += 1;
                dgvGoods[colNameModel.Index, dgvGoods.RowCount - 1].Value = goods.NameGood;
                dgvGoods[colBrend.Index, dgvGoods.RowCount - 1].Value     = goods.Brand;
                dgvGoods[colPrice.Index, dgvGoods.RowCount - 1].Value     = goods.Price;

                var good = new Goods
                {
                    Date  = DateTime.Now,
                    Name  = goods.NameGood,
                    Brend = goods.Brand,
                    Price = goods.Price
                };
                _storageGood.Goods.Add(good);
            }
        }