Ejemplo n.º 1
0
 private void FinalizeBindings()
 {
     BindingSource.EndEdit();
     GridViewSupplierProduct.CloseEditor();
     GridViewSupplierProduct.UpdateCurrentRow();
     //Set the code for each mapping just in case
     for (int rowCtr = 0; rowCtr < GridViewSupplierProduct.DataRowCount; rowCtr++)
     {
         SupplierProduct suppProd = (SupplierProduct)GridViewSupplierProduct.GetRow(rowCtr);
         suppProd.Product_Type          = "WAY";
         suppProd.Product_Code_Internal = TextEditCode.Text ?? string.Empty;
     }
     BindingSourceSupplierProduct.EndEdit();
 }
Ejemplo n.º 2
0
 private void ButtonDeleteMapping_Click(object sender, EventArgs e)
 {
     if (GridViewSupplierProduct.FocusedRowHandle >= 0)
     {
         SupplierProduct suppProduct = (SupplierProduct)GridViewSupplierProduct.GetFocusedRow();
         _selectedRecord.SupplierProduct.Remove(suppProduct);
         //Removing from the collection just removes the object from its parent, but does not mark
         //it for deletion, effectively orphaning it.  This will cause foreign key errors when saving.
         //To flag for deletion, delete it from the context as well.
         if (!suppProduct.IsNew())
         {
             _context.SupplierProduct.DeleteObject(suppProduct);
         }
         BindSupplierProducts();
     }
 }