Пример #1
0
        private void ux_buttonSave_Click(object sender, EventArgs e)
        {
            int errorCount = 0;

            errorCount = SaveCooperatorData();
            if (errorCount == 0)
            {
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("All data was saved successfully", "Cooperator Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage1";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                ggMessageBox.ShowDialog();
            }
            else
            {
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The data being saved has errors that should be reviewed.\n\n  Error Count: {0}", "Cooperator Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage2";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                if (ggMessageBox.MessageText.Contains("{0}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, errorCount);
                }
                ggMessageBox.ShowDialog();
            }
            // Refresh the formatting of the cells in the DGV on the Cooperator tab page...
            RefreshDGVFormatting(ux_datagridviewCooperator);
        }
Пример #2
0
        private void CooperatorWizard_FormClosing(object sender, FormClosingEventArgs e)
        {
            // The user might be closing the form during the middle of edit changes in the datagridview - if so ask the
            // user if they would like to save their data...
            int intRowEdits = 0;

            _cooperatorBindingSource.EndEdit();
            if (_cooperator.GetChanges() != null)
            {
                intRowEdits = _cooperator.GetChanges().Rows.Count;
            }

            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s), are you sure you want to cancel your edits and close this window?", "Cancel Edits and Close", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "CooperatorWizard_FormClosingMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}"))
            {
                ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
            }
            // Show the warning dialog message if there are unsaved edits...
            if (intRowEdits > 0 && DialogResult.No == ggMessageBox.ShowDialog())
            {
                e.Cancel = true;
            }
        }
Пример #3
0
        private void ux_buttonSaveAndExit_Click(object sender, EventArgs e)
        {
            int errorCount = 0;

            errorCount = SaveCooperatorData();
            if (errorCount == 0)
            {
                //MessageBox.Show(this, "All data was saved successfully", "Accession Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("All data was saved successfully", "Cooperator Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage1";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                ggMessageBox.ShowDialog();
                this.Close();
            }
            else
            {
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The data being saved has errors that should be reviewed.\n\nWould you like to review them now?\n\nClick Yes to review the errors now.\n(Click No to abandon the errors and exit the Cooperator Wizard).\n\n  Error Count: {0}", "Cooperator Wizard Data Save Results", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage3";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                if (ggMessageBox.MessageText.Contains("{0}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, errorCount);
                }
                //if (DialogResult.No == MessageBox.Show(this, "The data being saved has errors that should be reviewed.\n\nWould you like to review them now?\n\nClick Yes to review the errors now.\n(Click No to abandon the errors and exit the Accession Wizard).\n\n  Error Count: " + errorCount, "Accession Wizard Data Save Results", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1))
                if (DialogResult.No == ggMessageBox.ShowDialog())
                {
                    this.Close();
                }
                else
                {
                    // Update the row error message for this cooperator row...
                    //if (string.IsNullOrEmpty(((DataRowView)_cooperatorBindingSource.Current).Row.RowError))
                    //{
                    //    ux_textboxCooperatorRowError.Visible = false;
                    //    ux_textboxCooperatorRowError.Text = "";
                    //}
                    //else
                    //{
                    //    ux_textboxCooperatorRowError.Visible = true;
                    //    ux_textboxCooperatorRowError.ReadOnly = false;
                    //    ux_textboxCooperatorRowError.Enabled = true;
                    //    ux_textboxCooperatorRowError.Text = ((DataRowView)_cooperatorBindingSource.Current).Row.RowError;
                    //}
                }
            }
            // Refresh the formatting of the cells in the DGV on the Cooperator tab page...
            RefreshDGVFormatting(ux_datagridviewCooperator);
        }
        private void ux_buttonCancel_Click(object sender, EventArgs e)
        {
            int intRowEdits = ((DataTable)((BindingSource)_imageDGV.DataSource).DataSource).GetChanges().Rows.Count;

            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s), are you sure you want to cancel?", "Cancel Edits", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ux_buttonCancelEditDataMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}"))
            {
                ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
            }
            if (DialogResult.Yes == ggMessageBox.ShowDialog())
            {
                // Close the form...
                this.Close();
            }
        }
Пример #5
0
        void timerDelay_Tick(object sender, EventArgs e)
        {
            int intRowEdits = 0;
            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            textChangeDelayTimer.Stop();

            // If the user has changed the _cooperator filter text and there are unsaved row changes in the _cooperator table - so warn the user...
            if (ux_tabcontrolMain.SelectedTab == CooperatorPage)
            {
                _cooperatorBindingSource.EndEdit();
                if (_cooperator.GetChanges() != null)
                {
                    intRowEdits = _cooperator.GetChanges().Rows.Count;
                }

                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s) that will be lost if you refresh the data with new filters.\n\nAre you sure you want to lose your edit changes?", "Refreshing Data Will Lose Edits", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);
                ggMessageBox.Name = "CooperatorWizard_timerDelayMessage1";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                if (ggMessageBox.MessageText.Contains("{0}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
                }
                // Show the warning dialog message if there are unsaved edits...
                if (intRowEdits == 0 || DialogResult.Yes == ggMessageBox.ShowDialog())
                {
                    // User has chosen to refresh _cooperator data and lose edit changes...
                    BuildCooperatorPage();
                }
            }

            if (ux_tabcontrolMain.SelectedTab == WebCooperatorPage)
            {
                BuildWebCooperatorPage();
            }

            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
Пример #6
0
 private void ux_buttonSave_Click(object sender, EventArgs e)
 {
     int errorCount = 0;
     errorCount = SaveCooperatorData();
     if (errorCount == 0)
     {
         GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("All data was saved successfully", "Cooperator Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
         ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage1";
         _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
         ggMessageBox.ShowDialog();
     }
     else
     {
         GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The data being saved has errors that should be reviewed.\n\n  Error Count: {0}", "Cooperator Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
         ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage2";
         _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
     //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, errorCount);
     string[] argsArray = new string[100];
     argsArray[0] = errorCount.ToString();
     ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
         ggMessageBox.ShowDialog();
     }
     // Refresh the formatting of the cells in the DGV on the Cooperator tab page...
     RefreshDGVFormatting(ux_datagridviewCooperator);
 }
Пример #7
0
        void timerDelay_Tick(object sender, EventArgs e)
        {
            int intRowEdits = 0;
            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            textChangeDelayTimer.Stop();

            // If the user has changed the _cooperator filter text and there are unsaved row changes in the _cooperator table - so warn the user...
            if (ux_tabcontrolMain.SelectedTab == CooperatorPage)
            {
                _cooperatorBindingSource.EndEdit();
                if (_cooperator.GetChanges() != null) intRowEdits = _cooperator.GetChanges().Rows.Count;

                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s) that will be lost if you refresh the data with new filters.\n\nAre you sure you want to lose your edit changes?", "Refreshing Data Will Lose Edits", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);
                ggMessageBox.Name = "CooperatorWizard_timerDelayMessage1";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
            string[] argsArray = new string[100];
            argsArray[0] = intRowEdits.ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                // Show the warning dialog message if there are unsaved edits...
                if (intRowEdits == 0 || DialogResult.Yes == ggMessageBox.ShowDialog())
                {
                    // User has chosen to refresh _cooperator data and lose edit changes...
                    BuildCooperatorPage();
                }
            }

            if (ux_tabcontrolMain.SelectedTab == WebCooperatorPage) BuildWebCooperatorPage();

            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
Пример #8
0
        private string buildSearchCriteria()
        {
            DataTable dt = (DataTable)ux_datagridviewSearchCriteria.DataSource;

            if (dt == null || dt.Rows.Count < 1) return "";

            string searchCriteria = "";

            foreach (DataGridViewCell dgvc in ux_datagridviewSearchCriteria.Rows[0].Cells)
            {
                if (dgvc.Value != null &&
                    !string.IsNullOrEmpty(dgvc.Value.ToString()) &&
                    dt.Columns[dgvc.ColumnIndex].ExtendedProperties.Contains("table_name") &&
                    !string.IsNullOrEmpty(dt.Columns[dgvc.ColumnIndex].ExtendedProperties["table_name"].ToString()) &&
                    dt.Columns[dgvc.ColumnIndex].ExtendedProperties.Contains("table_field_name") &&
                    !string.IsNullOrEmpty(dt.Columns[dgvc.ColumnIndex].ExtendedProperties["table_field_name"].ToString()))
                {
                    string fieldName = "@" + dt.Columns[dgvc.ColumnIndex].ExtendedProperties["table_name"].ToString().ToLower().Trim() +
                                        "." + dt.Columns[dgvc.ColumnIndex].ExtendedProperties["table_field_name"].ToString().ToLower().Trim();

                    // Processing for dropdown controls for the code_value fields...
                    if (dt.Columns[dgvc.ColumnIndex].ExtendedProperties["gui_hint"].ToString().ToUpper() == "SMALL_SINGLE_SELECT_CONTROL")
                    {
                        string fieldCriteria = ((DataRowView)dgvc.OwningRow.DataBoundItem).Row[dgvc.ColumnIndex].ToString().Trim();

                        if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:is\s+|IS\s+|=\s*)(?:null|NULL)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                        {
                            fieldCriteria = " IS NULL";
                        }
                        else if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:(?:is\s+|IS\s+)(?:not\s+|NOT\s+)|<>\s*)(?:null|NULL)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                        {
                            fieldCriteria = " IS NOT NULL";
                        }
                        else
                        {
                            fieldCriteria = " = '" + fieldCriteria + "'";
                        }

                        if (searchCriteria.Trim().Length > 0)
                        {
                            searchCriteria += " AND " + fieldName + fieldCriteria;
                        }
                        else
                        {
                            searchCriteria += fieldName + fieldCriteria;
                        }
                    }
                    // Processing for foreign key fields...
                    else if (dt.Columns[dgvc.ColumnIndex].ExtendedProperties["gui_hint"].ToString().ToUpper() == "LARGE_SINGLE_SELECT_CONTROL")
                    {
                        if (!_sharedUtils.LookupTablesIsUpdated(dt.Columns[dgvc.ColumnIndex].ExtendedProperties["foreign_key_dataview_name"].ToString()))
                        {
                            //MessageBox.Show("The lookup table associated with the data in this column is missing or incomplete - this could compromise your search criteria.");
                            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The lookup table associated with the data in this column is missing or incomplete - this could compromise your search criteria.", "Missing Lookup Data", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                            ggMessageBox.Name = "GRINGlobalClientSearchTool_buildSearchCriteriaMessage1";
                            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                            ggMessageBox.ShowDialog();
                        }
                        DataTable matchingPKeys = _sharedUtils.LookupTablesGetMatchingRows(dt.Columns[dgvc.ColumnIndex].ExtendedProperties["foreign_key_dataview_name"].ToString(), dgvc.FormattedValue.ToString().TrimEnd('*').Replace('*', '%'), 0);

                        if (matchingPKeys != null &&
                            matchingPKeys.Rows.Count > 0)
                        {
                            if (matchingPKeys.Columns.Contains("display_member"))
                            {
                                if (System.Text.RegularExpressions.Regex.Match(dgvc.FormattedValue.ToString().Replace('*', '%'), @"\s*(?:(?:not\s+|NOT\s+)*(?:like\s+|LIKE\s+))\s*\S+\s*").Success)
                                {
                                    string searchOperator = "LIKE";
                                    string searchValue = dgvc.FormattedValue.ToString();
                                    searchOperator = System.Text.RegularExpressions.Regex.Match(dgvc.FormattedValue.ToString(), @"\s*(?:(?:not\s+|NOT\s+)*(?:like\s+|LIKE\s+))\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value.Trim().ToUpper();

                                    string[] splitValues = System.Text.RegularExpressions.Regex.Split(dgvc.FormattedValue.ToString(), @"\s*(?:(?:not\s+|NOT\s+)*(?:like\s+|LIKE\s+))\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                                    if (splitValues != null &&
                                        splitValues.Length > 0)
                                    {
                                        searchValue = splitValues[splitValues.Length - 1].Trim();
                                        if (!searchValue.StartsWith("'") &&
                                            !searchValue.EndsWith("'"))
                                        {
                                            searchValue = "'" + searchValue + "'";
                                        }
                                    }
                                    try
                                    {
                                        matchingPKeys.DefaultView.RowFilter = "display_member " + searchOperator + " " + searchValue;
                                    }
                                    catch
                                    {
                                        // The row filter does not handle some filters like smith%h% properly so in these cases, apply no row filter...
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        matchingPKeys.DefaultView.RowFilter = "display_member LIKE '" + dgvc.FormattedValue.ToString().Replace('_', '%') + "'";
                                    }
                                    catch
                                    {
                                        matchingPKeys.DefaultView.RowFilter = "";
                                        // The row filter does not handle some filters like smith%h% properly so in these cases, apply no row filter...
                                    }
                                }
                            }
                            // Add all rows matching the row filter to the list...
                            StringBuilder sb = new StringBuilder();
                            foreach (DataRowView drv in matchingPKeys.DefaultView)
                            {
                                sb.Append(drv["value_member"].ToString() + ", ");
                            }
                            if (sb.Length > 0)
                            {
                                if (searchCriteria.Trim().Length > 0)
                                {
                                    searchCriteria += " AND " + fieldName + " IN (" + sb.ToString().TrimEnd(' ').TrimEnd(',') + ")";
                                }
                                else
                                {
                                    searchCriteria += fieldName + " IN (" + sb.ToString().TrimEnd(' ').TrimEnd(',') + ")";
                                }
                            }
                            else
                            {
                                // No matches for your “Taxon” filter were found.  To broaden a search, remember that the wildcards  (  *   %  ) may be used.
                                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("No matches for your '{0}' filter were found. To broaden a search, remember that the wildcards  (  *   %  ) may be used.\n\nBecause no matches were found, this filter will not contribute to the search results returned.", "No Lookup Data Found", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                                ggMessageBox.Name = "GRINGlobalClientSearchTool_buildSearchCriteriaMessage2";
                                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                                if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dt.Columns[dgvc.ColumnIndex].ExtendedProperties["title"].ToString());
                                ggMessageBox.ShowDialog();
                            }
                        }
                    }
                    // Processing for everything else...
                    else
                    {
                        string fieldCriteria = dgvc.FormattedValue.ToString().Trim();
                        // Tidy up any 'bad' (math) grammar from the user...
                        fieldCriteria = System.Text.RegularExpressions.Regex.Replace(fieldCriteria, @"^\s*=\s*<\s*|^\s*<\s*=\s*", "<= ");
                        fieldCriteria = System.Text.RegularExpressions.Regex.Replace(fieldCriteria, @"^\s*=\s*>\s*|^\s*>\s*=\s*", ">= ");
                        fieldCriteria = System.Text.RegularExpressions.Regex.Replace(fieldCriteria, @"^\s*>\s*<\s*|^\s*<\s*>\s*", "<> ");
                        // First test to see if the user wants to search on IS NULL...
                        if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:is\s+|IS\s+|=\s*)(?:null|NULL)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                        {
                            fieldCriteria = "IS NULL";
                        }
                        // or search on IS NOT NULL...
                        else if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:(?:is\s+|IS\s+)(?:not\s+|NOT\s+)|<>\s*)(?:null|NULL)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                        {
                            fieldCriteria = "IS NOT NULL";
                        }
                        // or wants to search on other math/SQL operators
                        else
                        {
                            string searchOperator = "";
                            string searchValue = "";

                            // Test to see if the user wants to search on the LIKE operator...
                            if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:like\s+|LIKE\s+)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                            {
                                searchOperator = System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:like\s+|LIKE\s+)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value.Trim().ToUpper() + " ";
                                string[] splitValues = System.Text.RegularExpressions.Regex.Split(fieldCriteria, @"^\s*(?:like\s+|LIKE\s+)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                                if (splitValues != null &&
                                    splitValues.Length > 0)
                                {
                                    searchValue = splitValues[splitValues.Length - 1].Trim();
                                    searchValue = searchValue.Replace('*', '%');
                                }
                            }
                            // or test to see if the user wants to search on the NOT LIKE operator...
                            else if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:not\s+|NOT\s+)(?:like\s+|LIKE\s+)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                            {
                                searchOperator = System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:not\s+|NOT\s+)(?:like\s+|LIKE\s+)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value.Trim().ToUpper() + " ";
                                string[] splitValues = System.Text.RegularExpressions.Regex.Split(fieldCriteria, @"^\s*(?:not\s+|NOT\s+)(?:like\s+|LIKE\s+)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                                if (splitValues != null &&
                                    splitValues.Length > 0)
                                {
                                    searchValue = splitValues[splitValues.Length - 1].Trim();
                                    searchValue = searchValue.Replace('*', '%');
                                }
                            }
                            // or test to see if this is a two character operator...
                            else if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:<=|>=|<>)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                            {
                                // The math/SQL operator is two characters...
                                searchOperator = System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:<=|>=|<>)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value.Trim();
                                string[] splitValues = System.Text.RegularExpressions.Regex.Split(fieldCriteria, @"^\s*(?:<=|>=|<>)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                                if (splitValues != null &&
                                    splitValues.Length > 0)
                                {
                                    searchValue = splitValues[splitValues.Length - 1].Trim();
                                }
                            }
                            // or test to see if this is a one character operator...
                            else if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:<|>|=)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                            {
                                // The math/SQL operator is one character...
                                searchOperator = System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*(?:<|>|=)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Value.Trim();
                                string[] splitValues = System.Text.RegularExpressions.Regex.Split(fieldCriteria, @"^\s*(?:<|>|=)\s*", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                                if (splitValues != null &&
                                    splitValues.Length > 0)
                                {
                                    searchValue = splitValues[splitValues.Length - 1].Trim();
                                }
                            }
                            //// or test to see if the text is quoted (single or double quotes)...
                            //else if (System.Text.RegularExpressions.Regex.Match(fieldCriteria, @"^\s*""[^\a\b\r\v\f\n\e]+""(\s+|$)|^\s*'[^\a\b\r\v\f\n\e]+'(\s+|$)", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Success)
                            //{
                            //}
                            else
                            {
                                //
                                searchValue = fieldCriteria.Replace('*', '%');
                                if (searchValue.Contains('%') ||
                                    searchValue.Contains('_'))
                                {
                                    searchOperator = "LIKE";
                                }
                                else
                                {
                                    searchOperator = "=";
                                }
                            }

                            // If the table field has a text datatype, enclose the search value in single quotes...
                            if (dt.Columns[dgvc.ColumnIndex].ExtendedProperties["gui_hint"].ToString().ToUpper() == "TOGGLE_CONTROL" ||
                                dt.Columns[dgvc.ColumnIndex].ExtendedProperties["gui_hint"].ToString().ToUpper() == "TEXT_CONTROL")
                            {
                                if (searchValue.StartsWith("\"") &&
                                    searchValue.EndsWith("\""))
                                {
                                    searchValue = searchValue.TrimEnd('"').TrimStart('"');
                                }
                                if (!searchValue.StartsWith("'") &&
                                    !searchValue.EndsWith("'"))
                                {
                                    // Now wrap the search value in single quotes...
                                    searchValue = " '" + searchValue + "'";
                                }
                                else
                                {
                                    // The single quotes are there, so just add a space padding character...
                                    searchValue = " " + searchValue;
                                }
                            }
                            // If the table field has a date datatype, format the date and enclose it in single quotes...
                            else if (dt.Columns[dgvc.ColumnIndex].ExtendedProperties["gui_hint"].ToString().ToUpper() == "DATE_CONTROL")
                            {
                                DateTime searchDate;
                                // Scrub any beginning/ending single/double quotes the user may have provided...
                                if (searchValue.StartsWith("'") ||
                                    searchValue.StartsWith("\""))
                                {
                                    searchValue = searchValue.Substring(1);
                                }
                                if (searchValue.EndsWith("'") ||
                                    searchValue.EndsWith("\""))
                                {
                                    searchValue = searchValue.Substring(0, searchValue.Length - 1);
                                }
                                // Now see if you can convert the string to a valid datetime...
                                if (DateTime.TryParse(searchValue, out searchDate))
                                {
                                    // Format the date as 01-JAN-0001 format because Oracle accepts no other format (and the other databases are flexible enough to handle this format)...
                                    searchValue = searchDate.ToString("dd-MMM-yyyy");
                                }
                                // Now wrap the datetime back in single quotes...
                                searchValue = " '" + searchValue + "'";
                            }
                            // If the table field is a number datatype, do not enclose the search value in single quotes...
                            else
                            {
                                // Scrub any beginning/ending single/double quotes the user may have provided...
                                if (searchValue.StartsWith("'") ||
                                    searchValue.StartsWith("\""))
                                {
                                    searchValue = searchValue.Substring(1);
                                }
                                if (searchValue.EndsWith("'") ||
                                    searchValue.EndsWith("\""))
                                {
                                    searchValue = searchValue.Substring(0, searchValue.Length - 1);
                                }
                                // Now add a space delimiter...
                                searchValue = " " + searchValue;
                            }

                            // Build the search criteria for this field...
                            fieldCriteria = searchOperator + searchValue;
                        }

                        // Now stitch it all back together...
                        if (searchCriteria.Trim().Length > 0)
                        {
                            searchCriteria += " AND " + fieldName + " " + fieldCriteria + "";
                        }
                        else
                        {
                            searchCriteria += fieldName + " " + fieldCriteria + "";
                        }

                    }
                }
            }
            return searchCriteria;
        }
Пример #9
0
        public DataSet GetDGVData(string dataviewName, DataRow[] groupList, int pageSize)
        {
            DataSet results = new DataSet();

            // Reset the escapeKeyPressed flag...
            escapeKeyPressed = false;

            if (groupList != null &&
                groupList.Length > 0)
            {
            //string acids = "";
            //string ivids = "";
            //string ornos = "";
            //string coops = "";
                string centerMessage = ux_statusCenterMessage.Text;
                string rightMessage = ux_statusRightMessage.Text;
                ContentAlignment centerMessageAlignment = ux_statusCenterMessage.TextAlign;
                int nextPage = pageSize;

                // Set the statusbar up to show the query progress...
                ux_statusCenterMessage.TextAlign = ContentAlignment.MiddleRight;
            //ux_statusCenterMessage.Text = "Retrieving Data:";
            ux_statusCenterMessage.Text = "";
            // Update the statusbar...
            ux_statusLeftMessage.Text = ux_statusLeftMessage.Tag.ToString();
            //ux_statusRightMessage.Text = "   Press the escape key (esc) to cancel query   ";
                ux_statusProgressBar.Visible = true;
                ux_statusProgressBar.Minimum = 0;
                ux_statusProgressBar.Maximum = groupList.Length;
                ux_statusProgressBar.Step = pageSize;
                ux_statusProgressBar.Value = 0;
                ux_statusstripMain.Refresh();

                // Begin iterating through the collection of ACIDS, IVIDS, and ORNOS...
                int pageStart = 0;
                int pageStop = Math.Min(pageSize, groupList.Length);
                while (pageStart < groupList.Length && !escapeKeyPressed)
                {
            //acids = "";
            //ivids = "";
            //ornos = "";
            //coops = "";
            string pkeyCollection = ":" + searchResultType.Replace("_", "") + "id=";
                    for (int i = pageStart; i < pageStop; i++)
                    {
            //switch (searchResultType)
            //{
            //    case "accession":
            //        acids += groupList[i]["ID"].ToString() + ",";
            //        break;
            //    case "inventory":
            //        ivids += groupList[i]["ID"].ToString() + ",";
            //        break;
            //    case "order_request":
            //        ornos += groupList[i]["ID"].ToString() + ",";
            //        break;
            //    case "cooperator":
            //        coops += groupList[i]["ID"].ToString() + ",";
            //        break;
            //    default:
            //        acids += groupList[i]["ID"].ToString() + ",";
            //        break;
            //}
            pkeyCollection += groupList[i]["ID"].ToString() + ",";
                    }
                    // Update the paging indexes...
                    pageStart = pageStop;
                    pageStop = Math.Min((pageStart + pageSize), groupList.Length);
                    // Build the param string and get the data...
            //string pkeyCollection = ":accessionid=" + acids.TrimEnd(',') + "; :inventoryid=" + ivids.TrimEnd(',') + "; :orderrequestid=" + ornos.TrimEnd(',') + "; :cooperatorid=" + coops.TrimEnd(',');
            pkeyCollection = pkeyCollection.TrimEnd(',');
                    //DataSet pagedDataSet = GUIWebServices.GetData(false, _user, _password, resultsetName, pkeyCollection, 0, Int32.Parse(ux_numericupdownBasicMaxRecords.Value.ToString()));
                    DataSet pagedDataSet = _sharedUtils.GetWebServiceData(dataviewName, pkeyCollection, 0, Int32.Parse(ux_numericupdownBasicMaxRecords.Value.ToString()));
                    // Add the results to the dataset that will be returned...
                    if (results.Tables.Contains(dataviewName))
                    {
                        results.Tables[dataviewName].Merge(pagedDataSet.Tables[dataviewName].Copy());
                    }
                    else
                    {
                        results.Tables.Add(pagedDataSet.Tables[dataviewName].Copy());
                    }

                    // Update the progress bar on the statusbar...
                    ux_statusProgressBar.Value = pageStop;

                    // Check to see if we should bail out (at user request)...
                    Cursor currentCursor = Cursor.Current;
                    Application.DoEvents();
                    Cursor.Current = currentCursor;
                }

                // Now we need to get only distinct rows in the dataset to return...
                // First build a string array of the columns to return...
                ux_statusCenterMessage.Text = "Removing duplicate rows...  Please wait.";
                string[] columnNames = new string[results.Tables[dataviewName].Columns.Count];
                foreach (DataColumn dc in results.Tables[dataviewName].Columns)
                {
                    columnNames[dc.Ordinal] = dc.ColumnName;
                }
                DataTable dt = results.Tables[dataviewName].DefaultView.ToTable("distinct" + dataviewName, true, columnNames);
                results.Tables.Add(dt);
                results.Tables.Remove(dataviewName);
                results.Tables["distinct" + dataviewName].TableName = dataviewName;
                // Restore the statusbar back to it's original state...
                ux_statusCenterMessage.TextAlign = centerMessageAlignment;
                ux_statusCenterMessage.Text = centerMessage;
                ux_statusRightMessage.Text = rightMessage;
                ux_statusProgressBar.Visible = false;
                ux_statusstripMain.Refresh();
            }
            else
            {
                // If no primary keys were found return an empty dataset...
                results = _sharedUtils.GetWebServiceData(dataviewName, ":accessionid=; :inventoryid=; :orderrequestid=", 0, Int32.Parse(ux_numericupdownBasicMaxRecords.Value.ToString()));
            }

            if (results.Tables.Contains("ExceptionTable") &&
                results.Tables["ExceptionTable"].Rows.Count > 0)
            {
            //MessageBox.Show("There was an unexpected error retrieving data for " + dataviewName + ".\n\nFull error message:\n" + results.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data for {0}.\n\nFull error message:\n{1}", "Search Engine Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_GetDGVDataMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}") &&
            ggMessageBox.MessageText.Contains("{1}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName, results.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            }
            else if (ggMessageBox.MessageText.Contains("{0}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName);
            }
            else if (ggMessageBox.MessageText.Contains("{1}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, results.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            }
            ggMessageBox.ShowDialog();
            }

            return results;
        }
Пример #10
0
        private void ux_dataviewmenuTabProperties_Click(object sender, EventArgs e)
        {
            int indexOfCurrentTab = ux_tabcontrolSTDataviews.SelectedIndex;
            string origDataViewName = "";
            // Remember the name of the current tabs dataview...
            if (ux_tabcontrolSTDataviews.SelectedTab.Tag.GetType() == typeof(GRINGlobal.Client.Common.DataviewProperties) &&
                !string.IsNullOrEmpty(((GRINGlobal.Client.Common.DataviewProperties)ux_tabcontrolSTDataviews.SelectedTab.Tag).DataviewName))
            {
                origDataViewName = ((GRINGlobal.Client.Common.DataviewProperties)ux_tabcontrolSTDataviews.SelectedTab.Tag).DataviewName;
            }

            // Modify the properties of the dataview...
            _sharedUtils.ux_tabcontrolShowProperties(ux_tabcontrolSTDataviews, indexOfCurrentTab);

            // If the user changed the dataview associated with this tab - refresh the data now...
            if (ux_tabcontrolSTDataviews.SelectedTab.Tag.GetType() == typeof(GRINGlobal.Client.Common.DataviewProperties) &&
                ((GRINGlobal.Client.Common.DataviewProperties)ux_tabcontrolSTDataviews.SelectedTab.Tag).DataviewName != origDataViewName)
            {
                //RefreshDGVData();
                //RefreshDGVFormatting();
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("WARNING!\nYou have changed the DataView associated with this tab.\n\nWould you like clear your search criteria and search results?", "Changed DataView", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_ux_dataviewmenuTabPropertiesMessage1";
            if (_sharedUtils != null && _sharedUtils.IsConnected) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            string[] argsArray = new string[100];
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            if (System.Windows.Forms.DialogResult.Yes == ggMessageBox.ShowDialog())
            {
            ux_buttonClearQuery.PerformClick();
            }
                // Refresh the DataGridView now...
                ux_tabcontrolDataview_SelectedIndexChanged(ux_tabcontrolSTDataviews, e);
            }

            //SetAllUserSettings();
            //// Refresh the data view...
            //RefreshMainDGVData();
            //RefreshMainDGVFormatting();
            //RefreshForm();
        }
Пример #11
0
        private void GrinGlobalClient_Load(object sender, EventArgs e)
        {
            bool validLogin = false;
            //            bool connectedToWebService = false;
            //            int selectedCNOIndex = -1;
            //string selectedNodeFullPath = "";
            //username = "";
            //password = "";
            _usernameCooperatorID = "";// "117534";
            _currentCooperatorID = "";// "117534";
            site = "";// "NC7";
            languageCode = "";
            lastFullPath = "";
            lastTabName = "";
            commonUserApplicationDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\GRIN-Global\Curator Tool";
            roamingUserApplicationDataPath = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\GRIN-Global\Curator Tool";
            userSettingsXMLFilePath = roamingUserApplicationDataPath + @"\UserSettings_v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.Build.ToString() + ".xml";

            // Wireup the binding navigator and the Main datagridview...
            // NOTE:(right now the binding source is empty - but later on it will get bound to a data table)...
            defaultBindingSource = new BindingSource();
            defaultBindingSource.DataSource = new DataTable();
            ux_bindingnavigatorMain.BindingSource = defaultBindingSource;
            ux_datagridviewMain.DataSource = defaultBindingSource;

            //// Load the images for the tree view(s)...
            //navigatorTreeViewImages.ColorDepth = ColorDepth.Depth32Bit;
            //navigatorTreeViewImages.Images.Add("active_folder", Icon.ExtractAssociatedIcon(@"Images\active_Folder.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_folder", Icon.ExtractAssociatedIcon(@"Images\inactive_Folder.ico"));
            //navigatorTreeViewImages.Images.Add("active_INVENTORY_ID", Icon.ExtractAssociatedIcon(@"Images\active_INVENTORY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_INVENTORY_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_INVENTORY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_ACCESSION_ID", Icon.ExtractAssociatedIcon(@"Images\active_ACCESSION_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_ACCESSION_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_ACCESSION_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_ORDER_REQUEST_ID", Icon.ExtractAssociatedIcon(@"Images\active_ORDER_REQUEST_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_ORDER_REQUEST_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_ORDER_REQUEST_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_COOPERATOR_ID", Icon.ExtractAssociatedIcon(@"Images\active_COOPERATOR_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_COOPERATOR_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_COOPERATOR_ID.ico"));

            //navigatorTreeViewImages.Images.Add("active_GEOGRAPHY_ID", Icon.ExtractAssociatedIcon(@"Images\active_GEOGRAPHY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_GEOGRAPHY_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_GEOGRAPHY_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_TAXONOMY_GENUS_ID", Icon.ExtractAssociatedIcon(@"Images\active_TAXONOMY_GENUS_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_TAXONOMY_GENUS_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_TAXONOMY_GENUS_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_CROP_ID", Icon.ExtractAssociatedIcon(@"Images\active_CROP_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_CROP_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_CROP_ID.ico"));
            //navigatorTreeViewImages.Images.Add("active_CROP_TRAIT_ID", Icon.ExtractAssociatedIcon(@"Images\active_CROP_TRAIT_ID.ico"));
            //navigatorTreeViewImages.Images.Add("inactive_CROP_TRAIT_ID", Icon.ExtractAssociatedIcon(@"Images\inactive_CROP_TRAIT_ID.ico"));

            //navigatorTreeViewImages.Images.Add("new_tab", Icon.ExtractAssociatedIcon(@"Images\GG_newtab.ico"));
            //navigatorTreeViewImages.Images.Add("search", Icon.ExtractAssociatedIcon(@"Images\GG_search.ico"));

            try
            {
                // Load the wizards from the same directory (and all subdirectories) where the Curator Tool was launched...
                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                System.IO.FileInfo[] dllFiles = di.GetFiles("Wizards\\*.dll", System.IO.SearchOption.AllDirectories);
                if (dllFiles != null && dllFiles.Length > 0)
                {
                    for (int i = 0; i < dllFiles.Length; i++)
                    {
                        System.Reflection.Assembly newAssembly = System.Reflection.Assembly.LoadFile(dllFiles[i].FullName);
                        foreach (System.Type t in newAssembly.GetTypes())
                        {
                            if (t.GetInterface("IGRINGlobalDataWizard", true) != null)
                            {
                                System.Reflection.ConstructorInfo constInfo = t.GetConstructor(new Type[] { typeof(string), typeof(SharedUtils) });

                                if (constInfo != null)
                                {
                                    string pkeyCollection = ":accessionid=; :inventoryid=; :orderrequestid=; :cooperatorid=; :geographyid=; :taxonomygenusid=; :cropid=";
                                    // Instantiate an object of this type to load...
                                    Form wizardForm = (Form)constInfo.Invoke(new object[] { pkeyCollection, _sharedUtils });
                                    // Get the Form Name and button with this name...
                                    System.Reflection.PropertyInfo propInfo = t.GetProperty("FormName", typeof(string));
                                    string formName = (string)propInfo.GetValue(wizardForm, null);
                                    if (string.IsNullOrEmpty(formName)) formName = t.Name;
                                    ToolStripButton tsbWizard = new ToolStripButton(formName, Icon.ExtractAssociatedIcon(newAssembly.ManifestModule.FullyQualifiedName).ToBitmap(), ux_buttonWizard_Click, "toolStripButton" + newAssembly.ManifestModule.Name);
                                    tsbWizard.Tag = "Wizards\\" + newAssembly.ManifestModule.Name;
                                    toolStrip1.Items.Add(tsbWizard);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error binding to Wizard Form.\nError Message: {0}", "Wizard Binding Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GrinGlobalClient_LoadMessage2";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message);
            ggMessageBox.ShowDialog();
            }

            // Create the middle tier utilities class and connect to the web services...
            _sharedUtils = new SharedUtils(url, username, passwordClearText, false);

            // Display the splash page to let the user know that things are happening...
            Splash splash = new Splash();
            splash.StartPosition = FormStartPosition.CenterScreen;
            splash.Show();
            splash.Update();

            //if (validLogin)
            if (_sharedUtils.IsConnected)
            {
                localDBInstance = _sharedUtils.Url.ToLower().Replace("http://", "").Replace("/gringlobal/gui.asmx", "").Replace('-', '_').Replace('.', '_').Replace(':', '_');
                localDBInstance = "GRINGlobal_" + localDBInstance;
            //_sharedUtils = new SharedUtils(GRINGlobalWebServices.Url, username, password, localDBInstance, cno);
                username = _sharedUtils.Username;
                password = _sharedUtils.Password;
                passwordClearText = _sharedUtils.Password_ClearText;
                url = _sharedUtils.Url;
                _usernameCooperatorID = _sharedUtils.UserCooperatorID;
            //_currentCooperatorID = _sharedUtils.UserCooperatorID;
                site = _sharedUtils.UserSite;
                languageCode = _sharedUtils.UserLanguageCode.ToString();

                // Load the application data...
                LoadApplicationData();

            // Check the status of lookup tables and warn the user if some tables are missing data...
            LookupTableStatusCheck();

                // Wire up the list of valid GG servers to the combobox...
                ux_comboboxActiveWebService.DataSource = new BindingSource(_sharedUtils.WebServiceURLs, null);
                ux_comboboxActiveWebService.DisplayMember = "Key";
                ux_comboboxActiveWebService.ValueMember = "Value";
                ux_comboboxActiveWebService.SelectedValue = _sharedUtils.Url;
            // Indicate to the user which URL is the active GG server...
            if (ux_statusCenterMessage.Tag != null)
            {
            if (ux_statusCenterMessage.Tag.ToString().Contains("{0}"))
            {
            ux_statusCenterMessage.Text = string.Format(ux_statusCenterMessage.Tag.ToString(), _sharedUtils.Url);
            }
            else
            {
            ux_statusCenterMessage.Text = ux_statusCenterMessage.Tag.ToString() + " (" + _sharedUtils.Url + ")";
            }
            }
            else
            {
            ux_statusCenterMessage.Text = ux_statusCenterMessage.Text + " (" + _sharedUtils.Url + ")";
            }

            // Get the list of Dataview Forms embedded in assemblies in the CT Forms directiory...
            localFormsAssemblies = _sharedUtils.GetDataviewFormsData();

                // Save the list of valid web service urls...
                // But first make sure the roaming profile directory exists...
                if (!System.IO.Directory.Exists(roamingUserApplicationDataPath)) System.IO.Directory.CreateDirectory(roamingUserApplicationDataPath);
                // Now save the list of GRIN-Global servers...
                System.IO.StreamWriter sw = new System.IO.StreamWriter(roamingUserApplicationDataPath + @"\WebServiceURL.txt");
                foreach (KeyValuePair<string, string> kv in ux_comboboxActiveWebService.Items)
                {
                    if (kv.Key != "New...")
                    {
                        sw.WriteLine(kv.Key + "\t" + kv.Value);
                    }
                }
                sw.Close();
                sw.Dispose();

                // Load the cursors for the DGV...
                _cursorGG = _sharedUtils.LoadCursor(@"Images\cursor_GG.cur");
                if (_cursorGG == null) _cursorGG = Cursors.Default;
                _cursorLUT = _sharedUtils.LoadCursor(@"Images\cursor_LUT.cur");
                if (_cursorLUT == null) _cursorLUT = Cursors.Default;
                _cursorREQ = _sharedUtils.LoadCursor(@"Images\cursor_REQ.cur");
                if (_cursorREQ == null) _cursorREQ = Cursors.Default;
            //this.Cursor = _cursorGG;
            ux_datagridviewMain.Cursor = _cursorGG;
            }
            else
            {
                // Login aborted - disable controls...
                ux_tabcontrolDataviewOptions.Enabled = false;
                ux_tabcontrolCTDataviews.Enabled = false;
                ux_datagridviewMain.Enabled = false;
                ux_comboboxCNO.Enabled = false;
                ux_buttonEditData.Enabled = false;
                // Close the application???
                this.Close();
            }

            // Close the splash page...
            splash.Close();
        }
Пример #12
0
        private void ux_tab_cms_NavigatorDeleteTab_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            ContextMenuStrip cms = (ContextMenuStrip)tsmi.GetCurrentParent();
            TabControl tc = (TabControl)cms.SourceControl;

            string tabPageName = tc.SelectedTab.Name;
            ToolStripMenuItem tsmiDelete = (ToolStripMenuItem)((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems[tc.SelectedTab.Name];
            if (tabPageName != "ux_tabpageGroupListNavigatorNewTab")
            {
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Warning!!! \n\n Deleting this tab will remove all of it's lists from the database permanently!", "Delete Tab", MessageBoxButtons.OKCancel, MessageBoxDefaultButton.Button2);
                ggMessageBox.Name = "ux_navigatormenuDeleteTabMessage1";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                //if (DialogResult.OK == MessageBox.Show("Warning!!! \n\n Deleting this tab will remove all of it's lists from the database permanently!", "Delete Tab", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2))
            //                if (DialogResult.OK == ggMessageBox.ShowDialog())
                {
                    int currentTabIndex = tc.SelectedIndex;

                    // Temporarily de-select all tabs before removing the selected tab...
            //tc.SelectedIndex = -1;
            //tc.SelectedTab = null;
            //tc.TabPages.RemoveByKey(tabPageName);
            //tc.SelectTab(0);
            tc.TabPages.Remove(tc.SelectedTab);
            //tc.TabPages.RemoveAt(currentTabIndex);

                    // Remove the tool strip menu item from the list...
                    ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems.Remove(tsmiDelete);

                    // Build a list of app_user_item_list_ids to remove...
            foreach(Control ctrl in ((Dictionary<string, TabPage>)tc.Tag)[tabPageName].Controls)
            {
            if (ctrl.GetType() == typeof(TreeView))
            {
            _deletedTreeNodes.AddRange(AddToDeletedTreeNodeList((TreeNode)((TreeView)ctrl).Nodes[0]));
            }
            }

                    // Remove the tabpage from the tabcontrol's dictionary...
                    ((Dictionary<string, TabPage>)tc.Tag).Remove(tabPageName);

                    // Activate a new tab...
            //ux_tabcontrolGroupListNavigator_SelectNewActiveTab(currentTabIndex);
            //tc.SelectedIndex = Math.Max(0, currentTabIndex - 1);
            // Update the Show/Hide tabs menu items...
            if (((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems.Count < 2)
            {
            // We have more than one tab in the ShowTabs list so enable some menu choices...
            ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorHideTab"]).Enabled = false;
            ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorDeleteTab"]).Enabled = false;
            ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).Enabled = false;
            }
                }
            }
        }
Пример #13
0
        private void treeView_DragDrop(object sender, DragEventArgs e)
        {
            // The drag-drop event is coming to a close - process this event to handle the dropping of
            // data into the treeview...

            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            // Convert the mouse coordinates from screen to client...
            Point ptClientCoord = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));

            // Is this a collection of dataset rows being dragged to a node...
            //if (e.Data.GetDataPresent(typeof(DataSet)) && e.Effect != DragDropEffects.None)
            if (e.Data.GetDataPresent("System.Data.DataSet") && e.Effect != DragDropEffects.None)
            {
            //DataSet dndData = (DataSet)e.Data.GetData(typeof(DataSet));
            DataSet dndData = (DataSet)e.Data.GetData("System.Data.DataSet");

                // Set this treenode to a default of the currently selected node (just in
                // case the hit test on the mouse coordinates does not land on a node)...
                TreeNode tnNodeClosestToTheDrop = ((TreeView)sender).SelectedNode;
                if (((TreeView)sender).GetNodeAt(ptClientCoord) != null)
                {
                    tnNodeClosestToTheDrop = ((TreeView)sender).GetNodeAt(ptClientCoord);
                }

                // Add each node based on the info in the datarow...
                foreach (DataRow dr in dndData.Tables[0].Rows)
                {
                    TreeNode newNode = new TreeNode();

                    string dataviewPKeyName = dr.Table.PrimaryKey[0].ColumnName.Trim();
                    string tablePKeyName = dr.Table.PrimaryKey[0].ExtendedProperties["table_field_name"].ToString().Trim();
                    string tableName = dr.Table.PrimaryKey[0].ExtendedProperties["table_name"].ToString().Trim();
                    string properties = dataviewPKeyName.Trim().ToUpper();
                    //properties += ";:" + tablePKeyName + "=" + dr[dr.Table.PrimaryKey[0]].ToString();
                    properties += ";:" + tablePKeyName.Replace("_", "") + "=" + dr[dr.Table.PrimaryKey[0]].ToString();
                    properties += ";@" + tableName + "." + tablePKeyName + "=" + dr[dataviewPKeyName].ToString();
                    newNode.Name = properties.Split(';')[1].Trim();
                    newNode.Text = newNode.Name;
                    newNode.Tag = properties;
                    newNode.ImageKey = "inactive_" + tablePKeyName.ToUpper();
                    newNode.SelectedImageKey = "active_" + tablePKeyName.ToUpper();

                    // Now check to see if virtual nodes are wanted for this new node...
                    if (!string.IsNullOrEmpty(_sharedUtils.GetAppSettingValue(tablePKeyName + "_VIRTUAL_NODE_DATAVIEW")))
                    {
                        TreeNode dummyNode = new TreeNode();
                        string virtualQuery = _sharedUtils.GetAppSettingValue(tablePKeyName + "_VIRTUAL_NODE_DATAVIEW") + ", ";
                        virtualQuery += properties.Split(';')[1].Trim().ToLower();

                        dummyNode.Text = "!!DUMMYNODE!!";
                        dummyNode.Name = "!!DUMMYNODE!!"; ;
                        dummyNode.Tag = virtualQuery;
                        //dummyNode.ImageKey = "inactive_" + virtualQuery;
                        //dummyNode.SelectedImageKey = "active_" + virtualQuery;
                        newNode.Nodes.Add(dummyNode);
                    }

                    tnNodeClosestToTheDrop.Nodes.Add(newNode);
                }

                // Give the new nodes their proper titles...
            RefreshTreeviewNodeFormatting(tnNodeClosestToTheDrop);

                // Refresh the datagridview...
                tnNodeClosestToTheDrop.TreeView.SelectedNode = null;
                tnNodeClosestToTheDrop.TreeView.SelectedNode = tnNodeClosestToTheDrop;
            }

            // Is this a treeview node being dragged to a new location...
            //if (e.Data.GetDataPresent(typeof(TreeNode)) && e.Effect != DragDropEffects.None)
            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode") && e.Effect != DragDropEffects.None)
            {
            //TabPage SourceTab = (TabPage)((TreeNode)e.Data.GetData(typeof(TreeNode))).TreeView.Parent;
            TabPage SourceTab = (TabPage)((TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode")).TreeView.Parent;
                TabPage DestinationTab = (TabPage)((TreeView)sender).Parent;
            //TreeNode SourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
            TreeNode SourceNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
            //TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(((TreeView)sender).PointToClient(new Point(e.X, e.Y)));
            TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(ptClientCoord);
                TreeNode newNode = (TreeNode)SourceNode.Clone();

                // If the GetNodeAt method failed try to get the bottom node and check to see if the user dropped below the last node...
                if (DestinationNode == null && ((TreeView)sender).Nodes.Count == 1)
                {
                    int lastNode = ((TreeView)sender).Nodes[0].Nodes.Count-1;
                    if (ptClientCoord.Y > ((TreeView)sender).Nodes[0].Nodes[lastNode].Bounds.Bottom)
                    {
                        DestinationNode = ((TreeView)sender).Nodes[0].Nodes[lastNode];
                    }
                }
                // Bail if the user drops the source back on itself...
                if (SourceNode == null || DestinationNode == null || SourceNode == DestinationNode) return;
                // Do nothing if the destination node is the root node...
                //if (DestinationNode.Tag.ToString().Trim().ToUpper() == "FOLDER" ||
                if (isFolder(DestinationNode) ||
                    DestinationNode.Parent != null)
                {
                    // Make sure the new node has a unique name at the destination node...

                    // If the destination node is a folder and the user is dropping the source node
                    // on the middle of the folder node (not the bottom edge - which indicates the user would
                    // like to insert the source node below the folder (not IN the folder)...
                    //if ((DestinationNode.Tag.ToString().Trim().ToUpper() == "FOLDER" &&
                    if ((isFolder(DestinationNode) &&
                        (DestinationNode.Bounds.Bottom > ptClientCoord.Y + 5) ||
                        SourceNode.Parent == DestinationNode ||
                        DestinationNode.Parent == null))
                    {
                        if (!DestinationNode.Nodes.Contains(SourceNode) || e.Effect == DragDropEffects.Copy)
                        {
                            // If the source node is not an existing node in the destination folder (ie it is not being moved/re-ordered)
                            // or a copy of the source node is being made - get unique text for the new node...
                            newNode.Text = EnsureUniqueNodeText(DestinationNode, newNode);
                            // Make the nodes Name=Text if this is a folder...
                            //if (SourceNode.Tag.ToString().Trim().ToUpper() == "FOLDER")
                            if (isFolder(SourceNode))
                            {
                                newNode.Name = newNode.Text;
                            }
                        }
                        DestinationNode.Nodes.Insert(0, newNode);
                    }
                    else
                    {
                        // The destination is an item (not a folder) or the user wants to drop the source node
                        // below the destination folder - so insert the new node in the destination node's parent folder (at the top of the list)...
                        if (!DestinationNode.Parent.Nodes.Contains(SourceNode) || e.Effect == DragDropEffects.Copy)
                        {
                            // If the source node is not an existing node in the destination folder (ie it is not being moved/re-ordered)
                            // or a copy of the source node is being made - get unique text for the new node...
                            newNode.Text = EnsureUniqueNodeText(DestinationNode.Parent, newNode);
                            //if (SourceNode.Tag.ToString().Trim().ToUpper() == "FOLDER")
                            if (isFolder(SourceNode))
                            {
                                newNode.Name = newNode.Text;
                            }
                        }
                        DestinationNode.Parent.Nodes.Insert(DestinationNode.Index + 1, newNode);
                    }

                    // New node is ready to go - now decide to either copy or move it to the destination...
                    if (e.Effect == DragDropEffects.Move)
                    {
                        if (PathLengthOK(newNode))
                        {
                            //DestinationNode.Nodes.Add(newNode);
                            SourceNode.Remove();
                        }
                        else
                        {
                            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the 'Full Path' of: {0} (or one of the subfolders) exceeds maximum length.", "Label Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                            ggMessageBox.Name = "treeView_DragDropMessage1";
                            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, newNode.FullPath);
            string[] argsArray = new string[100];
            argsArray[0] = newNode.FullPath;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                            ggMessageBox.ShowDialog();
                            newNode.Remove();
                        }
                    }
                    else if (e.Effect == DragDropEffects.Copy)
                    {
                        if (PathLengthOK(newNode))
                        {
                            ResetTreeviewNodeToolTip(newNode);
                            //DestinationNode.Nodes.Add(newNode);
                        }
                        else
                        {
                            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the 'Full Path' of: {0} (or one of the subfolders) exceeds maximum length.", "Label Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                            ggMessageBox.Name = "treeView_DragDropMessage2";
                            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, newNode.FullPath);
            string[] argsArray = new string[100];
            argsArray[0] = newNode.FullPath;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                            ggMessageBox.ShowDialog();
                            newNode.Remove();
                        }
                    }
                }
                // Clear special drag and drop visual highlighting and insert bars...
                ResetTreeviewNodeFormatting(DestinationNode.TreeView.Nodes);
            }

            // Are these image files being dropped on to an accession or inventory node...
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] fullPaths = (string[])e.Data.GetData(DataFormats.FileDrop);
                TreeNode destinationNode = ((TreeView)sender).GetNodeAt(((TreeView)sender).PointToClient(new Point(e.X, e.Y)));

                if (destinationNode.Tag.ToString().ToUpper().StartsWith("INVENTORY_ID"))
                {
                    string inventoryID = "";
                    string[] pkeyTokens = destinationNode.Name.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    if (pkeyTokens != null &&
                        pkeyTokens.Length == 2)
                    {
                        inventoryID = pkeyTokens[1];
                        LoadInventoryImages(fullPaths, inventoryID);
                    }
                }
                else if (destinationNode.Tag.ToString().ToUpper().StartsWith("ACCESSION_ID"))
                {
                    string inventoryIDs = "";
                    //DataSet ds = _sharedUtils.GetWebServiceData("get_inventory", ":inventoryid=; :accessionid=" + destinationNode.Name + "; :orderrequestid=; :cooperatorid=;", 0, 0);
            //DataSet ds = _sharedUtils.GetWebServiceData("get_inventory", ":accessionid=" + destinationNode.Name, 0, 0);
            DataSet ds = _sharedUtils.GetWebServiceData("get_inventory", destinationNode.Name, 0, 0);
                    if (ds.Tables.Contains("get_inventory"))
                    {

                        //DataRow[] drs = ds.Tables["get_inventory"].Select("inventory_type_code='**'");
                        DataRow[] drs = ds.Tables["get_inventory"].Select("FORM_TYPE_CODE='**'");
                        foreach (DataRow dr in drs)
                        {
                            inventoryIDs += dr["INVENTORY_ID"].ToString() + ",";
                        }
                        inventoryIDs = inventoryIDs.TrimEnd(',');
                    }
                    if (!string.IsNullOrEmpty(inventoryIDs)) LoadInventoryImages(fullPaths, inventoryIDs);
                }
            }

            // Is this a query criteria from the Search Tool...
            if (e.Data.GetDataPresent(DataFormats.Text))
            {
                string dndText = (string)e.Data.GetData(DataFormats.Text);
                TreeNode destinationNode = ((TreeView)sender).GetNodeAt(((TreeView)sender).PointToClient(new Point(e.X, e.Y)));
                if (dndText.StartsWith("Search Tool Query :: ") &&
                    isFolder(destinationNode))
                {
            //returnedProperties = "QUERY; DYNAMIC_FOLDER_SEARCH_CRITERIA=" + ux_textboxDYNAMIC_FOLDER_SEARCH_CRITERIA.Text + "; ";
                    string newFolderTag = "";
                    string[] currentFolderProperties = destinationNode.Tag.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    string[] newFolderProperties = new string[currentFolderProperties.Length + 3];
                    string[] dndQueryProperties = dndText.Split(new string[] {" :: "}, StringSplitOptions.RemoveEmptyEntries);

                    // Create new dynamic folder properties for this node...
                    newFolderProperties[0] = "QUERY";
                    newFolderProperties[1] = "DYNAMIC_FOLDER_RESOLVE_TO=" + dndQueryProperties[1].Substring(dndQueryProperties[1].IndexOf("ResolveTo=") + 10);
                    newFolderProperties[2] = "DYNAMIC_FOLDER_SEARCH_CRITERIA=" + dndQueryProperties[2].Substring(dndQueryProperties[2].IndexOf("SearchCriteria=") + 15);
                    int newFolderPropertiesCounter = 3;

                    string currentSearchCriteria = GetTreeviewNodeProperty("DYNAMIC_FOLDER_SEARCH_CRITERIA", destinationNode, false, "DYNAMIC_FOLDER_SEARCH_CRITERIA_property_is_missing");
                    string currentResolveTo = GetTreeviewNodeProperty("DYNAMIC_FOLDER_RESOLVE_TO", destinationNode, false, "DYNAMIC_FOLDER_RESOLVE_TO_property_is_missing");

                    // Add back in the existing folder properties that are not associated with the dynamic query...
                    for (int i = 0; i < currentFolderProperties.Length; i++)
                    {
                        if (!currentFolderProperties[i].Trim().ToUpper().StartsWith("FOLDER") &&
                            !currentFolderProperties[i].Trim().ToUpper().StartsWith("QUERY") &&
                            !currentFolderProperties[i].Trim().ToUpper().StartsWith("DYNAMIC_FOLDER_") &&
                            !string.IsNullOrEmpty(currentFolderProperties[i].Trim()))
                        {
                            newFolderProperties[newFolderPropertiesCounter] = currentFolderProperties[i];
                            newFolderPropertiesCounter++;
                        }
                    }

                    // Finally create the new folder properties string to store in the node Tag property...
                    for (int i = 0; i < newFolderProperties.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(newFolderProperties[i]) &&
                            !string.IsNullOrEmpty(newFolderProperties[i].Trim())) newFolderTag += newFolderProperties[i] + "; ";
                    }
                    //if (folderProperties[0].Trim().ToUpper() == "FOLDER")
                    //{
                    //    folderProperties[0] = "QUERY";
                    //}
                    // Replace the folder's SEARCH_CRITERIA and RESOLVE_TO strings...
                    //if(currentResolveTo == "") folderProperties
            //for (int i = 0; i < folderProperties.Length; i++)
            //{
            //    if (folderProperties[i].Trim().ToUpper().StartsWith("FOLDER")) folderProperties[i] = "QUERY";
            //    if (folderProperties[i].Trim().ToUpper().StartsWith("DYNAMIC_FOLDER_SEARCH_CRITERIA")) folderProperties[i] = "DYNAMIC_FOLDER_SEARCH_CRITERIA=" + dndText.Substring(dndText.IndexOf(" :: SearchCriteria=") + 19);
            //    if (folderProperties[i].Trim().ToUpper().StartsWith("DYNAMIC_FOLDER_RESOLVE_TO")) folderProperties[i] = "DYNAMIC_FOLDER_RESOLVE_TO=" + dndText.Substring(dndText.IndexOf(" :: SearchCriteria=") + 19);
            //}
                //if (currentResolveTo == "DYNAMIC_FOLDER_RESOLVE_TO_property_is_missing")
                    //{
                    //    folderProperties = folderProperties.Replace("QUERY;", "QUERY; DYNAMIC_FOLDER_RESOLVE_TO=" + dndText.Substring(dndText.IndexOf(" :: ResolveTo=") + 14));
                    //}
                    //else if (currentResolveTo == "")
                    //{
                    //    folderProperties = folderProperties.Replace("DYNAMIC_FOLDER_RESOLVE_TO=;", "DYNAMIC_FOLDER_RESOLVE_TO=" + dndText.Substring(dndText.IndexOf(" :: ResolveTo=") + 14));
                    //}
                    //else
                    //{
                    //    folderProperties = folderProperties.Replace("DYNAMIC_FOLDER_RESOLVE_TO=" + currentResolveTo, "DYNAMIC_FOLDER_RESOLVE_TO=" + dndText.Substring(dndText.IndexOf(" :: ResolveTo=") + 14));
                    //}
                    //// Replace the folders search criteria string...
                    //string currentSearchCriteria = GetTreeviewNodeProperty("DYNAMIC_FOLDER_SEARCH_CRITERIA", destinationNode, false, "DYNAMIC_FOLDER_SEARCH_CRITERIA_property_is_missing");
                    //if (currentSearchCriteria == "DYNAMIC_FOLDER_SEARCH_CRITERIA_property_is_missing")
                    //{
                    //    folderProperties = folderProperties.Replace("QUERY;", "QUERY; DYNAMIC_FOLDER_SEARCH_CRITERIA=" + dndText.Substring(dndText.IndexOf(" :: SearchCriteria=") + 19) + "; DYNAMIC_FOLDER_RESOLVE_TO=;");
                    //}
                    //else if (currentSearchCriteria == "")
                    //{
                    //    folderProperties = folderProperties.Replace("DYNAMIC_FOLDER_SEARCH_CRITERIA=;", "DYNAMIC_FOLDER_SEARCH_CRITERIA=" + dndText.Substring(dndText.IndexOf(" :: SearchCriteria=") + 19));
                    //}
                    //else
                    //{
                    //    folderProperties = folderProperties.Replace("DYNAMIC_FOLDER_SEARCH_CRITERIA=" + currentSearchCriteria, "DYNAMIC_FOLDER_SEARCH_CRITERIA=" + dndText.Substring(dndText.IndexOf(" :: SearchCriteria=") + 19));
                    //}

                    // Update the treeview node...
                    //destinationNode.Tag = folderProperties;
                    destinationNode.Tag = newFolderTag;
                    destinationNode.ImageKey = "inactive_dynamic_folder";
                    destinationNode.SelectedImageKey = "active_dynamic_folder";

                    // If the query changed force a data refresh...
                    if (currentResolveTo != GetTreeviewNodeProperty("DYNAMIC_FOLDER_RESOLVE_TO", destinationNode, false, "") ||
                        currentSearchCriteria != GetTreeviewNodeProperty("DYNAMIC_FOLDER_SEARCH_CRITERIA", destinationNode, false, ""))
                    {
                        // Refresh the data and a new copy of the table should be retrieved...
                        // Resetting these two global variables will force a refresh of the DGV data...
                        lastFullPath = "";
                        lastTabName = "";
                        SetAllUserSettings();
                        // Refresh the data view...
                        RefreshMainDGVData();
                    }
                }
            }
            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
Пример #14
0
        private void treeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label != null && e.Label.Length == 0)
            {
                // Zero length treeview node names are not allowed so cancel the label edit action, inform the user...
                e.CancelEdit = true;
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the list name cannot be blank", "Label Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "treeView_AfterLabelEditMessage1";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                ggMessageBox.ShowDialog();
            }
            else if (e.Label != null)
            {
                if (e.Node.Parent != null && e.Node.Parent.Nodes.ContainsKey(e.Label))
                {
                    // Duplicate node names are not allowed
                    e.CancelEdit = true;
                    GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the list name cannot be a duplicate.\n\nThere is already an item named '{0}' in the folder '{1}'.", "Label Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                    ggMessageBox.Name = "treeView_AfterLabelEditMessage2";
                    _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, e.Label, e.Node.Parent.Text);
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, e.Label);
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, e.Node.Parent.Text);
            //}
            string[] argsArray = new string[100];
            argsArray[0] = e.Label;
            argsArray[1] = e.Node.Parent.Text;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                    ggMessageBox.ShowDialog();
                }
                else
                {
                    // Remember the original text for the node (in case the nodes new name exceeds max path length)
                    string origNodeText = e.Node.Text;
                    // Set the new label...
                    e.Node.Text = e.Label;
                    if (!PathLengthOK(e.Node))
                    {
                        e.Node.Text = origNodeText;
                        e.CancelEdit = true;
                        GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the 'Full Path' of: {0} (or one of the subfolders) exceeds maximum length.", "Label Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                        ggMessageBox.Name = "treeView_AfterLabelEditMessage3";
                        _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, e.Node.FullPath);
            string[] argsArray = new string[100];
            argsArray[0] = e.Node.FullPath;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                        ggMessageBox.ShowDialog();
                    }

                    // Disable the treeview property that allows label edits...
                    ((TreeView)sender).LabelEdit = false;
                }
            }
        }
Пример #15
0
        private DataSet SaveNavigatorTabControlData(TabControl tcUserItemLists, int cooperatorID)
        {
            DataSet modifiedData = new DataSet();
            DataSet saveErrors = new DataSet();

            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            // Only perform the save if the currently selected list is owned by the login user...
            if ((int)ux_comboboxCNO.SelectedValue == cooperatorID)
            {
                // Reload the user's item list from the remote database (so that we can sync to the current tabpage treeviews)...
                DataTable syncedItemList = GetUserItemList(cooperatorID);

                if (syncedItemList != null &&
                    tcUserItemLists != null &&
                    tcUserItemLists.Tag != null &&
                    tcUserItemLists.Tag.GetType() == typeof(Dictionary<string, TabPage>))
                {
                    // Get the complete collection of tab pages (both hidden and visible)...
                    Dictionary<string, TabPage> userTabPages = (Dictionary<string, TabPage>)tcUserItemLists.Tag;

                    // Iterate through these tabs to get the embedded treeview's nodes...
                    foreach (TabPage tp in userTabPages.Values)
                    {
                        TreeView tv;
                        if (tp.Controls.ContainsKey(tp.Name + "TreeView"))
                        {
                            tv = (TreeView)tp.Controls[tp.Name + "TreeView"];
                            //tv = (TreeView)tp.Controls["Test Hidden (1)TreeView"];
                            foreach (TreeNode tn in tv.Nodes)
                            {
                                SyncTreeNodesWithUserItemListTable(tn, syncedItemList);
                            }
                        }
                    }

                    // Delete any records associated with deleted treeview nodes...
                    DataRow deleteDR;
                    foreach (int pkey in _deletedTreeNodes)
                    {
                        deleteDR = syncedItemList.Rows.Find(pkey);
                        if (deleteDR != null &&
                            deleteDR.RowState != DataRowState.Deleted)
                        {
                            deleteDR.Delete();
                        }
                    }

                    // Get just the rows that have changed and put them in to a new dataset...
                    if (syncedItemList.GetChanges() != null)
                    {
                        modifiedData.Tables.Add(syncedItemList.GetChanges());
                    }
                    // Call the web method to update the changed data...
                    saveErrors = _sharedUtils.SaveWebServiceData(modifiedData);

                    // If the commandline during application startup had a parameter for _saveListDataDumpFile set to a valid filepath
                    // save the data to this file in XML format...
                    if (!string.IsNullOrEmpty(_saveListDataDumpFile))
                    {
                        try
                        {
                            modifiedData.WriteXml(_saveListDataDumpFile, XmlWriteMode.WriteSchema);
                        }
                        catch (Exception err)
                        {
            //MessageBox.Show("Error attempting to save XML dataset to: " + _saveListDataDumpFile + "\n\nError Message:\n" + err.Message);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error attempting to save XML dataset to: {0}\n\nError Message:\n{1}", "Save User Lists Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SaveListsMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _saveListDataDumpFile, err.Message);
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _saveListDataDumpFile);
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message);
            //}
            string[] argsArray = new string[100];
            argsArray[0] = _saveListDataDumpFile;
            argsArray[1] = err.Message;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                        }
                    }

                    if (saveErrors != null &&
                        saveErrors.Tables.Contains(syncedItemList.TableName))
                    {
                        foreach (DataRow dr in saveErrors.Tables[syncedItemList.TableName].Rows)
                        {
                            if (dr["SavedAction"].ToString() == "Insert" && dr["SavedStatus"].ToString() != "Success")
                            {
            //MessageBox.Show("The " + dr["TITLE"].ToString() + " item could not be successfully added to your list.\n\nError message:\n\n" + dr["ExceptionMessage"].ToString());
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The {0} item could not be successfully added to your list.\n\nError message:\n\n{1}", "Save User Lists Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SaveListsMessage2";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dr["TITLE"].ToString(), dr["ExceptionMessage"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dr["TITLE"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dr["ExceptionMessage"].ToString());
            //}
            string[] argsArray = new string[100];
            argsArray[0] = dr["TITLE"].ToString();
            argsArray[1] = dr["ExceptionMessage"].ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                            }
                            else if (dr["SavedAction"].ToString() == "Update" && dr["SavedStatus"].ToString() != "Success")
                            {
            //MessageBox.Show("The " + dr["TITLE"].ToString() + " item could not be successfully updated for your list.\n\nError message:\n\n" + dr["ExceptionMessage"].ToString());
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The {0} item could not be successfully updated for your list.\n\nError message:\n\n{1}", "Save User Lists Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SaveListsMessage3";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ggMessageBox.MessageText, dr["TITLE"].ToString(), dr["ExceptionMessage"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ggMessageBox.MessageText, dr["TITLE"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dr["ExceptionMessage"].ToString());
            //}
            string[] argsArray = new string[100];
            argsArray[0] = dr["TITLE"].ToString();
            argsArray[1] = dr["ExceptionMessage"].ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                            }
                            else if (dr["SavedAction"].ToString() == "Delete" && dr["SavedStatus"].ToString() != "Success")
                            {
            //MessageBox.Show("The " + dr["TITLE"].ToString() + " item could not be successfully deleted from your list.\n\nError message:\n\n" + dr["ExceptionMessage"].ToString());
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The {0} item could not be successfully deleted from your list.\n\nError message:\n\n{1}", "Save User Lists Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SaveListsMessage4";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ggMessageBox.MessageText, dr["TITLE"].ToString(), dr["ExceptionMessage"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ggMessageBox.MessageText, dr["TITLE"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dr["ExceptionMessage"].ToString());
            //}
            string[] argsArray = new string[100];
            argsArray[0] = dr["TITLE"].ToString();
            argsArray[1] = dr["ExceptionMessage"].ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                            }
                        }
                    }
                }
                else
                {
                    if(tcUserItemLists != null)
                    {
            //MessageBox.Show("There were errors syncronizing your lists with the remote server.\n\nYour list changes have not been saved.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There were errors syncronizing your lists with the remote server.\n\nYour list changes have not been saved.", "Save User Lists Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SaveListsMessage5";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog();
                    }
                }
            }
            // Restore cursor to default cursor...
            Cursor.Current = origCursor;

            return saveErrors;
        }
Пример #16
0
        private void ux_textboxThumbnailVirtualPath_TextChanged(object sender, EventArgs e)
        {
            #region WebRequest Method...
            //try
            //{
            //    System.Net.WebRequest req = System.Net.WebRequest.Create(ux_textboxThumbnailVirtualPath.Text.Trim());
            //    System.Net.WebResponse response = req.GetResponse();
            //    System.IO.Stream stream = response.GetResponseStream();
            //    //int imageBytesLength = (int)response.ContentLength + ((int)(response.ContentLength)%2);
            //    //byte[] imageBytes = new byte[imageBytesLength];
            //    //stream.Read(imageBytes, 0, (int)response.ContentLength);

            //    if (stream != null && stream.Length > 0)
            //    {
            //        stream.Position = 0L;
            //        Image thumbnailImage = Image.FromStream(stream, false, true);

            //        if (thumbnailImage != null)
            //        {
            //            ux_pictureboxThumbnail.Image = thumbnailImage;
            //        }
            //        else
            //        {
            //            ux_pictureboxThumbnail.Image = null;
            //        }
            //    }
            //    else
            //    {
            //        ux_pictureboxThumbnail.Image = null;
            //    }
            //    stream.Dispose();
            //    response.Close();
            //}
            //catch (Exception err)
            //{
            //    ux_pictureboxThumbnail.Image = null;
            //}
            #endregion

            #region WebService Method...
            try
            {
                // Attempt to get the thumbnail from the remote server's WebService...
                byte[] imageBytes = _sharedUtils.GetImage(ux_textboxThumbnailVirtualPath.Text.Trim());

                if (imageBytes != null && imageBytes.Length > 0)
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes);
                    Image thumbnailImage      = Image.FromStream(ms, false, true);

                    if (thumbnailImage != null)
                    {
                        ux_pictureboxThumbnail.Image = thumbnailImage;
                    }
                    else
                    {
                        ux_pictureboxThumbnail.Image = null;
                    }
                }
                else
                {
                    ux_pictureboxThumbnail.Image = null;
                }
            }
            catch (Exception err)
            {
//MessageBox.Show("Remote server's WebServce 'DownloadImage()' returned a corrupt image file that cannot be displayed");
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Remote server's WebServce 'DownloadImage()' returned a corrupt image file that cannot be displayed", "Load Image Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "ImageForm_ux_textboxThumbnailVirtualPathMessage1";
                if (_sharedUtils != null)
                {
                    _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                }
                ggMessageBox.ShowDialog();
                ux_pictureboxThumbnail.Image = null;
            }
            #endregion
        }
Пример #17
0
        private void ux_buttonCancelEditData_Click(object sender, EventArgs e)
        {
            int intRowEdits = 0;
            bool bCancel = true;

            if (((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).GetChanges() != null)
            {
                intRowEdits = ((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).GetChanges().Rows.Count;
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s), are you sure you want to cancel?", "Cancel Edits", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ux_buttonCancelEditDataMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
            string[] argsArray = new string[100];
            argsArray[0] = intRowEdits.ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            //if (DialogResult.No == MessageBox.Show("You have " + intRowEdits + " unsaved row change(s), are you sure you want to cancel?", "Cancel Edits", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1))
            if (DialogResult.No == ggMessageBox.ShowDialog())
                {
                    bCancel = false;
                }
            }
            if (bCancel)
            {
                // Restore the grid view for handling row selections...
                ux_datagridviewMain.Enabled = true;
                ux_datagridviewMain.Focus();
                ux_datagridviewMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                ux_datagridviewMain.EditMode = DataGridViewEditMode.EditProgrammatically;
                ux_datagridviewMain.AllowUserToAddRows = false;
                ux_datagridviewMain.AllowUserToDeleteRows = false;
                ux_datagridviewMain.AllowDrop = false;

                // Update the controls on the interface...
                ux_groupboxEditMode.Visible = false;
                ux_checkboxHighlightChanges.Enabled = false;
                ux_checkboxHideNonErrorRows.Checked = false;
                ux_checkboxHideNonErrorRows.Enabled = false;
                ux_checkboxHideUnchangedRows.Checked = false;
                ux_checkboxHideUnchangedRows.Enabled = false;
                ux_buttonSaveData.Enabled = false;
                ux_buttonEditData.Enabled = true;
                ux_buttonCancelEditData.Enabled = false;
                ux_splitcontainerMain.Panel1.Enabled = true;
                ux_tabcontrolCTDataviews.Enabled = true;

            //// NOTE: removing the table forces RefreshMainDataViewer to retrieve the data from the DB...
            //((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).DataSet.Tables.Remove((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource);
                // Now refresh the data and a new copy of the table should be retrieved...
                // Resetting these two global variables will force a refresh of the DGV data...
                lastFullPath = "";
                lastTabName = "";

                // Remember the first visible column to restore later...
                int firstVisibleColumn = ux_datagridviewMain.FirstDisplayedScrollingColumnIndex;
                // Update the formatting for the datagridview cells (to remove highlighting of cells)
                RefreshMainDGVData();
                RefreshMainDGVFormatting();
                if (ux_datagridviewMain.Columns.Count > 0 &&
                    firstVisibleColumn > -1 &&
                    ux_datagridviewMain.Columns[firstVisibleColumn].Visible) ux_datagridviewMain.FirstDisplayedScrollingColumnIndex = firstVisibleColumn;

                // If a Form is being shown, enable its controls...
                if (dataviewForm != null)
                {
                    System.Reflection.PropertyInfo pi = dataviewForm.GetType().GetProperty("EditMode");
                    if (pi != null) pi.SetValue(dataviewForm, false, null);
                }

                // Un-wire the event handler for formatting cells in edit mode (populating the FK lookup values)...
                ux_datagridviewMain.CellFormatting -= new DataGridViewCellFormattingEventHandler(ux_datagridviewMain_EditDGVCellFormatting);
                ux_datagridviewMain.CellParsing -= new DataGridViewCellParsingEventHandler(ux_datagridviewMain_EditDGVCellParsing);
                ux_datagridviewMain.DataError -= new DataGridViewDataErrorEventHandler(dataGridView_DataError);

                // Wire up the event handler for formatting cells in readonly mode...
                ux_datagridviewMain.CellFormatting += new DataGridViewCellFormattingEventHandler(ux_datagridviewMain_ReadOnlyDGVCellFormatting);
            }
        }
Пример #18
0
        private void ux_treeview_cms_NavigatorNewList_Click(object sender, EventArgs e)
        {
            // First we need to find out which tree view has been clicked...
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            ContextMenuStrip cms = (ContextMenuStrip)tsmi.Owner;
            TreeView tv = (TreeView)cms.SourceControl;

            // Now we can get a unique name for this tree node (starting with the default node name: New List)...
            String newNodeText = "New List";
            TreeNode tnDestination = tv.SelectedNode;

            // Now add it to the treeview if it's parent is a list folder object...
            if (isFolder(tnDestination))
            {
                TreeNode tnNew = new TreeNode(newNodeText);

                // Let's make sure the new node name is unique..
                newNodeText = EnsureUniqueNodeText(tnDestination, tnNew);

                tnNew.Name = newNodeText;
                tnNew.Text = newNodeText;
                tnNew.Tag = "FOLDER; DYNAMIC_FOLDER_SEARCH_CRITERIA=; ";
                tnNew.ImageKey = "inactive_folder";
                tnNew.SelectedImageKey = "active_folder";
                tnDestination.Nodes.Add(tnNew);

                // If the path length exceeds the maximum allowed string length for a full path - remove the new folder...
                if (!PathLengthOK(tnNew))
                {
                    GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the 'Full Path' of: {0} (or one of the subfolders) exceeds maximum length.", "Invalid Path", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                    ggMessageBox.Name = "ux_treeviewmenuNewListMessage1";
                    _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, tnNew.FullPath);
            string[] argsArray = new string[100];
            argsArray[0] = tnNew.FullPath;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                    ggMessageBox.ShowDialog();
                    tnNew.Remove();
                }
                else
                {
                    // Make the new folder the active folder...
                    tnNew.EnsureVisible();
                }
            }
        }
Пример #19
0
        public DataSet SaveDGVData(DataSet dataToSave)
        {
            DataSet rollupReturn = new DataSet();
            string centerMessage = ux_statusCenterMessage.Text;
            string rightMessage = ux_statusRightMessage.Text;
            ContentAlignment centerMessageAlignment = ux_statusCenterMessage.TextAlign;

            // Set the statusbar up to show the query progress...
            ux_statusCenterMessage.TextAlign = ContentAlignment.MiddleRight;
            ux_statusCenterMessage.Text = "Saving Data:";
            ux_statusRightProgressBar.Visible = true;
            ux_statusRightProgressBar.Minimum = 0;
            ux_statusRightProgressBar.Maximum = 100;
            ux_statusRightProgressBar.Step = 1;
            ux_statusRightProgressBar.Value = 0;
            //ux_statusRightProgressBar.Visible = true;
            //ux_statusRightProgressBar.Minimum = 0;
            //ux_statusRightProgressBar.Maximum = 100;
            //ux_statusRightProgressBar.Step = 5;
            //ux_statusRightProgressBar.Value = 75;
            ux_statusstripMain.Refresh();

            try
            {
                // Pass the web service method 1000 records at a time (to keep the call smaller than 10MB)...
                DataTable modifiedTable = dataToSave.Tables[0];
                string errorMessage = "";
                DataSet pagedModifiedDataset = new DataSet();
                pagedModifiedDataset.Tables.Add(modifiedTable.Clone());
                int pageSize = (int)ux_numericupdownQueryPageSize.Value;
                pageSize = Math.Min(10000, Math.Max(1, pageSize)); // Clamp the page size between 1 and 10,000
                int pageStart = 0;
                int pageStop = Math.Min(pageSize, modifiedTable.Rows.Count);
                while (pageStart < modifiedTable.Rows.Count)
                {
                    // Clear the table page from the dataset...
                    pagedModifiedDataset.Tables[modifiedTable.TableName].Clear();
                    pagedModifiedDataset.AcceptChanges();

                    // Build a new 'modified data' table page row by row...
                    for (int i = pageStart; i < pageStop; i++)
                    {
                        // Make a copy of the datarow in the paged datatable...
                        DataRow newRow = pagedModifiedDataset.Tables[modifiedTable.TableName].NewRow();
                        switch (modifiedTable.Rows[i].RowState)
                        {
                            case DataRowState.Added:
                                // Populate the new row...
                                newRow.ItemArray = modifiedTable.Rows[i].ItemArray;
                                // Add it to the modified rows table...
                                pagedModifiedDataset.Tables[modifiedTable.TableName].Rows.Add(newRow);
                                break;
                            case DataRowState.Deleted:
                                // 'Undelete the original row (to allow access to the row's field data)...
                                modifiedTable.Rows[i].RejectChanges();
                                // Populate the new row...
                                newRow.ItemArray = modifiedTable.Rows[i].ItemArray;
                                // Add it to the modified rows table...
                                pagedModifiedDataset.Tables[modifiedTable.TableName].Rows.Add(newRow);
                                // Reset the rowstate for the new row...
                                newRow.AcceptChanges();
                                // Set the rowstate to the same as the original source rowstate...
                                newRow.Delete();
                                // 'Re-delete' the original row...
                                modifiedTable.Rows[i].Delete();
                                break;
                            case DataRowState.Detached:
                                break;
                            case DataRowState.Modified:
                                // Populate the new row with the original data from the modified row...
                                foreach (DataColumn dc in modifiedTable.Columns)
                                {
                                    newRow[dc.ColumnName] = modifiedTable.Rows[i][dc.ColumnName, DataRowVersion.Original];
                                }
                                // Add it to the modified rows table...
                                pagedModifiedDataset.Tables[modifiedTable.TableName].Rows.Add(newRow);
                                // Reset the rowstate for the new row...
                                newRow.AcceptChanges();
                                // Now modify the rows column to match the current data in the modified row...
                                foreach (DataColumn dc in modifiedTable.Columns)
                                {
                                    if (!modifiedTable.Rows[i][dc.ColumnName, DataRowVersion.Original].Equals(modifiedTable.Rows[i][dc.ColumnName, DataRowVersion.Current]))
                                    {
                                        newRow[dc.ColumnName] = modifiedTable.Rows[i][dc.ColumnName, DataRowVersion.Current];
                                    }
                                }
                                //newRow.ItemArray = modifiedTable.Rows[i].ItemArray;
                                // Set the rowstate to the same as the original source rowstate...
                                //newRow.SetModified();
                                break;
                            case DataRowState.Unchanged:
                                break;
                            default:
                                break;
                        }
                   }

                    // Call the web method to update the changed/new data...
            ////errors = GRINGlobalWebServices.SaveData(dataToSave);
            //            errors = _sharedUtils.SaveWebServiceData(dataToSave);
                    DataSet pagedModifiedDatasetResults = _sharedUtils.SaveWebServiceData(pagedModifiedDataset);

                    // Merge the returned rows into the dataset that will be returned...
                    if (pagedModifiedDatasetResults.Tables.Contains(modifiedTable.TableName) &&
                        pagedModifiedDatasetResults.Tables[modifiedTable.TableName].Rows.Count > 0)
                    {
                        // If the 'rollup' dataset does not have a return table - create it now...
                        if (!rollupReturn.Tables.Contains(modifiedTable.TableName))
                        {
                            rollupReturn.Tables.Add(pagedModifiedDatasetResults.Tables[modifiedTable.TableName].Clone());
                        }
                        // Load the returned rows to the 'rollup' dataset's table...
                        rollupReturn.Tables[modifiedTable.TableName].Load(pagedModifiedDatasetResults.Tables[modifiedTable.TableName].CreateDataReader(), LoadOption.Upsert);
                    }

                    // Roll up the dataset error messages for each page into one message...
                    if (pagedModifiedDatasetResults != null &&
                    pagedModifiedDatasetResults.Tables.Contains("ExceptionTable") &&
                    pagedModifiedDatasetResults.Tables["ExceptionTable"].Rows.Count > 0)
                    {
                        // If the 'rollup' dataset does not have an exceptions table - create it now...
                        if (!rollupReturn.Tables.Contains("ExceptionsTable") &&
                            pagedModifiedDatasetResults.Tables.Contains("ExceptionsTable"))
                        {
                            rollupReturn.Tables.Add(pagedModifiedDatasetResults.Tables["ExceptionsTable"].Clone());
                        }
                        // Append error message to the rollup error message...
                        errorMessage += "\n" + pagedModifiedDatasetResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString();
                    }

                    // Update the paging indexes...
                    pageStart = pageStop;
                    pageStop = Math.Min((pageStart + pageSize), modifiedTable.Rows.Count);

                    // Update the progress bar on the statusbar...
                    ux_statusRightProgressBar.Value = pageStart * 100 / modifiedTable.Rows.Count;
                    ux_statusstripMain.Refresh();

                    // Check to see if we should bail out (at user request)...
                    Application.DoEvents();
                }

                if (!string.IsNullOrEmpty(errorMessage))
                {
                    GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There were errors saving data.\n\nFull error message:\n{0}", "Save Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                    ggMessageBox.Name = "SaveDGVDataMessage1";
                    _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                    if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, errorMessage);
                    ggMessageBox.ShowDialog();
                }
            }
            catch
            {
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error saving data.", "Save Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "SaveDGVDataMessage2";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                ggMessageBox.ShowDialog();
            }

            // If the commandline during application startup had a parameter for _saveDataDumpFile set to a valid filepath
            // save the data to this file in XML format...
            if (!string.IsNullOrEmpty(_saveDGVDataDumpFile))
            {
                try
                {
                    dataToSave.WriteXml(_saveDGVDataDumpFile, XmlWriteMode.WriteSchema);
                }
                catch (Exception err)
                {
            //MessageBox.Show("Error attempting to save XML dataset to: " + _saveDGVDataDumpFile + "\n\nError Message:\n" + err.Message);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error attempting to save XML dataset to: {0}\n\nError Message:\n{1}", "Save Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SaveDGVDataMessage3";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}") &&
            ggMessageBox.MessageText.Contains("{1}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _saveDGVDataDumpFile, err.Message);
            }
            else if (ggMessageBox.MessageText.Contains("{0}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _saveDGVDataDumpFile);
            }
            else if (ggMessageBox.MessageText.Contains("{1}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message);
            }
            ggMessageBox.ShowDialog();
                }
            }

            // Restore the statusbar back to it's original state...
            ux_statusCenterMessage.TextAlign = centerMessageAlignment;
            ux_statusCenterMessage.Text = centerMessage;
            ux_statusRightMessage.Text = rightMessage;
            ux_statusRightProgressBar.Visible = false;
            ux_statusstripMain.Refresh();

            return rollupReturn;
        }
Пример #20
0
        private void ux_treeview_cms_NavigatorPaste_Click(object sender, EventArgs e)
        {
            // First we need to find out which tree view has been clicked...
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            ContextMenuStrip cms = (ContextMenuStrip)tsmi.Owner;
            TreeView tv = (TreeView)cms.SourceControl;

            // Process a treenode from the clipboard...
            if (Clipboard.ContainsData(typeof(TreeNode).ToString()))
            {
                DataObject obj = (DataObject)Clipboard.GetDataObject();
                TreeNode tn = (TreeNode)obj.GetData(typeof(TreeNode));
            RemoveFromDeletedTreeNodeList(tn, _deletedTreeNodes);
                // Make sure the new node has a unique name at the destination node...
                string uniqueText = EnsureUniqueNodeText(tv.SelectedNode, tn);
                if (isFolder(tn))
                {
                    tn.Name = uniqueText;
                    tn.Text = uniqueText;
                }
                else
                {
                    tn.Text = uniqueText;
                }
                tv.SelectedNode.Nodes.Add(tn);

                // Make sure the new node(s) do not exceed the max length of the full path...
                if (!PathLengthOK(tn))
                {
                    GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Invalid - the 'Full Path' of: {0} (or one of the subfolders) exceeds maximum length.", "Invalid Path", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                    ggMessageBox.Name = "ux_treeviewmenuPasteListMessage1";
                    _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, tn.FullPath);
            string[] argsArray = new string[100];
            argsArray[0] = tn.FullPath;
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
                    ggMessageBox.ShowDialog();
                    tn.Remove();
                }
            }
        }
Пример #21
0
        //public DataSet GetDGVData(string dataviewName, DataRow[] groupList, string paramsIn, int pageSize)
        public DataSet GetDGVData(string dataviewName, List<KeyValuePair<string, int>> itemList, string parameterList, int pageSize)
        {
            DataSet results = new DataSet();

            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            // Reset the escapeKeyPressed flag...
            escapeKeyPressed = false;

            // Remember the original layout of the status bar (before changing it)...
            ContentAlignment centerMessageAlignment = ux_statusCenterMessage.TextAlign;
            string centerMessage = ux_statusCenterMessage.Text;
            string rightMessage = ux_statusRightMessage.Text;
            ux_statusstripMain.DefaultStateSave();

            // Update the controls on the interface (to disable the user from
            // choosing a new view tab or tree node during the middle of a query)...
            ux_splitcontainerMain.Panel1.Enabled = false;
            ux_splitcontainerMain.Panel2.Enabled = false;
            try
            {
                if (itemList.Count > 0)
                {
                    int nextPage = pageSize;

                    // Set the statusbar up to show the query progress...
                    ux_statusCenterMessage.TextAlign = ContentAlignment.MiddleRight;
                    ux_statusCenterMessage.Text = "Retrieving Data:";
                    ux_statusRightMessage.Text = "   Press the escape key (esc) to cancel query   ";
                    ux_statusRightProgressBar.Visible = true;
                    ux_statusRightProgressBar.Minimum = 0;
                    ux_statusRightProgressBar.Maximum = 100; // groupList.Length;
                    ux_statusRightProgressBar.Step = 1; // pageSize;
                    ux_statusRightProgressBar.Value = 0;
                    ux_statusstripMain.Refresh();

                    // Begin iterating through the collection of ACIDS, IVIDS, and ORNOS...
                    int pageStart = 0;
                    int pageStop = Math.Min(pageSize, itemList.Count);
                    while (pageStart < itemList.Count && !escapeKeyPressed)
                    {
                        string pkeyCollection = parameterList;
                        for (int i = pageStart; i < pageStop; i++)
                        {
                            if (pkeyCollection.Contains(itemList[i].Key.Trim().ToLower() + "="))
                            {
                                pkeyCollection = pkeyCollection.Replace(itemList[i].Key.Trim().ToLower() + "=", itemList[i].Key.Trim().ToLower() + "=" + itemList[i].Value.ToString() + ",");
                            }
                            else if (pkeyCollection.Contains(itemList[i].Key.Trim().ToLower() + ";"))
                            {
                                pkeyCollection = pkeyCollection.Replace(itemList[i].Key.Trim().ToLower() + ";", itemList[i].Key.Trim().ToLower() + "=" + itemList[i].Value.ToString() + ";");
                            }
                            else
                            {
                                pkeyCollection += itemList[i].Key.Trim().ToLower() + "=" + itemList[i].Value.ToString();
                            }
                        }
                        // Update the paging indexes...
                        pageStart = pageStop;
                        pageStop = Math.Min((pageStart + pageSize), itemList.Count);
                        // Build the param string and get the data...
                        //string pkeyCollection = ":accessionid=" + acids.TrimEnd(',') + "; :inventoryid=" + ivids.TrimEnd(',') + "; :orderrequestid=" + ornos.TrimEnd(',') + "; :cooperatorid=" + coops.TrimEnd(',') + "; :geographyid=" + geos.TrimEnd(',') + "; :taxonomygenusid=" + genus.TrimEnd(',') + "; :cropid=" + crops.TrimEnd(',');
                        DataSet pagedDataSet = _sharedUtils.GetWebServiceData(dataviewName, pkeyCollection, 0, Convert.ToInt32(ux_numericupdownMaxRowsReturned.Value));

                        // Add the results to the dataset that will be returned...
                        if (pagedDataSet.Tables.Contains(dataviewName) &&
                            results.Tables.Contains(dataviewName))
                        {
                            results.Tables[dataviewName].Merge(pagedDataSet.Tables[dataviewName].Copy());
                        }
                        else if (pagedDataSet.Tables.Contains(dataviewName))
                        {
                            results.Tables.Add(pagedDataSet.Tables[dataviewName].Copy());
                        }
                        else
                        {
                            if (pagedDataSet.Tables.Contains("ExceptionTable") &&
                                pagedDataSet.Tables["ExceptionTable"].Rows.Count > 0)
                            {
                                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data for {0}.\n\nFull error message:\n{1}", "Get Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                                ggMessageBox.Name = "GetDGVDataMessage1";
                                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                                if (ggMessageBox.MessageText.Contains("{0}") &&
                                    ggMessageBox.MessageText.Contains("{1}"))
                                {
                                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName, pagedDataSet.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
                                }
                                else if (ggMessageBox.MessageText.Contains("{0}"))
                                {
                                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName);
                                }
                                else if (ggMessageBox.MessageText.Contains("{1}"))
                                {
                                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, pagedDataSet.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
                                }
                                ggMessageBox.ShowDialog();
                            }
                        }

                        // Check to see if we have hit the maximum rows returned limit...
                        if (results.Tables[dataviewName].Rows.Count > ux_numericupdownMaxRowsReturned.Value)
                        {
                            // We have hit the max rows limit so set the page start value so that the loop exits normally...
                            pageStart = itemList.Count;
                            for (int i = (int)ux_numericupdownMaxRowsReturned.Value; i < results.Tables[dataviewName].Rows.Count; i++)
                            {
                                results.Tables[dataviewName].Rows[i].Delete();
                            }
                            results.Tables[dataviewName].AcceptChanges();
                        }

                        // Update the progress bar on the statusbar...
                        ux_statusRightProgressBar.Value = pageStart * 100 / itemList.Count; // pageStart;
                        ux_statusstripMain.Refresh();

                        // Check to see if we should bail out (at user request)...
                        Application.DoEvents();
                        Cursor.Current = Cursors.WaitCursor;
                    }
                }
                else
                {
                    // If no primary keys were found return an empty dataset...
                    results = _sharedUtils.GetWebServiceData(dataviewName, "", 0, Convert.ToInt32(ux_numericupdownMaxRowsReturned.Value));

                    if (!results.Tables.Contains(dataviewName) &&
                        results.Tables.Contains("ExceptionTable") &&
                        results.Tables["ExceptionTable"].Rows.Count > 0)
                    {
                        GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data for {0}.\n\nFull error message:\n{1}", "Get Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                        ggMessageBox.Name = "GetDGVDataMessage2";
                        _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                        if (ggMessageBox.MessageText.Contains("{0}") &&
                            ggMessageBox.MessageText.Contains("{1}"))
                        {
                            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName, results.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
                        }
                        else if (ggMessageBox.MessageText.Contains("{0}"))
                        {
                            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName);
                        }
                        else if (ggMessageBox.MessageText.Contains("{1}"))
                        {
                            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, results.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
                        }
                        ggMessageBox.ShowDialog();
                    }
                }

            }
            catch (Exception err)
            {
                GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data for {0}.\n\nFull error message:\n{1}", "Get Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
                ggMessageBox.Name = "GetDGVDataMessage3";
                _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
                if (ggMessageBox.MessageText.Contains("{0}") &&
                    ggMessageBox.MessageText.Contains("{1}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName, err.Message);
                }
                else if (ggMessageBox.MessageText.Contains("{0}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewName);
                }
                else if (ggMessageBox.MessageText.Contains("{1}"))
                {
                    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message);
                }
                ggMessageBox.ShowDialog();
                if (!results.Tables.Contains(dataviewName))
                {
                    results.Tables.Add(dataviewName);
                }
            }
            finally
            {
                // Restore the statusbar back to it's original state...
                ux_statusCenterMessage.TextAlign = centerMessageAlignment;
                ux_statusCenterMessage.Text = centerMessage;
                ux_statusRightMessage.Text = rightMessage;
                ux_statusRightProgressBar.Visible = false;
                ux_statusstripMain.Refresh();

                // Allow the user to 'move freely about the cabin' again...
                ux_splitcontainerMain.Panel1.Enabled = true;
                ux_splitcontainerMain.Panel2.Enabled = true;

                // Restore cursor to default cursor...
                Cursor.Current = origCursor;
            }

            return results;
        }
Пример #22
0
        private void RefreshTreeviewNodeFormatting(TreeNode treeNode)
        {
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            //if (isFolder(treeNode))
            if (treeNode.Nodes.Count > 0)
            {
                // First rename (title) the node items...
                //value = "{get_accession.accession_number_part1} + \" \" + {get_accession.accession_number_part2} + \" \" + {get_accession.accession_number_part3}; ";
                System.Collections.Generic.Dictionary<string, string> idTypeFormattingFormula = new System.Collections.Generic.Dictionary<string, string>();
                System.Collections.Generic.List<string> idTypes = new System.Collections.Generic.List<string>();
                System.Collections.Generic.Dictionary<string, string> idNumbers = new System.Collections.Generic.Dictionary<string, string>();
                DataSet ds = new DataSet();

                // First find all of the distinct ID_TYPES,
                // their corresponding formatting formulas,
                // and gather all of the ID_NUMBERS for each ID_TYPE in the userItemList collection...
                foreach (TreeNode tn in treeNode.Nodes)
                {
                    if (!isFolder(tn))
                    {
            //string pKey = tn.Tag.ToString().Split(';')[1].Trim();
            //string nodePKeyType = pKey.Split('=')[0].Replace(":", "").Trim().ToUpper();
            //string nodePKeyValue = pKey.Split('=')[1].Trim().ToUpper();
            string[] pKey = tn.Name.Split('=');
            string nodePKeyType = pKey[0];
            string nodePKeyValue = pKey[1];

                        // Get the ID_TYPE...
                        if (!idTypes.Contains(nodePKeyType)) idTypes.Add(nodePKeyType);
                        // Now get the formatting formula for each ID_TYPE in the collection...
                        if (!idTypeFormattingFormula.ContainsKey(nodePKeyType))
                        {
                            //string formula = GetTreeviewNodeProperty(nodePKeyType + "_NAME_FORMULA", tn);
                            string formula = GetTreeviewNodeProperty(tn.Tag.ToString().Split(';')[0].Trim().ToUpper() + "_NAME_FORMULA", tn, true, "");
                            if (string.IsNullOrEmpty(formula))
                            {
                                // Could not find a formula for this type of treenode object type...
                            }
                            idTypeFormattingFormula.Add(nodePKeyType, formula);
                        }
                        // Next collect all of the ID_NUMBERS for each of the ID_TYPES for the userItemList collection...
                        if (!idNumbers.ContainsKey(nodePKeyType))
                        {
                            idNumbers.Add(nodePKeyType, nodePKeyValue + ",");
                        }
                        else
                        {
                            idNumbers[nodePKeyType] = idNumbers[nodePKeyType] + nodePKeyValue + ",";
                        }
                    }
                    else
                    {
                        if (ux_checkboxIncludeSubFolders.Checked)
                        {
                            RefreshTreeviewNodeFormatting(tn);
                        }
                    }
                }

                Dictionary<string, Dictionary<int, string>> friendlyNames = new Dictionary<string,Dictionary<int,string>>();

                // Make all the trips to the server now to get all data needed for new userItemList titles...
                foreach (string idType in idTypes)
                {
                    // Create the new dictionary LU for the friendly name and add it to the collection...
                    friendlyNames.Add(idType, new Dictionary<int, string>());

                    // Break down the name formula into tokens and process the tokens one by one...
                    string[] formatTokens = idTypeFormattingFormula[idType].Split(new string[] { " + " }, StringSplitOptions.RemoveEmptyEntries);
                    string staticTextSeparator = "";
                    foreach (string formatToken in formatTokens)
                    {
                        if (formatToken.Contains("{") &&
                            formatToken.Contains("}"))
                        {
                            // This is a DB field used in the title - so if we don't already have it go get it now...
                            string[] dataviewAndField = formatToken.Trim().Replace("{", "").Replace("}", "").Trim().Split(new char[] { '.' });
                            if (!ds.Tables.Contains(dataviewAndField[0]))
                            {
                                DataSet newDS = _sharedUtils.GetWebServiceData(dataviewAndField[0], idType.Trim().ToLower() + "=" + idNumbers[idType].Trim().TrimEnd(','), 0, 0);
                                if (newDS != null &&
                                    newDS.Tables.Contains(dataviewAndField[0]))
                                {
                                    ds.Tables.Add(newDS.Tables[dataviewAndField[0]].Copy());
                                }
            else if (newDS.Tables.Contains("ExceptionTable") &&
            newDS.Tables["ExceptionTable"].Rows.Count > 0)
            {
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data from {0} to use in building a node friendly name.\n\nFull error message:\n{1}", "Get Name Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "RefreshTreeviewNodeFormatting1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0], newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0]);
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            //}
            string[] argsArray = new string[100];
            argsArray[0] = dataviewAndField[0];
            argsArray[1] = newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
            }
                            }
                            // Process all of the rows in the table to add the dbToken to the friendly name...
                            // But first check to make sure the field exists in the datatable (if it doesn't exist just skip it)...
                            if (ds != null &&
                                ds.Tables.Count > 0 &&
                                ds.Tables[dataviewAndField[0]].Columns.Contains(dataviewAndField[1]))
                            {
                                foreach (DataRow dr in ds.Tables[dataviewAndField[0]].Rows)
                                {
                                    int pkey;
                                    string dbTokenText = dr[dataviewAndField[1]].ToString();
                                    DataColumn dc = ds.Tables[dataviewAndField[0]].Columns[dataviewAndField[1]];

                                    if (int.TryParse(dr[ds.Tables[dataviewAndField[0]].PrimaryKey[0]].ToString(), out pkey) &&
                                        !string.IsNullOrEmpty(dbTokenText))
                                    {
                                        // Resolve fkeys and code_values to the display_member if necessary...
                                        if (_sharedUtils.LookupTablesIsValidFKField(dc))
                                        {
                                            dbTokenText = _sharedUtils.GetLookupDisplayMember(dc.ExtendedProperties["foreign_key_dataview_name"].ToString().Trim(), dbTokenText, "", dbTokenText);
                                        }
                                        else if (_sharedUtils.LookupTablesIsValidCodeValueField(dc))
                                        {
                                            dbTokenText = _sharedUtils.GetLookupDisplayMember("code_value_lookup", dbTokenText, dc.ExtendedProperties["group_name"].ToString(), dbTokenText);
                                        }
                                        // If the pkey is already in the dictionary append to it (otherwise add it)...
                                        if (friendlyNames[idType].ContainsKey(pkey))
                                        {
                                            friendlyNames[idType][pkey] += staticTextSeparator + dbTokenText;
                                        }
                                        else
                                        {
                                            friendlyNames[idType][pkey] = staticTextSeparator + dbTokenText;
                                        }
                                    }
                                }
                            }
                            staticTextSeparator = "";
                        }
                        else
                        {
                            staticTextSeparator += formatToken.Trim().Replace("\"", "");
                        }
                    }
                    if (!string.IsNullOrEmpty(staticTextSeparator))
                    {
                        for (int i = 0; i < friendlyNames[idType].Keys.Count; i++)
                        {
                            friendlyNames[idType][friendlyNames[idType].ElementAt(i).Key] += staticTextSeparator;
                        }
                    }
                }

                // Now refresh the titles for each item in the collection...
                // This next line REALLY speeds things up (it tells the control to stop painting during a major update)...
                treeNode.TreeView.BeginUpdate();
                foreach (TreeNode tn in treeNode.Nodes)
                {
                    if (!isFolder(tn))
                    {
                        string[] pKey = tn.Name.Split('=');
                        string nodePKeyType = pKey[0];
                        string nodePKeyValue = pKey[1];
                        int pkey;
                        //
                        if (int.TryParse(nodePKeyValue, out pkey) &&
                            friendlyNames[nodePKeyType].ContainsKey(pkey))
                        {
                            string title = friendlyNames[nodePKeyType][pkey];
                            tn.Text = title;
                            title = EnsureUniqueNodeText(treeNode, tn);
                            tn.Text = title.Trim();
                        }
                    }
                }
                // We are all done updating names so now we can let the treeview resume painting its display...
                treeNode.TreeView.EndUpdate();

            //                foreach (TreeNode tn in treeNode.Nodes)
            //                {
            //                    if (!isFolder(tn))
            //                    {
            ////string pKey = tn.Tag.ToString().Split(';')[1].Trim();
            ////string nodePKeyType = pKey.Split('=')[0].Replace(":", "").Trim().ToUpper();
            ////string nodePKeyValue = pKey.Split('=')[1].Trim().ToUpper();
            //string[] pKey = tn.Name.Split('=');
            //string nodePKeyType = pKey[0];
            //string nodePKeyValue = pKey[1];

            //                        string title = "";
            //                        string[] formatTokens = idTypeFormattingFormula[nodePKeyType].Split(new string[] { " + " }, StringSplitOptions.RemoveEmptyEntries);
            //                        foreach (string formatToken in formatTokens)
            //                        {
            //                            if (formatToken.Contains("{") &&
            //                                formatToken.Contains("}"))
            //                            {
            //                                // This is a DB field used in the title - so go get it...
            //                                string[] dataviewAndField = formatToken.Trim().Replace("{", "").Replace("}", "").Trim().Split(new char[] { '.' });
            //                                if (dataviewAndField.Length == 2)
            //                                {
            //                                    if (ds.Tables.Contains(dataviewAndField[0]) &&
            //                                        ds.Tables[dataviewAndField[0]].Rows.Count > 0 &&
            //                                        ds.Tables[dataviewAndField[0]].Columns.Contains(dataviewAndField[1]))
            //                                    {
            //                                        // The list of dataviews that can be used for building node titles must have a pkey that is one of the ID_TYPES
            //                                        // otherwise this next line won't work...
            //                                        DataRow tokenRawDataRow = ds.Tables[dataviewAndField[0]].Rows.Find(nodePKeyValue);
            //                                        if (tokenRawDataRow != null)
            //                                        {
            //                                            DataColumn dc = tokenRawDataRow.Table.Columns[dataviewAndField[1]];
            //                                            string valueMember = tokenRawDataRow[dataviewAndField[1]].ToString();
            //                                            if (_sharedUtils.LookupTablesIsValidFKField(dc) &&
            //                                                !string.IsNullOrEmpty(valueMember))
            //                                            {
            //                                                title += _sharedUtils.GetLookupDisplayMember(dc.ExtendedProperties["foreign_key_dataview_name"].ToString().Trim(), valueMember, "", valueMember);
            //                                            }
            //                                            else if (_sharedUtils.LookupTablesIsValidCodeValueField(dc) &&
            //                                                    !string.IsNullOrEmpty(valueMember))
            //                                            {
            ////title += _sharedUtils.GetLookupDisplayMember("code_value_lookup", valueMember, "", valueMember);
            //                                                title += _sharedUtils.GetLookupDisplayMember("code_value_lookup", valueMember, dc.ExtendedProperties["group_name"].ToString(), valueMember);
            //                                            }
            //                                            else
            //                                            {
            //                                                title += valueMember;
            //                                            }
            //                                        }
            //                                    }
            //                                }
            //                            }
            //                            else
            //                            {
            //                                title += formatToken.Trim().Replace("\"", "");
            //                            }
            //                        }
            //                        // If there was success in building a new node title and it is a different name than the old title, make sure it is unique and then replace the old title...
            //                        if (!string.IsNullOrEmpty(title))
            //                        {
            //                            tn.Text = title;
            //title = EnsureUniqueNodeText(treeNode, tn);
            //tn.Text = title.Trim();
            //                        }
            //                    }

            //                }

                // Now resort the items...
                string sortMode = GetTreeviewNodeProperty("SORT_MODE", treeNode, true, "MANUAL");
                string folderGroupingMode = GetTreeviewNodeProperty("FOLDER_GROUPING_MODE", treeNode, true, "TOP");
                if (isFolder(treeNode) && sortMode.ToUpper().Trim() != "MANUAL") sortFolder(treeNode, sortMode);
            }

            /*
            // Find the user_item_list row corresponding to this node...
            if (isFolder(treeNode))
            {
                // First rename (title) the node items...
                RefreshUserItemListTitles(drcItems);
                // Now resort the items...
                // Get the sort settings from the folder (actually it will come from the parent of the collection items)...
                if (drcItems.Length > 0)
                {
                    string sortMode = GetUserItemListProperty("SORT_MODE", drcItems[0]);
                    string folderGroupingMode = GetUserItemListProperty("FOLDER_GROUPING_MODE", drcItems[0]);
                    SortUserItemList(tabText, treeNode, sortMode, folderGroupingMode == "TOP");
                }
            }
            */
            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
Пример #23
0
        private void GRINGlobalClientSearchTool_Load(object sender, EventArgs e)
        {
            // Indicate the web service connection...
            List<string> URLs = new List<string>();
            if (!string.IsNullOrEmpty(_url)) URLs.Add(_url);
            URLs.Add("http://localhost/GrinGlobal/GUI.asmx");
            URLs.Add("http://GRIN-Global-Test1.agron.iastate.edu/GrinGlobal/GUI.asmx");
            URLs.Add("http://GRIN-Global-Dev1.agron.iastate.edu/GrinGlobal/GUI.asmx");
            URLs.Add("http://GRIN-Global-Dev2.agron.iastate.edu/GrinGlobal/GUI.asmx");

            bool connectedToWebService = false;
            //_sharedUtils = new GRINGlobal.Client.Common.SharedUtils(_url, _user, _password);
            if (_sharedUtils.IsConnected)
            {
                _url = _sharedUtils.Url;
                _user = _sharedUtils.Username;
                _password = _sharedUtils.Password;
            //_cursorGG = _sharedUtils.LoadCursor(@"Images\cursor_GG.cur");
            _cursorGG = Cursors.Default;
            }
            else
            {
                // Could not find a web service - so bail out now...
            //MessageBox.Show("Error: Could not connect to GRIN-Global Web Services");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error: Could not connect to GRIN-Global Web Services", "Connection Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_LoadMessage1";
            if (_sharedUtils.IsConnected) _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog();
                this.Close();
            }
            //else
            //{
            //    Login loginDialog = new Login(_user, _password, GUIWebServices.Url);
            //    loginDialog.StartPosition = FormStartPosition.CenterScreen;
            //    loginDialog.ShowDialog();
            //    if (DialogResult.OK == loginDialog.DialogResult)
            //    {
            //        //validLogin = true;
            //        _user = loginDialog.UserName;
            //        _password = loginDialog.Password;
            //        //cno = loginDialog.UserCooperatorID;
            //        //site = loginDialog.UserSite;
            //        //languageCode = loginDialog.UserLanguageCode;
            //    }
            //    else
            //    {
            //        // Login is unsuccessful - so bail out now...
            //        this.Close();
            //    }
            //}

            if (!this.IsDisposed)
            {
                GUIData = GetGUIData(_user, _password);
                uxtvTableFields = BuildTreeView(GUIData);
                //uxtvTableFields.Height = splitContainer1.Panel2.Height;
                //uxtvTableFields.Width = splitContainer1.Panel2.Width;
                uxtvTableFields.Location = new Point(0, 0);
                uxtvTableFields.Size = new Size(splitContainer1.Panel2.Size.Width, splitContainer1.Panel2.Size.Height);
                uxtvTableFields.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
                splitContainer1.Panel2.Controls.Add(uxtvTableFields);
                //toolTip1.SetToolTip(uxtvTableFields, "This is a treeview...");
                toolTip1.SetToolTip(ux_buttonDoAdvancedQuery, "This is a button...");

                ux_tabpageAdvancedQuery.Enabled = false;
                ux_tabpageAdvancedQuery.Hide();

            //// Set the custom GG cursor for the form (if it is available)...
            //if (_cursorGG != null)
            //{
            //    this.Cursor = _cursorGG;
            //}

                // Set the title bar with the name and version of this application...
                this.Text = "GRIN-Global Search  v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();

            // Populate the dropdown list of 'Find Types'...
            DataSet ds = _sharedUtils.GetWebServiceData("sys_table", "", 0, 0);
            if (ds != null && ds.Tables.Contains("sys_table"))
            {
            foreach (DataRow dr in ds.Tables["sys_table"].Rows)
            {
            ux_comboboxCustomFind.Items.Add(dr["table_name"]);
            }
            ux_comboboxCustomFind.SelectedIndex = 0;
            }

            // Build the results Dataview horizontal TabControl...
            _sharedUtils.BuildDataviewTabControl(ux_tabcontrolSTDataviews);

            // Get language translations for the components and controls in this applicataion...
            _sharedUtils.UpdateComponents(this.components.Components, this.Name);
            _sharedUtils.UpdateControls(this.Controls, this.Name);

            // Save the statusbar text for the left, center, and right controls...
            if (string.IsNullOrEmpty(ux_statusLeftMessage.Text)) ux_statusLeftMessage.Text = "";
            if (string.IsNullOrEmpty(ux_statusCenterMessage.Text)) ux_statusCenterMessage.Text = "";
            if (string.IsNullOrEmpty(ux_statusRightMessage.Text)) ux_statusRightMessage.Text = "";
            ux_statusLeftMessage.Tag = ux_statusLeftMessage.Text;
            ux_statusCenterMessage.Tag = ux_statusCenterMessage.Text;
            ux_statusRightMessage.Tag = ux_statusRightMessage.Text;

            // Initialize/Update the statusbar...
            // First the left message...
            if (ux_statusLeftMessage.Tag != null)
            {
            if (ux_statusLeftMessage.Tag.ToString().Contains("{0}") &&
            ux_statusLeftMessage.Tag.ToString().Contains("{1}"))
            {
            ux_statusLeftMessage.Text = string.Format(ux_statusLeftMessage.Tag.ToString(), 0, 0);
            }
            else if (ux_statusLeftMessage.Tag.ToString().Contains("{0}"))
            {
            ux_statusLeftMessage.Text = string.Format(ux_statusLeftMessage.Tag.ToString(), 0);
            }
            }
            else
            {
            ux_statusLeftMessage.Text = "Showing rows: 0 of 0 retrieved";
            }
            // Then the center message...
            if (ux_statusCenterMessage.Tag != null)
            {
            if (ux_statusCenterMessage.Tag.ToString().Contains("{0}"))
            {
            ux_statusCenterMessage.Text = string.Format(ux_statusCenterMessage.Tag.ToString(), _url);
            }
            else
            {
            ux_statusCenterMessage.Text = ux_statusCenterMessage.Tag.ToString() + " (" + _url + ")";
            }
            }
            else
            {
            ux_statusCenterMessage.Text = "Connected to: " + _url;
            }
            ux_statusProgressBar.Visible = false;
            ux_statusRightMessage.Text = "";

            LoadUserSettings();

                // Select the first tab (initiates the updating of the DGV control...
                basicQuerySearchResults = new DataRow[0];
                ux_tabcontrolSTDataviews.SelectedIndex = -1;
                ux_tabcontrolSTDataviews.SelectedIndex = 0;
                // Set focus to the Basic Query textbox...
                ux_textboxBasicQueryText.Focus();
            }
        }
Пример #24
0
 private void ux_buttonCancel_Click(object sender, EventArgs e)
 {
     int intRowEdits = ((DataTable)((BindingSource)_imageDGV.DataSource).DataSource).GetChanges().Rows.Count;
     GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s), are you sure you want to cancel?", "Cancel Edits", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
     ggMessageBox.Name = "ux_buttonCancelEditDataMessage1";
     _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
     if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
     if (DialogResult.Yes == ggMessageBox.ShowDialog())
     {
     // Close the form...
     this.Close();
     }
 }
Пример #25
0
        private void ux_buttonDoBasicQuery_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            ux_buttonDoBasicQuery.Enabled = false;

            // Add any criteria in the criteria row to the query text box...
            ux_buttonAddToQuery.PerformClick();

            string strUsername = _user;
            string strPassword = _password;
            string filter = "ID IS NOT NULL";
            //int pageSize = 100;
            // Build the list of tables to search...
            string tablesToSearch = buildListOfTablesToSearch();

            // Detect the type of result the user wants...
            //if (ux_radiobuttonBasicReturnCooperators.Checked)
            //{
            //    searchResultType = "cooperator";
            //    filter = "ID IS NOT NULL";
            //}
            //else if (ux_radiobuttonBasicReturnOrders.Checked)
            //{
            //    searchResultType = "order_request";
            //    filter = "ID IS NOT NULL";
            //}
            //else if (ux_radiobuttonBasicReturnInventory.Checked)
            //{
            //    searchResultType = "inventory";
            //    filter = "ID IS NOT NULL";
            //}
            //else
            //{
            //    searchResultType = "accession";
            //    filter = "ID IS NOT NULL";
            //}
            if (ux_radiobuttonDefaultFind.Checked)
            {
            searchResultType = "accession";
            DataviewProperties dp = (DataviewProperties)ux_tabcontrolSTDataviews.SelectedTab.Tag;
            DataSet ds = _sharedUtils.GetWebServiceData("get_dataview_list", "", 0, 0);
            if (ds != null && ds.Tables.Contains("get_dataview_list"))
            {
            DataRow[] dvListRows = ds.Tables["get_dataview_list"].Select("dataview_name='" + dp.DataviewName + "'");
            if(dvListRows != null && dvListRows.Length > 0)
            {
            searchResultType = dvListRows[0]["primary_key"].ToString();
            searchResultType = searchResultType.Remove(searchResultType.Length - 3);
            }
            }
            }
            else
            {
            searchResultType = ux_comboboxCustomFind.SelectedItem.ToString();
            }

            // Clear the previous results and get new results...
            if (queryResults.Tables.Contains("BasicSearchResults")) queryResults.Tables.Remove("BasicSearchResults");
            // Clear the previous search results...
            basicQuerySearchResults = new DataRow[0];
            try
            {
                string searchCriteria = ux_textboxBasicQueryText.Text;
                DataSet dsBasicQuerySearchResults = null;
                if (ux_radiobuttonBasicMatchList.Checked)
                {
                    //searchCriteria = BuildSearchStringFromItemList(ux_textboxBasicQueryText.Text);
                    dsBasicQuerySearchResults = _sharedUtils.SearchWebService(searchCriteria, ux_checkboxIgnoreCase.Checked, ux_radiobuttonBasicMatchAll.Checked, tablesToSearch, searchResultType, 0, Int32.Parse(ux_numericupdownBasicMaxRecords.Value.ToString()), "OrMultipleLines=true");
            //ux_textboxBasicQueryText.Text = searchCriteria;
                }
                else
                {
                    dsBasicQuerySearchResults = _sharedUtils.SearchWebService(searchCriteria, ux_checkboxIgnoreCase.Checked, ux_radiobuttonBasicMatchAll.Checked, tablesToSearch, searchResultType, 0, Int32.Parse(ux_numericupdownBasicMaxRecords.Value.ToString()));
                }
                if (dsBasicQuerySearchResults != null && dsBasicQuerySearchResults.Tables.Contains("SearchResult"))
                {
                    basicQuerySearchResults = dsBasicQuerySearchResults.Tables["SearchResult"].Select(filter);
            //DialogResult userResponse = MessageBox.Show("Found at least " + basicQuerySearchResults.Length + " 'possible' matches in the database.  Continue to retrieve data?", "Query Results", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            DialogResult userResponse = DialogResult.Cancel;
            if (basicQuerySearchResults.Length == 0)
            {
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("No matches in the database were found.", "Query Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_ux_buttonDoBasicQueryMessage5";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            userResponse = ggMessageBox.ShowDialog();
            }
            else
            {
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Found at least {0} 'possible' matches in the database.  Continue to retrieve data?", "Query Results", MessageBoxButtons.OKCancel, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_ux_buttonDoBasicQueryMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, basicQuerySearchResults.Length);
            userResponse = ggMessageBox.ShowDialog();
            }
                    if (userResponse == DialogResult.Cancel)
                    {
                        // User is bailing out on the query so clear the results with an empty array...
                        basicQuerySearchResults = new DataRow[0];
                    }
                }
                else
                {
                    if (dsBasicQuerySearchResults != null && dsBasicQuerySearchResults.Tables.Contains("ExceptionTable"))
                    {
            //MessageBox.Show("There was an unexpected error searching for data.\n\nFull error message:\n" + dsBasicQuerySearchResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error searching for data.\n\nFull error message:\n{0}", "Search Engine Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_ux_buttonDoBasicQueryMessage2";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dsBasicQuerySearchResults.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            ggMessageBox.ShowDialog();
                    }
                    else
                    {
            //MessageBox.Show("There was an unexpected error searching for data.\n\nWeb Service at '" + _url + "' did not respond to your search request.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error searching for data.\n\nWeb Service at '{0}' did not respond to your search request.", "Search Engine Response Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_ux_buttonDoBasicQueryMessage3";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, _url);
            ggMessageBox.ShowDialog();
                    }
                    // Clear the results with an empty array...
                    basicQuerySearchResults = new DataRow[0];
                }
            }
            catch (Exception err)
            {
            //MessageBox.Show("There was an unexpected error searching for data.\n\nWeb Service at '" + _url + "' did not respond to your search request.\n\nFull error message:\n" + err.Message);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error searching for data.\n\nWeb Service at '{0}' did not respond to your search request.\n\nFull error message:\n{1}", "Search Engine Response Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "GRINGlobalClientSearchTool_ux_buttonDoBasicQueryMessage4";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}") &&
            ggMessageBox.MessageText.Contains("{1}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ggMessageBox.MessageText, _url, err.Message);
            }
            else if (ggMessageBox.MessageText.Contains("{0}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ggMessageBox.MessageText, _url);
            }
            else if (ggMessageBox.MessageText.Contains("{1}"))
            {
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message);
            }
            ggMessageBox.ShowDialog();
            }

            #region Old code for refreshing data...

            //// Get the name of the dataview to use...
            //string dataGridViewTableName = "get_accession";
            //if (ux_tabcontrolDataview.SelectedTab == null ||
            //    ux_tabcontrolDataview.SelectedTab.Tag == null ||
            //    ux_tabcontrolDataview.SelectedTab.Tag.GetType() != typeof(GRINGlobal.Client.Common.DataviewProperties) ||
            //    string.IsNullOrEmpty(((GRINGlobal.Client.Common.DataviewProperties)ux_tabcontrolDataview.SelectedTab.Tag).DataviewName))
            //{
            //    return;
            //}
            //else
            //{
            //    if (ux_tabcontrolDataview.SelectedTab.Tag.GetType() == typeof(GRINGlobal.Client.Common.DataviewProperties))
            //    {
            //        dataGridViewTableName = ((GRINGlobal.Client.Common.DataviewProperties)ux_tabcontrolDataview.SelectedTab.Tag).DataviewName;
            //    }
            //}

            //            //if (userResponse == DialogResult.OK)
            //            {
            //                // Get the data for the selected dataview tab based on the search results...
            ////DataSet ds = GetDGVData(ux_tabcontrolDataview.SelectedTab.Tag.ToString(), basicQuerySearchResults, pageSize);
            ////if (queryResults.Tables.Contains("BasicSearchResults")) queryResults.Tables.Remove("BasicSearchResults");
            ////if (ds.Tables.Contains(ux_tabcontrolDataview.SelectedTab.Tag.ToString()))
            //DataSet ds = GetDGVData(dataGridViewTableName, basicQuerySearchResults, pageSize);
            //if (queryResults.Tables.Contains("BasicSearchResults")) queryResults.Tables.Remove("BasicSearchResults");
            //if (ds.Tables.Contains(dataGridViewTableName))
            //                {
            ////queryResults.Tables.Add(ds.Tables[ux_tabcontrolDataview.SelectedTab.Tag.ToString()].Copy());
            ////queryResults.Tables[ux_tabcontrolDataview.SelectedTab.Tag.ToString()].TableName = "BasicSearchResults";
            //queryResults.Tables.Add(ds.Tables[dataGridViewTableName].Copy());
            //queryResults.Tables[dataGridViewTableName].TableName = "BasicSearchResults";

            //                    // Reset the rowfilter and the sortorder...
            //                    DataGridViewSortOrder = "";
            //                    DataGridViewFilter = "";
            //                    queryResults.Tables["BasicSearchResults"].DefaultView.Sort = DataGridViewSortOrder;
            //                    queryResults.Tables["BasicSearchResults"].DefaultView.RowFilter = DataGridViewFilter;

            //                    // Now build the DGV and bind it to the datasource...
            //                    _sharedUtils.BuildReadOnlyDataGridView(ux_datagridviewQueryResults, queryResults.Tables["BasicSearchResults"]);

            //// Update the statusbar...
            //if (ux_statusLeftMessage.Tag.ToString().Contains("{0}") &&
            //    ux_statusLeftMessage.Tag.ToString().Contains("{1}"))
            //{
            //    ux_statusLeftMessage.Text = string.Format(ux_statusLeftMessage.Tag.ToString(), ux_datagridviewQueryResults.Rows.Count.ToString(), ((DataTable)ux_datagridviewQueryResults.DataSource).Rows.Count.ToString());
            //}
            //else if (ux_statusLeftMessage.Tag.ToString().Contains("{0}"))
            //{
            //    ux_statusLeftMessage.Text = string.Format(ux_statusLeftMessage.Tag.ToString(), ((DataTable)ux_datagridviewQueryResults.DataSource).Rows.Count.ToString());
            //}
            ////ux_statusLeftMessage.Text = "Showing rows: " + ux_datagridviewQueryResults.Rows.Count.ToString() + " of " + ((DataTable)ux_datagridviewQueryResults.DataSource).Rows.Count.ToString() + " retrieved";

            //                    foreach (DataGridViewColumn dgvc in ux_datagridviewQueryResults.Columns)
            //                    {
            //                        dgvc.SortMode = DataGridViewColumnSortMode.Programmatic;
            //                        dgvc.ContextMenuStrip = ux_contextmenustripDGVResultsCell;
            //                        DataColumn dc = ((DataTable)dgvc.DataGridView.DataSource).Columns[dgvc.DataPropertyName];
            //                        dgvc.HeaderText = _sharedUtils.GetFriendlyFieldName(dc, dc.ColumnName);
            //                    }
            //                    RefreshDGVFormatting();
            //                }
            //            }

            #endregion
            RefreshDGVData();
            RefreshDGVFormatting();

            //Cursor.Current = Cursors.Default;
            Cursor.Current = _cursorGG;
            ux_buttonDoBasicQuery.Enabled = true;

            // Set focus to the text box...
            ux_textboxBasicQueryText.Focus();
        }
Пример #26
0
        private void LookupTableStatusCheck()
        {
            //// Display the splash page to let the user know that things are happening...
            //Splash splash = new Splash();
            //splash.StartPosition = FormStartPosition.CenterScreen;
            //splash.Show();
            //splash.Update();
            try
            {
                int partiallyLoadedTables = 0;
                DataTable lookupTableStatus = _sharedUtils.LookupTablesGetSynchronizationStats();
                if (lookupTableStatus != null &&
                    lookupTableStatus.Rows.Count > 0)
                {
                    foreach (DataRow dr in lookupTableStatus.Rows)
                    {
                        if (dr["status"].ToString().Trim().ToUpper() != "COMPLETED" &&
                            dr["status"].ToString().Trim().ToUpper() != "UPDATED")
                        {
                            // The program will not auto-update a partially loaded LUT because there could potentially
                            // be 10s of thousands of missing records - so just bail out and warn the user...
                            if (ux_checkboxWarnWhenLUTablesAreOutdated.Checked) partiallyLoadedTables++;
                        }
                        else
                        {
            //// If the attempted update fails for any reason - warn the user...
            //if (!_sharedUtils.LookupTablesUpdateTable(dr["dataview_name"].ToString()))
            //{
            //    if (ux_checkboxWarnWhenLUTablesAreOutdated.Checked) partiallyLoadedTables++;
            //}
                            // Thread the LU table update as a background task...
                            _sharedUtils.LookupTablesUpdateTable(dr["dataview_name"].ToString(), true);
                        }
                    }
                }
                if (partiallyLoadedTables > 0)
                {
            //if (DialogResult.Yes == MessageBox.Show(this, "There are " + partiallyLoadedTables.ToString() + " lookup tables with missing data.\nTo maximize performace of this application it is recommended that all lookup tables be downloaded.\n\nWould you like to do this now?", "Missing Lookup Table Data", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1))
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There are {0} lookup tables with missing data.\nTo maximize performace of this application it is recommended that all lookup tables be downloaded.\n\nWould you like to do this now?", "Missing Lookup Table Data", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "LookupTableStatusCheckMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, partiallyLoadedTables.ToString());
            if (DialogResult.Yes == ggMessageBox.ShowDialog(this))
                    {
                        LookupTableLoader ltl = new LookupTableLoader(localDBInstance, _sharedUtils);
            ltl.StartPosition = FormStartPosition.CenterParent;
                        ltl.Show();
                        ltl.Focus();
                    }
                }
            }
            catch
            {
            //MessageBox.Show("An error was encountered while performing the status check for lookup tables.  Stopping status check.", "Lookup Table Status Check Error");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("An error was encountered while performing the status check for lookup tables.  Stopping status check.", "Lookup Table Status Check Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "LookupTableStatusCheckMessage2";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog(this);
            }

            //// Close the splash page...
            //splash.Close();
        }
Пример #27
0
        private void CooperatorWizard_FormClosing(object sender, FormClosingEventArgs e)
        {
            // The user might be closing the form during the middle of edit changes in the datagridview - if so ask the
            // user if they would like to save their data...
            int intRowEdits = 0;

            _cooperatorBindingSource.EndEdit();
            if (_cooperator.GetChanges() != null) intRowEdits = _cooperator.GetChanges().Rows.Count;

            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have {0} unsaved row change(s), are you sure you want to cancel your edits and close this window?", "Cancel Edits and Close", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "CooperatorWizard_FormClosingMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, intRowEdits);
            string[] argsArray = new string[100];
            argsArray[0] = intRowEdits.ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            // Show the warning dialog message if there are unsaved edits...
            if (intRowEdits > 0 && DialogResult.No == ggMessageBox.ShowDialog())
            {
                e.Cancel = true;
            }
        }
Пример #28
0
        private int SyncSavedRecordsWithTreeViewAndDGV(DataTable savedRecords)
        {
            int errorCount = 0;
            TreeNode tempTreeNodeParent = new TreeNode();

            if (savedRecords != null && savedRecords.PrimaryKey.Length == 1)
            {
                // Make an empty copy of the user's item list...
            //DataTable newGETLISTSItems = userItemList.Clone();
                string pKeyCol = savedRecords.PrimaryKey[0].ColumnName.Trim().ToUpper();
                savedRecords.Columns[pKeyCol].ReadOnly = false;
                foreach (DataRow dr in savedRecords.Rows)
                {
                    DataRow originalRow = ((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).Rows.Find(dr["OriginalPrimaryKeyID"]);

                    switch (dr["SavedAction"].ToString())
                    {
                        case "Insert":
                            // "NewPrimaryKeyID"
                            if (dr["SavedStatus"].ToString() == "Success")
                            {
                                // Create a new new TreeNode...
                                TreeNode newNode = new TreeNode();

            string newPKeyValue = dr["NewPrimaryKeyID"].ToString();
                                string dataviewPKeyName = dr.Table.PrimaryKey[0].ColumnName.Trim();
                                string tablePKeyName = dr.Table.PrimaryKey[0].ExtendedProperties["table_field_name"].ToString().Trim();
                                string tableName = dr.Table.PrimaryKey[0].ExtendedProperties["table_name"].ToString().Trim();
                                string properties = dataviewPKeyName.Trim().ToUpper();
            //properties += ";:" + tablePKeyName + "=" + dr[dr.Table.PrimaryKey[0]].ToString();
            //properties += ";:" + tablePKeyName + "=" + newPKeyValue;
            properties += ";:" + tablePKeyName.Replace("_", "") + "=" + newPKeyValue;
            //properties += ";@" + tableName + "." + tablePKeyName + "=" + dr[dataviewPKeyName].ToString();
            properties += ";@" + tableName + "." + tablePKeyName + "=" + newPKeyValue;
                                newNode.Name = properties.Split(';')[1].Trim();
                                newNode.Text = newNode.Name;
                                newNode.Tag = properties;
                                newNode.ImageKey = "inactive_" + tablePKeyName.ToUpper();
                                newNode.SelectedImageKey = "active_" + tablePKeyName.ToUpper();

            //newNode.ToolTipText = "-1";
            newNode.ToolTipText = "";
            // Now check to see if virtual nodes are wanted for this new node...
            //if(_virtualNodeTypes.ContainsKey(drv["PROPERTIES"].ToString().Split(';')[0].Trim().ToUpper()))
            if (!string.IsNullOrEmpty(_sharedUtils.GetAppSettingValue(properties.Split(';')[0].Trim().ToUpper() + "_VIRTUAL_NODE_DATAVIEW")))
            {
            TreeNode dummyNode = new TreeNode();
            string virtualQuery = _sharedUtils.GetAppSettingValue(properties.Split(';')[0].Trim().ToUpper() + "_VIRTUAL_NODE_DATAVIEW") + ", ";
            virtualQuery += properties.Split(';')[1].Trim().ToLower();

            dummyNode.Text = "!!DUMMYNODE!!";
            dummyNode.Name = "!!DUMMYNODE!!"; ;
            dummyNode.Tag = virtualQuery;
            //dummyNode.ImageKey = "inactive_" + virtualQuery;
            //dummyNode.SelectedImageKey = "active_" + virtualQuery;
            newNode.Nodes.Add(dummyNode);
            }

                                // Add the node to the collection of nodes for new records...
                                tempTreeNodeParent.Nodes.Add(newNode);

            //// Create a new row for the user's item list...
            //dr[pKeyCol] = dr["NewPrimaryKeyID"];
            //if (((TreeView)ux_tabcontrolGroupListNavigator.SelectedTab.Controls[0]).SelectedNode != null)
            //{
            //    DataRow nItem = BuildUserItemListRow(dr, ((TreeView)ux_tabcontrolGroupListNavigator.SelectedTab.Controls[0]).SelectedNode);
            //    if (nItem != null) newGETLISTSItems.Rows.Add(nItem.ItemArray);
            //}
                                // Set the datagridview row's status for this new row to committed (and update the pkey with the int returned from the server DB)...
                                if (originalRow != null)
                                {
                                    bool origColumnReadOnlyValue = originalRow.Table.Columns[pKeyCol].ReadOnly;
                                    originalRow.Table.Columns[pKeyCol].ReadOnly = false;
                                    originalRow[pKeyCol] = dr["NewPrimaryKeyID"];
                                    originalRow.AcceptChanges();
                                    originalRow.Table.Columns[pKeyCol].ReadOnly = origColumnReadOnlyValue;
                                }
                            }
                            else
                            {
                                //MessageBox.Show(dr["ExceptionMessage"].ToString());
                                errorCount++;
                                if (originalRow != null) originalRow.RowError = "\t" + dr["ExceptionMessage"].ToString();
                            }
                            break;
                        case "Update":
                            if (dr["SavedStatus"].ToString() == "Success")
                            {
                                dr.ClearErrors();
                            }
                            else
                            {
                                //MessageBox.Show(dr["ExceptionMessage"].ToString());
                                errorCount++;
                                if (originalRow != null) originalRow.RowError = "\t" + dr["ExceptionMessage"].ToString();
                            }
                            break;
                        case "Delete":
                            if (dr["SavedStatus"].ToString() == "Success")
                            {
                                // Find the treeview nodes with this pkey and pkey_type...
                                foreach (TabPage tp in _ux_NavigatorTabControl.TabPages)
                                {
                                    foreach (Control ctrl in tp.Controls)
                                    {
                                        if (ctrl.GetType() == typeof(TreeView))
                                        {
                                            TreeView tv = (TreeView)ctrl;
                                            TreeNode[] deletedNodes = tv.Nodes.Find(":" + pKeyCol.Trim().ToLower().Replace("_", "") + "=" + dr[pKeyCol].ToString(), true);
                                            foreach (TreeNode tn in deletedNodes)
                                            {
                                                // Delete the entries in the users item list records...
            //DeleteTreeNodes(tv.Parent.Text, tn);
            // Add the app_user_item_list pkey(s) associated with this node to the collection of records
            // that should be deleted from the server when the CT exits...
            _deletedTreeNodes.AddRange(AddToDeletedTreeNodeList(tn));
            // Delete the node from the tree view...
            tn.Remove();
                                            }
                                        }
                                    }
                                }
                                // Set the row's status for this deleted row to committed...
                                if (originalRow != null)
                                {
                                    originalRow.AcceptChanges();
                                }
                            }
                            else
                            {
                                //MessageBox.Show(dr["ExceptionMessage"].ToString());
                                errorCount++;
                                // Find the deleted row (NOTE: datatable.rows.find() method does not work on deleted rows)...
                                foreach (DataRow deletedRow in ((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).Rows)
                                {
                                    if (deletedRow[0, DataRowVersion.Original].Equals(dr["OriginalPrimaryKeyID"]))
                                    {
                                        deletedRow.RejectChanges();
                                        deletedRow.RowError = "\t" + dr["ExceptionMessage"].ToString();
                                    }
                                }
                            }
                            break;
                        default:
                            break;
                    }
                }
            }

            // Ask the user if they would like to add the newly saved items to their treeview's selected node...
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have successfully added {0} new records to the database.\nWould you like links to these new records added to your current list folder?", "Add new item links", MessageBoxButtons.OKCancel, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SyncUserItemListMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, tempTreeNodeParent.Nodes.Count.ToString());
            if (tempTreeNodeParent.Nodes.Count > 0 &&
                DialogResult.OK == ggMessageBox.ShowDialog())
            {
                // Add the new nodes to the active node for the selected tab's treeview...
                foreach (Control ctrl in _ux_NavigatorTabControl.SelectedTab.Controls)
                {
                    if (ctrl.GetType() == typeof(TreeView))
                    {
                        TreeView tv = (TreeView)ctrl;
                        TreeNode parentFolder = null;

            // New method...
                        // Find a suitable folder to contain the new nodes...
                        if (tv != null && isFolder(tv.SelectedNode))
                        {
                            parentFolder = tv.SelectedNode;
                        }
                        else if (tv != null &&
                                tv.SelectedNode.Parent != null &&
                                isFolder(tv.SelectedNode.Parent))
                        {
                            parentFolder = tv.SelectedNode.Parent;
                        }
                        else if (tv != null &&
                                tv.SelectedNode.Parent != null &&
                                tv.SelectedNode.Parent.Parent != null)
                        {
                            parentFolder = tv.SelectedNode.Parent.Parent;
                        }

                        // Hopefully we have found a suitable folder to contain the new nodes
                        // and if so add them to that folder now and then refresh the folder's formatting...
                        if (parentFolder != null)
                        {
                            // Add the nodes to the folder...
                            foreach (TreeNode tnNewNode in tempTreeNodeParent.Nodes)
                            {
                                parentFolder.Nodes.Add(tnNewNode);
                            }
                            // Refresh the folder formatting to give the new nodes their proper titles...
                            RefreshTreeviewNodeFormatting(parentFolder);
                        }

            // Old method...
            //                        foreach (TreeNode tnNewNode in tempTreeNodeParent.Nodes)
            //                        {
            ////if (tv != null && tv.SelectedNode.Tag.ToString().ToUpper() == "FOLDER")
            //                            if (tv != null && isFolder(tv.SelectedNode))
            //                            {
            //                                tv.SelectedNode.Nodes.Add(tnNewNode);
            //                                // Give the new nodes their proper titles...
            //                                RefreshTreeviewNodeFormatting(tv.SelectedNode);
            //                            }
            //                            else if (tv.Parent != null &&
            //                                    tv.SelectedNode.Parent != null &&
            //                                    isFolder(tv.SelectedNode.Parent))
            ////tv.SelectedNode.Parent.Tag.ToString().ToUpper() == "FOLDER")
            //                            {
            //                                tv.SelectedNode.Parent.Nodes.Add(tnNewNode);
            //                                // Give the new nodes their proper titles...
            //                                RefreshTreeviewNodeFormatting(tv.SelectedNode.Parent);
            //                            }
            //                            else if (tv.Parent != null &&
            //                                    tv.SelectedNode.Parent != null &&
            //                                    tv.SelectedNode.Parent.Parent != null)
            //                            {
            //                                tv.SelectedNode.Parent.Parent.Nodes.Add(tnNewNode);
            //                                // Give the new nodes their proper titles...
            //                                RefreshTreeviewNodeFormatting(tv.SelectedNode.Parent.Parent);
            //                            }
            //                        }
                    }
                }
            }
            return errorCount;
        }
Пример #29
0
 private void ux_buttonSaveAndExit_Click(object sender, EventArgs e)
 {
     int errorCount = 0;
     errorCount = SaveCooperatorData();
     if (errorCount == 0)
     {
         //MessageBox.Show(this, "All data was saved successfully", "Accession Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxIcon.Information);
         GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("All data was saved successfully", "Cooperator Wizard Data Save Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
         ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage1";
         _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
         ggMessageBox.ShowDialog();
         this.Close();
     }
     else
     {
         GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The data being saved has errors that should be reviewed.\n\nWould you like to review them now?\n\nClick Yes to review the errors now.\n(Click No to abandon the errors and exit the Cooperator Wizard).\n\n  Error Count: {0}", "Cooperator Wizard Data Save Results", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
         ggMessageBox.Name = "CooperatorWizard_ux_buttonSaveMessage3";
         _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
     //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, errorCount);
     string[] argsArray = new string[100];
     argsArray[0] = errorCount.ToString();
     ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
         //if (DialogResult.No == MessageBox.Show(this, "The data being saved has errors that should be reviewed.\n\nWould you like to review them now?\n\nClick Yes to review the errors now.\n(Click No to abandon the errors and exit the Accession Wizard).\n\n  Error Count: " + errorCount, "Accession Wizard Data Save Results", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1))
         if (DialogResult.No == ggMessageBox.ShowDialog())
         {
             this.Close();
         }
         else
         {
             // Update the row error message for this cooperator row...
             //if (string.IsNullOrEmpty(((DataRowView)_cooperatorBindingSource.Current).Row.RowError))
             //{
             //    ux_textboxCooperatorRowError.Visible = false;
             //    ux_textboxCooperatorRowError.Text = "";
             //}
             //else
             //{
             //    ux_textboxCooperatorRowError.Visible = true;
             //    ux_textboxCooperatorRowError.ReadOnly = false;
             //    ux_textboxCooperatorRowError.Enabled = true;
             //    ux_textboxCooperatorRowError.Text = ((DataRowView)_cooperatorBindingSource.Current).Row.RowError;
             //}
         }
     }
     // Refresh the formatting of the cells in the DGV on the Cooperator tab page...
     RefreshDGVFormatting(ux_datagridviewCooperator);
 }
Пример #30
0
 void tsmiLanguage_Click(object sender, EventArgs e)
 {
     int newLangID = 1;
     ToolStripMenuItem tsmi = (ToolStripMenuItem) sender;
     if (int.TryParse(tsmi.Tag.ToString(), out newLangID))
     {
         _sharedUtils.ChangeLanguage(newLangID);
         languageCode = newLangID.ToString();
         _sharedUtils.UserLanguageCode = newLangID;
         _sharedUtils.UpdateComponents(this.components.Components, this.Name);
         _sharedUtils.UpdateControls(this.Controls, this.Name);
         // Save the statusbar text for the left, center, and right controls...
         ux_statusLeftMessage.Tag = ux_statusLeftMessage.Text;
         ux_statusCenterMessage.Tag = ux_statusCenterMessage.Text;
         ux_statusRightMessage.Tag = ux_statusRightMessage.Text;
         ux_statusRightMessage.Text = "";
         // Refresh the DGV data to get new column headings...
         ux_buttonRefreshData.PerformClick();
     // Warn the user that they should reload their LU tables...
     GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("You have successfully changed your language to {0}.\n\nWarning: Your lookup tables are language specific so you should reload them very soon.\n\nWould you like to do this now?", "Reload Lookup Tables", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
     ggMessageBox.Name = "tsmiLanguage1";
     _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
     if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, tsmi.Text);
     if (DialogResult.Yes == ggMessageBox.ShowDialog())
     {
     // Reload LU tables now...
     LookupTableLoader ltl = new LookupTableLoader(localDBInstance, _sharedUtils);
     ltl.StartPosition = FormStartPosition.CenterParent;
     ltl.Show();
     }
     }
 }
Пример #31
0
        private void LoadDBTables(string cooperatorID)
        {
            DataSet ds = new DataSet();

            // Get the sys_user table...
            ds = _sharedUtils.GetWebServiceData("get_sys_user", "", 0, 0);
            if (ds.Tables.Contains("get_sys_user"))
            {
                _sysUser = ds.Tables["get_sys_user"].Copy();
                // Build a display name for the cooperator_id...
                _sysUser.Columns.Add("cooperator_name", typeof(string));
                foreach (DataRow dr in _sysUser.Rows)
                {
                    dr["cooperator_name"] = _sharedUtils.GetLookupDisplayMember("cooperator_lookup", dr["cooperator_id"].ToString(), "", dr["cooperator_id"].ToString());
                }
                // Accept the changes to clean out all of the table modifications...
                _sysUser.AcceptChanges();
            }
            else
            {
            //MessageBox.Show("Error retrieving the get_sys_user dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "get_sys_user");
            string[] argsArray = new string[100];
            argsArray[0] = "get_sys_user";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

            // Get the sys_group_permission_map table...
            ds = _sharedUtils.GetWebServiceData("get_sys_group_permission_map", ":cooperatorid=" + cooperatorID, 0, 0);
            if (ds.Tables.Contains("get_sys_group_permission_map"))
            {
                _sysGroupPermissionMap = ds.Tables["get_sys_group_permission_map"].Copy();
            }
            else
            {
            //MessageBox.Show("Error retrieving the get_sys_group_permission_map dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "get_sys_group_permission_map");
            string[] argsArray = new string[100];
            argsArray[0] = "get_sys_group_permission_map";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

            // Get the sys_group_user_map table...
            ds = _sharedUtils.GetWebServiceData("get_sys_group_user_map", ":cooperatorid=" + cooperatorID, 0, 0);
            if (ds.Tables.Contains("get_sys_group_user_map"))
            {
                _sysGroupUserMap = ds.Tables["get_sys_group_user_map"].Copy();
            }
            else
            {
            //MessageBox.Show("Error retrieving the get_sys_group_user_map dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "get_sys_group_user_map");
            string[] argsArray = new string[100];
            argsArray[0] = "get_sys_group_user_map";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

            // Get the sys_permission_codes...
            _sysPermissionCode = _sharedUtils.GetLocalData("SELECT * FROM code_value_lookup WHERE group_name='sys_permission_code'", "");
            if (_sysPermissionCode == null)
            {
                _sysPermissionCode = new DataTable("sys_permission_code");
                _sysPermissionCode.Columns.Add("display_member", typeof(string));
                _sysPermissionCode.Columns.Add("value_member", typeof(string));
            }
            if (_sysPermissionCode.Rows.Count == 0)
            {
                DataRow newSysPermissionCodeRow = _sysPermissionCode.NewRow();
                newSysPermissionCodeRow["display_member"] = "Inherit";
                newSysPermissionCodeRow["value_member"] = "I";
                _sysPermissionCode.Rows.Add(newSysPermissionCodeRow);
                newSysPermissionCodeRow = _sysPermissionCode.NewRow();
                newSysPermissionCodeRow["display_member"] = "Deny";
                newSysPermissionCodeRow["value_member"] = "D";
                _sysPermissionCode.Rows.Add(newSysPermissionCodeRow);
                newSysPermissionCodeRow = _sysPermissionCode.NewRow();
                newSysPermissionCodeRow["display_member"] = "Allow";
                newSysPermissionCodeRow["value_member"] = "A";
                _sysPermissionCode.Rows.Add(newSysPermissionCodeRow);
            }
            // Wire up the permission comboboxes valid responses...
            ux_comboboxRead.DisplayMember = "display_member";
            ux_comboboxRead.ValueMember = "value_member";
            ux_comboboxRead.DataSource = _sysPermissionCode.Copy();
            ux_comboboxUpdate.DisplayMember = "display_member";
            ux_comboboxUpdate.ValueMember = "value_member";
            ux_comboboxUpdate.DataSource = _sysPermissionCode.Copy();
            ux_comboboxCreate.DisplayMember = "display_member";
            ux_comboboxCreate.ValueMember = "value_member";
            ux_comboboxCreate.DataSource = _sysPermissionCode.Copy();
            ux_comboboxDelete.DisplayMember = "display_member";
            ux_comboboxDelete.ValueMember = "value_member";
            ux_comboboxDelete.DataSource = _sysPermissionCode.Copy();

            // Get the sys_permission table...
            ds = _sharedUtils.GetWebServiceData("get_sys_permission", ":cooperatorid=" + cooperatorID, 0, 0);
            if (ds.Tables.Contains("get_sys_permission"))
            {
                _sysPermission = ds.Tables["get_sys_permission"].Copy();
            }
            else
            {
            //MessageBox.Show("Error retrieving the get_sys_permission dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "get_sys_permission");
            string[] argsArray = new string[100];
            argsArray[0] = "get_sys_permission";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

            // Get the sys_permission_field table...
            ds = _sharedUtils.GetWebServiceData("get_sys_permission_field", ":cooperatorid=" + cooperatorID, 0, 0);
            if (ds.Tables.Contains("get_sys_permission_field"))
            {
                _sysPermissionField = ds.Tables["get_sys_permission_field"].Copy();
            }
            else
            {
            //MessageBox.Show("Error retrieving the get_sys_permission_field dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "get_sys_permission_field");
            string[] argsArray = new string[100];
            argsArray[0] = "get_sys_permission_field";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

            // Get the sys_table_field_relationship table...
            ds = _sharedUtils.GetWebServiceData("sys_table_field_relationship", "", 0, 0);
            if (ds.Tables.Contains("sys_table_field_relationship"))
            {
                _sysTableFieldRelationship = ds.Tables["sys_table_field_relationship"].Copy();
                //_sysTableFieldRelationship.DefaultView.RowFilter = "(child_field_name='" + _pkeyColumnName + "' AND child_field_purpose='PRIMARY_KEY') OR parent_field_name='" + _pkeyColumnName + "'";
            }
            else
            {
            //MessageBox.Show("Error retrieving the sys_table_field_relationship dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "sys_table_field_relationship");
            string[] argsArray = new string[100];
            argsArray[0] = "sys_table_field_relationship";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

            // Get the 'owned_by' table_field_ID (using the table name and 'owned_by' field name in the table_field_relationship table)...
            DataRow[] drsSysTableFieldRelationship = _sysTableFieldRelationship.Select("child_table_name='" + _tableName + "' AND child_field_name='owned_by' AND child_field_purpose='AUTO_ASSIGN_OWN'");
            if (drsSysTableFieldRelationship.Length > 0)
            {
                // Populate the _ownedByColumnID variables...
                _ownedByColumnID = drsSysTableFieldRelationship[0]["child_table_field_id"].ToString();
            }

            // Get the table_ID and pkey table_field_ID (using the table name and field name in the table_field_relationship table)...
            drsSysTableFieldRelationship = _sysTableFieldRelationship.Select("child_table_name='" + _tableName + "' AND child_field_name='" + _pkeyColumnName + "' AND child_field_purpose='PRIMARY_KEY'");
            if (drsSysTableFieldRelationship.Length > 0)
            {
                // Populate the _tableID and pkeyColumnID variables...
                _tableID = drsSysTableFieldRelationship[0]["child_table_id"].ToString();
                _pkeyColumnID = drsSysTableFieldRelationship[0]["child_table_field_id"].ToString();
            }

            // Leave this table to last (so that it will filter the other lists properly when it gets populated - triggers a SelectedIndexChanged event)...
            // Get the sys_group table...
            ds = _sharedUtils.GetWebServiceData("get_sys_group", ":cooperatorid=" + cooperatorID, 0, 0);
            if (ds.Tables.Contains("get_sys_group"))
            {
                _sysGroup = ds.Tables["get_sys_group"].Copy();

                // Filter out all of the groups that do not contain a permission that uses the currentTableID...
                string validSysGroups = "null";
                if (_tableID != "-1" &&
                    _pkeyColumnID != "-1" &&
                    _ownedByColumnID != "-1")
                {
                    foreach (DataRow sysGroupRow in _sysGroup.Rows)
                    {
                        bool foundTableInGroupPolicy = false;
                        _sysGroupPermissionMap.DefaultView.RowFilter = "sys_group_id=" + sysGroupRow["sys_group_id"];
                        foreach (DataRowView sysGroupPermissionRow in _sysGroupPermissionMap.DefaultView)
                        {
                            DataRow sysPermissionRow = _sysPermission.Rows.Find(sysGroupPermissionRow["sys_permission_id"]);
                            if (sysPermissionRow != null &&
                                sysPermissionRow["sys_table_id"].ToString() == _tableID) foundTableInGroupPolicy = true;
                        }
                        // If this is a valid group - add it to the list...
                        if (foundTableInGroupPolicy) validSysGroups += "," + sysGroupRow["sys_group_id"].ToString();
                    }
                }
                _sysGroup.DefaultView.RowFilter = "sys_group_id IN (" + validSysGroups.TrimEnd(',') + ")";
            }
            else
            {
            //MessageBox.Show("Error retrieving the get_sys_group dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error retrieving the {0} dataview", "Security Wizard Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "SecurityWizard_LoadDBTablesMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, "get_sys_group");
            string[] argsArray = new string[100];
            argsArray[0] = "get_sys_group";
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }
Пример #32
0
        private void ux_comboboxActiveWebService_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Remember the URL that the user is currently using (in case we need to revert)...
            //string originalURL = GRINGlobalWebServices.Url;

            // Save the GUI settings for the user...
            SetAllUserSettings();
            //userSettings.Save();
            _sharedUtils.SaveAllUserSettings();

            // Now try to establish a new web service connection...
            try
            {
            //                GRINGlobalWebServices.Url = ux_comboboxActiveWebService.SelectedValue.ToString();
            //                string webserviceVersion = GRINGlobalWebServices.GetVersion();
            ////Login loginDialog = new Login(username, password, GUIWebServices.Url, null);
            //                Login loginDialog = new Login(GRINGlobalWebServices, GRINGlobalWebServices.Url, null);
            //                loginDialog.UserName = username;
            //                loginDialog.Password = password;
            //                loginDialog.StartPosition = FormStartPosition.CenterScreen;
            //                loginDialog.ShowDialog();
            SharedUtils tempSharedUtils = new SharedUtils(ux_comboboxActiveWebService.SelectedValue.ToString(), username, passwordClearText, true);

                //if (DialogResult.OK == loginDialog.DialogResult)
                if (tempSharedUtils.IsConnected)
                {
                    // Set the new global SharedUtils global variable to the newly created tempSharedUtils...
                    _sharedUtils = tempSharedUtils;
                    // Get the user login details for this user...
                    username = _sharedUtils.Username;
                    password = _sharedUtils.Password;
                    passwordClearText = _sharedUtils.Password_ClearText;
                    _usernameCooperatorID = _sharedUtils.UserCooperatorID;
                    _currentCooperatorID = _sharedUtils.UserCooperatorID;
                    site = _sharedUtils.UserSite;
                    languageCode = _sharedUtils.UserLanguageCode.ToString();
                    // Create new instance of shared utilities...
            //_sharedUtils = new SharedUtils(GRINGlobalWebServices.Url, username, password, localDBInstance, cno);

                    // Set the global variable for the localDBInstance...
                    //localDBInstance = GRINGlobalWebServices.Url.ToLower().Replace("http://", "").Replace("/gringlobal/gui.asmx", "").Replace('-', '_').Replace('.', '_').Replace(':', '_');
                    localDBInstance = _sharedUtils.Url.ToLower().Replace("http://", "").Replace("/gringlobal/gui.asmx", "").Replace('-', '_').Replace('.', '_').Replace(':', '_');
                    localDBInstance = "GRINGlobal_" + localDBInstance;
                    // Reload/rebuild the interface...
                    LoadApplicationData();
                    // Check the status of lookup tables and warn the user if some tables are missing data...
                    LookupTableStatusCheck();
                    // Indicate the web service connection...
                    ux_statusCenterMessage.Text = "Connected to: " + _sharedUtils.Url;
                }
                else
                {
            //MessageBox.Show("Unable to connect to " + ux_comboboxActiveWebService.Text + "\nAborting connection request.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Unable to connect to {0}\nAborting connection request.", "Connection Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ux_comboboxActiveWebServiceMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, ux_comboboxActiveWebService.Text);
            ggMessageBox.ShowDialog();
            ux_comboboxActiveWebService.SelectedValue = _sharedUtils.Url;
            //GRINGlobalWebServices.Url = originalURL;
                }
            }
            catch
            {
            //GRINGlobalWebServices.Url = originalURL;
            }
        }
Пример #33
0
        //        private void ux_datagridviewMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        //        {
        //            DataGridView dgv = (DataGridView)sender;
        //            System.Collections.Generic.Dictionary<string, string> lookupFilters = new System.Collections.Generic.Dictionary<string, string>();
        //            DataTable dt = (DataTable)((BindingSource)dgv.DataSource).DataSource;
        //            string columnName = dgv.CurrentCell.OwningColumn.Name;
        //            DataColumn dc = dt.Columns[columnName];
        //            if (dc.ExtendedProperties.Contains("gui_hint") && dc.ExtendedProperties["gui_hint"].ToString().ToUpper().Trim() == "LARGE_SINGLE_SELECT_CONTROL" &&
        //                dc.ExtendedProperties.Contains("foreign_key_field_name") && dc.ExtendedProperties["foreign_key_field_name"].ToString().Length > 0 &&
        //                dc.ExtendedProperties.Contains("foreign_key_resultset_name") && dc.ExtendedProperties["foreign_key_resultset_name"].ToString().Length > 0)
        //            {
        //                string luTableName = dc.ExtendedProperties["foreign_key_resultset_name"].ToString().Trim();
        //                    // Check to see if this is a hybrid combobox - if not start the lookup picker dialog...
        //                    if (e.Control.GetType() != typeof(DataGridViewComboBoxEditingControl))
        //                    {
        //                        //string dataSourceCellValue = "";
        //                        //System.Collections.Generic.List<object> pKeyVals = new System.Collections.Generic.List<object>();
        //                        DataRow dr;
        //                        //DataRowView drv = ((DataRowView)dgv.CurrentRow.DataBoundItem);
        //                        // Check to see if this is a DGV NewRow and if so, create a new row in the bound table (because
        //                        // the NewRow row in a DGV is not bound to anything...
        //                        if (dgv.CurrentRow.IsNewRow)
        //                        {
        ////int rowIndex = dgv.CurrentCell.RowIndex;
        ////int colIndex = dgv.CurrentCell.ColumnIndex;
        ////dgv.CancelEdit(); // This will take the NewRow's CurrentCell out of edit mode (otherwise two rows will be created)
        ////dr = ((DataTable)((BindingSource)dgv.DataSource).DataSource).NewRow();
        ////((DataTable)((BindingSource)dgv.DataSource).DataSource).Rows.Add(dr);
        ////dgv.CurrentCell = dgv[colIndex, rowIndex];
        //                            // The user is copying the values into the new row which doesn't have a datatable row yet - so create one using this HACK...
        //                            // BEGIN HACK...
        //                            int rowIndex = dgv.CurrentCell.RowIndex;
        //                            int colIndex = dgv.CurrentCell.ColumnIndex;
        //                            ux_datagridviewMain.AllowUserToAddRows = false;
        //                            ux_datagridviewMain.AllowUserToAddRows = true;
        //                            //dgv.CancelEdit();
        //                    dr = dt.NewRow();
        //                    dt.Rows.Add(dr);
        //                    //dt.Rows.Remove(dr);
        //                            dgv.CurrentCell = dgv[colIndex, rowIndex];
        //                            //ux_datagridviewMain.AllowUserToAddRows = true;
        //                            // END HACK...
        //                        }
        //                        else
        //                        {
        //                            //dr = ((DataTable)((BindingSource)dgv.DataSource).DataSource).NewRow();
        //                            dr = ((DataRowView)dgv.CurrentRow.DataBoundItem).Row;
        //                        }
        //                        // If the current row is bound to a data source (new rows may not be yet) get the suggested lookup value...
        //                        //if(dr != null) dataSourceCellValue = dr[dgv.CurrentCell.ColumnIndex].ToString();
        //                        //LookupTablePicker ltp = new LookupTablePicker(dataSourceCellValue, luTable, lookupFilters);
        //                        LookupTablePicker ltp = new LookupTablePicker(lookupTables, localDBInstance, columnName, dr, dgv.CurrentCell.EditedFormattedValue.ToString());
        //                        if (DialogResult.OK == ltp.ShowDialog())
        //                        {
        //                            dgv.CurrentCell.Value = ltp.NewValue.Trim();
        //                            if (dr != null)
        //                            {
        //                                if (ltp.NewKey != null && dr[dgv.CurrentCell.ColumnIndex].ToString().Trim() != ltp.NewKey.Trim())
        //                                {
        //                                    dr[dgv.CurrentCell.ColumnIndex] = ltp.NewKey.Trim();
        //                                }
        //                                else
        //                                {
        //                                    dr[dgv.CurrentCell.ColumnIndex] = DBNull.Value;
        //                                }
        //                            }
        //                        }
        //                        //dgv.EndEdit();
        //                    }
        //                    else // This is a hybrid combobox - attempt to refine the list to just choices associated with the current row...
        //                    {
        //                        string rowFilter = "";
        //                        foreach (string filterKey in lookupFilters.Keys)
        //                        {
        //                            if (!string.IsNullOrEmpty(lookupFilters[filterKey]))
        //                            {
        //                                rowFilter += filterKey + "=" + lookupFilters[filterKey] + " AND ";
        //                            }
        //                        }
        //                        if(!string.IsNullOrEmpty(rowFilter))rowFilter = rowFilter.Remove(rowFilter.LastIndexOf(" AND "));
        //                        DataGridViewComboBoxEditingControl editControl = (DataGridViewComboBoxEditingControl)e.Control;
        //                        DataTable editControlDataSource = (DataTable)((BindingSource)dgv.DataSource).DataSource;
        //                        editControlDataSource.DefaultView.RowFilter = rowFilter;
        //                        editControl.SelectedValue = dgv.CurrentCell.Value;
        //                    }
        //                //}
        //            }
        //        }
        void dataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;
            //string errorMessage = e.Exception.Message;
            //int columnWithError = -1;

            //// Find the cell the error belongs to (don't use e.ColumnIndex because it points to the current cell *NOT* the offending cell)...
            //foreach (DataGridViewColumn col in dgv.Columns)
            //{
            //    if (errorMessage.Contains(col.Name))
            //    {
            //        dgv[col.Name, e.RowIndex].ErrorText = errorMessage;
            //        columnWithError = col.Index;
            //    }
            //}
            // Display a warning message to the user that invalid data is entered for integer and datetime fields (but not FK lookups)...
            if ((dgv[e.ColumnIndex, e.RowIndex].ValueType == typeof(int) ||
                dgv[e.ColumnIndex, e.RowIndex].ValueType == typeof(DateTime)) &&
                !string.IsNullOrEmpty(dgv[e.ColumnIndex, e.RowIndex].OwningColumn.DataPropertyName))
            {
                // The code commented out below does not show properly because the edit control is overlaying the dgvc!!!
                //dgv[e.ColumnIndex, e.RowIndex].ErrorText = e.Exception.Message;
                //dgv.UpdateCellErrorText(e.ColumnIndex, e.RowIndex);
                //dgv.UpdateCellValue(e.ColumnIndex, e.RowIndex);
                // So we use this code instead...
            //MessageBox.Show(e.Exception.Message);
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox(e.Exception.Message, "Cancel Edits", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "dataGridView_DataErrorMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog();
            }
        }
Пример #34
0
 private void ux_menuitemHelpAbout_Click(object sender, EventArgs e)
 {
     //GGMessageBox.Show("Hello World", "Caption Text here...");
     GGMessageBox ggMessageBox = new GGMessageBox("GRIN-Global Curator Tool v{0}\n\n* * * * *\n\nThis software was created by USDA/ARS, with Bioversity International coordinating testing and feedback from the international genebank community.  Development was supported financially by USDA/ARS and by a major grant from the Global Crop Diversity Trust.  This statement by USDA does not imply approval of these enterprises to the exclusion of others which might also be suitable.\n\nUSDA grants to each Recipient of this software non-exclusive, royalty free, world-wide, permission to use, copy, modify, publish, distribute, perform publicly and display publicly this software.  Notice of this permission as well as the other paragraphs in this notice shall be included in all copies or modifications of this software.\n\nThis software application has not been tested or otherwise examined for suitability for implementation on, or compatibility with, any other computer systems.  USDA does not warrant, either explicitly or implicitly, that this software program will not cause damage to the user’s computer or computer operating system, nor does USDA warrant, either explicitly or implicitly, the effectiveness of the software application.\n\nThe English text above shall take precedence in the event of any inconsistencies between the English text and any translation of this notice.\n\n* * * * *", "GRIN-Global Curator Tool v{0}", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
     ggMessageBox.Name = "ux_menuitemHelpAboutMessageBox1";
     _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
     if (ggMessageBox.Caption.Contains("{0}")) ggMessageBox.Caption = string.Format(ggMessageBox.Caption, System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
     if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
     DialogResult returnJunk = ggMessageBox.ShowDialog();
 }
Пример #35
0
        private void ux_buttonSaveData_Click(object sender, EventArgs e)
        {
            DataSet modifiedRecords = new DataSet();
            DataSet errorRecords;
            int errorCount = 0;

            // Remember the changes the user has made to the DGV during edit mode...
            SetAllUserSettings();

            // Remember the state of the AllowUserToAddRows property...
            bool origAllowUsersToAddRows = ux_datagridviewMain.AllowUserToAddRows;
            // Remember the state of the hide non-error rows checkbox...
            bool hideNonErrorRows = ux_checkboxHideNonErrorRows.Checked;

            // Remove row filter for row errors...
            ux_checkboxHideNonErrorRows.Checked = false;

            foreach (DataRowView drv in ((BindingSource)ux_datagridviewMain.DataSource).List)
            {
                if (drv.IsEdit ||
                    drv.Row.RowState == DataRowState.Added ||
                    drv.Row.RowState == DataRowState.Deleted ||
                    drv.Row.RowState == DataRowState.Detached ||
                    drv.Row.RowState == DataRowState.Modified)
                {
                    drv.EndEdit();
                    drv.Row.ClearErrors();
                }
            }
            // Get just the rows that have changed and put them in to a new dataset...
            if (((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).GetChanges() != null)
            {
                modifiedRecords.Tables.Add(((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).GetChanges());
                ScrubData(modifiedRecords);
            }

            if (modifiedRecords.Tables.Contains(((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).TableName) &&
                modifiedRecords.Tables[((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).TableName].GetErrors().Length > 0)
            {
            //if (DialogResult.Yes == MessageBox.Show("The data being saved has errors that should be reviewed.\n\nWould you like to review them now?\n\nClick Yes to abort saving the data and review the errors now.\n(Click No to continue saving the data with errors).", "Data Errors Need Review", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)) return;
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("The data being saved has errors that should be reviewed.\n\nWould you like to review them now?\n\nClick Yes to abort saving the data and review the errors now.\n(Click No to continue saving the data with errors).", "Data Errors Need Review", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ux_buttonSaveDataMessage1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            if (DialogResult.Yes == ggMessageBox.ShowDialog()) return;
            }

            // Change cursor to the wait cursor...
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            // Temp. supress the AllowUserToAddRows property to allow processing of the save results...
            ux_datagridviewMain.AllowUserToAddRows = false;

            // If there are changes in this datagridview - save them now...
            if (modifiedRecords.Tables.Contains(((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).TableName))
            {
                // Save the data...
                errorRecords = SaveDGVData(modifiedRecords);

                // Update/refresh the treeview items with changes that were just saved...
                errorCount = SyncSavedRecordsWithTreeViewAndDGV(errorRecords.Tables[((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).TableName]);
            }

            if (errorCount == 0)
            {
                // Restore the grid view for handling row selections...
                ux_datagridviewMain.Enabled = true;
                ux_datagridviewMain.Focus();
                ux_datagridviewMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                ux_datagridviewMain.EditMode = DataGridViewEditMode.EditProgrammatically;
                ux_datagridviewMain.AllowUserToAddRows = false;
                ux_datagridviewMain.AllowUserToDeleteRows = false;
                ux_datagridviewMain.AllowDrop = false;

                // Update the controls on the interface...
                ux_groupboxEditMode.Visible = false;
                ux_checkboxHighlightChanges.Enabled = false;
                ux_checkboxHideNonErrorRows.Checked = false;
                ux_checkboxHideNonErrorRows.Enabled = false;
                ux_checkboxHideUnchangedRows.Checked = false;
                ux_checkboxHideUnchangedRows.Enabled = false;
                ux_buttonSaveData.Enabled = false;
                ux_buttonEditData.Enabled = true;
                ux_buttonCancelEditData.Enabled = false;
                ux_splitcontainerMain.Panel1.Enabled = true;
                ux_tabcontrolCTDataviews.Enabled = true;

                // Un-wire the event handler for formatting cells in edit mode (populating the FK lookup values)...
                ux_datagridviewMain.CellFormatting -= new DataGridViewCellFormattingEventHandler(ux_datagridviewMain_EditDGVCellFormatting);
                ux_datagridviewMain.CellParsing -= new DataGridViewCellParsingEventHandler(ux_datagridviewMain_EditDGVCellParsing);
            // Moved DataError event handler to down below to handle missing codes in edited rows during the RefreshMainDGVData() method call (this was done on 8/5/2014)...
            //ux_datagridviewMain.DataError -= new DataGridViewDataErrorEventHandler(dataGridView_DataError);

                // Wire up the event handler for formatting cells in readonly mode...
                ux_datagridviewMain.CellFormatting += new DataGridViewCellFormattingEventHandler(ux_datagridviewMain_ReadOnlyDGVCellFormatting);

                //// NOTE: removing the table forces RefreshMainDataViewer to retrieve the data from the DB...
                //if (((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).DataSet != null)
                //{
                //    ((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource).DataSet.Tables.Remove((DataTable)((BindingSource)ux_datagridviewMain.DataSource).DataSource);
                //}

                // Remember the first visible column to restore later...
                int firstVisibleColumn = ux_datagridviewMain.FirstDisplayedScrollingColumnIndex;

                // Now refresh the data and a new copy of the table should be retrieved...
                // Resetting these two global variables will force a refresh of the DGV data...
                lastFullPath = "";
                lastTabName = "";
                RefreshMainDGVData();
                // Is the next line needed anymore???
                RefreshMainDGVFormatting();

                // Restore the dataview left-most column (so that the user's perceived transition from edit to readonly is more seamless)...
                if (ux_datagridviewMain.Columns[firstVisibleColumn].Visible) ux_datagridviewMain.FirstDisplayedScrollingColumnIndex = firstVisibleColumn;

            // Moved the following code up above (before the refresh data and format calls)...
            //// Un-wire the event handler for populating the FK lookup values...
            //ux_datagridviewMain.CellFormatting -= new DataGridViewCellFormattingEventHandler(ux_datagridviewMain_CellFormatting);
            //ux_datagridviewMain.DataError -= new DataGridViewDataErrorEventHandler(dataGridView_DataError);

            // Moved DataError event handler to here to handle missing codes in edited rows during the RefreshMainDGVData() method call (this was done on 8/5/2014)...
            // Un-wire the event handler for processing data errors for cells in edit mode...
            ux_datagridviewMain.DataError -= new DataGridViewDataErrorEventHandler(dataGridView_DataError);

                // If a Form is being shown, disable its controls since we are done editing...
                if (dataviewForm != null)
                {
                    System.Reflection.PropertyInfo pi = dataviewForm.GetType().GetProperty("EditMode");
                    if (pi != null) pi.SetValue(dataviewForm, false, null);
                }
            }
            else
            {
                if (errorCount == 1)
                {
            //MessageBox.Show("There was an error encountered during the Save operation.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an error encountered during the Save operation.", "Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ux_buttonSaveDataMessage2";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            ggMessageBox.ShowDialog();
                }
                else
                {
            //MessageBox.Show("There were " + errorCount.ToString() + " errors encountered during the Save operation.");
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There were {0} errors encountered during the Save operation.", "Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "ux_buttonSaveDataMessage3";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, errorCount);
            string[] argsArray = new string[100];
            argsArray[0] = errorCount.ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
                }

                // Restore the state of the AllowUserToAddRows property...
                ux_datagridviewMain.AllowUserToAddRows = origAllowUsersToAddRows;
                // Restore row filter for row errors...
                ux_checkboxHideNonErrorRows.Checked = hideNonErrorRows;
                // If you are here there were errors in some of the changed rows so
                // update the datagridview with the results of the attempted save...
                RefreshMainDGVFormatting();
            }

            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
Пример #36
0
 private void ux_menuitemHelpMakeDBAccessible_Click(object sender, EventArgs e)
 {
     GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("This action will add all users on this computer to the local SQL Server database.\n\nDo you wish to continue with this action?", "Make Local Database Accessible", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1);
     ggMessageBox.Name = "ux_menuitemHelpMakeDBAccessibleMessageBox1";
     _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
     if (ggMessageBox.Caption.Contains("{0}")) ggMessageBox.Caption = string.Format(ggMessageBox.Caption, System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
     if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
     if (DialogResult.Yes == ggMessageBox.ShowDialog())
     {
         // Execute SQL to add the BUILTIN\Users account to the sysadmins role on the local database...
         // The SQL looks something like this: EXEC master..sp_addsrvrolemember @loginame = N'BUILTIN\Users', @rolename = N'sysadmin'
         if (_sharedUtils.LocalDatabaseMakeAccessibleToAllUsers())
         {
             ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Local SQL Server database is now accessible to all users of this computer.", "Make Local Database Accessible Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
             ggMessageBox.Name = "ux_menuitemHelpMakeDBAccessibleMessageBox2";
             _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
             if (ggMessageBox.Caption.Contains("{0}")) ggMessageBox.Caption = string.Format(ggMessageBox.Caption, System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
             ggMessageBox.ShowDialog();
         }
         else
         {
             ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Your attempt to make the local SQL Server database accessible to all users failed.\n\nNOTE: You must be an administrator on the local SQL Server database to perform this action.\n\nRefer to installation manual to perform this task manually if the problem persists.", "Make Local Database Accessible Results", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
             ggMessageBox.Name = "ux_menuitemHelpMakeDBAccessibleMessageBox3";
             _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
             if (ggMessageBox.Caption.Contains("{0}")) ggMessageBox.Caption = string.Format(ggMessageBox.Caption, System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString());
             ggMessageBox.ShowDialog();
         }
     }
 }