Exemple #1
0
        //Edit supplier
        private void btnEditSupplier_Click(object sender, EventArgs e)
        {
            frmAddEditSuppliers addSupplierForm = new frmAddEditSuppliers();

            addSupplierForm.addSupplier = false;

            // Get the key of the current supplier in the data grid view
            // Index of the current row
            int suprowNum = Convert.ToInt32(supplierDataGridView.CurrentCell.RowIndex);
            // Column for product Id
            int supordernum = Convert.ToInt32(supplierDataGridView["dataGridViewTextBoxColumn14", suprowNum].Value);

            using (TravelExpertDBDataContext db = new TravelExpertDBDataContext())
            {
                addSupplierForm.currentSupplier = (from p in db.Suppliers
                                                   where p.SupplierId == supordernum
                                                   select p).Single();
            }

            // Display second form model
            DialogResult result = addSupplierForm.ShowDialog();

            using (TravelExpertDBDataContext db = new TravelExpertDBDataContext())
            {
                // Update is successful
                if (result == DialogResult.OK)
                {
                    // Refresh grid
                    supplierDataGridView.DataSource = db.Suppliers;
                    MessageBox.Show("Supplier Name Edited Successfully");
                }
            }
        }
Exemple #2
0
        //Add supplier
        private void btnAddSupplier_Click(object sender, EventArgs e)
        {
            frmAddEditSuppliers addSupplierForm = new frmAddEditSuppliers();

            addSupplierForm.addSupplier = true;

            // Display second form model
            DialogResult result = addSupplierForm.ShowDialog();

            using (TravelExpertDBDataContext db = new TravelExpertDBDataContext())
            {
                // Update is successful
                if (result == DialogResult.OK)
                {
                    // Refresh grid
                    supplierDataGridView.DataSource = db.Suppliers;
                    MessageBox.Show("New Supplier Added Successfully");
                }
            }
        }