public ChangeTypes DiscoverChangeType() { // Status List (broken = unscheduled) // Created - Broken - appt_id is blank, apptdate is blank // Created - appt_id is blank (all initial fields will also be blank) // Deleted - new_appt_id is blank (all new fields will also be blank) // Broken - new apptdate is blank // Unbroken - apptdate was blank, and has a new apptdate // Time/Operatory change change to apptdate, apptlen, time_hour, time_min, operator_id // Status change - change to status // Other change - all others ChangeTypes returnValue; if (CommonFunctions.DBNullToZero(this["APPTID"]) == 0) { // Just created, check for broken if (this["APPTDATE"] == DBNull.Value) { returnValue = ChangeTypes.CreatedBroken; } else if (this.APPTDATE > new DateTime(1900, 1, 1)) { returnValue = ChangeTypes.CreatedBroken; } else { returnValue = ChangeTypes.Created; } } else if (CommonFunctions.DBNullToZero(this["n_APPTID"]) == 0) { returnValue = ChangeTypes.Deleted; } else if (this["n_APPTDATE"] == DBNull.Value) { returnValue = ChangeTypes.Broken; } else if (this["APPTDATE"] == DBNull.Value && this["n_APPTDATE"] != DBNull.Value) { returnValue = ChangeTypes.Unbroken; } else if (ValueChanged("APPTDATE", true) || ValueChanged("APPTLEN") || ValueChanged("TIME_HOUR") || ValueChanged("TIME_MINUTE") || ValueChanged("OPID")) { returnValue = ChangeTypes.Time_Operatory; } else if (ValueChanged("STATUS")) { returnValue = ChangeTypes.Status; } else { returnValue = ChangeTypes.Other; } return(returnValue); }
private bool ValueChanged(string startVal, bool isDate = false) { return(CommonFunctions.DBNullToString(this[startVal]) != CommonFunctions.DBNullToString(this["n_" + startVal])); }