Example #1
0
        /// <summary>
        /// AccountId, ProjectId, Title, OutlineLevel, OutlineNumber, IsSummary, IsCollapsed,
        /// TTotal, TCur, TSub,
        /// ETotal, ECur, ESub,
        /// ATotal, ACur, ASub
        /// </summary>
        /// <returns></returns>
        public static DataTable GetListAccountsByProjectCollapsed(int project_id)
        {
            DataTable dt = DBFinance.GetListAccountsByProjectCollapsed(project_id, Security.CurrentUser.UserID);

            // Удалим невидимые строки
            int       OldOutlineLevel = 1;
            bool      OldIsCollapsed  = false;
            Hashtable htT             = new Hashtable();
            Hashtable htE             = new Hashtable();

            foreach (DataRow dr in dt.Rows)
            {
                int  OutlineLevel = (int)dr["OutlineLevel"];
                bool IsCollapsed  = (bool)dr["IsCollapsed"];

                if (OldIsCollapsed && OldOutlineLevel < OutlineLevel)
                {
                    dr.Delete();
                }
                else
                {
                    OldOutlineLevel = OutlineLevel;
                    OldIsCollapsed  = IsCollapsed;

                    // Выставим значения для TParent и EParent
                    htT[OutlineLevel] = (decimal)dr["TCur"];
                    htE[OutlineLevel] = (decimal)dr["ECur"];

                    if (OutlineLevel == 1)
                    {
                        dr["TParent"] = decimal.MaxValue;
                        dr["EParent"] = decimal.MaxValue;
                    }
                    else
                    {
                        dr["TParent"] = (decimal)htT[OutlineLevel - 1] + (decimal)dr["TTotal"];
                        dr["EParent"] = (decimal)htE[OutlineLevel - 1] + (decimal)dr["ETotal"];
                    }
                }
            }
            return(dt);
        }