コード例 #1
0
ファイル: MainForm.cs プロジェクト: jbyrne2222/ITSE1430
        private void EditProduct(Product product)
        {
            var form   = new ProductDetailForm(product);
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            //Update the product
            form.Product.Id = product.Id;
            _database.Update(form.Product, out var message);
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }

            RefreshUI();
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: cmajors23/ITSE1430
        private void OnProductEdit(object sender, EventArgs e)

        {
            if (_product == null)
            {
                return;
            }
            var form = new ProductDetailForm();

            form.Text = "Add Product";
            //form.Product = _product;

            //Show form modally
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }
        }
コード例 #3
0
        private void OnProductEdit(object sender, EventArgs e)
        {
            if (_product == null)
            {
                return;
            }
            var form = new ProductDetailForm(_product);
            //form.Product = _product;

            //Show form modally
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            //"Editing" the product
            _product = form.Product;
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: carlos2047/ITSE1430Carlos
        private void OnProductAdd(object sender, EventArgs e)
        {
            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            try
            {
                //Save product
                _database.Add(child.Product);
                UpdateList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK);
            }
        }
コード例 #5
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Handle errors
            //Save product
            try
            {
                _database.Add(child.Product);
            } catch (Exception ex)
            {
                DisplayError(ex);
            }
            UpdateList();
        }
コード例 #6
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            //Make sure there is room left
            // var index = FindAvailableElement();
            // if (index < 0)
            // {
            //     MessageBox.Show("No more products available.");
            //     return;
            // };

            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Save product
            // _database.Add = child.Product;
        }
コード例 #7
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            try
            {
                var child = new ProductDetailForm("Product Details");
                if (child.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                //Save product
                _database.Add(child.Product);
                UpdateList();
            } catch (DataException)
            {
                ErrorMessage("Database failure!", "Add Failed!");
            } catch (Exception ex)
            {
                ErrorMessage(ex.Message, "Add failed!");
            }
        }
コード例 #8
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var form = new ProductDetailForm("Add Product");

            //form.Text = "Add Product";
            //modal form
            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //add product, add try catch
            try
            {
                _database.Add(form.Product);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            RefreshUI();
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: Insave/ITSE1430
        private void OnProductEdit(object sender, EventArgs e)
        {
            if (_product == null)
            {
                MessageBox.Show(this, "There is no product to edit.", "Edit Product", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            var form = new ProductDetailForm(_product);

            //Show form modally
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            //"Editing" the product
            _product = form.Product;
        }
コード例 #10
0
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //Save product
            try
            {
                _database.Update(child.Product);
            } catch (Exception ex)
            {
                DisplayError(ex, "Update Failed");
            };

            UpdateList();
        }
コード例 #11
0
ファイル: MainForm.cs プロジェクト: cmajors23/ITSE1430
        private void OnProductAdd(object sender, EventArgs e)
        {
            var button = sender as ToolStripMenuItem;
            var form   = new ProductDetailForm();
            //form.Text = "Add Product";

            //Show form modally
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            //add to database
            _database.Add(form.Product, out var message);
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }
        }
コード例 #12
0
        private void OnProductEdit(object sender, EventArgs e)
        {
            //Are there any products?
            //var index = FindFirstProduct();
            //if (index < 0)
            // {
            //    MessageBox.Show("No products avaialble.");
            //    return;
            //};
            var product = _database.Get();
            var child   = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Save product
            // _database.Update = child.Product;
        }
コード例 #13
0
ファイル: MainForm.cs プロジェクト: randonhyman316/itse-1430
        private void OnProductAdd(object sender, EventArgs e)
        {
            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //Save product
            try
            {
                _database.Add(child.Product);
                UpdateList();
            } catch
            {
                MessageBox.Show(this, "Cannot Add. Perhaps duplicate entry.", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
        }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: hdluu96/ITSE1430-Student
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            try
            {
                //Save product
                _database.Update(child.Product);
                UpdateList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK);
            }
        }
コード例 #15
0
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Handle errors
            //try
            //{
            //Save product
            _database.Update(product.Id, child.Product);
            //} catch (Exception ex)
            //{
            //    DisplayError(ex);
            //};

            UpdateList();
        }
コード例 #16
0
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Handle errors
            try
            {
                _database.Update(child.Product);
            } catch (Exception ex)
            {
                MessageBox.Show("Product could not be updated", ex.ToString());
            };
            //Save product

            UpdateList();
        }
コード例 #17
0
ファイル: MainForm.cs プロジェクト: ErikaSkaar/Erika_ITSE1430
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //***
            //Save product
            try
            {
                _database.Update(child.Product);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            };

            UpdateList();
        }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: davidkeeton821/ITSE1430
        private void EditProduct(Product product)
        {
            var form = new ProductDetailForm(product);

            //Show form modally
            var result = form.ShowDialog(this); //show child form (ProductRetailForm), return back dailog result

            if (result != DialogResult.OK)      //use dialog result from child form
            {
                return;
            }

            //Add to database
            form.Product.Id = product.Id;
            _database.Update(form.Product, out var message);
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }

            RefreshUI();
        }
コード例 #19
0
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Handle errors
            //Save product
            try
            {
                _database.Update(child.Product);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            };
            UpdateList();
        }
コード例 #20
0
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Edit Product");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Handle errors
            try
            {
                _database.Update(child.Product);
            }catch (Exception ex)
            {
                DisplayError("Update Failed", ex.Message);
            }
            //Save product
            //_database.Update(child.Product);
            UpdateList();
        }
コード例 #21
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //TODO: Handle errors
            try
            {
                _database.Add(child.Product);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            };

            //Save product

            UpdateList();
        }
コード例 #22
0
        private void OnProductEdit(object sender, EventArgs e)
        {
            //dont show form to edit if theres nothing to edit
            if (_product == null)
            {
                return;
            }

            var form = new ProductDetailForm(_product);
            //form.Product = _product;

            //Show form modally
            var result = form.ShowDialog(this); //show child form (ProductRetailForm), return back dailog result

            if (result != DialogResult.OK)      //use dialog result from child form
            {
                return;
            }

            //"Editing" the product
            _product = form.Product;
        }
コード例 #23
0
ファイル: MainForm.cs プロジェクト: randonhyman316/itse-1430
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //Save product
            try
            {
                _database.Update(child.Product);
                UpdateList();
            }
            catch
            {
                MessageBox.Show(this, $"Cannot update '{product.Name}'", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
        }
コード例 #24
0
ファイル: MainForm.cs プロジェクト: nuramkin/ITSE1430
        //Helper method to handle editing products
        private void EditProduct(Product product)
        {
            var form   = new ProductDetailForm(product);
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            //Update the product
            form.Product.Id = product.Id;

            try
            {
                _database.Update(form.Product);
            } catch (Exception e)
            {
                MessageBox.Show(e.Message);
            };

            RefreshUI();
        }
コード例 #25
0
ファイル: MainForm.cs プロジェクト: PeterDYoung/itse1430
        private void EditProduct(Product product)
        {
            var child = new ProductDetailForm("Product Details");

            child.Product = product;
            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }


            //Save product
            try {
                _database.Update(child.Product);
                UpdateList();
            } catch (ArgumentException ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } catch (ValidationException ex) {
                MessageBox.Show(ex.Message, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } catch (Exception ex) {
                MessageBox.Show("Save failed" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            };
        }
コード例 #26
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //Save product
            try
            {
                _database.Add(child.Product);
            } catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } catch (DuplicateNameException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            UpdateList();
        }
コード例 #27
0
ファイル: MainForm.cs プロジェクト: davidkeeton821/ITSE1430
        private void OnProductAdd(object sender, EventArgs e)
        {
            var button = sender as ToolStripMenuItem;

            var form = new ProductDetailForm("Add Product");

            //Show form modally
            var result = form.ShowDialog(this); //show child form (ProductRetailForm), return back dailog result

            if (result != DialogResult.OK)      //use dialog result from child form
            {
                return;
            }

            //Add to database
            _database.Add(form.Product, out var message);
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }

            RefreshUI();
        }
コード例 #28
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var form = new ProductDetailForm();

            do
            {
                var child = new ProductDetailForm("Product Details");
                if (child.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    AddProduct(form.Product);
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(this, ex.Message, "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(this, ex.Message, "Bad Argument", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception)
                {
                    MessageBox.Show(this, "Failed", "Add Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    throw;
                }



                //Save product
                _database.Add(child.Product);
                UpdateList();
            } while (true);
        }
コード例 #29
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }


            if (IsProductDuplicate(child.Product))
            {
                return;
            }

            //Handle errors
            try
            {
                //Save product
                _database.Add(child.Product);
                UpdateList();
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(this, ex.Message, "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(this, ex.Message, "Bad Argument", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex) // Equivalent to catch
            {
                //Handle errors
                MessageBox.Show(this, ex.Message, "Add Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
コード例 #30
0
        //Menus
        //private void OnFileExit( object sender, EventArgs e )
        //{
        //    Close();
        //}

        private void OnProductAdd(object sender, EventArgs e)
        {
            //_database.Add(null);

            var child = new ProductDetailForm("Product Details");

            if (child.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            //Save product
            try
            {
                _database.Add(child.Product);
            } catch (ValidationException ex)
            {
                DisplayError(ex, "Validation Failed");
            } catch (Exception ex)
            {
                DisplayError(ex, "Add Failed");
            };
            UpdateList();
        }