コード例 #1
0
        /// <summary>
        /// Set TabloidConfigColonne visibility using checkboxlist element
        /// </summary>
        /// <param name="c"></param>
        /// <param name="clb"></param>
        public static void SetFieldVisibilityProperties(TabloidConfigColonne c, CheckedListBox clb)
        {
            var checkedItems = clb.CheckedItems;

            foreach (string p in Visibilities.Keys)
            {
                var propertyInfo = c.GetType().GetProperty(Visibilities[p]);
                if (propertyInfo != null)
                {
                    propertyInfo.SetValue(c, checkedItems.Contains(p), null);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Add view/gridView field and distinct if required
        /// </summary>
        /// <param name="sourceView">tabloidConfigView containing the list field</param>
        /// <param name="FieldTitle">Title of created field</param>
        /// <param name="join">TabloidConfigJoin used for field</param>
        /// <param name="fieldName">datatable field name</param>
        /// <param name="gridView">true to create gridview false to create view</param>
        /// <param name="addDistinct">add distinct to source view</param>
        public static bool AddGridviewField(TabloidConfigView sourceView, string FieldTitle, TabloidConfigJointure join, string fieldName, bool gridView, bool addDistinct)
        {
            if (!string.IsNullOrEmpty(fieldName))
            {
                var c = new TabloidConfigColonne
                {
                    Type         = DbType.String,
                    Titre        = FieldTitle,
                    VisibleListe = false,
                    Champ        = fieldName,
                    Jointure     = join.Nom,
                    Editeur      = gridView ? TemplateType.GridView : TemplateType.View
                };

                WizardTools.Tools.AddWithUniqueName(sourceView.Colonnes, c, "C");
            }

            if (addDistinct)
            {
                var newDistinct = sourceView.NomTable + "." + sourceView.DbKey;

                sourceView.Distinct = addIfNotExist(sourceView.Distinct, newDistinct);

                if (string.IsNullOrEmpty(sourceView.Order))
                {
                    sourceView.Order = sourceView.Distinct;
                }
                else
                {
                    var orderParts = sourceView.Order.Split(' ');//remove order asc/desc
                    //orderParts[0] += "," + sourceView.Distinct;
                    addIfNotExist(orderParts[0], newDistinct);
                    sourceView.Order = string.Join(" ", orderParts);//retrieve asc/desc
                }
            }

            sourceView.Detail = true;
            return(true);
        }
コード例 #3
0
        //--Editeur-->Champ
        public WizardField(IViewFct view, TabloidConfigColonne parentField, string connectionString, Provider provider)
        {
            _iviewFct         = view;
            _parentField      = parentField;
            _provider         = provider;
            _connectionString = connectionString;

            InitializeComponent();

            Champ.CloseFromNext += validateFieldCreation;
            Champ.CloseFromNext += validateFieldEditorCompliance;
            Champ.CloseFromBack += validateFieldCreation;
            Champ.ShowFromBack  += ChampShowCreation;

            Button.ShowFromBack += Button_ShowFromBack;
            Button.ShowFromNext += Button_ShowFromNext;

            Editeur.ShowFromNext  += Editeur_ShowFromNext;
            Editeur.CloseFromNext += Editeur_CloseFromNext;
            Editeur.ShowFromBack  += Editeur_ShowFromBack;

            Graphique.ShowFromNext += Graphique_ShowFromNext;
            Graphique.ShowFromBack += Graphique_ShowFromBack;

            visibilite.ShowFromBack  += Visbile_ShowFromBack;
            visibilite.CloseFromBack += Visbile_CloseFromBack;
            visibilite.Enter         += updateVisibilityList;

            if (_iviewFct is TabloidConfigView)
            {
                cmbGraph.DataSource = ((TabloidConfigView)view).Graphiques;
            }


            fs.ConnectionString     = _connectionString;
            fs.cmdSchema.DataSource = AppSetting.GetSchemaList(_provider);//.Items.Add("finance_subv");
            fs.Enabled = false;
        }
コード例 #4
0
        /// <summary>
        /// Build required task on wizard end
        /// </summary>
        /// <returns></returns>
        bool addField()
        {
            var useJoinName = "";

            if (_iviewFct is TabloidConfigView && !radbutton.Checked)
            {
                var view = (TabloidConfigView)_iviewFct;

                if (_useDatabaseField && //handel label with no database field
                    ((TabloidBaseControl)wzCmbEditeur.SelectedItem).type != TemplateType.Graphique) //no database field for graphic
                {
                    if (radioCrea.Checked)                                                          //field must be created in database
                    {
                        var t       = (DbType)Enum.Parse(typeof(DbType), lstTypeCrea.SelectedItem.ToString());
                        var sqlType = dataHelper.DbTypeConverter.ConvertFromGenericDbType(t, Tools.ConvertProviderType(_provider));

                        var fieldArg = txtLong.Text;
                        if (txtDec.Text != "")
                        {
                            fieldArg = fieldArg + "," + txtDec.Text;
                        }
                        if (fieldArg != "")
                        {
                            fieldArg = "(" + fieldArg + ")";
                        }

                        var param = new string[] { view.NomTable, txtNomCrea.Text, sqlType + fieldArg, view.Schema };

                        if (!WizardSQLHelper.ExecuteFromFile("addField.sql", param, _connectionString, this))
                        {
                            return(true);
                        }
                    }
                    else//use existing field
                    {
                        if (fs.cmbTable.SelectedValue.ToString() != view.NomTable &&
                            ((TabloidBaseControl)wzCmbEditeur.SelectedItem).type != TemplateType.Graphique)//verify if field is in current table
                        {
                            var useJoin = view.Jointures.GetJoinFromTableName(fs.cmbTable.SelectedValue.ToString());
                            if (useJoin == null)//verify if table is in joined table list
                            {
                                if (MetroMessageBox.Show(this, Resources.add_join, Resources.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                                {
                                    var w = new WizardJoin(
                                        view,
                                        null,
                                        Program.AppSet.ConnectionString);

                                    w.ShowDialog();

                                    useJoin = view.Jointures.GetJoinFromTableName(fs.cmbTable.SelectedValue.ToString());
                                    if (useJoin != null)
                                    {
                                        useJoinName = useJoin.Nom;
                                    }
                                }
                            }
                            else
                            {
                                useJoinName = useJoin.Nom;
                            }
                        }
                    }
                }
            }

            if (radbutton.Checked)//add button
            {
                Tc = new TabloidConfigColonne
                {
                    Champ         = fs.lstChamp.Text,
                    Titre         = WzTxtTitre.Text,
                    Editeur       = TemplateType.Btn,
                    Type          = DbType.String,
                    EditeurParam2 = txtIcoBtn.Text,
                    EditeurParam3 = txtUrlBtn.Text,
                    EditeurParam4 = txtToolTipBtn.Text,
                    VisibleDetail = true,
                    Parent        = _parentField,
                    Nom           = "btn"
                }
            }
            ;
            else//add other type field
            {
                Tc = new TabloidConfigColonne
                {
                    Champ   = radioCrea.Checked ? txtNomCrea.Text : fs.lstChamp.Text,
                    Titre   = WzTxtTitre.Text,
                    Editeur = ((TabloidBaseControl)wzCmbEditeur.SelectedItem).type,
                    Type    = radioCrea.Checked ?
                              (DbType)Enum.Parse(typeof(DbType), lstTypeCrea.SelectedItem.ToString()) :
                              DbType.String,
                    EditeurParam1 = txtUrlBtn.Text,
                    Parent        = _parentField,
                    Jointure      = useJoinName,
                    Nom           = "C"
                };

                if (Tc.Editeur == TemplateType.Picture)
                {
                    Tc.EditeurParam1 = "144x200";
                    Tc.EditeurParam2 = "/Tabloid/images/inconnu.png";
                    Tc.EditeurParam3 = "jpg";
                    Tc.EditeurParam4 = "4";
                }

                if (Tc.Editeur == TemplateType.Graphique)
                {
                    Tc.EditeurParam1 = ((TabloidConfigGraph)cmbGraph.SelectedItem).Nom;
                }

                if (_iviewFct is TabloidConfigView)
                {
                    var view = (TabloidConfigView)_iviewFct;

                    if (Tc.Editeur == TemplateType.Mobile)
                    {
                        view.Recherche.ChampMobile = radioCrea.Checked ? txtNomCrea.Text : fs.lstChamp.Text;
                        WizardSQLHelper.SetMobile(view);
                    }
                    if (Tc.Editeur == TemplateType.Mail)
                    {
                        view.Recherche.ChampMail = radioCrea.Checked ? txtNomCrea.Text : fs.lstChamp.Text;
                    }
                }
            }

            WizardSQLHelper.SetFieldVisibilityProperties(Tc, lstVisibilites);

            var parent = _iviewFct.Colonnes;

            if (_parentField != null)
            {
                parent = _parentField.Colonnes;
            }

            Tools.AddWithUniqueName(_iviewFct.Colonnes, Tc, "C", parent);

            return(false);
        }
コード例 #5
0
 public WizardSimpleListConverter(TabloidConfigView view, TabloidConfigColonne field)
 {
     InitializeComponent();
     _field = field;
     _view  = view;
 }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <summary>
        /// Convert field to list
        /// </summary>
        /// <param name="view"></param>
        /// <param name="field"></param>
        /// <param name="newTableName"></param>
        /// <returns></returns>
        public static bool ConvertFieldToList(TabloidConfigView view, TabloidConfigColonne field, string newTableName, IWin32Window own)
        {
            //search for a unique constraint name
            var fk1Name   = SearchConstraintUniqueName(newTableName + "_fk", view.Schema);
            var fieldType = dataHelper.DbTypeConverter.ConvertFromGenericDbType(field.Type, WizardTools.Tools.ConvertProviderType(Program.AppSet.ProviderType));

            var param = new[]
            {
                view.Schema,   //0 schema
                newTableName,  //1 new table name
                view.NomTable, //2 old table name
                field.Champ,   //3 field name to convert
                fieldType,     //4 field type
                fk1Name        //5 constraint name
            };


            var result = ExecuteFromFile("fieldToList.sql", param, Program.AppSet.ConnectionString, own);

            if (!result)
            {
                return(false);
            }

            var join = new TabloidConfigJointure
            {
                NomTable   = newTableName,
                DbKey      = "id_" + newTableName,
                ChampDeRef = newTableName + "_id",
            };

            var tabloidJoinID = WizardTools.Tools.AddWithUniqueName(view.Jointures, join, "J");

            field.Jointure = tabloidJoinID;
            field.Editeur  = TemplateType.ComboBoxPlus;

            var lstView = new TabloidConfigView
            {
                Nom    = newTableName,
                Titre  = newTableName,
                Schema = view.Schema,
                DbKey  = "id_" + newTableName
            };

            var c2 = new TabloidConfigColonne
            {
                Titre       = field.Titre,
                Type        = field.Type,
                Champ       = field.Champ,
                Valideurs   = field.Valideurs,
                Obligatoire = field.Obligatoire,
                Information = field.Information,
                DSID        = field.DSID,
                Editeur     = field.Editeur
            };

            field.DSID = "";

            WizardTools.Tools.AddWithUniqueName(lstView.Colonnes, c2, "C");

            TabloidConfig.Config.Views.Add(lstView);

            AddToParamMenu(lstView, own);

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// add field to main table with constraint
        /// add join to main table collection collection
        /// add new table to table collection
        ///
        /// return true if job done
        /// </summary>
        /// <param name="complexList"></param>
        /// <param name="schema"></param>
        /// <param name="newtableName"></param>
        /// <param name="sourceView"></param>
        /// <param name="tableSrcFieldRef"></param>
        /// <param name="connectionString"></param>
        /// <param name="provider"></param>
        /// <param name="alias">if not empty buil a new join with given alias</param>
        /// <param name="addFieldOnly">Add field and join but not new table</param>
        /// <param name="useJoin">if not null join is not created and given join is used</param>
        /// <param name="addFieldOnly">Add only join</param>
        /// <returns></returns>
        public static bool SetDataBaseForList(IWin32Window own, bool complexList, string schema, string newtableName, string newDbKey, string newViewName, bool addToParamMenu, TabloidConfigView sourceView, string tableSrcFieldRef, string connectionString, Provider provider, bool addNameField = true, bool addDistinct = false, string alias = null, bool addFieldOnly = false, string schemaNewtable = null, TabloidConfigJointure useJoin = null, bool addOnlyJoin = false)
        {
            try
            {
                var    param        = new[] { schema, newtableName.ToLower(), sourceView.NomTable, tableSrcFieldRef };
                var    complexParam = new[] { schema, newtableName.ToLower(), sourceView.NomTable, sourceView.DbKey };
                string select       = null;
                string aliasDbKey   = null;

                if (!addOnlyJoin)
                {
                    if (addFieldOnly)
                    {
                        // add field to table
                        var sqlType = dataHelper.DbTypeConverter.ConvertFromGenericDbType(DbType.Int16, WizardTools.Tools.ConvertProviderType(Program.AppSet.ProviderType));

                        //    var fieldOnlyParam = new[] {
                        //sourceView.NomTable,
                        //tableSrcFieldRef,
                        //sqlType,
                        //schema };
                        tableSrcFieldRef = addField(sourceView.NomTable, tableSrcFieldRef, sqlType, schema, own);
                        if (tableSrcFieldRef == null)
                        {
                            return(false);
                        }

                        //var fieldOnlyParam = new[] { schema, newtableName, sourceView.NomTable, tableSrcFieldRef, schemaNewtable ?? schema, newDbKey };//"id_"+ newtableName
                        //if (!ExecuteFromFile("addConstraint.sql", fieldOnlyParam, connectionString)) return false;//TO DO handel duplicate name

                        //add constraint do not stop on error
                        addConstraint(schema, newtableName, sourceView.NomTable, tableSrcFieldRef, schemaNewtable ?? schema, newDbKey, own);

                        if (!string.IsNullOrEmpty(alias))
                        {
                            aliasDbKey = "id_" + alias;
                            select     = $"{alias}.id_{newtableName} as id_{alias},{alias}.nom_{newtableName} as nom_{alias}";
                        }
                    }
                    else
                    if (!ExecuteFromFile(complexList ? "fieldComplexList.sql" : "fieldList.sql", complexList ? complexParam : param, connectionString, own))
                    {
                        return(false);
                    }
                }

                //add join
                var newJoin = useJoin;

                if (useJoin == null)
                {
                    var j = new TabloidConfigJointure
                    {
                        NomTable    = newtableName,
                        DbKey       = newDbKey,//"id_" + newtableName,
                        Relation    = complexList ? "1:N" : "",
                        AliasTable  = alias,
                        Select      = select,
                        AliasDbKey  = aliasDbKey,
                        ChampDeRef  = complexList ? sourceView.Nom + "." + sourceView.DbKey : tableSrcFieldRef,
                        ChampDeRef2 = complexList ? sourceView.Nom + "_id" : "",
                        Order       = complexList ? "" : "nom_" + newtableName + " asc"
                    };

                    Classes.WizardTools.Tools.AddWithUniqueName(sourceView.Jointures, j, "J");

                    newJoin = j;
                }

                if (!complexList)
                {//add combo list field
                    var c = new TabloidConfigColonne
                    {
                        Type     = DbType.String,
                        Titre    = newViewName,
                        Champ    = "nom_" + (string.IsNullOrEmpty(alias) ? newtableName : alias),
                        Jointure = newJoin.Nom,
                        Editeur  = TemplateType.ComboBoxPlus
                    };

                    WizardTools.Tools.AddWithUniqueName(sourceView.Colonnes, c, "C");
                }
                else
                {//add gridview field
                    AddGridviewField(sourceView, newtableName, newJoin, "nom_" + newtableName, true, addDistinct);
                }

                if (addFieldOnly)
                {
                    return(true);
                }

                //add new table
                var t = new TabloidConfigView
                {
                    Schema = schema,
                    Nom    = newtableName,
                    Titre  = newViewName,
                    DbKey  = "id_" + newtableName
                };
                if (!complexList || true)
                {// add field name to the new created table
                    t.Order = "nom_" + newtableName + " asc";

                    var ct = new TabloidConfigColonne
                    {
                        Nom   = "C" + t.Colonnes.Count,
                        Type  = DbType.String,
                        Titre = "Nom",
                        Champ = "nom_" + newtableName
                    };

                    WizardTools.Tools.AddWithUniqueName(t.Colonnes, ct, "C");
                }
                TabloidConfig.Config.Views.Add(t);

                //add new table in menu
                try
                {
                    if (addToParamMenu)
                    {
                        AddToParamMenu(t, own);
                    }
                }
                catch (Exception e)
                {
                    MetroMessageBox.Show(own, e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(true);
                }
            }
            catch (Exception e)
            {
                MetroMessageBox.Show(own, e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }


            return(true);
        }
コード例 #9
0
ファイル: QGen.cs プロジェクト: legrandnarbonne/TabloidWizard
        private void btnGen_Click(object sender, EventArgs e)
        {
            bool result;
            var  createdList = new List <string>();

            var startViewCount = TabloidConfig.Config.Views.Count;

            //clean response list
            foreach (DataRow dr in _tbContainer.Rows)
            {
                if (dr.RowState != DataRowState.Deleted && dr["Réponses"].ToString() != "")
                {
                    var r = dr["Réponses"].ToString().Trim();
                    r = r.Replace('-', ';');
                    dr["Réponses"] = r;
                }
            }

            _tbContainer.AcceptChanges();

            //search duplicate response list for combo box
            _tbContainer.Columns.Add("Liste");
            var list = 0;

            foreach (DataRow dr in _tbContainer.Rows)
            {
                if (dr.RowState != DataRowState.Deleted && dr["Réponses"].ToString() != "" && dr["Liste"] == DBNull.Value)
                {
                    var currentListName = "lr" + list.ToString();

                    dr["Liste"] = currentListName;

                    var dv = new DataView(_tbContainer, string.Format("Réponses like '{0}'", DataTools.ExtendedStringToSql(dr["Réponses"].ToString())), "", DataViewRowState.Unchanged);
                    foreach (DataRowView drv in dv)
                    {
                        drv["Liste"] = currentListName;
                    }

                    list++;
                }
            }

            //add new View
            var param = new string[] { Program.AppSet.Schema, txtVue.Text, "id_" + txtVue.Text };
            var t     = new TabloidConfigView
            {
                Schema          = param[0],
                Nom             = txtVue.Text,
                Titre           = txtVue.Text,
                NomTable        = txtVue.Text,
                DbKey           = param[2],
                Detail          = true,
                DisplayOnTowRow = true
            };

            result = WizardSQLHelper.ExecuteFromFile("table.sql", param, Program.AppSet.ConnectionString, this);
            if (!result)
            {
                return;
            }

            var i = 1;

            param = new string[] { txtVue.Text, "", "", Program.AppSet.Schema };
            foreach (DataRow dr in _tbContainer.Rows)
            {
                if (dr.RowState != DataRowState.Deleted)
                {
                    param[1] = "R" + i;
                    var info = dr["Info"].ToString();

                    var Tc = new TabloidConfigColonne
                    {
                        Nom          = "C" + i,
                        Champ        = "r" + i,
                        Groupe       = "!!!" + dr["Groupe"],
                        Titre        = dr["Questions"].ToString(),
                        VisibleListe = false,
                        Information  = info
                    };

                    if (dr["Réponses"].ToString() == "")
                    { //TextBox
                        Tc.Editeur = Tabloid.Classes.Controls.TemplateType.Defaut;
                        Tc.Type    = DbType.String;
                        param[2]   = dataHelper.DbTypeConverter.ConvertFromGenericDbType(DbType.String, Classes.WizardTools.Tools.ConvertProviderType(Program.AppSet.ProviderType));
                        result     = WizardSQLHelper.ExecuteFromFile("addField.sql", param, Program.AppSet.ConnectionString, this);

                        t.Colonnes.Add(Tc);
                    }
                    else
                    {//ComboBox
                        var tableCreationNeeded = !createdList.Contains(dr["Liste"].ToString());

                        result = WizardSQLHelper.SetDataBaseForList(this, false, Program.AppSet.Schema, dr["Liste"].ToString(), dr["Liste"].ToString(), "id_" + dr["Liste"].ToString(), false, t, Tc.Champ, Program.AppSet.ConnectionString, Program.AppSet.ProviderType, true, false, tableCreationNeeded ? "" : "alr" + i, !tableCreationNeeded);

                        var c = t.Colonnes[t.Colonnes.Count - 1];                        //last added column
                        c.Groupe       = "!!!" + dr["Groupe"];
                        c.Editeur      = Tabloid.Classes.Controls.TemplateType.ComboBox; //replace comboboxplus by combobox
                        c.Titre        = dr["Questions"].ToString();
                        c.VisibleListe = false;
                        c.Obligatoire  = true;
                        c.Information  = info;
                        createdList.Add(dr["Liste"].ToString());
                    }

                    i++;
                }
            }

            t.Index = TabloidConfig.Config.Views.Count - startViewCount;
            TabloidConfig.Config.Views.Add(t);

            // fill possible response table (lrx)
            DataView  view           = new DataView(_tbContainer);
            DataTable distinctValues = view.ToTable(true, "Liste", "Réponses");

            foreach (DataRow dr in distinctValues.Rows)
            {
                if (dr.RowState != DataRowState.Deleted)
                {
                    var sols   = dr["Réponses"].ToString().Split(';');
                    var values = "";

                    foreach (string sol in sols)
                    {
                        values += $"('{DataTools.StringToSql(sol.Trim())}'),";
                    }


                    values = values.TrimEnd(',');

                    var sql = $"INSERT INTO {Program.AppSet.Schema}.{ dr["Liste"]} (nom_{ dr["Liste"]}) VALUES {values}";

                    string error;
                    DataTools.Command(sql, null, Program.AppSet.ConnectionString, out error);
                }
            }


            //add default url field in user table
            var sqlType      = dataHelper.DbTypeConverter.ConvertFromGenericDbType(DbType.String, Classes.WizardTools.Tools.ConvertProviderType(Program.AppSet.ProviderType));
            var requestParam = new string[] { "roles", "default_url", sqlType + $"(300)", Program.AppSet.Schema };

            WizardSQLHelper.ExecuteFromFile("addField.sql", requestParam, Program.AppSet.ConnectionString, this);

            //add role "sonde"
            var detailURL    = AppSetting.GetDefaultPageURL(t.Nom, TabloidPages.Type.Detail) + "&mode=questionnaire";
            var profileRight = (ulong)Math.Pow(2, t.Index);
            //var profileRight2 = ~profileRight;

            var sql2 = $"insert into roles (titre_role,datemaj_roles,droits_lecture,droits_ecriture,droits_limite,droits_limiteecr,droits_suppression,default_url) values ('Sondé',now(),{profileRight},{profileRight},{profileRight},{profileRight},0,'{detailURL}')";

            sql2 += string.Format(
                SqlConverter.GetSql(SqlConverter.SqlType.InsertCommandKeyOut),
                "id_role");

            string error2;

            var roleId = DataTools.ScalarCommand(sql2, null, Program.AppSet.ConnectionString, out error2);

            //set config
            Program.AppSet.TabloidType = TabloidTypes.Questionnaire;
            AppSetting.setDefaultPage(t.Nom);
            Program.AppSet.champPageDefaut    = "default_url";
            Program.AppSet.AutoenrollmentRole = roleId.ToString();

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #10
0
        private void Button_end(object sender, PageEventArgs e)
        {
            string sql = "";

            var titre = buildField(chkCreaTitre, cmbTitre, txtTitre, ref sql);
            var deb   = buildField(chkCreaDeb, cmbDeb, txtDebut, ref sql);
            var fin   = buildField(chkCreaFin, cmbFin, txtFin, ref sql);

            if (sql != "")
            {
                sql     += "commit;";
                e.Cancel = !WizardSQLHelper.ExecuteSQLString(sql, this);
                if (e.Cancel)
                {
                    return;
                }
            }

            var cal = new TabloidConfigCalendrier
            {
                Titre = titre,
                Debut = deb,
                Fin   = fin
            };

            var cTitre = new TabloidConfigColonne
            {
                Titre = "Titre",
                Champ = titre,
                Type  = DbType.String
            };

            var cDebut = new TabloidConfigColonne
            {
                Titre = "Début",
                Champ = deb,
                Type  = DbType.DateTime
            };

            var cFin = new TabloidConfigColonne
            {
                Titre = "Fin",
                Champ = fin,
                Type  = DbType.DateTime
            };

            if (chkCreaTitre.Checked)
            {
                Tools.AddWithUniqueName(_view.Colonnes, cTitre, "C");
            }
            if (chkCreaDeb.Checked)
            {
                Tools.AddWithUniqueName(_view.Colonnes, cDebut, "C");
            }
            if (chkCreaFin.Checked)
            {
                Tools.AddWithUniqueName(_view.Colonnes, cFin, "C");
            }

            _view.Calendrier = cal;

            if (chkAddToMenu.Checked)
            {
                var mn = radMnParam.Checked ? WizardSQLHelper.getParamMenu() : null;

                WizardSQLHelper.AddToMenu(this, _view, null, TabloidConfigMenuItem.MenuType.Calendrier, mn);
            }
        }
コード例 #11
0
        private void Button_end(object sender, PageEventArgs e)
        {
            var param = new string[] { txtSchema.Text, txtTable.Text, TxtRef.Text };

            if (radUseExistingTable.Checked)
            {
                string lastError;
                //find db key
                var dc = DataTools.Data(SqlCommands.SqlGetColums(cmbTable.Text), _connectionString, out lastError);//3

                param = new string[] { Program.AppSet.Schema, cmbTable.Text, dc.Select(dc.Columns[3].ColumnName + " like 'PRI%'")[0][0].ToString() };
            }

            var viewName = String.IsNullOrEmpty(txtNomVue.Text) ? param[1] : txtNomVue.Text;

            if (TabloidConfig.Config.Views.Contains(viewName))
            {
                MetroMessageBox.Show(this, TabloidWizard.Properties.Resources.ViewNameAlreadyExist, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.Cancel = true;
                return;
            }


            //add new View
            CreatedView = new TabloidConfigView
            {
                Schema   = param[0],
                Nom      = viewName,
                Titre    = txtInititView.Text,
                NomTable = param[1],// String.IsNullOrEmpty(txtNomVue.Text) ? "" : txtNomVue.Text,
                DbKey    = param[2]
            };

            if (radUseExistingTable.Checked)
            {
                TabloidConfig.Config.Views.Add(CreatedView);

                //set as default view
                setAsDefaultView(viewName);

                //add to menu
                addToMenu(CreatedView);

                return;
            }

            e.Cancel = !WizardSQLHelper.ExecuteFromFile("table.sql", param, _connectionString, this);
            if (e.Cancel)
            {
                return;
            }

            var Tc = new TabloidConfigColonne
            {
                Champ   = "nom_" + param[1],
                Titre   = "Nom",
                Editeur = TemplateType.TextBox,
                Type    = DbType.String
            };

            Tools.AddWithUniqueName(CreatedView.Colonnes, Tc, "C");

            TabloidConfig.Config.Views.Add(CreatedView);

            //set as default view
            setAsDefaultView(viewName);

            //add to menu
            addToMenu(CreatedView);
        }
コード例 #12
0
        /// <summary>
        /// verify tabloid table aviability
        /// </summary>
        /// <param name="tableName">table to search</param>
        /// <param name="schema"></param>
        /// <param name="tableConfig"></param>
        /// <param name="avt"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public static bool GetTable(IWin32Window own, string tableName, string schema, ref TabloidConfigView tableConfig, ref ArrayVerify avt, BaseImporterConfig config)
        {
            var indexTable = TabloidTables.IsTabloidTable(tableName, ref avt);
            var toShow     = indexTable == -1;

            if (!toShow)                                                       //this is a tabloid table
            {
                toShow = !TabloidTables.TabloidTablesArray[indexTable].Hidden; //for tabloid table verify hidden propertie
            }
            if (toShow)                                                        //this is not a tabloid table
            {
                tableConfig        = new TabloidConfigView();
                tableConfig.Nom    = tableConfig.Titre = tableName;
                tableConfig.Titre  = ModifyTitle(tableConfig.Titre, tableName, config);
                tableConfig.Schema = schema;

                string lastError;

                var dc = DataTools.Data(SqlCommands.SqlGetColums(tableName), config.ConnectionString, out lastError);//013

                if (!string.IsNullOrEmpty(lastError))
                {
                    throw new Exception(lastError);
                    //lblState.Text = lastError;
                    return(false);
                }
                //read Fields
                var avc  = new ArrayVerify();
                var cmpt = 0;

                foreach (DataRow dcr in dc.Rows)
                {
                    cmpt++;

                    if (TabloidFields.IstabloidField(dcr[0].ToString(), ref avc) == -1)
                    {
                        var colonneConfig = new TabloidConfigColonne();

                        if (dcr[3].ToString().StartsWith("PRI", StringComparison.InvariantCulture))
                        {
                            tableConfig.DbKey = dcr[0].ToString();
                        }
                        else
                        {
                            colonneConfig.Nom   = "C" + cmpt;
                            colonneConfig.Champ = colonneConfig.Titre = dcr[0].ToString();

                            colonneConfig.Titre = ModifyTitle(colonneConfig.Titre, tableName, config);



                            colonneConfig.Type = dataHelper.DbTypeConverter.Convert(dcr[1].ToString(), SqlCommands.Provider.ToString());

                            tableConfig.Colonnes.Add(colonneConfig);
                        }
                    }
                }

                if (!avc.IsThereAll(TabloidFields.TabloidFieldsArray.Count()))        //is all tabloid field there?
                {
                    var l = avc.NotInIndex(TabloidFields.TabloidFieldsArray.Count()); //list unaviable fields
                    var r = DialogResult.Yes;

                    if (!config.CreateAuto)
                    {
                        //Show message
                        var strCh = string.Join("\n\t- ",
                                                TabloidFields.TabloidFieldsArray
                                                .Where((f, index) => l.Any(i => i == index))
                                                .Select((x, index) => x.Name + "_" + tableName).ToArray());

                        r = MetroMessageBox.Show(own,
                                                 string.Format(
                                                     Resources.NewFromBaseForm_GetTable_,
                                                     tableName, strCh),
                                                 Resources.Information,
                                                 MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Exclamation);
                    }

                    if (r == DialogResult.Yes)
                    {
                        TabloidFields.CreateField(
                            TabloidFields.TabloidFieldsArray
                            .Where((f, index) => l.Any(i => i == index))
                            .ToList(), tableName, schema, config.ConnectionString);
                    }
                }

                var jr = WizardSQLHelper.SetJoinFromConstraint(tableConfig, config.ConnectionString, ref lastError); //getting join

                if (jr != null && !string.IsNullOrEmpty(lastError))
                {
                    throw new Exception(lastError);                                               //lblState.Text = lastError;
                }
                return(jr != null);
            }

            return(false);
        }