Exemple #1
0
        private void EditSupplierButton_Click(object sender, EventArgs e)
        {
            //get the key of the current Supplier in the data grid view
            int    rowNum     = supplierDataGridView.CurrentCell.RowIndex;
            string supplierID = supplierDataGridView["dataGridViewTextBoxColumn1", rowNum].Value.ToString();
            //create a current Supplier object
            Supplier existingSupplier;

            using (SupplierDataContext dataContext = new SupplierDataContext())
            {
                existingSupplier = (from s in dataContext.Suppliers
                                    where s.SupplierId.ToString() == supplierID
                                    select s).Single();
            }
            //instantiate the addeditSupplierForm
            frmAddEditSupplier frmAddEdit = new frmAddEditSupplier();

            frmAddEdit.EditMode          = true;                           //editing Supplier
            frmAddEdit.exsistingSupplier = existingSupplier;
            DialogResult result = frmAddEdit.ShowDialog();                 // display second form modal

            if (result == DialogResult.OK || result == DialogResult.Retry) // successful update or concurrency exception
            {
                reloadGridView();
            }
        }
Exemple #2
0
        private void AddSupplierButton_Click(object sender, EventArgs e)
        {
            frmAddEditSupplier frmAddEdit = new frmAddEditSupplier();

            frmAddEdit.EditMode          = false;
            frmAddEdit.exsistingSupplier = null;
            DialogResult result = frmAddEdit.ShowDialog();

            if (result == DialogResult.OK)
            {
                reloadGridView();
            }
        }