コード例 #1
0
ファイル: CityCodeForm.cs プロジェクト: mdgiles/TraceOffice
 private void FinalizeBindings()
 {
     BindingSource.EndEdit();
     GridViewSupplierCity.CloseEditor();
     GridViewSupplierCity.UpdateCurrentRow();
     //Set the city code for each mapping just in case
     for (int rowCtr = 0; rowCtr < GridViewSupplierCity.DataRowCount; rowCtr++)
     {
         SupplierCity suppCity = (SupplierCity)GridViewSupplierCity.GetRow(rowCtr);
         suppCity.Citycod_Code = TextEditCode.Text ?? string.Empty;
     }
     BindingSourceSupplierCity.EndEdit();
 }
コード例 #2
0
ファイル: CityCodeForm.cs プロジェクト: mdgiles/TraceOffice
 private void ButtonDeleteMapping_Click(object sender, EventArgs e)
 {
     if (GridViewSupplierCity.FocusedRowHandle >= 0)
     {
         SupplierCity suppCity = (SupplierCity)GridViewSupplierCity.GetFocusedRow();
         _selectedRecord.SupplierCity.Remove(suppCity);
         //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.
         _selectedRecord.SupplierCity.Remove(suppCity);
         _context.SupplierCity.DeleteObject(suppCity);
         BindSupplierCities();
     }
 }