public bool Delete() { if (Dataset == null || masterDataAdapterProperties == null) { return(false); } if (!OnBeforeDelete()) { return(false); } UpdateFiscalControl(DBOperation.Delete); FindRecord(lastKey); Dataset.Tables[masterDataAdapterProperties.Name].Rows[masterBinding.Position].Delete(); DeleteRecursive(masterDataAdapterProperties.SlaveDataAdapters); var ds2 = Dataset.GetChanges(); if (ds2 != null) { // Visto che esiste il delete recursivo, devo solo cancellare la testa masterDataAdapterProperties.DataAdapter.Update(Dataset, masterDataAdapterProperties.Name); UpdateRecursiveDataAdapter(Dataset, masterDataAdapterProperties); Dataset.AcceptChanges(); } slaveBindingCollection.AllowNew = false; return(OnAfterDelete()); }
public bool Save() { if (masterBinding == null || Dataset == null || masterDataAdapterProperties == null) { return(false); } if (!OnBeforeSave()) { return(false); } try { var ds2 = Dataset.GetChanges(); if (ds2 != null) { if (ds2.HasErrors) { MessageBox.Show("Errori"); } if (ds2.HasChanges()) { Dataset.AcceptChanges(); UpdateRecursiveDataAdapter(ds2, masterDataAdapterProperties); } } } catch (Exception exc) { MessageBox.Show(exc.Message, "Save"); return(false); } return(OnAfterSave()); }