/// <summary> /// Initialisation en controle de visualisation en Colonne source /// </summary> /// <param name="mappage"></param> /// <param name="tpTableSrc"></param> public void Initialiser(CMappageColonneTableParametrableColonneTableParametrable mappage, CTypeTableParametrable tpTableSrc) { m_mappage = mappage; m_ctrlEditVal.Initialiser(null, mappage.ColonneB.TypeDonneeChamp.TypeDotNetAssocie); m_tpTableSrc = tpTableSrc; IsColonneSource = true; InitialiserAffichage(); }
public void Initialiser( CTypeTableParametrable tpSource, CTypeTableParametrable tpCible, DataTable dtSource, DataTable dtCible) { m_tpCible = tpCible; m_dtCible = dtCible; m_tpSource = tpSource; m_dtSource = dtSource; m_mappeur = new CMappeurTypeTableParametrableTypeTableParametrable(tpSource, tpCible, true); m_ctrlEditMappage.Initialiser(m_mappeur); }
/// ////////////////////////////////////////// protected override void InitChamps() { base.InitChamps(); m_txtFormuleRow.Init(ActionImportFromTableRow.Process, typeof(CProcess)); m_txtFormuleRow.Formule = ActionImportFromTableRow.FormuleRow; m_txtFormuleTarget.Init(ActionImportFromTableRow.Process, typeof(CProcess)); m_txtFormuleTarget.Formule = ActionImportFromTableRow.FormuleElementCible; m_cmbTypeTable.Init(typeof(CTypeTableParametrable), "Libelle", false); CTypeTableParametrable typeTable = new CTypeTableParametrable(CContexteDonneeSysteme.GetInstance()); if (typeTable.ReadIfExists(ActionImportFromTableRow.IdTypeTable)) { m_cmbTypeTable.ElementSelectionne = typeTable; } InitPanelMappages(); }
/// ////////////////////////////////////////// protected override sc2i.common.CResultAErreur MAJ_Champs() { CResultAErreur result = base.MAJ_Champs(); C2iExpression formule = m_txtFormuleRow.Formule; if (!m_txtFormuleRow.ResultAnalyse) { result.EmpileErreur(m_txtFormuleRow.ResultAnalyse.Erreur); return(result); } ActionImportFromTableRow.FormuleRow = formule; formule = m_txtFormuleTarget.Formule; if (!m_txtFormuleTarget.ResultAnalyse) { result.EmpileErreur(m_txtFormuleTarget.ResultAnalyse.Erreur); return(result); } ActionImportFromTableRow.FormuleElementCible = formule; CTypeTableParametrable typeTable = m_cmbTypeTable.ElementSelectionne as CTypeTableParametrable; if (typeTable == null) { result.EmpileErreur(I.T("Select a table type|20823")); return(result); } ActionImportFromTableRow.IdTypeTable = typeTable.Id; ActionImportFromTableRow.IgnorerValeursVide = m_chkIgnorerLignesVides.Checked; List <CActionImportFromTableRow.CMappageColonne> lstMappages = new List <CActionImportFromTableRow.CMappageColonne>(); foreach (CControleEditeMappageImportTableRow ctrl in m_panelMappage.Controls) { result = ctrl.MajChamps(); if (!result) { return(result); } lstMappages.Add(ctrl.Mappage); } ActionImportFromTableRow.Mappages = lstMappages.ToArray(); return(result); }
/// ////////////////////////////////////////// private void InitPanelMappages() { C2iExpression formuleCible = m_txtFormuleTarget.Formule; CTypeTableParametrable typeTable = m_cmbTypeTable.ElementSelectionne as CTypeTableParametrable; Dictionary <int, CActionImportFromTableRow.CMappageColonne> dicMappages = new Dictionary <int, CActionImportFromTableRow.CMappageColonne>(); foreach (CActionImportFromTableRow.CMappageColonne map in ActionImportFromTableRow.Mappages) { dicMappages[map.IdColonne] = map; } List <CActionImportFromTableRow.CMappageColonne> lstOld = new List <CActionImportFromTableRow.CMappageColonne>(); foreach (CControleEditeMappageImportTableRow ctrl in m_panelMappage.Controls) { if (ctrl.MajChamps()) { dicMappages[ctrl.Mappage.IdColonne] = ctrl.Mappage; } } m_panelMappage.SuspendDrawing(); m_panelMappage.ClearAndDisposeControls(); if (formuleCible != null && typeTable != null) { Type tpElements = formuleCible.TypeDonnee.TypeDotNetNatif; List <CActionImportFromTableRow.CMappageColonne> lst = new List <CActionImportFromTableRow.CMappageColonne>(); foreach (CColonneTableParametrable col in typeTable.Colonnes) { CActionImportFromTableRow.CMappageColonne map = null; if (!dicMappages.TryGetValue(col.Id, out map)) { map = new CActionImportFromTableRow.CMappageColonne(); map.IdColonne = col.Id; } CControleEditeMappageImportTableRow controle = new CControleEditeMappageImportTableRow(); controle.Init(ActionImportFromTableRow.Process, tpElements, map); m_panelMappage.Controls.Add(controle); controle.Dock = DockStyle.Top; controle.BringToFront(); } } m_panelMappage.ResumeDrawing(); }
//-------------------------------------------------------------------------- public CResultAErreur Init(CTypeTableParametrable typeTable) { CResultAErreur result = CResultAErreur.True; m_ctrlEditCol.Visible = false; m_typeTable = typeTable; m_gestionnaireTabControl.ForceInitPageActive(); m_gestionnaireColonnes.ObjetEdite = typeTable.Colonnes; m_extFieldCol.FillDialogFromObjet(m_typeTable); MAJComboBoxPKs(); MAJColonnesPks(); // Visibilité de l'onglet Formulaires bool bHasFormulaires = false; foreach (IDefinisseurChampCustom def in TypeTableParametrable.DefinisseursDeChamps) { if (def.RelationsFormulaires.Length > 0) { bHasFormulaires = true; break; } } if (!bHasFormulaires) { if (m_TabControl.TabPages.Contains(m_pageFormulaires)) { m_TabControl.TabPages.Remove(m_pageFormulaires); } } else { if (!m_TabControl.TabPages.Contains(m_pageFormulaires)) { m_TabControl.TabPages.Insert(0, m_pageFormulaires); } } return(result); }
public void TestVersionsDeTables() { System.Console.WriteLine("-----------------------------------Test versions de tables----------------------"); System.Console.WriteLine("Initialisation"); ResetModifs(); string strNomTableTest = "TEST_NUNIT"; string[] strNomsCols = new string[] { "Cle", "Val1", "Val2" }; //Supprime les tables de test m_contexteDonnee.SetVersionDeTravail(-1, false); //Toutes versions CListeObjetsDonnees listeTables = new CListeObjetsDonnees(m_contexteDonnee, typeof(CTableParametrable)); listeTables.Filtre = new CFiltreData(CTableParametrable.c_champLibelle + "=@1", strNomTableTest); Assert.IsTrue(CObjetDonneeAIdNumerique.Delete(listeTables)); //Création du type de table m_contexteDonnee.SetVersionDeTravail(null, false); CTypeTableParametrable typeTable = new CTypeTableParametrable(m_contexteDonnee); if (typeTable.ReadIfExists(new CFiltreData(CTypeTableParametrable.c_champLibelle + "=@1", strNomTableTest))) { Assert.IsTrue(CObjetDonneeAIdNumerique.Delete(typeTable.Colonnes)); typeTable.BeginEdit(); } else { typeTable.CreateNew(); } typeTable.Libelle = strNomTableTest; CColonneTableParametrable col1 = new CColonneTableParametrable(typeTable.ContexteDonnee); col1.CreateNewInCurrentContexte(); col1.Libelle = strNomsCols[0]; col1.TypeDonneeChamp = new C2iTypeDonnee(TypeDonnee.tString); col1.AllowNull = false; col1.TypeTable = typeTable; col1.PrimaryKeyPosition = 0; col1.Position = 0; CColonneTableParametrable col2 = new CColonneTableParametrable(typeTable.ContexteDonnee); col2.CreateNewInCurrentContexte(); col2.Libelle = strNomsCols[1]; col2.TypeDonneeChamp = new C2iTypeDonnee(TypeDonnee.tString); col2.TypeTable = typeTable; col2.Position = 1; CColonneTableParametrable col3 = new CColonneTableParametrable(typeTable.ContexteDonnee); col3.CreateNewInCurrentContexte(); col3.Libelle = strNomsCols[2]; col3.TypeDonneeChamp = new C2iTypeDonnee(TypeDonnee.tString); col3.TypeTable = typeTable; col3.Position = 2; Assert.IsTrue(typeTable.CommitEdit()); //Création d'une table dans le référentiel CTableParametrable tableP = new CTableParametrable(m_contexteDonnee); tableP.CreateNew(); tableP.Libelle = strNomTableTest; tableP.TypeTable = typeTable; DataTable table = tableP.DataTableObject; /*Table dans le referentiel * KEY | Val1 | Val2 * A1 | A2 | A3 * B1 | B2 | B3 * C1 | C2 | C3 * D1 | D2 | D3 * */ DataRow row = null; for (int nRow = 0; nRow < 4; nRow++) { row = table.NewRow(); string strCleLigne = (new string[] { "A", "B", "C", "D" })[nRow]; for (int nCol = 1; nCol < table.Columns.Count; nCol++) { if (table.Columns[nCol].ColumnName != CTableParametrable.c_strColTimeStamp) { row[nCol] = strCleLigne + (nCol).ToString(); } } table.Rows.Add(row); } tableP.DataTableObject = table; Assert.IsTrue(tableP.CommitEdit()); //--------------------------------------------------------- ///Modification de la table en V1 System.Console.Write("Modif dans V1"); string strA2V1 = "A2 en V1"; m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[0], false); table = tableP.DataTableObject; row = table.Rows[0]; row[strNomsCols[1]] = strA2V1; tableP.BeginEdit(); tableP.DataTableObject = table; Assert.IsTrue(tableP.CommitEdit()); //La table n'a pas bougé en version référentiel m_contexteDonnee.SetVersionDeTravail(null, false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", "A3" }, new string[] { "B1", "B2", "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table n'a pas bougé en V2 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[1], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", "A3" }, new string[] { "B1", "B2", "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table a bougé en V1 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[0], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V1, "A3" }, new string[] { "B1", "B2", "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table a bougé en V3 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[2], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V1, "A3" }, new string[] { "B1", "B2", "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //--------------------------------------------------------- //Modification de la table dans le référentiel : //Modif ligne 1 et ligne 2. System.Console.Write("Modif dans Ref"); m_contexteDonnee.SetVersionDeTravail(null, false); table = tableP.DataTableObject; row = table.Rows[0]; string strA3REF = "A3 ref"; row[strNomsCols[2]] = strA3REF; row = table.Rows[1]; string strB2REF = "B2 ref"; row[strNomsCols[1]] = strB2REF; tableP.BeginEdit(); tableP.DataTableObject = table; Assert.IsTrue(tableP.CommitEdit()); //La table n'a pas bougé en version référentiel m_contexteDonnee.SetVersionDeTravail(null, false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", strA3REF }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table n'a pas bougé en V2 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[1], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", strA3REF }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //la ligne A de V1 ne doit pas être modifiée, //Par contre la ligne 2 oui m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[0], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V1, "A3" }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //V3 = V1 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[2], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V1, "A3" }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //--------------------------------------------------------- System.Console.Write("Modif dans V3"); //Modification de la ligne en V3 string strA2V3 = "A2 en V3"; m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[2], false); table = tableP.DataTableObject; row = table.Rows[0]; row[strNomsCols[1]] = strA2V3; tableP.BeginEdit(); tableP.DataTableObject = table; Assert.IsTrue(tableP.CommitEdit()); //La table n'a pas bougé en version référentiel m_contexteDonnee.SetVersionDeTravail(null, false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", strA3REF }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table n'a pas bougé en V2 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[1], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", strA3REF }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table a bougé en V1 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[0], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V1, "A3" }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table a bougé en V3 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[2], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V3, "A3" }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //----------------------------------------------- //Suppression de la ligne C en V1 System.Console.Write("Delete dans V1"); m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[0], false); table = tableP.DataTableObject; table.Rows[2].Delete(); tableP.BeginEdit(); tableP.DataTableObject = table; Assert.IsTrue(tableP.CommitEdit()); //La table n'a pas bougé en version référentiel m_contexteDonnee.SetVersionDeTravail(null, false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", strA3REF }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table n'a pas bougé en V2 m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[1], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", "A2", strA3REF }, new string[] { "B1", strB2REF, "B3" }, new string[] { "C1", "C2", "C3" }, new string[] { "D1", "D2", "D3" } }); //La table a bougé en V1 (plus de ligne C) m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[0], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V1, "A3" }, new string[] { "B1", strB2REF, "B3" }, new string[] { "D1", "D2", "D3" } }); //La table a bougé en V3 (plus de ligne C) m_contexteDonnee.SetVersionDeTravail(m_nIdsVersions[2], false); table = tableP.DataTableObject; VerifTable(table, strNomsCols, new string[][] { new string[] { "A1", strA2V3, "A3" }, new string[] { "B1", strB2REF, "B3" }, new string[] { "D1", "D2", "D3" } }); }
//------------------------------------------------------------------------- public CFormEditionTypeTableParametrable(CTypeTableParametrable TypeTable, CListeObjetsDonnees liste) : base(TypeTable, liste) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); }