private void btnDeleteProductSup_Click(object sender, EventArgs e) { TravelExpertDataContext dbContext = new TravelExpertDataContext(); int sup_id = Convert.ToInt32(productSupplierIdComboBox.SelectedItem); DialogResult answer = MessageBox.Show("Are you sure you want to delete Supplier Id: " + sup_id + "?", "Confirm", MessageBoxButtons.OKCancel); if (answer == DialogResult.OK) { using (TravelExpertDataContext dataContext = new TravelExpertDataContext()) { try { Products_Supplier selectedValue = (from m in dataContext.Products_Suppliers where m.ProductSupplierId == sup_id select m).Single(); dataContext.Products_Suppliers.DeleteOnSubmit(selectedValue); dataContext.SubmitChanges(); productSupIds = (from m in dataContext.Products_Suppliers select m.ProductSupplierId).ToList(); productSupplierIdComboBox.DataSource = productSupIds; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } } } }
private void detach_Products_Suppliers(Products_Supplier entity) { this.SendPropertyChanging(); entity.Supplier = null; }
private void attach_Products_Suppliers(Products_Supplier entity) { this.SendPropertyChanging(); entity.Product = this; }
partial void DeleteProducts_Supplier(Products_Supplier instance);
partial void UpdateProducts_Supplier(Products_Supplier instance);
partial void InsertProducts_Supplier(Products_Supplier instance);