Exemplo n.º 1
0
        private static void SelectCommand(DatabaseParameters Parameters, string TableNames)
        {
            DatabaseParametersGroup parametersGroup = new DatabaseParametersGroup();

            parametersGroup.Add(Parameters);
            string[] tableNames = new string[] { TableNames };
            SelectCommand(parametersGroup, tableNames);
        }
Exemplo n.º 2
0
        private static void SelectCommand(DatabaseParametersGroup ParametersGroup, string[] TableNames)
        {
            int           num;
            StringBuilder builder  = new StringBuilder("SELECT * FROM ");
            StringBuilder builder2 = new StringBuilder();

            for (num = 0; num < TableNames.Length; num++)
            {
                builder.Append(TableNames[num] + ",");
            }
            builder.Remove(builder.Length - 1, 1);
            for (num = 0; num < ParametersGroup.Count; num++)
            {
                if (ParametersGroup[num].Count > 0)
                {
                    builder.Append((num == 0) ? " WHERE " : (" " + ParametersGroup[num].DataLinkage.ToString() + " "));
                    builder.Append(" (");
                    for (int i = 0; i < ParametersGroup[num].Count; i++)
                    {
                        builder.Append((i == 0) ? "" : (" " + ParametersGroup[num][i].ParamLinkage.ToString() + " "));
                        builder.Append(((ParametersGroup[num][i].ParamType == DBDataType.SQLFormula) || (ParametersGroup[num][i].ParamType == DBDataType.Formula)) ? (ParametersGroup[num][i].FieldName + ParametersGroup[num][i].ParamCompare + ParametersGroup[num][i].FieldValue) : (ParametersGroup[num][i].FieldName + " " + ParametersGroup[num][i].ParamCompare + " '" + ParametersGroup[num][i].FieldValue + "'"));
                        if (ParametersGroup[num][i].SortBy)
                        {
                            builder2.Append(ParametersGroup[num][i].FieldName + " " + (ParametersGroup[num][i].ASC ? "ASC" : "DESC") + ", ");
                        }
                    }
                    builder.Append(" )");
                }
            }
            if (builder2.Length > 0)
            {
                builder2.Remove(builder2.Length - 1, 1);
                builder.Append(" ORDER BY " + builder2.ToString());
            }
            sql = builder.ToString();
        }