private void RefreshList()
        {
            DataTable dt        = new DataTable();
            string    rowFilter = "";

            if (_boundTable != null)
            {
                rowFilter = _boundTable.DefaultView.RowFilter;
            }

            // Break the row filter up into tokens...
            string[] tokens = rowFilter.Split(new string[1] {
                " AND "
            }, StringSplitOptions.RemoveEmptyEntries);

            // Start rebuilding the row filter for all criteria except display_member...
            rowFilter = "";
            foreach (string token in tokens)
            {
                if (!token.Contains("display_member"))
                {
                    rowFilter += token + " AND ";
                }
            }
            // Now add back in the display_member row filter...
            rowFilter += "display_member like @displaymember + '%'";


            if (_sharedUtils.LocalDatabaseTableExists(_lookupTableName))
            {
                // Query the local copy of the lookup...
                // Get rows from the full lookup table that match the 'Find Filter' text...
                dt = _sharedUtils.GetLocalData("SELECT TOP 1000 * FROM " + _boundTable.TableName + " WHERE " + rowFilter + " ORDER BY display_member ASC", "@displaymember=" + ux_textboxFind.Text);
            }
            else
            {
                dt = _sharedUtils.LookupTablesGetMatchingRows(_lookupTableName, ux_textboxFind.Text, 1000);
            }

            // First clear the bound table...
            _boundTable.Clear();
            _boundTable.Load(dt.CreateDataReader(), LoadOption.Upsert);
            // Apply the row filter to the returned data...
            _boundTable.DefaultView.RowFilter = rowFilter.Replace("@displaymember + '%'", "'" + ux_textboxFind.Text.Replace("'", "''") + "%'");

            ux_textboxFind.Focus();
            ux_textboxFind.SelectionStart = ux_textboxFind.Text.Length;
        }
Пример #2
0
        private void LookupTableLoader_Load(object sender, EventArgs e)
        {
            // Indicate that things are working and the user should be patient...
            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            _sharedUtils.UpdateControls(this.Controls, this.Name);
            toolStripStatusLabel1.Tag = toolStripStatusLabel1.Text;

            DataTable lookupTables = _sharedUtils.LookupTablesGetSynchronizationStats();

            tableLayoutPanel1.Visible = true;

            tableLayoutPanel1.Show();

            // Set the style for the header row...
            tableLayoutPanel1.RowCount              = lookupTables.Rows.Count + 2;
            tableLayoutPanel1.RowStyles[0].Height   = 52;
            tableLayoutPanel1.RowStyles[0].SizeType = SizeType.Absolute;

            // Create the column headers...
            CheckBox autoUpdateCheckBox = new CheckBox();

            autoUpdateCheckBox.CheckAlign        = ContentAlignment.MiddleRight;
            autoUpdateCheckBox.TextImageRelation = TextImageRelation.ImageAboveText;
            autoUpdateCheckBox.Image             = Image.FromFile(@"Images\GG_LUTableAutoUpdate.ico");// Icon.ExtractAssociatedIcon(@"Images\GG-LUTableAutoUpdate.ico").ToBitmap();
            autoUpdateCheckBox.Text            = ux_labelAutoUpdateCheckbox.Text;
            autoUpdateCheckBox.Tag             = "_AUTOUPDATEALL_";
            autoUpdateCheckBox.TextAlign       = ContentAlignment.MiddleCenter;
            autoUpdateCheckBox.Anchor          = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            autoUpdateCheckBox.CheckedChanged += new EventHandler(autoUpdate_CheckedChanged);
            tableLayoutPanel1.Controls.Add(autoUpdateCheckBox, (int)CtrlPosition.autoUpdate, 0);
            Label tableNameLabel = new Label();

            tableNameLabel.Text      = ux_labelTableNameLabel.Text;
            tableNameLabel.TextAlign = ContentAlignment.MiddleCenter;
            tableNameLabel.Anchor    = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            tableLayoutPanel1.Controls.Add(tableNameLabel, (int)CtrlPosition.tableName, 0);
            Label progressBarLabel = new Label();

            progressBarLabel.Text      = ux_labelProgressBarLabel.Text;
            progressBarLabel.TextAlign = ContentAlignment.MiddleCenter;
            progressBarLabel.Anchor    = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            tableLayoutPanel1.Controls.Add(progressBarLabel, (int)CtrlPosition.progressBar, 0);
            Button loadAllTablesButton = new Button();

            loadAllTablesButton.Text   = ux_labelLoadAllTablesLabel.Text;
            loadAllTablesButton.Tag    = "_LOADALL_";
            loadAllTablesButton.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            loadAllTablesButton.Click += new EventHandler(loadButton_Click);
            tableLayoutPanel1.Controls.Add(loadAllTablesButton, (int)CtrlPosition.loadTableNow, 0);
            Label activityBarLabel = new Label();

            activityBarLabel.Text      = ux_labelActivityBarLabel.Text;
            activityBarLabel.TextAlign = ContentAlignment.MiddleCenter;
            activityBarLabel.Anchor    = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
            tableLayoutPanel1.Controls.Add(activityBarLabel, (int)CtrlPosition.activityProgressBar, 0);

            for (int i = 0; i < lookupTables.Rows.Count; i++)
            {
                CheckBox autoUpdate = new CheckBox();
                autoUpdate.Text            = "";
                autoUpdate.CheckAlign      = ContentAlignment.MiddleRight;
                autoUpdate.Tag             = lookupTables.Rows[i]["dataview_name"].ToString();
                autoUpdate.CheckedChanged += new EventHandler(autoUpdate_CheckedChanged);
                autoUpdate.Anchor          = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
                autoUpdate.TextAlign       = ContentAlignment.MiddleCenter;
                tableLayoutPanel1.Controls.Add(autoUpdate, (int)CtrlPosition.autoUpdate, i + 1);
                Label dataviewName = new Label();
                if (!string.IsNullOrEmpty(lookupTables.Rows[i]["title"].ToString()))
                {
                    dataviewName.Text = lookupTables.Rows[i]["title"].ToString();
                }
                else
                {
                    dataviewName.Text = lookupTables.Rows[i]["dataview_name"].ToString();
                }
                dataviewName.Anchor    = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
                dataviewName.Tag       = lookupTables.Rows[i]["dataview_name"].ToString();
                dataviewName.TextAlign = ContentAlignment.MiddleCenter;
                tableLayoutPanel1.Controls.Add(dataviewName, (int)CtrlPosition.tableName, i + 1);
                ProgressBar progressBar = new ProgressBar();
                progressBar.Value  = 0;
                progressBar.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
                progressBar.Tag    = lookupTables.Rows[i]["dataview_name"].ToString();
                tableLayoutPanel1.Controls.Add(progressBar, (int)CtrlPosition.progressBar, i + 1);
                Button loadTableNow = new Button();
                loadTableNow.Text   = ux_labelLoadTableNowLabel.Text;
                loadTableNow.Tag    = lookupTables.Rows[i]["dataview_name"].ToString();
                loadTableNow.Width  = 100;
                loadTableNow.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left;
                loadTableNow.Click += new EventHandler(loadButton_Click);
                tableLayoutPanel1.Controls.Add(loadTableNow, (int)CtrlPosition.loadTableNow, i + 1);
                ProgressBar activityProgressBar = new ProgressBar();
                activityProgressBar.Style = ProgressBarStyle.Blocks;
                activityProgressBar.MarqueeAnimationSpeed = 100;
                activityProgressBar.Minimum = 0;
                activityProgressBar.Maximum = 100;
                activityProgressBar.Value   = 0;
                activityProgressBar.Anchor  = AnchorStyles.Right | AnchorStyles.Left;
                activityProgressBar.Height  = 10;
                activityProgressBar.Tag     = lookupTables.Rows[i]["dataview_name"].ToString();
                tableLayoutPanel1.Controls.Add(activityProgressBar, (int)CtrlPosition.activityProgressBar, i + 1);
            }

            // Set the checkboxes for Auto Updating LU Tables...
            if (_sharedUtils.LocalDatabaseTableExists("lookup_table_status"))
            {
                DataTable dt = _sharedUtils.GetLocalData("SELECT * FROM lookup_table_status", "");
                for (int i = 1; i < tableLayoutPanel1.RowCount; i++)
                {
                    string tableName = "";
                    if (tableLayoutPanel1.GetControlFromPosition((int)CtrlPosition.autoUpdate, i) != null &&
                        tableLayoutPanel1.GetControlFromPosition((int)CtrlPosition.autoUpdate, i).GetType() == typeof(CheckBox))
                    {
                        tableName = ((CheckBox)tableLayoutPanel1.GetControlFromPosition((int)CtrlPosition.autoUpdate, i)).Tag.ToString().Trim();
                        DataRow dr = dt.Rows.Find(tableName);
                        if (dr != null)
                        {
                            CheckState cs = dr["auto_update"].ToString().Trim().ToUpper() == "Y" ? CheckState.Checked : CheckState.Unchecked;
                            ((CheckBox)tableLayoutPanel1.GetControlFromPosition((int)CtrlPosition.autoUpdate, i)).CheckState = cs;
                        }
                    }
                }
            }

            // Update the dialog box controls with current database information...
            UpdateControls();
            // Start the timer to update the interface...
            timer1.Start();

            // Indicate that the dialog is built and the user can navigate normally...
            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
        public LookupTablePicker(SharedUtils sharedUtils, string columnNameToLookup, DataRow parentRow, string currentValue)
        {
            InitializeComponent();
            // Initialize new objects to access the local lookup tables...
            _sharedUtils = sharedUtils;
            // Save the key for the cell that is being edited...
            _currentKey = parentRow[columnNameToLookup].ToString();
            _newKey     = _currentKey;
            // Create new filter dictionary...
            _filters = new Dictionary <string, string>();
            // Get the table for the datarow being edited...
            DataTable dt = parentRow.Table;
            // Get the column for the cell being edited...
            DataColumn dc = parentRow.Table.Columns[columnNameToLookup];

            // Make sure this is an FK column and if so inspect the fields available
            // in the lookup table that might match fields in the parentRow's table
            // If there are matches - wire them up as filters to restrict the number
            // of rows returned to the dialog box that the user chooses from...
            if (_sharedUtils.LookupTablesIsValidFKField(dc))
            {
                //_lookupTableName = dc.ExtendedProperties["foreign_key_resultset_name"].ToString().Trim();
                _lookupTableName = dc.ExtendedProperties["foreign_key_dataview_name"].ToString().Trim();
                if (_sharedUtils.LocalDatabaseTableExists(_lookupTableName))
                {
                    // This is a query to 1) get data for the current FK and also 2) get the schema for the lookup table...
                    _boundTable = _sharedUtils.GetLocalData("SELECT TOP 1000 * FROM " + _lookupTableName + " WHERE value_member = @valuemember" + " ORDER BY display_member ASC", "@valuemember=" + _currentKey);
                }
                else
                {
//MessageBox.Show("Warning!!!\n\nYour computer does not have a local copy of this lookup table.  Until this lookup table is downloaded, the Curator Tool will connect to the central database to retrieve lookup values.\n\nTIP:  To maximize performance of the Curator Tool please download all lookup tables to your local computer.", "Missing Lookup Table", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Warning!!!\n\nYour computer does not have a local copy of this lookup table.  Until this lookup table is downloaded, the Curator Tool will connect to the central database to retrieve lookup values.\n\nTIP:  To maximize performance of the Curator Tool please download all lookup tables to your local computer.", "Missing Lookup Table", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                    ggMessageBox.Name = "LookupTablePicker_LookupTablePickerMessage1";
                    if (_sharedUtils != null)
                    {
                        _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                    }
                    ggMessageBox.ShowDialog();
//_boundTable = _lookupTables.GetFilteredLookupTableRows(_lookupTableName, ux_textboxFind.Text, 1000);
                    _boundTable = _sharedUtils.LookupTablesGetMatchingRows(_lookupTableName, ux_textboxFind.Text, 1000);
                    ux_buttonRefresh.Enabled = false;
                }

                if (_boundTable != null)
                {
                    foreach (DataColumn luColumn in _boundTable.Columns)
                    {
                        if (luColumn.ColumnName != "value_member" &&
                            luColumn.ColumnName != "display_member" &&
                            luColumn.ColumnName != "created_date" &&
                            luColumn.ColumnName != "modified_date")
                        {
                            if (dt.Columns.Contains(luColumn.ColumnName) &&
                                parentRow[luColumn.ColumnName] != null)
                            {
                                _filters.Add(luColumn.ColumnName, parentRow[luColumn.ColumnName].ToString().Trim());
                            }
                            if (luColumn.ColumnName.StartsWith("is_"))
                            {
                                _filters.Add(luColumn.ColumnName, "Y");
                            }
                        }
                    }
                }
            }
            textChangeDelayTimer.Tick += new EventHandler(timerDelay_Tick);
            ux_textboxFind.Text        = currentValue;
            ux_textboxFind.Focus();
            ux_textboxFind.SelectionStart = ux_textboxFind.Text.Length;
            sharedUtils.UpdateControls(this.Controls, this.Name);
        }
Пример #4
0
        public LookupTablePicker(SharedUtils sharedUtils, string columnNameToLookup, DataRow parentRow, string currentValue)
        {
            InitializeComponent();
            // Initialize new objects to access the local lookup tables...
            _sharedUtils = sharedUtils;
            // Save the key for the cell that is being edited...
            _currentKey = parentRow[columnNameToLookup].ToString();
            _newKey = _currentKey;
            // Create new filter dictionary...
            _filters = new Dictionary<string, string>();
            // Get the table for the datarow being edited...
            DataTable dt = parentRow.Table;
            // Get the column for the cell being edited...
            DataColumn dc = parentRow.Table.Columns[columnNameToLookup];
            // Make sure this is an FK column and if so inspect the fields available
            // in the lookup table that might match fields in the parentRow's table
            // If there are matches - wire them up as filters to restrict the number
            // of rows returned to the dialog box that the user chooses from...
            if (_sharedUtils.LookupTablesIsValidFKField(dc))
            {
                //_lookupTableName = dc.ExtendedProperties["foreign_key_resultset_name"].ToString().Trim();
                _lookupTableName = dc.ExtendedProperties["foreign_key_dataview_name"].ToString().Trim();
                if (_sharedUtils.LocalDatabaseTableExists(_lookupTableName))
                {
                    // This is a query to 1) get data for the current FK and also 2) get the schema for the lookup table...
                    _boundTable = _sharedUtils.GetLocalData("SELECT TOP 1000 * FROM " + _lookupTableName + " WHERE value_member = @valuemember" + " ORDER BY display_member ASC", "@valuemember=" + _currentKey);
                }
                else
                {
            //MessageBox.Show("Warning!!!\n\nYour computer does not have a local copy of this lookup table.  Until this lookup table is downloaded, the Curator Tool will connect to the central database to retrieve lookup values.\n\nTIP:  To maximize performance of the Curator Tool please download all lookup tables to your local computer.", "Missing Lookup Table", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Warning!!!\n\nYour computer does not have a local copy of this lookup table.  Until this lookup table is downloaded, the Curator Tool will connect to the central database to retrieve lookup values.\n\nTIP:  To maximize performance of the Curator Tool please download all lookup tables to your local computer.", "Missing Lookup Table", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "LookupTablePicker_LookupTablePickerMessage1";
            if (_sharedUtils != null) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog();
            //_boundTable = _lookupTables.GetFilteredLookupTableRows(_lookupTableName, ux_textboxFind.Text, 1000);
            _boundTable = _sharedUtils.LookupTablesGetMatchingRows(_lookupTableName, currentValue, 1000);
                    ux_buttonRefresh.Enabled = false;
                }

                if (_boundTable != null)
                {
                    foreach (DataColumn luColumn in _boundTable.Columns)
                    {
                        if (luColumn.ColumnName != "value_member" &&
                            luColumn.ColumnName != "display_member" &&
                            luColumn.ColumnName != "created_date" &&
                            luColumn.ColumnName != "modified_date")
                        {
                            if (dt.Columns.Contains(luColumn.ColumnName) &&
            //parentRow[luColumn.ColumnName] != null &&
            parentRow[luColumn.ColumnName] != DBNull.Value &&
                                !luColumn.ColumnName.StartsWith("is_")) _filters.Add(luColumn.ColumnName, parentRow[luColumn.ColumnName].ToString().Trim());
                            if (luColumn.ColumnName.StartsWith("is_") &&
                                !_filters.ContainsKey(luColumn.ColumnName)) _filters.Add(luColumn.ColumnName, "Y");
                        }
                    }
                }
            }
            textChangeDelayTimer.Tick += new EventHandler(timerDelay_Tick);
            ux_textboxFind.Text = currentValue;
            ux_textboxFind.Focus();
            ux_textboxFind.SelectionStart = ux_textboxFind.Text.Length;
            sharedUtils.UpdateControls(this.Controls, this.Name);
        }