//------------------------------------------------------------------- public override CResultAErreur BeforeSave(CContexteSauvegardeObjetsDonnees contexte, IDataAdapter adapter, DataRowState etatsAPrendreEnCompte) { CResultAErreur result = base.BeforeSave(contexte, adapter, etatsAPrendreEnCompte); if (!result) { return(result); } DataTable table = contexte.ContexteDonnee.Tables[GetNomTable()]; if (table == null) { return(result); } //Recale les mappages de champs custom avec les nouveaux ids de champs Dictionary <int, CMapChampEntiteToRowCustom> dicEntitesToChamps = table.ExtendedProperties[GetType()] as Dictionary <int, CMapChampEntiteToRowCustom>; if (dicEntitesToChamps == null) { return(result); } foreach (KeyValuePair <int, CMapChampEntiteToRowCustom> maps in dicEntitesToChamps) { CTypeEntiteSnmp te = new CTypeEntiteSnmp(contexte.ContexteDonnee); if (te.ReadIfExists(maps.Key)) { foreach (KeyValuePair <string, DataRow> map in maps.Value) { CChampEntiteFromQueryToChampCustom champ = te.GetChamp(map.Key); champ.IdChampCustom = (int)map.Value[CChampCustom.c_champId]; } } te.CommitChampsFromQuery(); } table.ExtendedProperties.Remove(GetType()); return(result); }
//-------------------------------------- public static bool EditeChamp( CChampEntiteFromQueryToChampCustom champToCustom, CTypeEntiteSnmpPourSupervision typeEntite, CContexteDonnee contexteDonnee) { CFormEditChampEntiteFromQueryToChampCustom form = new CFormEditChampEntiteFromQueryToChampCustom(); form.m_contexteDonnee = contexteDonnee; form.m_champToCustom = CCloner2iSerializable.Clone(champToCustom) as CChampEntiteFromQueryToChampCustom; form.m_champEdite = form.m_champToCustom.Champ; form.m_typeEntite = typeEntite; bool bResult = false; if (form.ShowDialog() == DialogResult.OK) { bResult = true; CCloner2iSerializable.CopieTo(form.m_champToCustom, champToCustom); } form.Dispose(); return(bResult); }