///<summary>Submits the Query to the database and fills ReportTable with the results. Returns false if the user clicks Cancel on the Parameters dialog.</summary> public bool SubmitQuery() { string outputQuery = Query; if (parameterFields.Count > 0) //djc only display parameter dialog if parameters were specified //display a dialog for user to enter parameters { FormParameterInput FormPI = new FormParameterInput(); for (int i = 0; i < parameterFields.Count; i++) { FormPI.AddInputItem(parameterFields[i].PromptingText, parameterFields[i].ValueType , parameterFields[i].DefaultValues, parameterFields[i].EnumerationType , parameterFields[i].DefCategory, parameterFields[i].FKeyType); } FormPI.ShowDialog(); if (FormPI.DialogResult != DialogResult.OK) { return(false); } for (int i = 0; i < parameterFields.Count; i++) { parameterFields[i].CurrentValues = FormPI.GetCurrentValues(i); parameterFields[i].ApplyParamValues(); } //the outputQuery will get altered without affecting the original Query. string replacement = ""; //the replacement value to put into the outputQuery for each match //first replace all parameters with values: MatchCollection mc; Regex regex = new Regex(@"\?\w+"); //? followed by one or more text characters mc = regex.Matches(outputQuery); //loop through each occurance of "?etc" for (int i = 0; i < mc.Count; i++) { replacement = parameterFields[mc[i].Value.Substring(1)].OutputValue; regex = new Regex(@"\" + mc[i].Value); outputQuery = regex.Replace(outputQuery, replacement); } //then, submit the query } //MessageBox.Show(outputQuery); reportTable = Reports.GetTable(outputQuery); //ODReportData.SubmitQuery(outputQuery); return(true); }
///<summary>Submits the Query to the database and fills ReportTable with the results. Returns false if the user clicks Cancel on the Parameters dialog.</summary> public bool SubmitQuery() { string outputQuery=Query; if(parameterFields.Count>0){//djc only display parameter dialog if parameters were specified //display a dialog for user to enter parameters FormParameterInput FormPI=new FormParameterInput(); for(int i=0;i<parameterFields.Count;i++){ FormPI.AddInputItem(parameterFields[i].PromptingText,parameterFields[i].ValueType ,parameterFields[i].DefaultValues,parameterFields[i].EnumerationType ,parameterFields[i].DefCategory,parameterFields[i].FKeyType); } FormPI.ShowDialog(); if(FormPI.DialogResult!=DialogResult.OK){ return false; } for(int i=0;i<parameterFields.Count;i++){ parameterFields[i].CurrentValues=FormPI.GetCurrentValues(i); parameterFields[i].ApplyParamValues(); } //the outputQuery will get altered without affecting the original Query. string replacement="";//the replacement value to put into the outputQuery for each match //first replace all parameters with values: MatchCollection mc; Regex regex=new Regex(@"\?\w+");//? followed by one or more text characters mc=regex.Matches(outputQuery); //loop through each occurance of "?etc" for(int i=0;i<mc.Count;i++){ replacement=parameterFields[mc[i].Value.Substring(1)].OutputValue; regex=new Regex(@"\"+mc[i].Value); outputQuery=regex.Replace(outputQuery,replacement); } //then, submit the query } //MessageBox.Show(outputQuery); reportTable=Reports.GetTable(outputQuery); //ODReportData.SubmitQuery(outputQuery); return true; }