예제 #1
0
        private IParamBuilder CreateItemParamBuilder(string value, bool isEqual, int index = 0)
        {
            IParamBuilder[] builders = new IParamBuilder[fFields.Length];

            for (int i = 0; i < fFields.Length; ++i)
            {
                if (isEqual)
                {
                    builders[i] = SqlParamBuilder.CreateEqualSql(Context, fFields[i], value);
                }
                else
                {
                    if (index == 0)
                    {
                        builders[i] = LikeParamBuilder.CreateLikeSql(Context, fFields[i], value);
                    }
                    else
                    {
                        builders[i] = LikeParamBuilder.CreateLikeSql(Context, fFields[i],
                                                                     fFields[i].FieldName + index, value);
                    }
                }
            }
            return(SqlParamBuilder.CreateParamBuilderWithOr(builders));
        }
예제 #2
0
        protected override OutputData DoGet(IInputData input)
        {
            using (TableResolver resolver = PlugInFactoryManager.CreateInstance <TableResolver>(
                       ResolverPlugInFactory.REG_NAME, "TaxDocument", this))
            {
                MetaDataTableResolver metaResolver = resolver as MetaDataTableResolver;
                string conditionStr = string.Empty;
                if (metaResolver != null)
                {
                    Dictionary <string, string> query = new Dictionary <string, string>
                    {
                        { "Title", input.QueryString["Title"] }
                    };

                    IParamBuilder builder = metaResolver.GetQueryCondition(new QueryConditionObject(false, query));
                    if (builder != null)
                    {
                        QueryCondition condition = new QueryCondition(query, builder);
                        conditionStr = "&Condition=" + HttpUtility.UrlEncode(condition.ToEncodeString());
                    }
                }
                string url = WebUtil.ResolveUrl("~/Library/WebListXmlPage.tkx?Source=Cxcs/FaGui");
                return(OutputData.Create(url + conditionStr));
            }
        }
예제 #3
0
        protected override OutputData DoGet(IInputData input)
        {
            Tk5TableResolver getResovler = new Tk5TableResolver(@"Weixin\CorpTagDept.xml", this);

            using (getResovler)
            {
                DataTable     table   = getResovler.CreateVirtualTable();
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(Context, "CU_USER_ID",
                                                                       TkDataType.Int, input.QueryString["UserId"]);
                string          dept = DbUtil.ExecuteScalar(SQL, Context, builder).ToString();
                QuoteStringList list = dept.Value <QuoteStringList>();
                if (list != null)
                {
                    List <int> deptList = list.ConvertToList <int>();
                    if (deptList != null)
                    {
                        foreach (var item in deptList)
                        {
                            DataRow userRow = table.NewRow();
                            userRow["DeparmentId"] = item;
                            table.Rows.Add(userRow);
                        }
                        getResovler.Decode(input.Style);
                    }
                }

                input.CallerInfo.AddInfo(DataSet);
            }
            return(OutputData.Create(DataSet));
        }
예제 #4
0
        private string SetPostListInfo(IInputData input, ParamBuilderContainer condition, ListSortInfo listInfo)
        {
            MetaDataTableResolver metaResolver = MainResolver as MetaDataTableResolver;

            if (metaResolver != null)
            {
                QueryConditionObject conditionData = input.PostObject.Convert <QueryConditionObject>();
                IParamBuilder        builder       = metaResolver.GetQueryCondition(conditionData);
                if (builder != null)
                {
                    QueryCondition queryCondition = new QueryCondition(conditionData.Condition, builder);
                    condition.Add(builder);
                    listInfo.SqlCon = queryCondition.ToEncodeString();
                }
            }
            if (SortQuery)
            {
                //string orderby;
                //int sort;
                //string order;
                var jsonOrder = ParseSortParams2(input);
                //ParseSortParams(input, out orderby, out sort, out order);
                //listInfo.SortField = sort;
                //listInfo.Order = order != "DESC" ? "ASC" : "DESC";
                listInfo.JsonOrder = jsonOrder.ToJson();

                return(jsonOrder.ToSqlOrder(MainResolver));
            }

            return(string.Empty);
        }
예제 #5
0
        protected virtual IParamBuilder CreateAdditionCondition(TkDbContext context, IFieldInfoIndexer indexer)
        {
            TkDebug.AssertArgumentNull(context, "context", this);
            TkDebug.AssertArgumentNull(indexer, "indexer", this);

            ParamBuilderContainer result = new ParamBuilderContainer();

            if (FilterSql != null)
            {
                string sql = Expression.Execute(FilterSql, context, indexer);
                result.Add(sql);
            }
            if (DataRight != null)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                IUserInfo     userInfo = BaseGlobalVariable.Current.UserInfo;
                IParamBuilder builder  = DataRight.GetListSql(new ListDataRightEventArgs(context, userInfo, indexer));
                result.Add(builder);
            }
            if (ActiveData != null)
            {
                IParamBuilder builder = ActiveData.CreateParamBuilder(context, indexer);
                result.Add(builder);
            }
            if (result.IsEmpty)
            {
                return(null);
            }
            return(result);
        }
예제 #6
0
        private void ProcessIdRootNode(string rootId)
        {
            DataRow row;

            if (!UseCustomParamBuilder)
            {
                row = fSelector.TrySelectRowWithKeys(rootId);
            }
            else
            {
                IParamBuilder builder = fSelector.CreateParamBuilder(null,
                                                                     new string[] { fDefinition.IdField }, rootId);
                builder = GetCustomParamBuilder(builder);
                row     = fSelector.TrySelectRow(builder);
            }
            if (row != null)
            {
                fRootParentId = row[fDefinition.ParentIdField].ToString();
            }
            else
            {
                fRootParentId = DbTreeDefinition.DEFAULT_PARENT_VALUE;
                fRootNodes    = Enumerable.Empty <ITreeNode>();
                SetTopLevel(null);
            }
            if (row != null)
            {
                // 由于在CreateNode的时候需要检测RootId,所以必须先给RootParentId赋值,然后才能创建Node
                ITreeNode root = CreateNode(row);
                fRootNodes = EnumUtil.Convert(root);
                SetTopLevel(root);
            }
        }
예제 #7
0
        internal static string GetLayer(ListDataRightEventArgs e)
        {
            IParamBuilder builder = SqlParamBuilder.CreateEqualSql(e.Context, "ORG_ID", TkDataType.Int, e.User.MainOrgId);
            string        layer   = DbUtil.ExecuteScalar(SQL, e.Context, builder).ToString();

            return(layer);
        }
예제 #8
0
        public IEnumerable <ITreeNode> GetDisplayTreeNodes(string id)
        {
            ITreeNode node = GetTreeNode(id);

            if (node == null)
            {
                return(RootNodes);
            }

            IParamBuilder builder = TreeUtil.GetValueBuilder(fSelector, fDefinition,
                                                             TopLevel, node.Convert <NormalDataRowTreeNode>());

            builder = GetCustomParamBuilder(builder);
            if (builder == null)
            {
                return(Enumerable.Empty <ITreeNode>());
            }
            //IParamBuilder customSql = fTreeProvider.CustomSql;
            //if (builder == null && customSql == null)
            //    return TreeUtil.CreateEmptyEnumerable();
            //if (customSql != null)
            //    builder = builder == null ? customSql : SqlParamBuilder.CreateParamBuilder(builder, customSql);
            var data = TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder, fOrder), id);

            return(TreeUtil.GetDisplayTreeNodes(data, id));
        }
예제 #9
0
 public override IParamBuilder GetCondition(IFieldInfo field, string fieldValue)
 {
     if (IsEqual)
     {
         return(SqlParamBuilder.CreateParamBuilderWithOr(
                    SqlParamBuilder.CreateEqualSql(Context, fField1, fieldValue),
                    SqlParamBuilder.CreateEqualSql(Context, fField2, fieldValue)));
     }
     else
     {
         if (WordSplit)
         {
             string[]             values = fieldValue.Split(' ');
             List <IParamBuilder> items  = new List <IParamBuilder>(values.Length);
             int index = 0;
             foreach (var value in values)
             {
                 string newValue = value.Trim();
                 if (!string.IsNullOrEmpty(newValue))
                 {
                     ++index;
                     IParamBuilder builder = GetLikeParamBuilder(newValue, index);
                     items.Add(builder);
                 }
             }
             return(ParamBuilder.CreateParamBuilder(items));
         }
         else
         {
             return(GetLikeParamBuilder(fieldValue));
         }
     }
 }
예제 #10
0
        protected override FieldErrorInfo CheckError(IInputData inputData, string value,
                                                     int position, params object[] args)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(null);
            }
            string original = null;

            try
            {
                DataRow row = HostDataSet.Tables[TableName].Rows[position];
                original = row[Field.NickName, DataRowVersion.Original].ToString();
            }
            catch
            {
            }
            if (!string.IsNullOrEmpty(original) && original == value)
            {
                return(null);
            }
            else
            {
                TkDbContext context = ObjectUtil.ConfirmQueryObject <TkDbContext>(this, args);

                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, Field, value);
                int           count   = DbUtil.ExecuteScalar("SELECT COUNT(*) FROM " + TableName,
                                                             context, builder).Value <int>();
                if (count > 0)
                {
                    return(CreateErrorObject(Message));
                }
                return(null);
            }
        }
예제 #11
0
 public ListTabSheet(string id, string caption, IParamBuilder paramBuilder)
 {
     Id           = id;
     Caption      = caption;
     ParamBuilder = paramBuilder;
     Selected     = false;
 }
예제 #12
0
        public void Select(string tableName, string selectSql, IParamBuilder builder, string orderBy)
        {
            TkDebug.AssertArgumentNullOrEmpty(tableName, "tableName", this);
            TkDebug.AssertArgumentNullOrEmpty(selectSql, "selectSql", this);
            TkDebug.AssertArgumentNull(builder, "builder", this);

            StringBuilder sqlBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(builder.Sql))
            {
                sqlBuilder.Append(" WHERE ").Append(builder.Sql);
            }
            if (!string.IsNullOrEmpty(orderBy))
            {
                sqlBuilder.Append(" ").Append(orderBy);
            }
            string sql = sqlBuilder.ToString();

            sqlBuilder.Length = 0;

            if (string.IsNullOrEmpty(sql))
            {
                Select(tableName, selectSql);
            }
            else
            {
                Select(tableName, selectSql + sql, builder.Parameters);
            }
        }
예제 #13
0
        public override IDecoderItem[] SearchByName(string name, params object[] args)
        {
            TkDbContext context;
            bool        createContext;

            GetContext(args, out context, out createContext);

            try
            {
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, NameField, name);
                DataTable     table   = FetchRows(context, fDataSet, builder, 2);
                if (table == null || table.Rows.Count == 0)
                {
                    return(null);
                }
                IDecoderItem[]       result  = new IDecoderItem[table.Rows.Count];
                int                  index   = 0;
                DataColumnCollection columns = table.Columns;
                foreach (DataRow row in table.Rows)
                {
                    result[index++] = new DataRowDecoderItem(columns, row,
                                                             DecoderConst.CODE_NICK_NAME, fExpression, fDisplayExpression);
                }

                return(result);
            }
            finally
            {
                if (createContext)
                {
                    context.Dispose();
                }
            }
        }
예제 #14
0
        protected virtual TabConditionCount DoTabCountAction(IInputData input)
        {
            TabConditionCount result = new TabConditionCount();

            if (TabSheets != null && TabSheets.Count > 0)
            {
                ParamBuilderContainer condition = CreateListCondition(input);
                string sql = string.Format(ObjectUtil.SysCulture,
                                           "SELECT COUNT(*) FROM {0}", GetTableName(Context));
                string queryCon = input.QueryString[CONDITION_HEADER_NAME];
                if (!string.IsNullOrEmpty(queryCon))
                {
                    queryCon = Uri.UnescapeDataString(queryCon);
                    QueryCondition queryCondition = QueryCondition.FromEncodeString(queryCon);
                    condition.Add(queryCondition.Builder);
                }
                foreach (var tabItem in TabSheets)
                {
                    IParamBuilder builder = condition.IsEmpty ? tabItem.ParamBuilder :
                                            ParamBuilder.CreateParamBuilder(condition, tabItem.ParamBuilder);
                    int count = DbUtil.ExecuteScalar(sql, Context, builder).Value <int>();
                    result.Add(tabItem.Id, count);
                }
            }

            return(result);
        }
예제 #15
0
        protected override DataTable FetchRows(TkDbContext context, DataSet dataSet,
                                               IParamBuilder builder, int topCount)
        {
            SqlSelector selector = new SqlSelector(context, dataSet);

            using (selector)
            {
                IParamBuilder addBuilder = CreateAdditionCondition(context, fScheme);
                builder = ParamBuilder.CreateParamBuilder(builder, addBuilder);
                string whereSql;
                if (builder == null)
                {
                    whereSql = string.Empty;
                }
                else
                {
                    whereSql = "WHERE " + builder.Sql;
                }

                TableSchemeData schemeData = TableSchemeData.Create(context, fScheme);
                var             result     = context.ContextConfig.GetListSql(schemeData.SelectFields,
                                                                              GetTableName(context), schemeData.KeyFieldArray,
                                                                              whereSql, OrderBy, 0, topCount);
                ISimpleAdapter adapter = selector;
                adapter.SetSql(result.ListSql, builder);
                context.ContextConfig.SetListData(result, adapter, dataSet, 0, TopCount, EASYSEARCH_TABLE_NAME);

                return(dataSet.Tables[EASYSEARCH_TABLE_NAME]);
            }
        }
예제 #16
0
        public static RegNameList <ListTabSheet> CreateTabSheets(this CodeTable codeTable,
                                                                 TkDbContext context, IFieldInfo field)
        {
            DataSet ds = new DataSet()
            {
                Locale = ObjectUtil.SysCulture
            };

            using (ds)
            {
                codeTable.Fill(ds, context);
                if (ds.Tables.Count == 0)
                {
                    return(null);
                }
                DataTable table = ds.Tables[0];
                if (table.Rows.Count == 0)
                {
                    return(null);
                }

                RegNameList <ListTabSheet> result = new RegNameList <ListTabSheet>();
                foreach (DataRow row in table.Rows)
                {
                    object        value   = row[DecoderConst.CODE_NICK_NAME];
                    IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, field,
                                                                           value);
                    ListTabSheet tab = new ListTabSheet(value.ToString(),
                                                        row[DecoderConst.NAME_NICK_NAME].ToString(), builder);
                    result.Add(tab);
                }

                return(result);
            }
        }
예제 #17
0
        public XmlParamBuilder(IParamBuilder builder)
        {
            TkDebug.AssertArgumentNull(builder, "builder", null);

            Sql        = builder.Sql;
            Parameters = builder.Parameters;
        }
예제 #18
0
        private void InternalSelect(IParamBuilder builder, string orderBy)
        {
            builder = ParamBuilder.CreateParamBuilder(builder, CreateFixCondition());

            StringBuilder sqlBuilder = new StringBuilder();

            if (builder != null && !string.IsNullOrEmpty(builder.Sql))
            {
                sqlBuilder.Append("WHERE ").Append(builder.Sql);
            }
            if (!string.IsNullOrEmpty(orderBy))
            {
                sqlBuilder.Append(" ").Append(orderBy);
            }
            string          sql  = sqlBuilder.ToString();
            DbParameterList list = builder == null ? null : builder.Parameters;

            SqlBuilder.GetSelectCommand(this);
            IDbCommand command = DataAdapter.SelectCommand;

            command.CommandText = ReplaceWhereClause(command.CommandText, sql);
            if (list != null && !list.IsEmpty)
            {
                DbUtil.SetCommandParams(command, list.CreateParameters(Context));
            }
            FillDataSet();
        }
예제 #19
0
        internal static string GetLayer(TableResolver resolver, DbTreeDefinition tree, string parentId)
        {
            TkDbContext   context    = resolver.Context;
            IFieldInfo    layerField = resolver.GetFieldInfo(tree.LayerField);
            IParamBuilder fixBuilder = resolver.CreateFixCondition();
            string        execRootId = tree.ExecuteRootId;

            if (execRootId == parentId)
            {
                string subStringSql = context.ContextConfig.GetFunction("SubString",
                                                                        layerField.FieldName, 1, 3);
                string sql = string.Format(ObjectUtil.SysCulture,
                                           "SELECT MAX({0}) FROM {1}", subStringSql, resolver.TableName);
                string value = (fixBuilder == null ? DbUtil.ExecuteScalar(sql, context)
                    : DbUtil.ExecuteScalar(sql, context, fixBuilder)).ToString();
                if (string.IsNullOrEmpty(value))
                {
                    return("000");
                }
                else
                {
                    return(AddLayer(value));
                }
            }
            else
            {
                try
                {
                    string sql = string.Format(ObjectUtil.SysCulture, "SELECT {0} FROM {1}",
                                               layerField.FieldName, resolver.TableName);
                    IParamBuilder builder = ParamBuilder.CreateParamBuilder(fixBuilder,
                                                                            SqlParamBuilder.CreateEqualSql(context, resolver.GetFieldInfo(tree.IdField), parentId));
                    string topLayer     = DbUtil.ExecuteScalar(sql, context, builder).ToString();
                    string subStringSql = context.ContextConfig.GetFunction("SubString",
                                                                            layerField.FieldName, topLayer.Length + 1, 3);

                    builder = CreateLayerParamBuilder(context, layerField, topLayer);
                    builder = SqlParamBuilder.CreateParamBuilder(fixBuilder, builder);
                    sql     = string.Format(ObjectUtil.SysCulture, "SELECT MAX({0}) FROM {1}",
                                            subStringSql, resolver.TableName);
                    string value = DbUtil.ExecuteScalar(sql, context, builder).ToString().Trim();
                    if (string.IsNullOrEmpty(value))
                    {
                        DataRow parentRow = resolver.SelectRowWithParam(tree.IdField, parentId);
                        parentRow[tree.LeafField] = 0;
                        resolver.SetCommands(AdapterCommand.Update);
                        return(topLayer + "000");
                    }
                    else
                    {
                        return(topLayer + AddLayer(value.Substring(value.Length - 3)));
                    }
                }
                catch
                {
                    return(string.Empty);
                }
            }
        }
예제 #20
0
 public static void Select(TkDbContext context, DataSet dataSet, string tableName,
                           string selectSql, IParamBuilder builder, string orderBy)
 {
     using (SqlSelector selector = new SqlSelector(context, dataSet))
     {
         selector.Select(tableName, selectSql, builder, orderBy);
     }
 }
예제 #21
0
        public static IParamBuilder CreateParamBuilder(string filterSql, params IParamBuilder[] builders)
        {
            TkDebug.AssertArgumentNullOrEmpty(filterSql, "filterSql", null);

            IParamBuilder builder = CreateSql(filterSql);

            return(CreateParamBuilder(EnumUtil.Convert(builder, builders)));
        }
예제 #22
0
        public QueryCondition(Dictionary <string, string> queryData, IParamBuilder builder)
        {
            TkDebug.AssertArgumentNull(queryData, "queryData", null);
            TkDebug.AssertArgumentNull(builder, "builder", null);

            QueryData = queryData;
            Builder   = new XmlParamBuilder(builder);
        }
예제 #23
0
        private static IParamBuilder CreateLayerParamBuilder(TkDbContext context,
                                                             IFieldInfo layer, string topLayer)
        {
            string        fieldName = layer.FieldName;
            IParamBuilder builder   = SqlParamBuilder.CreateParamBuilder(
                SqlParamBuilder.CreateSingleSql(context, layer, "!=", fieldName + "0", topLayer),
                SqlParamBuilder.CreateSingleSql(context, layer, "LIKE", fieldName + "1", topLayer + "%"));

            return(builder);
        }
예제 #24
0
        public IEnumerable <ITreeNode> GetDisplayTreeNodes(string id)
        {
            int           level   = fProvider.GetLevel(fDefinition, id);
            IParamBuilder builder = TreeUtil.GetLevelBuilder(fSelector, fDefinition,
                                                             level, id, fProvider);

            var data = TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder), id);

            return(TreeUtil.GetDisplayTreeNodes(data, id));
        }
예제 #25
0
        private void SetDataSet(object userId)
        {
            fDataSet = new DataSet {
                Locale = CultureInfo.CurrentCulture
            };
            TkDbContext context = DbContextUtil.CreateDefault();

            using (context)
            {
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, "USER_ID", TkDataType.String, userId);
                fAdmin = DbUtil.ExecuteScalar("SELECT USER_ADMIN FROM UR_USERS", context, builder).ToString() == "1";
                SqlSelector selector = new SqlSelector(context, fDataSet);
                using (selector)
                {
                    string userIdName = context.GetSqlParamName("USER_ID");
                    string sql        = string.Format(ObjectUtil.SysCulture, FUNC_SQL, userIdName,
                                                      context.ContextConfig.GetFunction("LENGTH", "FN_TREE_LAYER"));
                    selector.Select("SYS_FUNCTION", sql, builder.Parameters);

                    Dictionary <int, FunctionItem> idFunctions = new Dictionary <int, FunctionItem>();

                    DataTable table = fDataSet.Tables["SYS_FUNCTION"];
                    foreach (DataRow row in table.Rows)
                    {
                        FunctionItem item = new FunctionItem(row);
                        if (item.IsLeaf)
                        {
                            try
                            {
                                idFunctions.Add(item.Id, item);
                                fFunctions.Add(item.Key, item);
                            }
                            catch
                            {
                            }
                        }
                    }

                    sql = string.Format(ObjectUtil.SysCulture, SUB_FUNC_SQL, userIdName);
                    selector.Select("SYS_SUB_FUNC", sql, builder.Parameters);
                    table = fDataSet.Tables["SYS_SUB_FUNC"];
                    var group = from item in table.AsEnumerable()
                                group item by item.Field <int>("FnId");

                    foreach (var groupItem in group)
                    {
                        FunctionItem item;
                        if (idFunctions.TryGetValue(groupItem.Key, out item))
                        {
                            item.AddSubFunctions(groupItem);
                        }
                    }
                }
            }
        }
예제 #26
0
        protected override DataRow FetchRow(string code, TkDbContext context, DataSet dataSet)
        {
            SqlSelector selector = new SqlSelector(context, dataSet);

            using (selector)
            {
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, ValueField, code);
                String        sql     = string.Format("SELECT {0} FROM ({1}) {2}", fSelectFields, fSql, TABLE_NAME);
                return(selector.TrySelectRow(TABLE_NAME, sql, builder));
            }
        }
예제 #27
0
 /// <summary>
 /// Initializes a new instance of the FilledListEventArgs class.
 /// </summary>
 public FilledListEventArgs(bool isPost, int pageNumber, int pageSize, int count,
                            string order, TableSelector listView, Object postObject, IParamBuilder condition)
 {
     IsPost     = isPost;
     PageNumber = pageNumber;
     PageSize   = pageSize;
     Count      = count;
     Order      = order;
     ListView   = listView;
     PostObject = postObject;
     Condition  = condition;
 }
예제 #28
0
 public ITreeNode GetTreeNode(string id)
 {
     if (!UseCustomParamBuilder)
     {
         return(TreeUtil.GetTreeNode(fSelector, this, id));
     }
     else
     {
         IParamBuilder builder = fSelector.CreateParamBuilder(null,
                                                              new string[] { fDefinition.IdField }, id);
         return(GetTreeNodes(builder).FirstOrDefault());
     }
 }
예제 #29
0
        internal static void SortTree(TableResolver resolver, DbTreeDefinition tree,
                                      string id, TreeNodeMoveDirection direct)
        {
            TkDebug.AssertArgumentNull(resolver, "resolver", null);
            TkDebug.AssertArgumentNull(tree, "tree", null);
            TkDebug.AssertArgumentNullOrEmpty(id, "id", null);

            IParamBuilder fixBuilder = resolver.CreateFixCondition();
            IParamBuilder builder    = ParamBuilder.CreateParamBuilder(fixBuilder,
                                                                       SqlParamBuilder.CreateEqualSql(resolver.Context, resolver.GetFieldInfo(tree.IdField), id));

            IFieldInfo layerField = resolver.GetFieldInfo(tree.LayerField);
            string     sql        = string.Format(ObjectUtil.SysCulture, "SELECT {0} FROM {1}",
                                                  layerField.FieldName, resolver.TableName);
            string layer       = DbUtil.ExecuteScalar(sql, resolver.Context, builder).ToString();
            string parentLayer = layer.Substring(0, layer.Length - 3);

            resolver.SetCommands(AdapterCommand.Update);
            builder = SqlParamBuilder.CreateSingleSql(resolver.Context, layerField, "LIKE", parentLayer + "___");
            resolver.Select(builder, "ORDER BY " + layerField.FieldName);
            if (resolver.HostTable == null || resolver.HostTable.Rows.Count == 0)
            {
                return;
            }

            int rowNum = GetRowNum(resolver.HostTable, tree.IdField, id);

            if (rowNum == -1)
            {
                return;
            }
            //根据移动方向,执行不同操作
            switch (direct)
            {
            case TreeNodeMoveDirection.Up:
                if (rowNum == 0)    //已经最前,不能向上移动
                {
                    return;
                }
                SwapLayer(resolver, tree, rowNum, rowNum - 1);
                break;

            case TreeNodeMoveDirection.Down:
                if (rowNum == resolver.HostTable.Rows.Count - 1)    //已经最后,不能向下移动
                {
                    return;
                }
                SwapLayer(resolver, tree, rowNum, rowNum + 1);
                break;
            }
        }
예제 #30
0
 public override IParamBuilder GetCondition(IFieldInfo fieldName, string fieldValue)
 {
     try
     {
         DateTime      date     = DateTime.Parse(fieldValue, ObjectUtil.SysCulture);
         IParamBuilder builder1 = SqlParamBuilder.CreateSingleSql(Context, fieldName, ">=", fieldName.FieldName, date);
         IParamBuilder builder2 = SqlParamBuilder.CreateSingleSql(Context, fieldName, "<", fieldName.FieldName + "END", date.AddDays(1));
         return(SqlParamBuilder.CreateParamBuilder(builder1, builder2));
     }
     catch
     {
         return(SqlParamBuilder.NoResult);
     }
 }