예제 #1
0
파일: Form1.cs 프로젝트: ssashkaa01/wf
        private void buttonDetails_Click(object sender, EventArgs e)
        {
            if (listProducts.SelectedIndex != -1)
            {
                Product product = (Product)products.Where(prod => prod.GetID() == listProducts.Text).FirstOrDefault();

                using (ProductForm form = new ProductForm())
                {
                    form.SetButtonText("Закрити");
                    form.DisableForm();
                    form.SetName(product.name);
                    form.SetPrice(product.price);
                    form.SetSale(product.sale);
                    form.SetCountry(product.country);
                    form.SetCount(product.count);

                    form.ShowDialog(this);
                }
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: ssashkaa01/wf
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listProducts.SelectedIndex != -1)
            {
                Product product = (Product)products.Where(prod => prod.GetID() == listProducts.Text).FirstOrDefault();

                using (ProductForm form = new ProductForm())
                {
                    form.SetButtonText("Редагувати");
                    form.SetName(product.name);
                    form.SetPrice(product.price);
                    form.SetSale(product.sale);
                    form.SetCountry(product.country);
                    form.SetCount(product.count);

                    form.ShowDialog(this);

                    if (form.DialogResult == DialogResult.OK)
                    {
                        int index = products.IndexOf(product);

                        products.RemoveAt(index);

                        Product edit = new Product()
                        {
                            name    = form.GetName(),
                            count   = form.GetCount(),
                            sale    = form.GetSale(),
                            price   = form.GetPrice(),
                            country = form.GetCountry()
                        };

                        products.Insert(index, edit);
                        ReloadList();
                    }
                }
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: ssashkaa01/wf
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            using (ProductForm form = new ProductForm())
            {
                form.SetButtonText("Створити");
                form.ShowDialog(this);

                if (form.DialogResult == DialogResult.OK)
                {
                    Product product = new Product()
                    {
                        name    = form.GetName(),
                        count   = form.GetCount(),
                        sale    = form.GetSale(),
                        price   = form.GetPrice(),
                        country = form.GetCountry()
                    };

                    products.Add(product);
                    ReloadList();
                }
            }
        }