コード例 #1
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            var addEditProduct = new AddEditProduct(this);

            addEditProduct.MdiParent = this.MdiParent;
            addEditProduct.Show();
        }
コード例 #2
0
        private void addProductsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var addProduct = new AddEditProduct
            {
                MdiParent = this
            };

            addProduct.Show();
        }
コード例 #3
0
        private void btnEditProduct_Click(object sender, EventArgs e)
        {
            try
            {
                //select row
                var id = Convert.ToString(gvProductList.CurrentRow.Cells[0].Value);

                //query database for record
                var product = _db.Products.FirstOrDefault(p => p.ProdName == id);

                //launch AddEditProduct window with Data
                var addEditProduct = new AddEditProduct(product, this);
                addEditProduct.MdiParent = this.MdiParent;
                addEditProduct.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }