Exemplo n.º 1
0
 //当按下Query按钮之后执行的事件
 protected void OnAfterQuery(AfterQueryEventArgs value)
 {
     AfterQueryEventHandler handler = (AfterQueryEventHandler)base.Events[EventOnAfterQuery];
     if (handler != null)
     {
         handler(this, value);
     }
 }
Exemplo n.º 2
0
 void faq_AfterQuery(object sender, AfterQueryEventArgs e)
 {
     OnAfterQuery(e);
 }
Exemplo n.º 3
0
        private void buttonQuery_Click(object sender, EventArgs e)
        {
            InfoDataSet ids = innerAnyQuery.BindingSource.DataSource as InfoDataSet;
            if (ids != null)
            {
                List<String> detailWhere = new List<string>();

                String whereString = String.Empty;
                String[] remotename = (innerAnyQuery.BindingSource.DataSource as InfoDataSet).RemoteName.Split('.');
                String strModuleName = remotename[0];
                String strTableName = remotename[1];
                String tablename = CliUtils.GetTableName(strModuleName, strTableName, CliUtils.fCurrentProject);
                String detailtablename = String.Empty;
                String strDetailTableName = String.Empty;
                if (innerAnyQuery.DetailBindingSource != null)
                {
                    DataView dataView = innerAnyQuery.DetailBindingSource.List as DataView;
                    if (dataView != null)
                    {
                        strDetailTableName = dataView.Table.TableName;
                    }
                    else
                    {
                        int iRelationPos = -1;
                        DataSet dSet = ((InfoDataSet)innerAnyQuery.DetailBindingSource.GetDataSource()).RealDataSet;
                        for (int i = 0; i < dSet.Relations.Count; i++)
                        {
                            if (innerAnyQuery.DetailBindingSource.DataMember == dSet.Relations[i].RelationName)
                            {
                                iRelationPos = i;
                                break;
                            }
                        }
                        if (iRelationPos != -1)
                        {
                            strDetailTableName = dSet.Relations[iRelationPos].ChildTable.TableName;
                        }
                    }
                    detailtablename = CliUtils.GetTableName(strModuleName, strDetailTableName, CliUtils.fCurrentProject);
                    //if (!detailtablename.Contains("[") && !detailtablename.Contains("}"))
                    //{
                    //    detailtablename = String.Format("[{0}]", detailtablename);
                    //}
                }

                String[] quote = CliUtils.GetDataBaseQuote();
                for (int i = 1; i <= Count; i++)
                {
                    String strWhere = String.Empty;
                    foreach (DataColumn dc in ids.RealDataSet.Tables[0].Columns)
                    {
                        String caption = String.Empty;
                        String columnName = String.Empty;
                        String operatorMask = String.Empty;
                        String value1 = String.Empty;
                        String value2 = String.Empty;
                        Type valueType = null;
                        String condition = String.Empty;
                        object realValue1 = null;
                        object realValue2 = null;
                        bool DateConver = false;

                        CheckBox cbActive = this.panel2.Controls[i + "AnyQueryActiveCheckBox"] as CheckBox;
                        if (!cbActive.Checked) break;

                        ComboBox cbColumn = this.panel2.Controls[i + "AnyQueryColumnComboBox"] as ComboBox;
                        caption = cbColumn.Text;
                        columnName = cbColumn.SelectedValue.ToString();
                        if (columnName != CliUtils.GetTableNameForColumn(masterSql, dc.ColumnName)) continue;

                        valueType = dc.DataType;
                        bool isNvarChar = false;
                        foreach (AnyQueryColumns aqc in innerAnyQuery.Columns)
                        {
                            if (aqc.Column == dc.ColumnName)
                            {
                                isNvarChar = aqc.IsNvarChar;
                                break;
                            }
                        }
                        String nvarCharMark = valueType == typeof(string) && isNvarChar ? "N" : string.Empty;

                        Control[] tempCondition = this.Controls.Find(this.cbCondition.Name, true);
                        condition = tempCondition[0].Text;

                        ComboBox cbOperator = this.panel2.Controls[i + "AnyQueryOperatorComboBox"] as ComboBox;
                        operatorMask = cbOperator.Text;

                        DateConver = GetDataConver(dc.ColumnName);
                        foreach (Control c in this.panel2.Controls)
                        {
                            if (c.Name.StartsWith(i + "AnyQueryValue1"))
                            {
                                if (c.Name.StartsWith(i + "AnyQueryValue1CheckBox"))
                                {
                                    if (valueType == typeof(bool))
                                    {
                                        if ((c as CheckBox).Checked)
                                            value1 = "1";
                                        else
                                            value1 = "0";
                                    }
                                    else
                                    {
                                        if ((c as CheckBox).Checked)
                                            value1 = "'Y'";
                                        else
                                            value1 = "'N'";
                                    }
                                }
                                else if (c.Name.StartsWith(i + "AnyQueryValue1RefTextBox"))
                                {
                                    if (operatorMask == "IN" || operatorMask == "NOT IN")
                                    {
                                        String[] temp = (c as InfoRefbuttonBox).RealValue.Split(',');
                                        for (int j = 0; j < temp.Length; j++)
                                        {
                                            if (temp[j] != String.Empty)
                                            {
                                                temp[j] = IsLike(operatorMask, temp[j]);
                                                value1 += Mark(valueType, dc.ColumnName, operatorMask, temp[j], DateConver, nvarCharMark) + ",";
                                            }
                                        }
                                        if (value1.EndsWith(","))
                                        {
                                            value1 = value1.Remove(value1.LastIndexOf(","));
                                        }
                                    }
                                    else
                                    {
                                        value1 = (c as InfoRefbuttonBox).RealValue;
                                        value1 = Mark(valueType, dc.ColumnName, operatorMask, value1, DateConver, nvarCharMark);
                                        realValue1 = (c as InfoRefbuttonBox).RealValue;
                                    }
                                }
                                else if (c.Name.StartsWith(i + "AnyQueryValue1InfoRefvalBox"))
                                {
                                    if (operatorMask == "IN" || operatorMask == "NOT IN")
                                    {
                                        String[] temp = (c as InfoRefvalBox).TextBoxSelectedValue.Split(',');
                                        for (int j = 0; j < temp.Length; j++)
                                        {
                                            if (temp[j] != String.Empty)
                                            {
                                                temp[j] = IsLike(operatorMask, temp[j]);
                                                value1 += Mark(valueType, dc.ColumnName, operatorMask, temp[j], DateConver, nvarCharMark) + ",";
                                            }
                                        }
                                        if (value1.EndsWith(","))
                                        {
                                            value1 = value1.Remove(value1.LastIndexOf(","));
                                        }

                                        realValue1 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                    }
                                    else
                                    {
                                        value1 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                        value1 = Mark(valueType, dc.ColumnName, operatorMask, value1, DateConver, nvarCharMark);
                                        realValue1 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                    }
                                }
                                else if (c.Name.StartsWith(i + "AnyQueryValue1InfoDateTimePicker"))
                                {
                                    if ((c as InfoDateTimePicker).Checked)
                                    {
                                        value1 = (c as InfoDateTimePicker).Value.ToString("yyyy/MM/dd");
                                        value1 = Mark(valueType, columnName, operatorMask, value1, DateConver, nvarCharMark);
                                        realValue1 = Convert.ToDateTime((c as InfoDateTimePicker).Value);
                                    }
                                }
                                else if (c.Name.StartsWith(i + "AnyQueryValue1InfoComboBox"))
                                {
                                    if ((c as InfoComboBox).SelectedValue != null)
                                    {
                                        value1 = IsLike(operatorMask, (c as InfoComboBox).SelectedValue.ToString());
                                        realValue1 = (c as InfoComboBox).SelectedValue.ToString();
                                    }
                                    else
                                    {
                                        value1 = IsLike(operatorMask, (c as InfoComboBox).Text);
                                        realValue1 = (c as InfoComboBox).Text;
                                    }
                                    value1 = Mark(valueType, dc.ColumnName, operatorMask, value1, DateConver, nvarCharMark);
                                }
                                else
                                {
                                    if (operatorMask == "IN" || operatorMask == "NOT IN")
                                    {
                                        String[] temp = c.Text.Split(',');
                                        for (int j = 0; j < temp.Length; j++)
                                        {
                                            if (temp[j] != String.Empty)
                                            {
                                                temp[j] = IsLike(operatorMask, temp[j]);
                                                value1 += Mark(valueType, dc.ColumnName, operatorMask, temp[j], DateConver, nvarCharMark) + ",";
                                            }
                                        }
                                        if (value1.EndsWith(","))
                                        {
                                            value1 = value1.Remove(value1.LastIndexOf(","));
                                        }
                                        realValue1 = c.Text;
                                    }
                                    else
                                    {
                                        value1 = IsLike(operatorMask, c.Text);
                                        value1 = Mark(valueType, dc.ColumnName, operatorMask, value1, DateConver, nvarCharMark);
                                        realValue1 = c.Text;
                                    }
                                }
                                break;
                            }
                        }

                        if (value1 == String.Empty)
                        {
                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueNull");
                            MessageBox.Show(String.Format(message, caption));
                            this.DialogResult = System.Windows.Forms.DialogResult.None;
                            return;
                        }

                        if (operatorMask == "IN" || operatorMask == "NOT IN")
                            value1 = String.Format("({0})", value1);

                        if (operatorMask == "<->" || operatorMask == "!<->")
                        {
                            foreach (Control c in this.panel2.Controls)
                            {
                                if (c.Name.StartsWith(i + "AnyQueryValue2InfoRefvalBox"))
                                {
                                    value2 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                    value2 = Mark(valueType, dc.ColumnName, operatorMask, value2, DateConver, nvarCharMark);
                                    realValue2 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                    break;
                                }
                                else if (c.Name.StartsWith(i + "AnyQueryValue2InfoDateTimePicker"))
                                {
                                    if ((c as InfoDateTimePicker).Checked)
                                    {
                                        value2 = (c as InfoDateTimePicker).Value.ToString("yyyy/MM/dd");
                                        value2 = Mark(valueType, columnName, operatorMask, value2, DateConver, nvarCharMark);
                                        realValue2 = Convert.ToDateTime((c as InfoDateTimePicker).Value);

                                        //value2 = (c as InfoDateTimePicker).Value.AddDays(1).AddSeconds(-1).ToString();
                                        //realValue2 = Convert.ToDateTime((c as InfoDateTimePicker).Value.AddDays(1).AddSeconds(-1));
                                        break;
                                    }
                                }
                                else if (c.Name.StartsWith(i + "AnyQueryValue2"))
                                {
                                    value2 = c.Text;
                                    value2 = Mark(valueType, dc.ColumnName, operatorMask, value2, DateConver, nvarCharMark);
                                    realValue2 = c.Text;
                                    break;
                                }
                            }
                        }

                        if (String.IsNullOrEmpty(value2))
                        {
                            value2 = value1;
                            realValue2 = realValue1;
                        }

                        if (caption != String.Empty)
                        {
                            if (dc.DataType != typeof(DateTime) || !DateConver)
                            {
                                if (operatorMask == "<->")
                                {
                                    if (realValue2 != null)
                                    {
                                        bool flag = false;
                                        if (realValue2 is DateTime && ((DateTime)realValue2).Date < ((DateTime)realValue1).Date)
                                            flag = true;
                                        else if (realValue2 is Int32 && Convert.ToInt32(realValue2) < Convert.ToInt32(realValue1))
                                            flag = true;

                                        if (flag)
                                        {
                                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueOverFlow");
                                            MessageBox.Show(message);
                                            this.DialogResult = System.Windows.Forms.DialogResult.None;
                                            return;
                                        }
                                    }
                                    strWhere = columnName + ">=" + value1 + " AND " + columnName + "<=" + value2;
                                }
                                else if (operatorMask == "!<->")
                                {
                                    if (realValue2 != null)
                                    {
                                        bool flag = false;
                                        if (realValue2 is DateTime && ((DateTime)realValue2).Date < ((DateTime)realValue1).Date)
                                            flag = true;
                                        else if (realValue2 is Int32 && Convert.ToInt32(realValue2) < Convert.ToInt32(realValue1))
                                            flag = true;

                                        if (flag)
                                        {
                                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueOverFlow");
                                            MessageBox.Show(message);
                                            this.DialogResult = System.Windows.Forms.DialogResult.None;
                                            return;
                                        }
                                    }
                                    strWhere = columnName + "<" + value1 + " OR " + columnName + ">" + value2;
                                }
                                else if (operatorMask == "%**" || operatorMask == "**%" || operatorMask == "%%")
                                    strWhere = columnName + " like " + value1;
                                else if (operatorMask == "!%%")
                                    strWhere = columnName + " not like " + value1;
                                else
                                    strWhere = columnName + " " + operatorMask + " " + value1;
                            }
                            else
                            {
                                if (operatorMask == "<->")
                                {
                                    if (realValue2 != null)
                                    {
                                        bool flag = false;
                                        if (realValue2 is DateTime)
                                        {
                                            if (((DateTime)realValue2).Date < ((DateTime)realValue1).Date)
                                                flag = true;
                                        }
                                        else if (Convert.ToInt32(realValue2) < Convert.ToInt32(realValue1))
                                            flag = true;

                                        if (flag)
                                        {
                                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueOverFlow");
                                            MessageBox.Show(message);
                                            this.DialogResult = System.Windows.Forms.DialogResult.None;
                                            return;
                                        }
                                    }
                                    strWhere = value1.Replace("<->", ">=") + " AND " + value2.Replace("<->", "<=");
                                }
                                else if (operatorMask == "!<->")
                                {
                                    if (realValue2 != null)
                                    {
                                        bool flag = false;
                                        if (realValue2 is DateTime)
                                        {
                                            if (((DateTime)realValue2).Date < ((DateTime)realValue1).Date)
                                                flag = true;
                                        }
                                        else if (Convert.ToInt32(realValue2) < Convert.ToInt32(realValue1))
                                            flag = true;

                                        if (flag)
                                        {
                                            string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueOverFlow");
                                            MessageBox.Show(message);
                                            this.DialogResult = System.Windows.Forms.DialogResult.None;
                                            return;
                                        }
                                    }
                                    strWhere = value1.Replace("<->", "<") + " OR " + value2.Replace("<->", ">");
                                }
                                else
                                    strWhere = value1;
                            }

                            strWhere = String.Format("({0})", strWhere);
                            whereString += strWhere + " " + condition + " ";
                            break;
                        }
                    }

                    if (strDetailTableName != String.Empty && ids.RealDataSet.Tables[strDetailTableName] != null)
                    {
                        foreach (DataColumn dc in ids.RealDataSet.Tables[strDetailTableName].Columns)
                        {
                            String caption = String.Empty;
                            String columnName = String.Empty;
                            String operatorMask = String.Empty;
                            String value1 = String.Empty;
                            String value2 = String.Empty;
                            Type valueType = null;
                            String condition = String.Empty;
                            object realValue1 = null;
                            object realValue2 = null;
                            bool DateConver = false;

                            CheckBox cbActive = this.panel2.Controls[i + "AnyQueryActiveCheckBox"] as CheckBox;
                            if (!cbActive.Checked) break;

                            ComboBox cbColumn = this.panel2.Controls[i + "AnyQueryColumnComboBox"] as ComboBox;
                            caption = cbColumn.Text;
                            columnName = cbColumn.SelectedValue.ToString();
                            if (detailSql == String.Empty) continue;
                            if (columnName != CliUtils.GetTableNameForColumn(detailSql, dc.ColumnName)) continue;

                            valueType = dc.DataType;
                            bool isNvarChar = false;
                            foreach (AnyQueryColumns aqc in innerAnyQuery.Columns)
                            {
                                if (aqc.Column == dc.ColumnName)
                                {
                                    isNvarChar = aqc.IsNvarChar;
                                    break;
                                }
                            }
                            String nvarCharMark = valueType == typeof(string) && isNvarChar ? "N" : string.Empty;

                            Control[] tempCondition = this.Controls.Find(this.cbCondition.Name, true);
                            condition = tempCondition[0].Text;

                            ComboBox cbOperator = this.panel2.Controls[i + "AnyQueryOperatorComboBox"] as ComboBox;
                            operatorMask = cbOperator.Text;
                            DateConver = GetDataConver(dc.ColumnName);
                            foreach (Control c in this.panel2.Controls)
                            {
                                if (c.Name.StartsWith(i + "AnyQueryValue1"))
                                {
                                    if (c.Name.StartsWith(i + "AnyQueryValue1CheckBox"))
                                    {
                                        if (valueType == typeof(bool))
                                        {
                                            if ((c as CheckBox).Checked)
                                                value1 = "1";
                                            else
                                                value1 = "0";
                                        }
                                        else
                                        {
                                            if ((c as CheckBox).Checked)
                                                value1 = "'Y'";
                                            else
                                                value1 = "'N'";
                                        }
                                    }
                                    else if (c.Name.StartsWith(i + "AnyQueryValue1RefTextBox"))
                                    {
                                        String[] temp = (c as InfoRefbuttonBox).RealValue.Split(',');
                                        for (int j = 0; j < temp.Length; j++)
                                        {
                                            if (temp[j] != String.Empty)
                                            {
                                                temp[j] = IsLike(operatorMask, temp[j]);
                                                value1 += Mark(valueType, dc.ColumnName, operatorMask, temp[j], DateConver, nvarCharMark) + ",";
                                            }
                                        }
                                        if (value1.EndsWith(","))
                                        {
                                            value1 = value1.Remove(value1.LastIndexOf(","));
                                        }
                                    }
                                    else if (c.Name.StartsWith(i + "AnyQueryValue1InfoRefvalBox"))
                                    {
                                        String[] temp = (c as InfoRefvalBox).TextBoxSelectedValue.Split(',');
                                        for (int j = 0; j < temp.Length; j++)
                                        {
                                            if (temp[j] != String.Empty)
                                            {
                                                temp[j] = IsLike(operatorMask, temp[j]);
                                                value1 += Mark(valueType, dc.ColumnName, operatorMask, temp[j], DateConver, nvarCharMark) + ",";
                                            }
                                        }
                                        if (value1.EndsWith(","))
                                        {
                                            value1 = value1.Remove(value1.LastIndexOf(","));
                                        }

                                        realValue1 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                    }
                                    else if (c.Name.StartsWith(i + "AnyQueryValue1InfoDateTimePicker"))
                                    {
                                        if ((c as InfoDateTimePicker).Checked)
                                        {
                                            value1 = (c as InfoDateTimePicker).Value.ToString("yyyy/MM/dd");
                                            value1 = Mark(valueType, dc.ColumnName, operatorMask, value1, DateConver, nvarCharMark);
                                            realValue1 = Convert.ToDateTime((c as InfoDateTimePicker).Value);
                                        }
                                    }
                                    else if (c.Name.StartsWith(i + "AnyQueryValue1InfoComboBox"))
                                    {
                                        if ((c as InfoComboBox).SelectedValue != null)
                                        {
                                            value1 = IsLike(operatorMask, (c as InfoComboBox).SelectedValue.ToString());
                                            realValue1 = (c as InfoComboBox).SelectedValue.ToString();
                                        }
                                        else
                                        {
                                            value1 = IsLike(operatorMask, (c as InfoComboBox).Text);
                                            realValue1 = (c as InfoComboBox).Text;
                                        }
                                        value1 = Mark(valueType, dc.ColumnName, operatorMask, value1, DateConver, nvarCharMark);
                                    }
                                    else
                                    {
                                        String[] temp = c.Text.Split(',');
                                        for (int j = 0; j < temp.Length; j++)
                                        {
                                            if (temp[j] != String.Empty)
                                            {
                                                temp[j] = IsLike(operatorMask, temp[j]);
                                                value1 += Mark(valueType, dc.ColumnName, operatorMask, temp[j], DateConver, nvarCharMark) + ",";
                                            }
                                        }
                                        if (value1.EndsWith(","))
                                        {
                                            value1 = value1.Remove(value1.LastIndexOf(","));
                                        }
                                        realValue1 = c.Text;
                                    }

                                    break;
                                }
                            }

                            if (value1 == String.Empty)
                            {
                                string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueNull");
                                MessageBox.Show(String.Format(message, caption));
                                this.DialogResult = System.Windows.Forms.DialogResult.None;
                                return;
                            }

                            if (operatorMask == "IN" || operatorMask == "NOT IN")
                                value1 = String.Format("({0})", value1);

                            if (operatorMask == "<->" || operatorMask == "!<->")
                            {
                                foreach (Control c in this.panel2.Controls)
                                {
                                    if (c.Name.StartsWith(i + "AnyQueryValue2InfoRefvalBox"))
                                    {
                                        value2 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                        realValue2 = (c as InfoRefvalBox).TextBoxSelectedValue;
                                        break;
                                    }
                                    else if (c.Name.StartsWith(i + "AnyQueryValue2InfoDateTimePicker"))
                                    {
                                        if ((c as InfoDateTimePicker).Checked)
                                        {
                                            value2 = (c as InfoDateTimePicker).Value.ToString("yyyy/MM/dd");
                                            realValue2 = Convert.ToDateTime((c as InfoDateTimePicker).Value);
                                            break;
                                        }
                                    }
                                    else if (c.Name.StartsWith(i + "AnyQueryValue2"))
                                    {
                                        value2 = c.Text;
                                        realValue2 = c.Text;
                                        break;
                                    }
                                }
                                value2 = Mark(valueType, dc.ColumnName, operatorMask, value2, DateConver, nvarCharMark);
                            }

                            if (caption != String.Empty)
                            {
                                if (dc.DataType != typeof(DateTime) || !DateConver)
                                {
                                    if (operatorMask == "<->")
                                    {
                                        if (realValue2 != null)
                                        {
                                            bool flag = false;
                                            int iRealValue1 = 0;
                                            int iRealValue2 = 0;
                                            if (realValue2 is DateTime)
                                            {
                                                if (((DateTime)realValue2).Date < ((DateTime)realValue1).Date)
                                                    flag = true;
                                            }
                                            else if (int.TryParse(realValue1.ToString(), out iRealValue1) && int.TryParse(realValue2.ToString(), out iRealValue2))
                                            {
                                                if (iRealValue2 < iRealValue1)
                                                    flag = true;
                                            }

                                            if (flag)
                                            {
                                                string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueOverFlow");
                                                MessageBox.Show(message);
                                                this.DialogResult = System.Windows.Forms.DialogResult.None;
                                                return;
                                            }
                                        }
                                        strWhere = columnName + ">=" + value1 + " AND " + columnName + "<=" + value2;
                                    }
                                    else if (operatorMask == "!<->")
                                    {
                                        if (realValue2 != null)
                                        {
                                            bool flag = false;
                                            int iRealValue1 = 0;
                                            int iRealValue2 = 0;
                                            if (realValue2 is DateTime)
                                            {
                                                if (((DateTime)realValue2).Date < ((DateTime)realValue1).Date)
                                                    flag = true;
                                            }
                                            else if (int.TryParse(realValue1.ToString(), out iRealValue1) && int.TryParse(realValue2.ToString(), out iRealValue2))
                                            {
                                                if (iRealValue2 < iRealValue1)
                                                    flag = true;
                                            }
                                            if (flag)
                                            {
                                                string message = SysMsg.GetSystemMessage(CliUtils.fClientLang, "Srvtools", "AnyQuery", "ValueOverFlow");
                                                MessageBox.Show(message);
                                                this.DialogResult = System.Windows.Forms.DialogResult.None;
                                                return;
                                            }
                                        }
                                        strWhere = columnName + "<" + value1 + " OR " + columnName + ">" + value2;
                                    }
                                    else if (operatorMask == "%**" || operatorMask == "**%" || operatorMask == "%%")
                                        strWhere = columnName + " like " + value1;
                                    else if (operatorMask == "!%%")
                                        strWhere = columnName + " not like " + value1;
                                    else
                                        strWhere = columnName + " " + operatorMask + " " + value1;
                                }

                                strWhere = String.Format("({0})", strWhere);
                                detailWhere.Add(strWhere);
                                break;
                            }
                        }
                    }
                }

                if (detailWhere.Count > 0)
                {
                    String strDetail = String.Empty;
                    foreach (String str in detailWhere)
                    {
                        Control[] tempCondition = this.Controls.Find(this.cbCondition.Name, true);
                        strDetail += str + tempCondition[0].Text;
                    }
                    if (strDetail.EndsWith("OR"))
                        strDetail = strDetail.Remove(strDetail.LastIndexOf("OR"));
                    else if (strDetail.EndsWith("AND"))
                        strDetail = strDetail.Remove(strDetail.LastIndexOf("AND"));

                    //if (detailtablename.Contains(" ") && !detailtablename.Contains("[")) detailtablename = "[" + detailtablename + "]";

                    String[] detailTemp = detailSql.Split(new string[] { "SELECT", "FROM", "WHERE" }, StringSplitOptions.RemoveEmptyEntries);
                    if (String.IsNullOrEmpty(innerAnyQuery.MasterDetailField))
                        innerAnyQuery.MasterDetailField = innerAnyQuery.DetailKeyField;
                    whereString += String.Format("{3} in (SELECT {1} FROM {0} WHERE {2})", detailTemp[1], innerAnyQuery.DetailKeyField, strDetail, innerAnyQuery.MasterDetailField);
                    if (detailTemp.Length > 2)
                        whereString += " and " + detailTemp[2];
                }

                if (whereString.EndsWith("OR "))
                    whereString = whereString.Remove(whereString.LastIndexOf("OR "));
                else if (whereString.EndsWith("AND "))
                    whereString = whereString.Remove(whereString.LastIndexOf("AND "));
                Where = whereString;

                if (aInfoNavigator != null && !aInfoNavigator.QuerySQLSend)
                {
                    aInfoNavigator.OnQueryConfirm(new QueryConfirmEventArgs(Where));
                }
                else if (isExecute)
                {
                    AfterQueryEventArgs aqe = new AfterQueryEventArgs();
                    aqe.whereString = whereString;
                    OnAfterQuery(aqe);
                    if (!aqe.Cancel)
                        ids.SetWhere(aqe.whereString);
                }
            }
            if (Where == String.Empty)
                Where = "1=1";
            this.DialogResult = System.Windows.Forms.DialogResult.Yes;
            this.Close();
        }