Пример #1
0
        public string Query_FormatDetail(ReportingSubject.Detail detail, string selection, ref string language)
        {
            string q = ""; // pad a space?
            string[] selections;
            string selectionlang;
            DataType datatype = new DataType();
            switch (detail.lang)
            {
                case "equals":
                case "IS":
                    selectionlang = selection;
                    if (detail.type == "bit")
                    {
                        if (selection == "1") { selectionlang = "True"; } else { selectionlang = "False"; }
                    }
                    if (datatype.UseQuotes(detail.type))
                    {// use quotes
                        q = detail.db + "='" + selection + "' AND ";
                        language = " Where '" + detail.name + "' is: '" + selectionlang + "' <br/>";
                    }
                    else
                    { // no quotes
                        q = detail.db + "=" + selection + " AND ";
                        language = " Where '" + detail.name + "' is: " + selectionlang + " <br/>";
                    }
                    break;
                case "IS ONE OF":
                case "IS IN":
                    // convert the comma delimited list of values into an array and parse
                    selections = selection.Split(new char[] { ',' });
                    q = detail.db + " IN (";
                    foreach (string specificdetail in selections)
                    {
                        if (datatype.UseQuotes(detail.type))
                        {// use quotes
                            q = q +"'" +specificdetail + "',";
                        }
                        else
                        { // no quotes
                            q = q + specificdetail + ",";
                        }
                    }
                    q = q.Remove(q.Length - 1); // remove last comma
                    q = q + ") AND ";
                    language = " Where '" + detail.name + "' is one of: '" + selection + "' <br/>";
                    break;
                case "IS BETWEEN":
                    selections = selection.Split(new char[] { ',' });
                    if (datatype.UseQuotes(detail.type))
                    {// use quotes
                        q = detail.db + ">='" + selections[0] + "' AND " + detail.db + "<='" + selections[1]+"'";
                    }
                    else
                    { // no quotes
                        q = detail.db + ">=" + selections[0] + " AND " + detail.db + "<=" + selections[1];
                    }
                    language = " Where '" + detail.name + "' is between: '" + selections[0] + " and " + selections[1] + "' <br/>";
                    break;
                case "IS BEFORE":
                    if (datatype.UseQuotes(detail.type))
                    {// use quotes
                        q = detail.db + "<'" + selection + "' AND ";
                        language = " Where '" + detail.name + "' is before: '" + selection + "' <br/>";
                    }
                    else
                    { // no quotes
                        q = detail.db + "<" + selection + " AND ";
                        language = " Where '" + detail.name + "' is after: " + selection + " <br/>";
                    }
                    break;
                case "IS AFTER":
                    if (datatype.UseQuotes(detail.type))
                    {// use quotes
                        q = detail.db + ">'" + selection + "' AND ";
                        language = " Where '" + detail.name + "' is before: '" + selection + "' <br/>";
                    }
                    else
                    { // no quotes
                        q = detail.db + ">" + selection + " AND ";
                        language = " Where '" + detail.name + "' is after: " + selection + " <br/>";
                    }
                    break;

            }
            return q;
        }