Beispiel #1
0
        //button to Add supplier
        private void btnAddSupplier_Click(object sender, EventArgs e)
        {
            var addEditSupplier = new AddEditSupplier(this);

            addEditSupplier.MdiParent = this.MdiParent;
            addEditSupplier.Show();
        }
        private void addSuppliersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var addSupplier = new AddEditSupplier
            {
                MdiParent = this
            };

            addSupplier.Show();
        }
Beispiel #3
0
        //Button to edit a supplier
        private void btnEditSupplier_Click(object sender, EventArgs e)
        {
            try
            {
                //select row
                var id = Convert.ToString(gvSupplierList.CurrentRow.Cells[0].Value);

                //query database for record
                var supplier = _db.Suppliers.FirstOrDefault(s => s.SupName == id);

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