protected override void FillUpdateTables(TableResolver resolver, IInputData input)
 {
     if (SupportData)
     {
         var fieldInfo            = resolver.GetFieldInfo(ParentKey);
         ListDataRightEventArgs e = new ListDataRightEventArgs(Context,
                                                               BaseGlobalVariable.Current.UserInfo, resolver);
         var builder = DataRight.GetListSql(e);
         builder = ParamBuilder.CreateParamBuilder(
             SqlParamBuilder.CreateEqualSql(Context, fieldInfo, fParentKey), builder);
         resolver.Select(builder);
     }
     else
     {
         resolver.SelectWithParam(ParentKey, fParentKey);
     }
 }
Ejemplo n.º 2
0
        private static void ChangeChildLayer(TableResolver resolver,
                                             DbTreeDefinition fields, string id, string layer, int isLeaf)
        {
            if (isLeaf == 0)
            {
                string layerField  = fields.LayerField;
                string parentField = fields.ParentIdField;
                resolver.SelectWithParam(parentField, id);

                DataRow[] childRows = resolver.HostTable.Select(string.Format(
                                                                    ObjectUtil.SysCulture, "{0} = {1}", parentField, id), layerField + " ASC");

                for (int i = 0; i < childRows.Length; i++)
                {
                    DataRow childRow   = childRows[i];
                    string  childLayer = childRow[layerField].ToString();
                    string  lastThree  = childLayer.Substring(childLayer.Length - 3, 3);
                    childRows[i][layerField] = string.Format(ObjectUtil.SysCulture,
                                                             "{0}{1}", layer, lastThree);
                    ChangeChildLayer(resolver, fields, childRow[fields.IdField].ToString(),
                                     childRow[fields.LayerField].ToString(), childRow[fields.LeafField].Value <int>());
                }
            }
        }
Ejemplo n.º 3
0
        public void FillDetailTable(TableResolver masterResolver, TableResolver detailResolver)
        {
            TkDebug.AssertNotNull(masterResolver, "masterResolver", this);
            TkDebug.AssertNotNull(detailResolver, "detailResolver", this);

            if ((fType & RelationType.OnlyFill) != RelationType.OnlyFill)
            {
                return;
            }
            DataTable table = masterResolver.HostTable;

            TkDebug.AssertNotNull(table, string.Format(ObjectUtil.SysCulture, "主表{0}不存在",
                                                       masterResolver.TableName), this);

            foreach (DataRow row in table.Rows)
            {
                string filterSql = FilterSql == null ? string.Empty
                    : Expression.Execute(FilterSql, masterResolver.Source);
                if (Top == 0)
                {
                    if (fDetailFields.Length == 1)
                    {
                        if (fManyToMany == null)
                        {
                            detailResolver.SelectWithParam(filterSql, OrderBy,
                                                           fDetailFields[0], row[fMasterFields[0]]);
                        }
                        else
                        {
                            IParamBuilder container = GetDetailParamBuilder(detailResolver, row, filterSql);

                            detailResolver.Select(container, OrderBy);
                        }
                    }
                    else
                    {
                        if (fManyToMany == null)
                        {
                            object[] masterValues = new object[fMasterFields.Length];
                            for (int i = 0; i < fMasterFields.Length; ++i)
                            {
                                masterValues[i] = row[fMasterFields[i]];
                            }
                            detailResolver.SelectWithParams(filterSql, OrderBy, fDetailFields, masterValues);
                        }
                        else
                        {
                            ThrowErrorManyToManyMode();
                        }
                    }
                }
                else
                {
                    if (fManyToMany == null)
                    {
                        object[]      values  = (from item in fMasterFields select row[item]).ToArray();
                        IParamBuilder builder = detailResolver.CreateParamBuilder(filterSql, fDetailFields, values);
                        detailResolver.SelectTopRows(Top, builder, OrderBy);
                    }
                    else
                    {
                        if (fDetailFields.Length == 1)
                        {
                            IParamBuilder container = GetDetailParamBuilder(detailResolver, row, filterSql);

                            detailResolver.SelectTopRows(Top, container, OrderBy);
                        }
                        else
                        {
                            ThrowErrorManyToManyMode();
                        }
                    }
                }
            }
            detailResolver.AddVirtualFields();
        }