Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!NamingGuidance.CheckNameFocus(tbName, "Query Name", true))
            {
                return;
            }

            // Check length of queryname
            if (MaxQueryNameLength > 0 &&
                tbName.Text.Trim().Length > MaxQueryNameLength)
            {
                MessageBox.Show("The Query Name is too long, it can be maximum " + MaxQueryNameLength.ToString() + " characters.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Find the parameters that is nonunique
            if (outParameterNames.Count > 0)
            {
                IList <string> list = outParameterNames.Values.GroupBy(s => s).Where(g => g.Count() > 1).Select(g => g.Key).ToList();

                if (list.Count > 0)
                {
                    // Make a nice comma separated list!
                    string listNames = list.Aggregate((current, next) => current + ", " + next);

                    if (list.Count > 1)
                    {
                        MessageBox.Show("The parameters with the names " + listNames + " must be renamed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("The parameters with the name " + listNames + " must be renamed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    return;
                }
            }

            ReportQuery parentReportQuery;
            string      errorText;

            if (!ReportHelper.CheckReportParameterCombinations(ExistingSources, rtSQL.Text, out errorText, out parentReportQuery))
            {
                MessageBox.Show(errorText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ParentReportQuery = parentReportQuery;

            CurrentQuery.Name = tbName.Text.Trim();

            DialogResult = DialogResult.OK;
        }