Exemplo n.º 1
0
        /// <summary>
        /// 新建子表记录
        /// </summary>
        /// <returns></returns>
        public virtual RecData NewDRecord()
        {
            RecData rec = new RecData();

            FormDRec(rec);
            return(rec);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 格式化表格记录
 /// </summary>
 /// <param name="rec">表格记录</param>
 public override void FormRec(RecData rec)
 {
     base.FormRec(rec);
     foreach (RecData drec in rec.childList)
     {
         FormDRec(drec);
         drec.ownerList = rec.childList;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 复制数据对象
        /// </summary>
        /// <param name="sou">源对象,需从DataPacket继承</param>
        public override void AssignFrom(DataPacket sou)
        {
            base.AssignFrom(sou);
            RecData s = sou as RecData;

            if (s != null)
            {
                _recId     = s._recId;
                _recDeep   = s._recDeep;
                _recNum    = s._recNum;
                _recStatus = s._recStatus;
                _colList.AssignFrom(s._colList);
                _childList.AssignFrom(s._childList);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 是否有子项
        /// </summary>
        /// <param name="rec"></param>
        /// <param name="ownerlist"></param>
        /// <returns></returns>
        public bool HasChild(RecData rec, DataList ownerlist)
        {
            bool ret = false;
            int  idx = ownerlist.IndexOf(rec);

            if (idx < ownerlist.Count - 1)
            {
                RecData arec = ownerlist[idx + 1] as RecData;
                if (arec.recDeep > rec.recDeep)
                {
                    ret = true;
                }
            }
            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 取父记录
        /// </summary>
        /// <param name="rec"></param>
        /// <returns></returns>
        public RecData GetParentRec(RecData rec)
        {
            RecData ret = null;

            int idx = recList.IndexOf(rec);

            if (idx >= 0)
            {
                for (int i = idx - 1; i >= 0; i--)
                {
                    RecData arec = recList[i] as RecData;
                    if (rec.recDeep == arec.recDeep - 1)
                    {
                        ret = arec;
                        break;
                    }
                }
            }

            return(ret);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 将对象写入XML节点
        /// </summary>
        /// <param name="node">XML节点</param>
        public override void XMLEncode(XmlNode node)
        {
            base.XMLEncode(node);
            WriteXmlAttrValue(node, "RecId", _recId);
            WriteXmlAttrValue(node, "RecDeep", _recDeep);
            WriteXmlAttrValue(node, "RecNum", _recNum);
            WriteXmlAttrValue(node, "RecStatus", (int)_recStatus);
            WriteXmlAttrValue(node, "ChildCount", childCount);
            RecData parRec = parentRec;

            if (parRec != null)
            {
                WriteXmlAttrValue(node, "ParRecId", parRec.UniqId);
            }
            if (_colList.Count > 0)
            {
                WriteXMLValue(node, "ColList", _colList);
            }
            if (_childList.Count > 0)
            {
                WriteXMLValue(node, "ChildList", _childList);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 格式化子表记录
 /// </summary>
 /// <param name="rec">表格记录</param>
 public virtual void FormDRec(RecData rec)
 {
     rec.fields     = _dcolList;
     rec.ownerTable = this;
 }
Exemplo n.º 8
0
        /// <summary>
        /// 重设记录状态(序号重排)
        /// </summary>
        public void ReSetRecStatus()
        {
            int[] deepArr = new int[15];
            for (int i = 0; i < 15; i++)
            {
                deepArr[i] = 0;
            }
            ;

            for (int i = 0; i < recList.Count - 1; i++)
            {
                RecData rec = recList[i] as RecData;
                // 设记录状态,是否含有子项
                if (HasChild(rec))
                {
                    rec.recStatus = _recStatusEnum.rsTotal;
                }
                else
                {
                    rec.recStatus = _recStatusEnum.rsData;
                }

                // 设记录序号
                deepArr[rec.recDeep] = deepArr[rec.recDeep] + 1;
                //rec.recNum = "";
                rec.SetValue(0, "");
                for (int j = 1; j <= rec.recDeep; j++)
                {
                    if (string.IsNullOrEmpty(rec.recNum))
                    {
                        rec.SetValue(0, deepArr[j].ToString());
                    }
                    else
                    {
                        rec.SetValue(0, rec.GetValue(0) + "." + deepArr[j].ToString());
                    }
                }
                for (int j = rec.recDeep + 1; j < 15; j++)
                {
                    deepArr[j] = 0;
                }
                //补全colList
                rec.CheckColListData();
                //rec.colList.Sort(new SortByColIndex());
                //rec.colList.Cast<ColData>().OrderBy(a => a.colIndex).ToList().Distinct();

                #region 设子记录信息
                int[] ddeepArr = new int[15];
                for (int di = 0; di < 15; di++)
                {
                    ddeepArr[di] = 0;
                }
                ;

                for (int di = 0; di < rec.childList.Count - 1; di++)
                {
                    RecData drec = rec.childList[di] as RecData;
                    if (HasChild(drec, rec.childList))
                    {
                        drec.recStatus = _recStatusEnum.rsTotal;
                    }
                    else
                    {
                        drec.recStatus = _recStatusEnum.rsData;
                    }

                    ddeepArr[drec.recDeep] = ddeepArr[drec.recDeep] + 1;
                    drec.recNum            = "";
                    for (int dj = 1; dj <= drec.recDeep; dj++)
                    {
                        if (string.IsNullOrEmpty(drec.recNum))
                        {
                            drec.recNum = ddeepArr[dj].ToString();
                        }
                        else
                        {
                            drec.recNum = drec.recNum + "." + ddeepArr[dj].ToString();
                        }
                    }
                    // 清空低级别计数
                    for (int dj = drec.recDeep + 1; dj < 15; dj++)
                    {
                        ddeepArr[dj] = 0;
                    }
                    // 列记录排序
                    drec.colList.Sort(new SortByColIndex());
                    drec.CheckColListData();
                }
                #endregion
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 是否有子项(主表记录)
 /// </summary>
 /// <param name="rec"></param>
 /// <returns></returns>
 public bool HasChild(RecData rec)
 {
     return(HasChild(rec, recList));
 }
Exemplo n.º 10
0
 /// <summary>
 /// 格式化表格记录
 /// </summary>
 /// <param name="rec">表格记录</param>
 public virtual void FormRec(RecData rec)
 {
     rec.fields     = _colList;
     rec.ownerTable = this;
     rec.ownerList  = _recList;
 }