Ejemplo n.º 1
0
        public static void PopulateRecentQueryComboBox(List <OMQuery> qrylist, ComboBox comboboxRecentQueries)
        {
            DataTable recentQueriesDatatable;

            try
            {
                recentQueriesDatatable = new DataTable();
                recentQueriesDatatable.Columns.Add(RECENT_QUERY_QUERY_COLUMN, typeof(string));
                recentQueriesDatatable.Columns.Add(RECENT_QUERY_OMQUERY_COLUMN, typeof(OMQuery));

                comboboxRecentQueries.DataSource = null;
                comboboxRecentQueries.Items.Clear();

                DataRow newRow = recentQueriesDatatable.NewRow();
                newRow[0] = GetResourceString(Constants.COMBOBOX_DEFAULT_TEXT);
                newRow[1] = null;

                recentQueriesDatatable.Rows.Add(newRow);
                long TimeForRecentQueriesCreation =
                    dbInteraction.GetTimeforRecentQueriesCreation(dbInteraction.GetCurrentRecentConnection().ConnParam);
                long TimeforDbCreation = DbInteraction.dbCreationTime();
                if (TimeForRecentQueriesCreation != 0)
                {
                    if (TimeForRecentQueriesCreation > TimeforDbCreation)
                    {
                        foreach (OMQuery qry in qrylist)
                        {
                            if (qry != null)
                            {
                                newRow    = recentQueriesDatatable.NewRow();
                                newRow[0] = qry.QueryString;
                                newRow[1] = qry;

                                recentQueriesDatatable.Rows.Add(newRow);
                            }
                        }
                    }
                    else
                    {
                        dbInteraction.RemoveRecentQueries(dbInteraction.GetCurrentRecentConnection().ConnParam);
                        ListOMQueries.Clear();
                    }
                }

                comboboxRecentQueries.DisplayMember = RECENT_QUERY_QUERY_COLUMN;
                comboboxRecentQueries.ValueMember   = RECENT_QUERY_OMQUERY_COLUMN;

                comboboxRecentQueries.DataSource = recentQueriesDatatable;
            }
            catch (Exception oEx)
            {
                LoggingHelper.ShowMessage(oEx);
            }
        }