public bool AllColumnsAreDirty(esDataRowState state) { if (this.es.ModifiedColumns.Count == 8 && this.RowState == state) { return(true); } else { return(false); } }
/// <summary> /// Called by all of the property setters /// </summary> /// <param name="columnName">The name of the column to set</param> /// <param name="data">the value to set it to</param> /// <returns>True if the value has truly changed</returns> protected bool SetValue(object data, [CallerMemberName] string propertyName = null) { bool changed = true; if (rowState == esDataRowState.Deleted) { throw new Exception("Cannot modifiy deleted records"); } try { if (currentValues == null) { currentValues = new esSmartDictionary(); CurrentValues_OnFirstAccess(currentValues); } if (currentValues.Count == 0) { if (rowState == esDataRowState.Added && !applyDefaultsCalled) { applyDefaultsCalled = true; ApplyDefaults(); } } string columnName = Getters[propertyName]; if (!currentValues.ContainsKey(columnName)) { currentValues[columnName] = data; changed = true; if (rowState == esDataRowState.Unchanged) { rowState = esDataRowState.Modified; } } else { object o = currentValues[columnName]; bool isNull = (o == DBNull.Value || o == null); // Note that we grab this before we make the change esDataRowState state = rowState; if (data == null && isNull) { // Nothing to do here changed = false; } else { if (isNull && data != null) { currentValues[columnName] = data; } else if (data == null && !isNull) { currentValues[columnName] = DBNull.Value; } else if (!o.Equals(data)) { this.currentValues[columnName] = data; // Special logic to see if we have changed it back to it's original value, if // so we mark this column as no longer dirty, which if the only one could return // the rowstate back to "Unchanged" if (originalValues != null && originalValues.ContainsKey(columnName)) { if (data == originalValues[columnName]) { MarkFieldAsUnchanged(columnName); return(true); // it still changed but we don't want to mark it as dirty } } } else { changed = false; } } } if (changed) { MarkFieldAsModified(columnName); } } finally { } return(changed); }
public bool AllColumnsAreDirty(esDataRowState state) { if (this.es.ModifiedColumns.Count == 8 && this.RowState == state) { return true; } else { return false; } }