//Method used to display the add edit supplier form in supplier add mode private void suppAddButton_Click(object sender, EventArgs e) { AddEditSupplier aesForm = new AddEditSupplier(); aesForm.supAddMode = true; aesForm.prodValue = (int)prodComboBox.SelectedValue; //Shows the AddEditSupplier form DialogResult result = aesForm.ShowDialog(); if (result == DialogResult.OK) // Save { using (TravelExpertsLINQDataContext dbContext = new TravelExpertsLINQDataContext()) { supComboBox.DataSource = dbContext.Suppliers; prodComboBox.DataSource = dbContext.Products; prodComboBox.SelectedIndex = 0; } } }
//Method used to display the add edit supplier form in product edit mode private void prodEditButton_Click(object sender, EventArgs e) { AddEditSupplier aesForm = new AddEditSupplier(); //Sets the Add mode to true aesForm.prodEditMode = true; aesForm.prodToEdit = prodComboBox.Text; //Shows the AddEditSupplier form DialogResult result = aesForm.ShowDialog(); if (result == DialogResult.OK) // Save { //Refresh the Grid View //dbContext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, // dbContext.Products); using (TravelExpertsLINQDataContext dbContext = new TravelExpertsLINQDataContext()) { prodComboBox.DataSource = dbContext.Products; } } }
//Method used to display the add edit supplier form in supplier edit mode private void suppEditButton_Click(object sender, EventArgs e) { AddEditSupplier aesForm = new AddEditSupplier(); aesForm.supToEdit = supComboBox.Text; aesForm.supEditMode = true; //supToEdit = supComboBox.Text; DialogResult result = aesForm.ShowDialog(); if (result == DialogResult.OK) // Save { //Refresh the Grid View //dbContext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, // dbContext.Products); using (TravelExpertsLINQDataContext dbContext = new TravelExpertsLINQDataContext()) { supComboBox.DataSource = dbContext.Suppliers; prodComboBox.SelectedIndex = 0; } } }