示例#1
0
        private void CalcTotal(ref IList list)
        {
            //合计
            string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'";

            int[] year = GetYears();
            Ps_Table_200PH parent = new Ps_Table_200PH();
            parent.ID += "|" + GetProjectID;
            parent.ParentID = "0"; parent.Title = "全网220千伏合计"; parent.Sort = 1000;// OperTable.GetMaxSort() + 1;
            list.Add(parent);
            totoalParent = parent.ID;
            Ps_Table_200PH tablex = new Ps_Table_200PH();
            conn = "Col1='0' and ProjectID='" + GetProjectID + "'";
            IList childx = Common.Services.BaseService.GetList("SelectPs_Table_200PHSumByConn", conn);
            tablex = (Ps_Table_200PH)childx[0];
            tablex.ParentID = parent.ID;
            tablex.ID = Guid.NewGuid().ToString();
            tablex.ID += "|" + GetProjectID;
            tablex.Sort = 1;
            tablex.Col1 = "no";
            tablex.Title = "220千伏主变供电负荷";
            list.Add(tablex);

            Ps_Table_200PH table1 = new Ps_Table_200PH();
            // Ps_Table_200PH con1 = new Ps_Table_200PH();
            // con1.Col4 = rongZai220;
            conn = "Col1='0' and ProjectID='" + GetProjectID + "'";// con1.Title = "Col1='0'";
            //IList child1 = Common.Services.BaseService.GetList("SelectPs_Table_200PHSumByConn", conn);
            table1 = (Ps_Table_200PH)tablex.Clone();// (Ps_Table_200PH)child1[0];
            for (int j = year[1]; j <= year[2]; j++)
            {
                double d = (double)table1.GetType().GetProperty("y" + j).GetValue(table1, null);
                table1.GetType().GetProperty("y" + j).SetValue(table1, Math.Round(double.Parse(rongZai220) * d, 1), null);
            }
            table1.ParentID = parent.ID;
            table1.ID = Guid.NewGuid().ToString();
            table1.ID += "|" + GetProjectID;
            table1.Sort = 2;
            table1.Col1 = "no";
            table1.Title = "220千伏需主变容量(" + rongZai220 + ")";
            list.Add(table1);

            Ps_Table_200PH table = new Ps_Table_200PH();
            //conn = "Col1='1'";
            //IList child = Common.Services.BaseService.GetList("SelectPs_Table_200PHSumByConn", conn);
            //table = (Ps_Table_200PH)child[0];
            for (int j = 0; j < list.Count; j++)
            {
                if (((Ps_Table_200PH)list[j]).Col1 == "1")
                {
                    for (int k = year[1]; k <= year[2]; k++)
                    {
                        table.GetType().GetProperty("y" + k).SetValue(table, double.Parse(table.GetType().GetProperty("y" + k).GetValue(table, null).ToString()) + double.Parse(((Ps_Table_200PH)list[j]).GetType().GetProperty("y" + k).GetValue(((Ps_Table_200PH)list[j]), null).ToString()), null);
                    }
                }
            }
            table.ParentID = parent.ID;
            table.ID = Guid.NewGuid().ToString();
            table.ID += "|" + GetProjectID;
            table.Sort = 3;
            table.Col1 = "no";
            table.Title = "220千伏主变总容量";
            list.Add(table);

            //IList allChild = Common.Services.BaseService.GetList("SelectPs_Table_200PHListByConn", conn);
            for (int k = 0; k < list.Count; k++)
            {
                if (((Ps_Table_200PH)list[k]).Col1 == "1")
                {
                    Ps_Table_200PH ps1 = new Ps_Table_200PH();
                    ps1 = (Ps_Table_200PH)((Ps_Table_200PH)list[k]).Clone();
                    ps1.ID = Guid.NewGuid().ToString();
                    ps1.ID += "|" + GetProjectID;
                    ps1.ParentID = parent.ID;
                    ps1.Col1 = "no";
                    ps1.BuildEd = "total";
                    list.Add(ps1);
                }
            }

            //conn = "Col1='0'";
            //Ps_Table_200PH temp1 = (Ps_Table_200PH)Common.Services.BaseService.GetList("SelectPs_Table_200PHListByConn", conn)[0];
            Ps_Table_200PH table2 = new Ps_Table_200PH();
            for (int j = year[1]; j <= year[2]; j++)
            {
                double d = (double)tablex.GetType().GetProperty("y" + j).GetValue(tablex, null);
                if (d != 0.0)
                {
                    double chu = (double)table.GetType().GetProperty("y" + j).GetValue(table, null);
                    table2.GetType().GetProperty("y" + j).SetValue(table2, Math.Round(chu / d, 1), null);
                }
            }
            table2.ParentID = parent.ID;
            table2.ID = Guid.NewGuid().ToString();
            table2.ID += "|" + GetProjectID;
            table2.Sort = 1000;
            table2.Col1 = "no";
            table2.Title = "220千伏容载比";
            list.Add(table2);
        }