Esempio n. 1
0
        //private DataGridViewRow selectedRow;
        private void ModifyPartButton_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow selectedRow = PartsDataGrid.SelectedRows[0];
                var             idVal       = selectedRow.Cells["PartID"].Value;

                if (idVal.Equals(null))
                {
                    throw new NullReferenceException("Selected row contains null value for partID");
                }
                int  partID = Convert.ToInt32(selectedRow.Cells["PartID"].Value);
                Part part   = Inventory.LookupPart(partID);

                EditPart partForm = new EditPart(part)
                {
                    MdiParent = this.MdiParent
                };
                partForm.Show();
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Selected row contains null value for partID");
                return;
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("No parts exist to modify.");
            }
        }
Esempio n. 2
0
        private void AddPartButton_Click(object sender, EventArgs e)
        {
            EditPart partForm = new EditPart()
            {
                MdiParent = this.MdiParent
            };

            partForm.Show();
        }