Exemplo n.º 1
0
        ///<summary>This method takes care of parsing the query by pulling out SET statements and finding the variables with their assigned values.
        ///Puts all of this information into the grid.</summary>
        private void FillGrid(bool isTypingText = false)
        {
            Point         selectedCell = gridMain.SelectedCell;
            List <string> listSetStmts = UserQueries.ParseSetStatements(_queryCur.QueryText);

            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "Variable"), 200));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(gridMain.TranslationName, "Value"), 200, true));
            gridMain.ListGridRows.Clear();
            foreach (string strSetStmt in listSetStmts)                                                //for each SET statement
            {
                List <QuerySetStmtObject> listQObjs = UserQueries.GetListQuerySetStmtObjs(strSetStmt); //find the variable name
                foreach (QuerySetStmtObject qObj in listQObjs)
                {
                    GridRow row = new GridRow();
                    row.Cells.Add(qObj.Variable);
                    row.Cells.Add(qObj.Value);
                    row.Tag = qObj;
                    gridMain.ListGridRows.Add(row);
                }
            }
            gridMain.EndUpdate();
            if (!isTypingText)
            {
                try {
                    gridMain.SetSelected(selectedCell);
                }
                catch {
                    //suppress if the row doesn't exist (such as filling the grid for the first time)
                }
            }
        }
Exemplo n.º 2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (UserQueryCur == null)
            {
                MsgBox.Show(this, "Please select an item first.");
                return;
            }
            ReportSimpleGrid report = new ReportSimpleGrid();

            if (UserQueryCur.IsPromptSetup && UserQueries.ParseSetStatements(UserQueryCur.QueryText).Count > 0)
            {
                //if the user is not a query admin, they will not have the ability to edit
                //the query before it is run, so show them the SET statement edit window.
                FormQueryParser FormQP = new FormQueryParser(UserQueryCur);
                FormQP.ShowDialog();
                if (FormQP.DialogResult == DialogResult.OK)
                {
                    report.Query = UserQueryCur.QueryText;
                    DialogResult = DialogResult.OK;
                }
            }
            else
            {
                //user has permission to edit the query, so just run the query.
                DialogResult = DialogResult.OK;
            }
        }