Example #1
0
        private void Add_Click(object sender, EventArgs e)
        {
            var product = new ProductForm(new Product());
            var res     = product.ShowDialog(this);

            if (res == DialogResult.OK)
            {
                ProductList.Items.Add(product.Prod);
            }
            CostUD.Value += (decimal)product.Prod.Amount * (decimal)product.Prod.Cost;
            Save.Enabled  = true;
        }
Example #2
0
        private void ProductList_DoubleClick(object sender, EventArgs e)
        {
            var prod = ProductList.SelectedItem as Product;

            if (prod == null)
            {
                return;
            }
            CostUD.Value -= (decimal)prod.Amount * (decimal)prod.Cost;
            var form = new ProductForm(prod.Clone());
            var res  = form.ShowDialog(this);

            if (res == DialogResult.OK)
            {
                var si = ProductList.SelectedIndex;
                ProductList.Items.Remove(ProductList.SelectedItem);
                ProductList.Items.Insert(si, form.Prod);
            }
            CostUD.Value += (decimal)form.Prod.Amount * (decimal)form.Prod.Cost;
        }