Exemple #1
0
        private void miEditQueryInfo_Click(object sender, EventArgs e)
        {
            TreeNode queryNode = tvQueries.SelectedNode;

            if (queryNode != null)
            {
                ConfigItems.NodeDescription nodeDescription = (ConfigItems.NodeDescription)queryNode.Tag;

                TreeNode folderNode = queryNode.Parent;

                FormQueryName frm = new FormQueryName(Utils.ConnectionId, tvQueries, folderNode);

                TDSQueriesTree.QueriesRow query = (TDSQueriesTree.QueriesRow)nodeDescription.NodeData;

                frm.QueryName = query.Name;

                frm.QueryDescription = query.Description;

                DialogResult result = frm.ShowDialog(this);

                if (result == DialogResult.OK)
                {
                    query.Name = frm.QueryName;

                    query.Description = frm.QueryDescription;

                    queryNode.ToolTipText = frm.QueryDescription;

                    tvQueries_AfterLabelEdit(this, new NodeLabelEditEventArgs(queryNode, query.Name));
                }
            }
        }
Exemple #2
0
        private void btnSaveQuery_Click(object sender, EventArgs e)
        {
            if (!IsConnectionAlive)
            {
                MessageBox.Show("The current query connection does not exist anymore! This tab should be closed", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                string queryName = String.Empty;
                string queryDescription = String.Empty;
                int folderID = -1;
                ConfigItems.TDSQueriesTree tree = ConfigItems.TDSQueriesTree.Instance();
                //update params collection with values from UI
                try
                {
                    //if search criteria was not opened, _ucAdvSearch.GetSearchCriteria will crash
                    //but saving must continue
                    if (!IsGeneralQuery)
                    {
                        _searchParams = _ucAdvSearch.GetSearchCriteria();

                    }

                }catch{}

                //if (_queryNodeKey == null)
                if (Int32.Parse(_queryNodeKey.Split(' ')[1])<0)
                {
                    #region show dialog for choosing a query name
                    FormQueryName frm = new FormQueryName(_connectionId, _tree, null);

                    DialogResult result = frm.ShowDialog(this);

                    //check respose of the user from the dialog form
                    switch (result)
                    {
                        case DialogResult.OK:
                            queryName = frm.QueryName;
                            folderID = frm.FolderId;
                            queryDescription = frm.QueryDescription;

                            int bugsCount = -1;
                            if (_bugs != null)
                                bugsCount = _bugs.Count;

                            ConfigItems.TDSQueriesTree.QueriesRow query = tree.AddNewQuery(queryName, queryDescription, folderID, (int)QueryType.UserCustom, bugsCount, _searchParams);

                            tree.AddQueryToTree(_tree, query);

                            QueryNameChanged(this, new OnQueryNameChangedEventArgs(query.ID, query.Name, frm.FolderName));

                            _queryNodeKey = "query " + query.ID.ToString();
                            break;

                    }
                    #endregion
                }
                else {
                    TreeNode[] nodes = _tree.Nodes.Find(_queryNodeKey, true);
                    if (nodes.GetLength(0) == 1) {
                        ConfigItems.NodeDescription nodeDescr = (ConfigItems.NodeDescription)nodes[0].Tag;
                        ConfigItems.TDSQueriesTree.QueriesRow query = (ConfigItems.TDSQueriesTree.QueriesRow)nodeDescr.NodeData;
                        if (!tree.UpdateQuery(query.ID, _searchParams))
                            MessageBox.Show("Updating query failed!");
                        else {
                            MessageBox.Show(String.Format(Properties.Messages.QuerySuccessfulSaved, query.Name), "Query saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }