/// <summary> /// Convert combox list to table list /// </summary> /// <param name="view"></param> /// <param name="field"></param> /// <param name="newTableName"></param> /// <returns></returns> public static bool ConvertSimpleList(TabloidConfigView view, TabloidConfigColonne field, string newTableName, IWin32Window own) { var join = view.Jointures.GetJointure(field.Jointure); //search for a unique constraint name var fk1Name = SearchConstraintUniqueName(view.NomTable + "_fk", view.Schema); var fk2Name = SearchConstraintUniqueName(join.NomTable + "_fk", view.Schema); var param = new[] { view.Schema, //0 schema view.NomTable, //1 master table join.NomTable, //2 actually joined table newTableName, //3 new intermediate table view.DbKey, //4 master table dbkey join.ChampDeRef, //5 master table foreign key field join.DbKey, //6 actually joined table primary key fk1Name, fk2Name }; var result = ExecuteFromFile("fieldListTOfieldComplexList.sql", param, Program.AppSet.ConnectionString, own); if (!result) { return(false); } SqlCommands.DropColumn(view.NomTable, join.ChampDeRef, view.Schema, own); var joinLst = new TabloidConfigJointure { Relation = "1:N", NomTable = newTableName, DbKey = "id_" + newTableName, ChampDeRef = view.NomTable + "." + view.DbKey, ChampDeRef2 = view.NomTable + "_id" }; var join2 = new TabloidConfigJointure { NomTable = join.NomTable, DbKey = join.DbKey, ChampDeRef = join.NomTable + "_id", Order = join.Order }; var joinLstRoleID = WizardTools.Tools.AddWithUniqueName(view.Jointures, joinLst, "J"); WizardTools.Tools.AddWithUniqueName(view.Jointures, join2, "J", joinLst.Jointures); view.Detail = true; view.Jointures.Remove(join); field.Jointure = joinLstRoleID; field.Editeur = TemplateType.GridView; field.VisibleListe = false; var lstView = new TabloidConfigView { Nom = newTableName, Titre = newTableName, Schema = view.Schema, DbKey = "id_" + newTableName }; var joinLstView = new TabloidConfigJointure { NomTable = view.NomTable, DbKey = view.DbKey, ChampDeRef = view.NomTable + "_id" }; var joinLstView2 = new TabloidConfigJointure { NomTable = join.NomTable, DbKey = join.DbKey, ChampDeRef = join.NomTable + "_id" }; var j1 = WizardTools.Tools.AddWithUniqueName(lstView.Jointures, joinLstView, "J"); var j2 = WizardTools.Tools.AddWithUniqueName(lstView.Jointures, joinLstView2, "J"); //var c1 = new TabloidConfigColonne //{ // Titre = view.NomTable, // Type = DbType.Int16, // Champ = view.DbKey, // Editeur = TemplateType.ComboBoxPlus, // Jointure = j1 //}; var c2 = new TabloidConfigColonne { Titre = field.Titre, Type = DbType.Int16, Champ = field.Champ, Valideurs = field.Valideurs, Obligatoire = field.Obligatoire, Information = field.Information, Editeur = TemplateType.ComboBoxPlus, Jointure = j2 }; //WizardTools.addWithUniqueName(lstView.Colonnes, c1, "C"); WizardTools.Tools.AddWithUniqueName(lstView.Colonnes, c2, "C"); TabloidConfig.Config.Views.Add(lstView); return(true); }