Example #1
0
        public CtaRecData FindRecByKeyCols(CtaRecData sourec, int startpos)
        {
            CtaRecData ret = null;

            for (int i = startpos; i < recList.Count; i++)
            {
                CtaRecData rec  = recList[i] as CtaRecData;
                bool       find = true;
                foreach (CtaColDef coldef in colList)
                {
                    if (coldef.keyCol)
                    {
                        find = (sourec.GetValue(coldef.colIndx)) == (rec.GetValue(coldef.colIndx));
                        if (find)
                        {
                            break;
                        }
                    }
                }
                if (find)
                {
                    ret = rec;
                    break;
                }
            }
            return(ret);
        }
Example #2
0
        public override RecData NewDRecord()
        {
            CtaRecData rec = new CtaRecData();

            FormDRec(rec);
            return(rec);
        }
Example #3
0
        /// <summary>
        /// 通过sid取对比表格记录
        /// </summary>
        /// <param name="sid"></param>
        /// <returns></returns>
        public CtaRecData GetContrastRec(int sid)
        {
            CtaRecData ret = null;

            if (_synColTable != null)
            {
                ret = _synColTable.GetRecBySid(sid);
            }
            return(ret);
        }
Example #4
0
        /// <summary>
        /// 刷新对照关系
        /// </summary>
        public void FormCtaRelates()
        {
            ClearAllRecsTags();

            int startPos = 0;
            int asid     = 1;

            foreach (CtaRecData rec in recList)
            {
                CtaRecData drec = dzTable.FindRecByKeyCols(rec, startPos);
                if (drec != null)
                {
                    startPos = dzTable.recList.IndexOf(drec) + 1;
                    rec.Sid  = asid;
                    drec.Sid = asid;
                    asid++;

                    if (CompareRec(rec, drec) != 0)
                    {
                        rec.ctaStatus  = (int)_ctaStatusEnum.csDiff;
                        drec.ctaStatus = rec.ctaStatus;
                    }

                    FormChildCtaRelates(rec, drec);
                }
                else
                {
                    rec.ctaStatus = (int)_ctaStatusEnum.csAdd;
                };
            }
            foreach (CtaRecData drec in dzTable.recList)
            {
                if (drec.Sid == 0)
                {
                    drec.ctaStatus = (int)_ctaStatusEnum.csDecrease;
                }
            }

            // 统计错误数量
            foreach (CtaRecData rec in recList)
            {
                if (rec.ctaStatus != (int)_ctaStatusEnum.csConsis)  // 多项或不一致
                {
                    _errorCount++;
                }
            }
            foreach (CtaRecData rec in dzTable.recList)
            {
                if (rec.ctaStatus == (int)_ctaStatusEnum.csDecrease)  // 漏项
                {
                    _errorCount++;
                }
            }
        }
Example #5
0
        /// <summary>
        /// 复制数据对象
        /// </summary>
        /// <param name="sou">源对象,需从DataPacket继承</param>
        public override void AssignFrom(DataPacket sou)
        {
            base.AssignFrom(sou);
            CtaRecData s = sou as CtaRecData;

            if (s != null)
            {
                _ctaStatus  = s._ctaStatus;
                _souRecId   = s._souRecId;
                _souTableId = s._souTableId;
                _souDocId   = s._souDocId;
            }
        }
Example #6
0
        /// <summary>
        /// 刷新表格数据
        /// </summary>
        public virtual void RefreshRecs()
        {
            recList.Clear();
            if (souTable != null)
            {
                foreach (RecData sourec in souTable.recList)
                {
                    CtaRecData rec = NewRecord() as CtaRecData;

                    rec.AssignFrom(sourec);
                    FormRec(rec);

                    recList.Add(rec);
                }
            }
        }
Example #7
0
        /// <summary>
        /// 刷新子记录对照关系
        /// </summary>
        /// <param name="list"></param>
        /// <param name="dlist"></param>
        private void FormChildCtaRelates(CtaRecData prec, CtaRecData dprec)
        {
            int startPos = 0;
            int asid     = 1;

            foreach (CtaRecData rec in prec.childList)
            {
                CtaRecData drec = FindDRecByKeyCols(rec, startPos, dprec.childList);
                if (drec != null)
                {
                    startPos = prec.childList.IndexOf(rec) + 1;
                    rec.Sid  = asid;
                    drec.Sid = asid;
                    asid++;

                    if (CompareRec(rec, drec, true) != 0)
                    {
                        rec.ctaStatus  = (int)_ctaStatusEnum.csDiff; // 不一致
                        drec.ctaStatus = rec.ctaStatus;
                        // 父项设为不一致
                        prec.ctaStatus  = (int)_ctaStatusEnum.csDiff;
                        dprec.ctaStatus = prec.ctaStatus;
                    }
                }
                else
                {
                    rec.ctaStatus = (int)_ctaStatusEnum.csAdd;  // 多项
                    // 父项设为不一致
                    prec.ctaStatus  = (int)_ctaStatusEnum.csDiff;
                    dprec.ctaStatus = prec.ctaStatus;
                };
            }
            foreach (CtaRecData drec in dprec.childList)
            {
                if (drec.Sid == 0)
                {
                    drec.ctaStatus = (int)_ctaStatusEnum.csDecrease;  // 漏项
                    // 父项设为不一致
                    prec.ctaStatus  = (int)_ctaStatusEnum.csDiff;
                    dprec.ctaStatus = prec.ctaStatus;
                }
            }
        }
Example #8
0
        /// <summary>
        /// 比较记录一致
        /// </summary>
        /// <param name="rec"></param>
        /// <param name="drec"></param>
        /// <param name="compd">比较子表记录</param>
        /// <returns></returns>
        public int CompareRec(CtaRecData rec, CtaRecData drec, bool compd = false)
        {
            int ret = 0;

            DataList fields = colList;

            if (compd)
            {
                fields = dcolList;
            }
            foreach (CtaColDef coldef in fields)
            {
                if (!coldef.unCheck)
                {
                    CtaColData coldata  = rec.GetColDataByCol(coldef.colIndx) as CtaColData;
                    CtaColData dcoldata = drec.GetColDataByCol(coldef.colIndx) as CtaColData;
                    bool       issame   = true;
                    switch (coldef.colType)
                    {
                    case (int)_dataType.dtInt:
                    case (int)_dataType.dtFloat:
                    {
                        double v1 = 0, v2 = 0;
                        if (coldata != null)
                        {
                            double.TryParse(coldata.express, out v1);
                        }
                        if (dcoldata != null)
                        {
                            double.TryParse(dcoldata.express, out v2);
                        }
                        issame = (v1 == v2);
                        break;
                    }

                    case (int)_dataType.dtBoolean:
                    {
                        bool v1 = false, v2 = false;
                        if (coldata != null)
                        {
                            bool.TryParse(coldata.express, out v1);
                        }
                        if (dcoldata != null)
                        {
                            bool.TryParse(dcoldata.express, out v2);
                        }
                        issame = (v1 == v2);
                        break;
                    }

                    default:
                    {
                        string v1 = ""; string v2 = "";
                        if (coldata != null)
                        {
                            v1 = coldata.express;
                        }
                        if (dcoldata != null)
                        {
                            v2 = dcoldata.express;
                        }
                        issame = (v1 == v2);
                        break;
                    }
                    }
                    if (!issame)
                    {
                        if (coldata != null)
                        {
                            coldata.ctaStatus = (int)_ctaStatusEnum.csDiff;
                        }
                        if (dcoldata != null)
                        {
                            dcoldata.ctaStatus = (int)_ctaStatusEnum.csDiff;
                        }
                        ret = (int)_ctaStatusEnum.csDiff;
                    }
                }
            }

            return(ret);
        }