Exemple #1
0
 public void UpdateFuHe(string pid, string col1, Ps_Table_ElecPH oldrs, Ps_Table_ElecPH newrs)
 {
     string conn = "ProjectID='" + GetProjectID + "' and Col1='" + col1 + "' and ParentID='" + pid + "'";
     IList list = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
     if (list.Count > 0)
     {
         for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
         {
             double oldyf = double.Parse(oldrs.GetType().GetProperty("y" + i.ToString()).GetValue(oldrs, null).ToString());
             double newyf = double.Parse(newrs.GetType().GetProperty("y" + i.ToString()).GetValue(newrs, null).ToString());
             double myyf = double.Parse(list[0].GetType().GetProperty("y" + i.ToString()).GetValue(list[0], null).ToString());
             list[0].GetType().GetProperty("y" + i.ToString()).SetValue(list[0], Math.Round(myyf - oldyf + newyf, 1), null);
         }
         Common.Services.BaseService.Update<Ps_Table_ElecPH>((Ps_Table_ElecPH)list[0]);
     }
 }
Exemple #2
0
        public void AddTotalRow(ref IList list)
        {
            //合计110
            string conn = "ProjectID='" + GetProjectID + "' and Col2='110'";
            IList tList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
            int[] year = GetYears();
            Ps_Table_ElecPH table1 = new Ps_Table_ElecPH();
            table1.ID += "|" + GetProjectID;
            table1.Title = "110千伏供电量合计";
            table1.ParentID = "0";
            table1.ProjectID = GetProjectID;
            table1.Col2 = "110he";
            table1.Col1 = "bind1";
            table1.Sort = 1000;
            table1.BuildEd = "total";
            for (int j = year[1]; j <= year[2]; j++)
            {
                double first = 0.0;
                for (int k = 0; k < tList.Count; k++)
                {
                    first += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                }
                table1.GetType().GetProperty("y" + j).SetValue(table1, first, null);
            }
            list.Add(table1);
            //220
            conn = "ProjectID='" + GetProjectID + "' and Col2='110he'";
            tList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
            Ps_Table_ElecPH table2 = new Ps_Table_ElecPH();
            table2 = (Ps_Table_ElecPH)table1.Clone();
            table2.Title = "220千伏供电量";
            table2.ParentID = "0";
            table2.ProjectID = GetProjectID;
            table2.Col2 = "220he";
            table2.Sort = 2000;
            table2.Col1 = "bind2";
            table2.BuildEd = "total";
            for (int j = year[1]; j <= year[2]; j++)
            {
                double first = double.Parse(table2.GetType().GetProperty("y" + j).GetValue(table2, null).ToString());
                for (int k = 0; k < tList.Count; k++)
                {
                    if (((Ps_Table_ElecPH)tList[k]).Title == "外网110千伏送出电量")
                        first += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    else
                        first -= double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                }
                table2.GetType().GetProperty("y" + j).SetValue(table2, first, null);
            }
            list.Add(table2);
            //500
            conn = "ProjectID='" + GetProjectID + "' and Col2='220he'";
            tList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
            Ps_Table_ElecPH table3 = new Ps_Table_ElecPH();
            Ps_Table_ElecPH table4 = new Ps_Table_ElecPH();
            table3 = (Ps_Table_ElecPH)table2.Clone();
            table3.Title = "500千伏供电量";
            table3.ParentID = "0";
            table3.ProjectID = GetProjectID;
            table3.Col2 = "500he";
            table3.Sort = 3000;
            table3.BuildEd = "total";
            table4 = (Ps_Table_ElecPH)table3.Clone();
            table4.Sort = 3001;
            table3.Col1 = "bind3";
            table4.Col1 = "bind4";
            int t = 1;
            string ji = "";
            for (int j = year[1]; j <= year[2]; j++)
            {
                double first = double.Parse(table3.GetType().GetProperty("y" + j).GetValue(table3, null).ToString());
                double sec = double.Parse(table4.GetType().GetProperty("y" + j).GetValue(table4, null).ToString());
                for (int k = 0; k < tList.Count; k++)
                {
                    if (((Ps_Table_ElecPH)tList[k]).Title == "外网220千伏送出电量")
                    {
                        first += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                        sec += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    }
                    else if (((Ps_Table_ElecPH)tList[k]).Title == "220千伏大用户输电量")
                    {
                        if (t == 1)
                        {
                            conn = "ParentId='" + ((Ps_Table_ElecPH)tList[k]).ID + "'";
                            IList teList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
                            for (int z = 0; z < teList.Count; z++)
                            {
                                ji += ((Ps_Table_ElecPH)teList[z]).Title + (z == teList.Count - 1 ? ")" : "、");
                            }
                            t = 2;
                        }
                        sec += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    }
                    else
                    {
                        first -= double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                        sec -= double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    }

                }
                table3.GetType().GetProperty("y" + j).SetValue(table3, first, null);
                table4.GetType().GetProperty("y" + j).SetValue(table4, sec, null);
            }
            table3.Title = "500千伏供电量(不计"+ji;
            table4.Title = "500千伏供电量(计" + ji;
            list.Add(table3);
            list.Add(table4);
        }
Exemple #3
0
        private bool SaveCellValue(string year, string typeID, double value)
        {
            Ps_Table_ElecPH psp = new Ps_Table_ElecPH();
            Ps_Table_ElecPH old = Common.Services.BaseService.GetOneByKey<Ps_Table_ElecPH>(typeID);
            psp = (Ps_Table_ElecPH)old.Clone();
            psp.GetType().GetProperty(year).SetValue(psp, Math.Round(value,1),null);

            try
            {
                Common.Services.BaseService.Update<Ps_Table_ElecPH>(psp);
            }
            catch(Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return false;
            }
            return true;
        }