public void AppliquerFiltre() { Filtre = new CFiltreData( ); if (m_cmbRole.SelectedValue is CRoleChampCustom) { Filtre = CFiltreData.GetAndFiltre(Filtre, CChampCustom.GetFiltreChampsForRole(((CRoleChampCustom)m_cmbRole.SelectedValue).CodeRole)); } if (m_txtLibelle.Text != string.Empty) { Filtre = CFiltreData.GetAndFiltre( Filtre, new CFiltreData(CChampCustom.c_champNom + " like @1", "%" + m_txtLibelle.Text + "%")); } if (m_txtFolderName.Text != string.Empty) { Filtre = CFiltreData.GetAndFiltre(Filtre, new CFiltreData(CChampCustom.c_champFolder + " LIKE @1", "%" + m_txtFolderName.Text + "%")); } OnAppliqueFiltre(new object(), null); }
private void CControlActionReleve_Load(object sender, EventArgs e) { //Cherche les champs relevé CListeObjetsDonnees lst = CChampCustom.GetListeChampsForRole(CContexteDonneeSysteme.GetInstance(), CReleveEquipement.c_roleChampCustom); if (lst.Count == 0) { m_panelReleve.Height = m_lblSerialReleve.Height; m_panelOriginal.Height = m_lblSerialDB.Height; Height = m_panelReleve.Height + m_panelOriginal.Height; m_panelChampsOriginaux.Visible = false; m_panelChampsReleve.Visible = false; } else { foreach (CChampCustom champ in lst) { CControleForCustomFieldReleve ctrl = new CControleForCustomFieldReleve(); ctrl.Init(champ); m_panelChampsReleve.Controls.Add(ctrl); ctrl.Dock = DockStyle.Left; ctrl.LockEdition = true; ctrl.OnValueChanged += new EventHandler(ctrlCustom_OnValueChanged); ctrl = new CControleForCustomFieldReleve(); ctrl.Init(champ); m_panelChampsOriginaux.Controls.Add(ctrl); ctrl.Dock = DockStyle.Left; ctrl.LockEdition = true; } m_panelChampsOriginaux.Visible = true; m_panelChampsReleve.Visible = true; } }
//------------------------------------------------------- public void FillFromEquipement(CEquipement equipement, CReleveEquipement releveEqptParent) { if (Database is CReleveDb) { Equipement = equipement; ReleveEquipementParent = releveEqptParent; TypeEquipement = equipement.TypeEquipement; TypeEquipementConstructeur = equipement.TypeEquipementConstructeur; Coordonnee = equipement.Coordonnee; NumeroSerie = equipement.NumeroSerie; foreach (CRelationEquipementChampCustom rel in equipement.RelationsChampsCustom) { CChampCustom champ = rel.ChampCustom.GetChampInMemoryDb(Database); if (champ != null) { SetValeurChamp(champ.Id, rel.Valeur); } } foreach (CEquipement eqptFils in equipement.EquipementsContenus) { CReleveEquipement relFils = new CReleveEquipement(Database as CReleveDb); relFils.CreateNew(); relFils.ReleveSite = ReleveSite; relFils.FillFromEquipement(eqptFils, this); } } }
//-------------------------------------- private void InitChamps() { m_txtNomChamp.Text = m_champEdite.NomChamp; m_txtDescription.Text = m_champEdite.Description; m_lblDataType.Text = new CTypeChampBasique(m_champEdite.TypeChamp).Libelle; m_chkNoUpdate.Checked = m_champEdite.NoUpdateFromSnmp; m_chkNoWriteSNMP.Checked = m_champEdite.IsReadOnly; m_lblAcces.Text = m_champEdite.IsReadOnly ? I.T("Read only|20296") : I.T("Read/write|20297"); CFournisseurGeneriqueProprietesDynamiques fournisseur = new CFournisseurGeneriqueProprietesDynamiques(); CEntiteSnmpPourSupervision entiteTest = m_typeEntite.GetEntiteDeTest(); m_txtFormuleIndex.Init(fournisseur, new CObjetPourSousProprietes(entiteTest)); m_txtFormuleIndex.Formule = m_champEdite.FormuleIndex; TypeDonnee typeChampMap = TypeDonnee.tString; switch (m_champEdite.TypeChamp) { case ETypeChampBasique.Bool: typeChampMap = TypeDonnee.tBool; break; case ETypeChampBasique.Date: typeChampMap = TypeDonnee.tDate; break; case ETypeChampBasique.Decimal: typeChampMap = TypeDonnee.tDouble; break; case ETypeChampBasique.Int: typeChampMap = TypeDonnee.tEntier; break; case ETypeChampBasique.String: typeChampMap = TypeDonnee.tString; break; default: break; } m_txtSelectChampCustom.InitAvecFiltreDeBase(typeof(CChampCustom), "Nom", CFiltreData.GetAndFiltre(CChampCustom.GetFiltreChampsForRole(CEntiteSnmp.c_roleChampCustom), new CFiltreData(CChampCustom.c_champType + "=@1", (int)typeChampMap)), false); CChampCustom champ = new CChampCustom(m_contexteDonnee); if (m_champToCustom.IdChampCustom != null && champ.ReadIfExists(m_champToCustom.IdChampCustom.Value)) { m_txtSelectChampCustom.ElementSelectionne = champ; } else { m_txtSelectChampCustom.ElementSelectionne = null; } }
//--------------------------------------------- protected override void MyAppliqueRestriction( CRestrictionUtilisateurSurType restrictionSurObjetEdite, CListeRestrictionsUtilisateurSurType listeRestrictions, IGestionnaireReadOnlySysteme gestionnaireReadOnly) { bool bShowPictureRestriction = false; if (listeRestrictions != null && EditedElement != null) { CChampCustom champ = WndVariable.Variable as CChampCustom; if (champ != null && restrictionSurObjetEdite != null && m_controleForVariable.Control != null) { ERestriction rest = restrictionSurObjetEdite.GetRestriction(champ.CleRestriction); if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly) { gestionnaireReadOnly.SetReadOnly(m_controleForVariable.Control, true); bShowPictureRestriction = true; } } } if (VisualiseurReadOnly != null) { if (bShowPictureRestriction) { VisualiseurReadOnly.Visible = true; } else { VisualiseurReadOnly.Visible = false; } } }
private void CFormEditVariableFiltreCalculee_Load(object sender, System.EventArgs e) { // Lance la traduction du formulaire sc2i.win32.common.CWin32Traducteur.Translate(this); CRoleChampCustom role = CRoleChampCustom.GetRoleForType(m_typeDonnees); if (role != null) { CListeObjetsDonnees listeChamps = CChampCustom.GetListeChampsForRole(CSc2iWin32DataClient.ContexteCourant, role.CodeRole); listeChamps.Tri = CChampCustom.c_champNom; m_wndListeChamps.ListeSource = listeChamps; Dictionary <int, bool> lstChecks = new Dictionary <int, bool>(); if (!(m_champ.Origine is C2iOrigineChampExportChampCustom)) { m_champ.Origine = new C2iOrigineChampExportChampCustom(); } m_champ.NomChamp = "CUSTOM_FIELDS"; C2iOrigineChampExportChampCustom origineChamp = (C2iOrigineChampExportChampCustom)m_champ.Origine; foreach (int nId in origineChamp.IdsChampCustom) { lstChecks[nId] = true; } for (int nChamp = 0; nChamp < listeChamps.Count; nChamp++) { CChampCustom champ = (CChampCustom)listeChamps[nChamp]; if (lstChecks.ContainsKey(champ.Id)) { m_wndListeChamps.CheckItem(nChamp); } } } }
//--------------------------------------------------------------------- public void SetValeur(object objet, object valeur) { if (objet != null && objet is IObjetDonneeAChamps) { if (valeur is int) { if ((int)valeur >= 0) { CContexteDonnee contexte = ((IObjetDonneeAChamps)objet).ContexteDonnee; CChampCustom champ = new CChampCustom(contexte); if (champ.ReadIfExists(IdChampCustom)) { CObjetDonneeAIdNumerique objetDonne = (CObjetDonneeAIdNumerique)Activator.CreateInstance(champ.TypeObjetDonnee, new object[] { contexte }); if (objetDonne.ReadIfExists((int)valeur)) { CUtilElementAChamps.SetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom, objetDonne); } else { throw new Exception(I.T("Object @1 @2 doesn't exist|515", DynamicClassAttribute.GetNomConvivial(champ.TypeObjetDonnee), valeur.ToString())); } } } } else { CUtilElementAChamps.SetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom, null); } } }
//////////////////////////////////////////// private void OnChangeExpression(string strTexte, ref C2iExpression expToSet, CComboboxAutoFilled combo) { CContexteAnalyse2iExpression ctx = new CContexteAnalyse2iExpression(ActionSynchronisme.Process, typeof(CProcess)); CResultAErreur result = new CAnalyseurSyntaxiqueExpression(ctx).AnalyseChaine(strTexte); if (result) { ArrayList lstChamps = new ArrayList(); expToSet = (C2iExpression)result.Data; Type tp = expToSet.TypeDonnee.TypeDotNetNatif; CStructureTable structure = null; try { structure = CStructureTable.GetStructure(tp); ArrayList lst = new ArrayList(); foreach (CInfoChampTable champ in structure.Champs) { if (champ.TypeDonnee == typeof(DateTime) || champ.TypeDonnee == typeof(DateTime?)) { lst.Add(champ); } } //Cherche les champs custom if (typeof(CElementAChamp).IsAssignableFrom(tp)) { //Crée les infos champ custom pour le type using (CContexteDonnee contexte = new CContexteDonnee( CSessionClient.GetSessionUnique().IdSession, true, false)) { string strCodeRole = CRoleChampCustom.GetRoleForType(tp).CodeRole; CListeObjetsDonnees listeChamps = CChampCustom.GetListeChampsForRole( contexte, strCodeRole); new CListeObjetsDonnees(contexte, typeof(CChampCustom)); listeChamps.Filtre = new CFiltreData( CChampCustom.c_champType + "=@1", (int)TypeDonnee.tDate); foreach (CChampCustom champ in listeChamps) { CInfoChampTable info = new CInfoChampTable( CSynchronismeDonnees.c_idChampCustom + champ.Id.ToString(), typeof(DateTime), 0, false, false, true, false, true); info.NomConvivial = champ.Nom; lst.Add(info); } } } combo.ListDonnees = lst; } catch { } } }
private void CControlePourInventaire_Load(object sender, EventArgs e) { CListeEntitesDeMemoryDb <CChampCustom> lstChamps = new CListeEntitesDeMemoryDb <CChampCustom>(CTimosInventoryDb.GetTimosDatas()); lstChamps.Filtre = CChampCustom.GetFiltreChampsForRole(CReleveEquipement.c_roleChampCustom); if (lstChamps.Count() == 0) { m_panelChampsCustom.Visible = false; } else { m_panelChampsCustom.Visible = true; foreach (CChampCustom champOrg in lstChamps) { CChampCustom champ = new CChampCustom(CTimosInventoryDb.GetInventaireDatas()); if (!champ.ReadIfExist(champOrg.Id)) { champ = champOrg.GetChampInMemoryDb(CTimosInventoryDb.GetInventaireDatas()); } if (champ != null) { CControleForCustomFieldReleve ctrl = new CControleForCustomFieldReleve(); m_panelChampsCustom.Controls.Add(ctrl); ctrl.Dock = DockStyle.Left; ctrl.Init(champ); ctrl.OnValueChanged += new EventHandler(ctrlCustom_OnValueChanged); } } } Height = m_panelTop.Height + m_lblLigneBas.Height + (m_panelChampsCustom.Controls.Count > 0 ? m_panelChampsCustom.Height : 0); }
//------------------------------------------------------- public CChampCustom SelectChamp(CChampCustom lastSelectionne) { CFormListeChampsCustom form = new CFormListeChampsCustom(m_strCodeRole); return((CChampCustom)CFormNavigateurPopupListe.SelectObject( form, lastSelectionne, CFormNavigateurPopupListe.CalculeContexteUtilisation(form))); }
//------------------------------------------------------------------------- private void m_lnkNewChampCustom_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { CChampCustom champ = new CChampCustom(CSc2iWin32DataClient.ContexteCourant); champ.CreateNew(); CFormEditionChampCustom frm = new CFormEditionChampCustom(champ); CSc2iWin32DataNavigation.Navigateur.AffichePage(frm); }
//-------------------------------------------------------------- private void CFormCreerEquipement_Load(object sender, EventArgs e) { m_lblSite.Text = m_releveEqpt.ReleveSite.Site.Libelle; if (m_releveEqpt.ReleveEquipementParent != null) { m_panelEqptParent.Visible = true; m_lblEqptParent.Text = m_releveEqpt.ReleveEquipementParent.NumeroSerie + " " + m_releveEqpt.ReleveEquipementParent.TypeEquipement.Libelle + " (" + m_releveEqpt.ReleveEquipementParent.CoordonneeComplete + ")"; } else { m_panelEqptParent.Visible = false; } m_txtSerial.Text = m_releveEqpt.NumeroSerie; m_selectTypeEquipement.Init(m_releveEqpt, true); m_panelCoordonnee.Init(m_releveEqpt, true); CListeEntitesDeMemoryDb <CChampCustom> lstChamps = new CListeEntitesDeMemoryDb <CChampCustom>(CTimosInventoryDb.GetTimosDatas()); lstChamps.Filtre = CChampCustom.GetFiltreChampsForRole(CReleveEquipement.c_roleChampCustom); if (lstChamps.Count() == 0) { m_panelChampsCustom.Visible = false; } else { m_panelChampsCustom.Visible = true; foreach (CChampCustom champOrg in lstChamps) { CChampCustom champ = new CChampCustom(CTimosInventoryDb.GetInventaireDatas()); if (!champ.ReadIfExist(champOrg.Id)) { champ = champOrg.GetChampInMemoryDb(CTimosInventoryDb.GetInventaireDatas()); } if (champ != null) { CControleForCustomFieldReleve ctrl = new CControleForCustomFieldReleve(); m_panelChampsCustom.Controls.Add(ctrl); ctrl.Dock = DockStyle.Left; ctrl.Init(champ); } } } foreach (Control ctrl in m_panelChampsCustom.Controls) { CControleForCustomFieldReleve c = ctrl as CControleForCustomFieldReleve; if (c != null) { c.InitChamps(m_releveEqpt); } } }
//------------------------------------------------------ public void SetVariable(IVariableDynamique variable) { m_variable = variable; CChampCustom champ = variable as CChampCustom; if (champ != null && champ.Precision >= 1) { MaxLength = champ.Precision; } }
//------------------------------------------------------------------------- private void FillListeChamps(CRestrictionUtilisateurSurType restriction) { m_wndListeChamps.BeginUpdate(); m_wndListeChamps.Items.Clear(); CInfoStructureDynamique info = CInfoStructureDynamique.GetStructure(restriction.TypeAssocie, 0); List <ListViewItem> lstItems = new List <ListViewItem>(); foreach (CInfoChampDynamique champ in info.Champs) { string strTmp = ""; CDefinitionProprieteDynamique def = CConvertisseurInfoStructureDynamiqueToDefinitionChamp.GetDefinitionProprieteDynamique(champ.NomPropriete, ref strTmp); //Uniquement les propriétés "classiques" //voir CTimosApp.GetStructure if (def != null && typeof(CDefinitionProprieteDynamiqueDotNet).IsAssignableFrom(def.GetType())) { ListViewItem item = new ListViewItem(); item.Text = champ.NomChamp; item.Tag = def.NomProprieteSansCleTypeChamp; item.ImageIndex = GetIndexImage(restriction.GetRestriction(def.NomProprieteSansCleTypeChamp)); lstItems.Add(item); } } lstItems.Sort((x, y) => x.Text.CompareTo(y.Text)); if (typeof(IElementAChamps).IsAssignableFrom(restriction.TypeAssocie)) { CRoleChampCustom role = CRoleChampCustom.GetRoleForType(restriction.TypeAssocie); if (role != null) { CListeObjetsDonnees listeChampsCustom = CChampCustom.GetListeChampsForRole(CContexteDonneeSysteme.GetInstance(), role.CodeRole); foreach (CChampCustom champ in listeChampsCustom) { ListViewItem item = new ListViewItem(); item.Text = champ.Nom; item.Tag = champ.CleRestriction; item.ImageIndex = GetIndexImage(restriction.GetRestriction(champ.CleRestriction)); lstItems.Add(item); } lstItems.Sort((x, y) => x.Text.CompareTo(y.Text)); CListeObjetsDonnees listeFormulaires = new CListeObjetsDonnees(CContexteDonneeSysteme.GetInstance(), typeof(CFormulaire)); listeFormulaires.Filtre = CFormulaire.GetFiltreFormulairesForRole(role.CodeRole); foreach (CFormulaire formulaire in listeFormulaires) { ListViewItem item = new ListViewItem(); item.Text = "{" + formulaire.Libelle + "}"; item.Tag = formulaire.CleRestriction; item.ImageIndex = GetIndexImage(restriction.GetRestriction(formulaire.CleRestriction)); lstItems.Add(item); } } } m_wndListeChamps.Items.AddRange(lstItems.ToArray()); m_wndListeChamps.EndUpdate(); }
private static void ImporterChamps() { StreamReader reader = new StreamReader("C:\\Partage\\Import Orange\\Champs controles.txt", Encoding.Default); string strLigne = reader.ReadLine(); strLigne = reader.ReadLine(); using (CContexteDonnee contexte = new CContexteDonnee(CSessionClient.GetSessionUnique().IdSession, true, false)) { while (strLigne != null) { CRoleChampCustom roleSite = CRoleChampCustom.GetRole(CSite.c_roleChampCustom); CRoleChampCustom roleWorkBook = CRoleChampCustom.GetRole(CDossierSuivi.c_roleChampCustom); CRoleChampCustom roleCaracteristique = CRoleChampCustom.GetRole(CCaracteristiqueEntite.c_roleChampCustom); string[] datas = strLigne.Split('\t'); if (datas.Length >= 1) { CChampCustom champ = new CChampCustom(contexte); if (!champ.ReadIfExists(new CFiltreData(CChampCustom.c_champNom + "=@1", datas[0]))) { champ.CreateNewInCurrentContexte(); } champ.Nom = datas[0]; C2iTypeDonnee tp = new C2iTypeDonnee(TypeDonnee.tString); if (datas.Length > 1) { if (datas[1].ToUpper() == "BOOL") { tp = new C2iTypeDonnee(TypeDonnee.tBool); } else if (datas[1].ToUpper() == "DATE") { tp = new C2iTypeDonnee(TypeDonnee.tDate); } } champ.TypeDonneeChamp = tp; champ.Categorie = ""; if (datas.Length > 2) { champ.Categorie = datas[2]; } CRoleChampCustom role = roleCaracteristique; champ.Role = role; } strLigne = reader.ReadLine(); } reader.Close(); CResultAErreur result = contexte.SaveAll(true); if (!result) { CFormAfficheErreur.Show(result.Erreur); } } }
public C2iExpression GetFormuleForChamp(CChampCustom champ) { foreach (CRemplisssageChampActiviteActeur remplissage in m_listeRemplissage) { if (remplissage.IdChampCustom == champ.Id) { return(remplissage.Formule); } } return(null); }
/// /////////////////////////////////////////////////////// /// <summary> /// Passe la cellule en édition grâce au contrôle correspondant /// </summary> protected override void Edit( CurrencyManager cur, int nLigne, Rectangle bounds, bool bReadOnly, string strValue, bool bCellIsVisible) { CChampCustom champ = ((CChampCustom)m_listeChamps[nLigne]); if (champ.ListeValeurs.Count == 0) { m_control = GetControl(champ.TypeDonneeChamp.TypeDonnee, champ.Precision, champ.Nom); } else { m_control = m_combobox; m_combobox.Items.Clear(); foreach (CValeurChampCustom valeur in ((CChampCustom)m_listeChamps[nLigne]).ListeValeurs) { m_combobox.Items.Add(valeur.Display); } } if (m_control == null) { return; } if (this.DataGridTableStyle.DataGrid.ReadOnly) { m_control.Hide(); return; } m_bEnEdition = true; if (strValue == null) { strValue = GetValeurColumn(cur, nLigne).ToString(); } if (champ.ListeValeurs.Count > 0) { strValue = champ.DisplayFromValue(strValue); } m_control.Parent = this.DataGridTableStyle.DataGrid; m_control.Bounds = bounds; m_control.Show(); SetValeurControl(m_control, strValue); m_control.Focus(); //Définit le controle qui doit éditer la valeur de la cellule ColumnStartedEditing(m_control); }
//--------------------------------------------------- public CColumnDefinitionChampCustom(ITableDefinition table, CChampCustom champ) { m_table = table; //m_dbKeyChampCustom = champ != null ? champ.DbKey : null; if (champ != null) { m_dbKeyChampCustom = champ.DbKey; m_strNomColonne = champ.Nom; m_typeDonnee = champ.TypeDonneeChamp.TypeDotNetAssocie; } }
//--------------------------------------------------- public CColumnDefinitionChampCustom(ITableDefinition table, CChampCustom champ) { m_table = table; m_nIdChampCustom = champ != null ? champ.Id : -1; if (champ != null) { m_nIdChampCustom = champ.Id; m_strNomColonne = champ.Nom; m_typeDonnee = champ.TypeDonneeChamp.TypeDotNetAssocie; } }
//------------------------------------------------------- private void InitChamps() { if (m_blocWorkflow == null) { return; } m_txtSelectWorkflow.Init(typeof(CTypeWorkflow), "Libelle", false); if (m_blocWorkflow.DbKeyTypeWorkflow != null) { CTypeWorkflow wkf = new CTypeWorkflow(CSc2iWin32DataClient.ContexteCourant); if (wkf.ReadIfExists(m_blocWorkflow.DbKeyTypeWorkflow)) { m_txtSelectWorkflow.ElementSelectionne = wkf; } } m_txtSelectTypeProjet.Init(typeof(CTypeProjet), "Libelle", false); if (m_blocWorkflow.DbKeyTypeProjet != null) { CTypeProjet typeProjet = new CTypeProjet(CSc2iWin32DataClient.ContexteCourant); if (typeProjet.ReadIfExists(m_blocWorkflow.DbKeyTypeProjet)) { m_txtSelectTypeProjet.ElementSelectionne = typeProjet; } } m_cmbProjectField.Init(typeof(CChampCustom), CFiltreData.GetAndFiltre(CChampCustom.GetFiltreChampsForRole(CWorkflow.c_roleChampCustom), new CFiltreData( CChampCustom.c_champTypeObjetDonnee + "=@1", typeof(CProjet).ToString())), "Nom", false); if (m_blocWorkflow.IdChampProjet != null) { CChampCustom champ = new CChampCustom(CSc2iWin32DataClient.ContexteCourant); if (champ.ReadIfExists(m_blocWorkflow.IdChampProjet.Value)) { m_cmbProjectField.ElementSelectionne = champ; } } m_listeAffectations.Clear(); m_listeAffectations.AddRange(m_blocWorkflow.AffectationsCreationEtDemarrage); m_txtFormuleGanttId.Init(new CFournisseurPropDynStd(), typeof(CEtapeWorkflow)); m_txtFormuleGanttId.Formule = m_blocWorkflow.FormuleGanttId; m_chkGererIterations.Checked = m_blocWorkflow.GererIteration; }
//------------------------------------------------------------------- public CChampCustom[] GetTousLesChampsAssocies(string strCodeRole) { Hashtable tableChamps = new Hashtable(); FillHashtableChamps(tableChamps, strCodeRole); CChampCustom[] liste = new CChampCustom[tableChamps.Count]; int nChamp = 0; foreach (CChampCustom champ in tableChamps.Values) { liste[nChamp++] = champ; } return(liste); }
//------------------------------------------------------------------------ private static void AddChampsCustom(CContexteDonnee ctx, CMemoryDb db) { CListeObjetDonneeGenerique <CChampCustom> lst = new CListeObjetDonneeGenerique <CChampCustom>(ctx); lst.Filtre = CChampCustom.GetFiltreChampsForRole(CReleveEquipement.c_roleChampCustom); lst.ReadDependances("ListeValeurs"); foreach (CChampCustom champTimos in lst) { if (champTimos.TypeDonneeChamp.TypeDonnee != TypeDonnee.tObjetDonneeAIdNumeriqueAuto) { AssureChampInMemoryDb(champTimos, db); } } }
//------------------------------------------------------ public void SetVariable(IVariableDynamique variable) { m_variable = variable; CChampCustom champ = variable as CChampCustom; if (champ != null) { Arrondi = champ.Precision; } else { Arrondi = 10; } }
/// /////////////////////////////////////////////////////// /// <summary> /// Valide les modifications apportées à la valeur de la source /// </summary> protected override bool Commit( CurrencyManager dataSource, int rowNum ) { CChampCustom champ = ((CChampCustom)m_listeChamps[rowNum]); m_control = GetControl(champ.TypeDonneeChamp.TypeDonnee, champ.Precision, champ.Nom); if (m_control == null || !m_bEnEdition) { return(true); } if (this.DataGridTableStyle.DataGrid.ReadOnly) { m_control.Hide(); return(true); } if (this.DataGridTableStyle.DataGrid.DataSource == null) { return(true); } object valeur = GetValeurControl(m_control, champ, rowNum); try { SetValeurColumn(dataSource, rowNum, valeur); } catch { Console.WriteLine("\n\n\n**************************\nOn ne devrait pas passer là : C2iDataGridValeurChampStyle : Erreur CommitEdit\n*****************************"); if (dataSource.Position != rowNum) { dataSource.Refresh(); dataSource.Position = rowNum; try { SetValeurColumn(dataSource, rowNum, valeur); } catch { throw new Exception("Y a plus rien a faire !!!"); } } } m_control.Hide(); m_bEnEdition = false; return(true); }
//------------------------------------------------------------- private int?GetIdChampOptimFromFormule(C2iExpression formule) { C2iExpressionChamp exp = formule as C2iExpressionChamp; if (exp != null) { //TESTDBKEYOK CDefinitionProprieteDynamiqueChampCustom prop = exp.DefinitionPropriete as CDefinitionProprieteDynamiqueChampCustom; if (prop != null) { return(CChampCustom.GetIdFromDbKey(prop.DbKeyChamp)); } } return(null); }
//------------------------------------------------------------------------------- public CDefinitionProprieteDynamique[] GetDefinitionsChamps(Type typeInterroge, int nNbNiveaux) { List <CDefinitionProprieteDynamique> lst = new List <CDefinitionProprieteDynamique>(); foreach (CChampEntiteFromQueryToChampCustom champ in m_typeEntite.ChampsFromQueryList) { champ.ContexteDonneePourChamp = m_typeEntite.ContexteDonnee; CChampCustom chCust = champ.ChampCustom; if (chCust != null) { lst.Add(new CDefinitionProprieteDynamiqueChampCustom(chCust)); } } return(lst.ToArray()); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_lnkCreateField_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (m_txtSelectChampCustom.ElementSelectionne == null) { m_champToCustom.IdChampCustom = null; if (m_champToCustom.AssociationRapide(m_contexteDonnee, true)) { CChampCustom champ = new CChampCustom(m_contexteDonnee); if (m_champToCustom.IdChampCustom != null && champ.ReadIfExists(m_champToCustom.IdChampCustom.Value, false)) { m_txtSelectChampCustom.ElementSelectionne = champ; } } } }
private void InitComboCategories() { if (m_bCmbComboCategoriesInit) { return; } m_cmbCategorie.BeginUpdate(); m_cmbCategorie.Items.Clear(); foreach (string strChaine in CChampCustom.GetListeRubriques(FonctionDynamiqueInDb.ContexteDonnee)) { m_cmbCategorie.Items.Add(strChaine); } m_cmbCategorie.EndUpdate(); m_bCmbComboCategoriesInit = true; }
//------------------------------------------------------ public void SetVariable(IVariableDynamique variable) { m_variable = variable; CChampCustom champ = variable as CChampCustom; if (m_variable.FormatAffichageUnite.Length > 0) { this.DefaultFormat = m_variable.FormatAffichageUnite; } else if (m_variable.ClasseUnite != null) { this.DefaultFormat = m_variable.ClasseUnite.UniteBase; } UseValueFormat = true; }
//------------------------------------------------------------------- public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = base.TraitementAvantSauvegarde(contexte); if (result) { result = SObjetHierarchiqueServeur.TraitementAvantSauvegarde(contexte, GetNomTable()); } DataTable table = contexte.Tables[GetNomTable()]; if (table == null) { return(result); } ArrayList lst = new ArrayList(table.Rows); Dictionary <int, CMapChampEntiteToRowCustom> dicEntitesToChamps = new Dictionary <int, CMapChampEntiteToRowCustom>(); foreach (DataRow row in table.Rows) { if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added) { CTypeEntiteSnmp typeEntite = new CTypeEntiteSnmp(row); CMapChampEntiteToRowCustom map = null; foreach (CChampEntiteFromQueryToChampCustom champ in typeEntite.ChampsFromQuery) { if (champ.IdChampCustom != null && champ.IdChampCustom.Value < 0) { CChampCustom champCustom = new CChampCustom(contexte); if (champCustom.ReadIfExists(champ.IdChampCustom.Value, false)) { if (map == null) { map = new CMapChampEntiteToRowCustom(); dicEntitesToChamps[typeEntite.Id] = map; } map[champ.Champ.Id] = champCustom.Row.Row; } } } } } if (dicEntitesToChamps.Count > 0) { table.ExtendedProperties[GetType()] = dicEntitesToChamps; } return(result); }