public void CreateProduct()
        {
            var product = new Product();
            var f       = new ProductEditForm(product)
            {
                Text = "Новый продукт"
            };

            if (f.ShowDialog() == DialogResult.OK)
            {
                DataManager.ProductRepository.Insert(product);
                DataManager.Save();
                Products.Add(product);
                Products = Products.OrderBy(t => t.Name).ToList();

                FillProducts();

                foreach (ListViewItem lv in Form.ListProducts.Items)
                {
                    if (lv.Text == product.Name)
                    {
                        lv.Selected = true;
                        lv.Focused  = true;
                        lv.EnsureVisible();
                    }
                    else
                    {
                        lv.Selected = false;
                    }
                }
            }
        }
        private void OpenForm(ETipoEntidad entityType, long oid)
        {
            switch (entityType)
            {
            case ETipoEntidad.Producto:
            {
                ProductEditForm form = new ProductEditForm(oid, this);
                form.ShowDialog();
            } break;

            case ETipoEntidad.CurrencyExchange:
            {
                CurrencyExchangeUIForm form = new CurrencyExchangeUIForm(this);
                form.ShowDialog();
            } break;
            }
        }
        public void DeleteProduct(int id)
        {
            var product = Products.FirstOrDefault(t => t.Id == id);

            if (product == null)
            {
                return;
            }


            var f = new ProductEditForm(product)
            {
                Text = "Удалить продукт"
            };

            f.SetProductNameDisable(true);
            f.SetBtnSaveName("Удалить");

            if (f.ShowDialog() == DialogResult.OK)
            {
                DataManager.ProductRepository.Delete(product);
                DataManager.Save();

                var index = Products.IndexOf(product);

                Products.Remove(product);
                Products = Products.OrderBy(t => t.Name).ToList();
                FillProducts();

                if (Products.Count != 1)
                {
                    var newSelectedIndex = index - 1;
                    if (newSelectedIndex < 0)
                    {
                        newSelectedIndex = index;
                    }


                    var lv = ListProcucts.Items[newSelectedIndex];
                    lv.Selected = true;
                    lv.Focused  = true;
                    lv.EnsureVisible();
                }
            }
        }
        public void EditProduct(int id)
        {
            var product = Products.FirstOrDefault(t => t.Id == id);

            if (product == null)
            {
                return;
            }

            var f = new ProductEditForm(product)
            {
                Text = "Редактировать продукт"
            };

            if (f.ShowDialog() == DialogResult.OK)
            {
                DataManager.ProductRepository.Update(product);
                DataManager.Save();

                FillProducts();

                foreach (ListViewItem lv in Form.ListProducts.Items)
                {
                    if (lv.Text == product.Name)
                    {
                        lv.Selected = true;
                        lv.Focused  = true;
                        lv.EnsureVisible();
                    }
                    else
                    {
                        lv.Selected = false;
                    }
                }
            }
        }