/// <summary> /// Before Save /// </summary> /// <param name="newRecord">newRecord new</param> /// <returns>true</returns> protected override bool BeforeSave(bool newRecord) { if (DB.UseMigratedConnection) { return(true); } // Sync Terminology if ((newRecord || Is_ValueChanged("AD_Column_ID")) && IsCentrallyMaintained()) { M_Element element = M_Element.GetOfColumn(GetCtx(), GetAD_Column_ID()); SetName(element.GetName()); SetDescription(element.GetDescription()); SetHelp(element.GetHelp()); } return(true); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord">new</param> /// <returns>true</returns> protected override Boolean BeforeSave(Boolean newRecord) { // Sync Terminology if ((newRecord || Is_ValueChanged("AD_Element_ID")) && GetAD_Element_ID() != 0 && IsCentrallyMaintained()) { M_Element element = new M_Element(GetCtx(), GetAD_Element_ID(), null); SetName(element.GetName()); SetDescription(element.GetDescription()); SetHelp(element.GetHelp()); } // Auto Numbering if (newRecord && GetSeqNo() == 0) { String sql = "SELECT COALESCE(MAX(SeqNo),0)+10 FROM AD_InfoColumn WHERE AD_InfoWindow_ID=" + GetAD_InfoWindow_ID(); int no = DataBase.DB.GetSQLValue(null, sql); SetSeqNo(no); } return(true); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord"></param> /// <returns></returns> protected override bool BeforeSave(bool newRecord) { if (!CheckVersions(false)) { return(false); } int displayType = GetAD_Reference_ID(); // Length if (DisplayType.IsLOB(displayType)) // LOBs are 0 { if (GetFieldLength() != 0) { SetFieldLength(0); } } else if (GetFieldLength() == 0) { if (DisplayType.IsID(displayType)) { SetFieldLength(10); } else if (DisplayType.IsNumeric(displayType)) { SetFieldLength(14); } else if (DisplayType.IsDate(displayType)) { SetFieldLength(7); } else if (DisplayType.YesNo == displayType) { SetFieldLength(1); } else { log.SaveError("FillMandatory", Utility.Msg.GetElement(GetCtx(), "FieldLength")); return(false); } } /** Views are not updateable * UPDATE AD_Column c * SET IsUpdateable='N', IsAlwaysUpdateable='N' * WHERE AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE IsView='Y') **/ // Virtual Column if (IsVirtualColumn()) { if (IsMandatory()) { SetIsMandatory(false); } if (IsMandatoryUI()) { SetIsMandatoryUI(false); } if (IsUpdateable()) { SetIsUpdateable(false); } } // Updateable/Mandatory if (IsParent() || IsKey()) { SetIsUpdateable(false); SetIsMandatory(true); } if (IsAlwaysUpdateable() && !IsUpdateable()) { SetIsAlwaysUpdateable(false); } // Encrypted if (IsEncrypted()) { int dt = GetAD_Reference_ID(); if (IsKey() || IsParent() || IsStandardColumn() || IsVirtualColumn() || IsIdentifier() || IsTranslated() || DisplayType.IsLookup(dt) || DisplayType.IsLOB(dt) || "DocumentNo".ToLower().Equals(GetColumnName().ToLower()) || "Value".ToLower().Equals(GetColumnName().ToLower()) || "Name".ToLower().Equals(GetColumnName().ToLower())) { log.Warning("Encryption not sensible - " + GetColumnName()); SetIsEncrypted(false); } } // Sync Terminology if ((newRecord || Is_ValueChanged("AD_Element_ID")) && GetAD_Element_ID() != 0) { _element = new M_Element(GetCtx(), GetAD_Element_ID(), Get_TrxName()); SetColumnName(_element.GetColumnName()); SetName(_element.GetName()); SetDescription(_element.GetDescription()); SetHelp(_element.GetHelp()); } if (IsKey() && (newRecord || Is_ValueChanged("IsKey"))) { SetConstraintType(null); } return(true); }