Пример #1
0
        //When user clicks add button in Supplier Tab

        private void btnAddSupplier_Click(object sender, EventArgs e)
        {
            frmAddEditSupplier secondFormSupplier = new frmAddEditSupplier();

            secondFormSupplier.isAdd           = true;
            secondFormSupplier.currentSupplier = null;
            DialogResult result = secondFormSupplier.ShowDialog(); // display second form modal

            if (result == DialogResult.OK)                         // new row got inserted
            {
                loadComboBox_Supplier();
            }
        }
Пример #2
0
        //When user clicks edit button in Supplier Tab
        private void btnEditSupplier_Click(object sender, EventArgs e)
        {
            //get the current supplier id to pass on to 2nd form
            this.tabControl1.SelectedTab = tabSupplier;
            int sup_id = Convert.ToInt32(cboSupplierId.SelectedValue);

            using (TravelExpertDataContext dbContext = new TravelExpertDataContext())
            {
                Supplier currentSup = (from sup in dbContext.Suppliers
                                       where sup.SupplierId == sup_id
                                       select sup).Single();

                frmAddEditSupplier secondformSupplier = new frmAddEditSupplier();
                secondformSupplier.isAdd           = false;
                secondformSupplier.currentSupplier = currentSup;

                DialogResult result = secondformSupplier.ShowDialog();         // display second form modal
                if (result == DialogResult.OK || result == DialogResult.Retry) // successful update or concurrency exception
                {
                    loadComboBox_Supplier();
                }
            }
        }