Example #1
0
        private void btnSaveQuery_Click(object sender, EventArgs e)
        {
            string queryName        = String.Empty;
            string queryDescription = String.Empty;

            ConfigItems.TDSQueriesTree.QueriesRow query;
            ConfigItems.QueriesTree queriesTree = ConfigItems.QueriesTree.Instance();
            int folderID = -1;

            _searchParam = Utils.GetSearchCriteriaFromUI(this);

            if (this.Tag != null)
            {
                ConfigItems.NodeDescription nodeDescription = (ConfigItems.NodeDescription) this.Tag;
                query = (ConfigItems.TDSQueriesTree.QueriesRow)nodeDescription.NodeData;
                queriesTree.AddParameterValuesForQuery(query, _searchParam);
            }
            else
            {
                #region show dialog for choosing a query name
                FormQueryName frm = new FormQueryName(_userID, _tree);

                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;

                    query = queriesTree.AddNewQuery(queryName, queryDescription, folderID, (int)QueryTypes.UserCustom, _searchParam);
                    queriesTree.AddQueryToTree(_tree, query);

                    _tabCtrl.SelectedTab.Name = query.ID.ToString();
                    _tabCtrl.SelectedTab.Text = query.Name;
                    this.Tag = new ConfigItems.NodeDescription(NodeType.Query, query);
                    break;
                }
                #endregion
            }
        }
Example #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.QueriesTree tree = ConfigItems.QueriesTree.Instance();
                //update params collection with values from UI
                try
                {
                    //if search criteria was not opened, _ucAdvSearch.GetSearchCriteria will crash
                    //but saving must continue
                    _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);

                    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)QueryTypes.UserCustom, bugsCount, _searchParams);

                            tree.AddQueryToTree(_tree, query);

                            QueryNameChanged(this, new OnQueryNameChangedArgs(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.QueriesTree.QueriesRow query = (ConfigItems.QueriesTree.QueriesRow)nodeDescr.NodeData;
                        if (!tree.UpdateQuery(query.ID, _searchParams))
                            MessageBox.Show("Updating query failed!");
                        else {
                            MessageBox.Show(String.Format(Properties.Messages.QuerySuccesfullySaved, query.Name), "Query saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
        }
        private void btnSaveQuery_Click(object sender, EventArgs e)
        {
            string queryName = String.Empty;
            string queryDescription = String.Empty;
            ConfigItems.TDSQueriesTree.QueriesRow query;
            ConfigItems.QueriesTree queriesTree = ConfigItems.QueriesTree.Instance();
            int folderID = -1;

            _searchParam = Utils.GetSearchCriteriaFromUI(this);

            if (this.Tag!=null)
            {
                ConfigItems.NodeDescription nodeDescription = (ConfigItems.NodeDescription)this.Tag;
                query = (ConfigItems.TDSQueriesTree.QueriesRow)nodeDescription.NodeData;
                queriesTree.AddParameterValuesForQuery(query, _searchParam);
            }
            else
            {
                #region show dialog for choosing a query name
                FormQueryName frm = new FormQueryName(_userID, _tree);

                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;

                        query = queriesTree.AddNewQuery(queryName, queryDescription, folderID, (int)QueryTypes.UserCustom, _searchParam);
                        queriesTree.AddQueryToTree(_tree, query);

                        _tabCtrl.SelectedTab.Name = query.ID.ToString();
                        _tabCtrl.SelectedTab.Text = query.Name;
                        this.Tag = new ConfigItems.NodeDescription(NodeType.Query, query);
                        break;
                }
                #endregion

            }
        }