public void UpdateFuHe(string pid,string col1,Ps_Table_110Result oldrs,Ps_Table_110Result newrs) { string conn = "ProjectID='" + GetProjectID + "' and Col1='"+col1+"' and ParentID='"+pid+"'"; IList list = Common.Services.BaseService.GetList("SelectPs_Table_110ResultByConn", conn); if (list.Count > 0) { for(int i=yAnge.BeginYear;i<=yAnge.EndYear;i++) { double oldyf = double.Parse(oldrs.GetType().GetProperty("yf"+i.ToString()).GetValue(oldrs,null).ToString()); double oldyk = double.Parse(oldrs.GetType().GetProperty("yk" + i.ToString()).GetValue(oldrs, null).ToString()); double newyf = double.Parse(newrs.GetType().GetProperty("yf" + i.ToString()).GetValue(newrs, null).ToString()); double newyk = double.Parse(newrs.GetType().GetProperty("yk" + i.ToString()).GetValue(newrs, null).ToString()); double myyf = double.Parse(list[0].GetType().GetProperty("yf" + i.ToString()).GetValue(list[0], null).ToString()); double myyk = double.Parse(list[0].GetType().GetProperty("yk" + i.ToString()).GetValue(list[0], null).ToString()); list[0].GetType().GetProperty("yf" + i.ToString()).SetValue(list[0], Math.Round(myyf - oldyf + newyf,1), null); list[0].GetType().GetProperty("yk" + i.ToString()).SetValue(list[0], Math.Round(myyk - oldyk + newyk,1), null); } Common.Services.BaseService.Update<Ps_Table_110Result>((Ps_Table_110Result)list[0]); } }
private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { ClearChen(); UpdateChen(); IList pareList = Common.Services.BaseService.GetList("SelectPS_Table_AreaWHByConn", "ProjectID='" + GetProjectID + "' and ID not in (Select BuildIng From Ps_Table_110Result where ProjectID='" + GetProjectID + "' and ParentID='0') order by sort"); for (int i = 0; i < pareList.Count; i++) { Ps_Table_110Result table_yd = new Ps_Table_110Result(); table_yd.ID += "|" + GetProjectID; table_yd.Title = ((PS_Table_AreaWH)pareList[i]).Title; table_yd.ParentID = "0"; table_yd.Sort = OperTable.Get110ResultMaxSort() + 1; table_yd.ProjectID = GetProjectID; table_yd.BuildIng = ((PS_Table_AreaWH)pareList[i]).ID; for (int j = yAnge.BeginYear; j <= yAnge.EndYear; j++) { table_yd.GetType().GetProperty("yf" + j.ToString()).SetValue(table_yd, null, null); table_yd.GetType().GetProperty("yk" + j.ToString()).SetValue(table_yd, null, null); } try { Common.Services.BaseService.Create("InsertPs_Table_110Result", table_yd); } catch (Exception ex) { MsgBox.Show("增加城区出错:" + ex.Message); } string[] lei = new string[6] { "一、负荷", "二、35千伏及以下地方电源出力", "三、35千伏及以下外网送入电力", "四、35千伏及以下送出外网电力", "五、220千伏变电站低压侧供电负荷", "六、110千伏供电负荷" }; for (int k = 0; k < lei.Length; k++) { Ps_Table_110Result table1 = new Ps_Table_110Result(); table1.ID += "|" + GetProjectID; table1.Title = lei[k]; table1.ParentID = table_yd.ID; table1.ProjectID = GetProjectID; table1.Col1 = Convert.ToString(k + 1); if (k == 5) { table1.Col1 = "no"; table1.Col2 = table_yd.Title; } if (k == 1) AddModelChild(table1.ID, table_yd.Title); table1.Sort = k + 1; try { Common.Services.BaseService.Create("InsertPs_Table_110Result", table1); } catch (Exception ex) { MsgBox.Show("增加项目出错:" + ex.Message); } } this.Cursor = Cursors.WaitCursor; treeList1.BeginUpdate(); //treeList1.ExpandAll(); LoadData1(); treeList1.EndUpdate(); this.Cursor = Cursors.Default; } }
public void AddTotalRow(ref IList list) { //合计 string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'"; int[] year = GetYears(); Ps_Table_110Result parent = new Ps_Table_110Result(); parent.ID += "|" + GetProjectID; parent.ParentID = "0"; parent.Title = "110千伏合计"; parent.Sort = 1000;// OperTable.GetMaxSort() + 1; list.Add(parent); totoalParent = parent.ID; string[] lei = new string[6] { "一、负荷合计", "二、35千伏及以下地方电源出力", "三、35千伏及以下外网送入电力", "四、35千伏及以下送出外网电力", "五、220千伏变电站低压侧供电负荷", "六、110千伏供电负荷" }; for (int i = 0; i < lei.Length; i++) { conn = "Col1='"+Convert.ToString(i+1)+"' and ProjectID='" + GetProjectID + "'"; string conn1 = "ProjectID='" + GetProjectID + "' and Col2='"+Convert.ToString(i+1)+"'"; if (i == 5) { conn = "Col1='no' and ProjectID='" + GetProjectID + "'"; conn1 = "ProjectID='" + GetProjectID + "' and Col2='no'"; } Ps_Table_110Result table1 = new Ps_Table_110Result(); table1.ID += "|" + GetProjectID; table1.Title = lei[i]; table1.ParentID = parent.ID; table1.ProjectID = GetProjectID; table1.Col1 = Convert.ToString(i + 1); table1.BuildEd = "total"; if (i == 5) table1.Col1 = "no"; IList tList = Common.Services.BaseService.GetList("SelectPs_Table_110ResultByConn", conn); for (int j = year[1]; j <= year[2]; j++) { double first = 0.0, sec = 0.0; for (int k = 0; k < tList.Count; k++) { first += double.Parse(((Ps_Table_110Result)tList[k]).GetType().GetProperty("yf" + j).GetValue((Ps_Table_110Result)tList[k], null).ToString()); sec += double.Parse(((Ps_Table_110Result)tList[k]).GetType().GetProperty("yk" + j).GetValue((Ps_Table_110Result)tList[k], null).ToString()); } table1.GetType().GetProperty("yf" + j).SetValue(table1,first, null); table1.GetType().GetProperty("yk" + j).SetValue(table1, sec, null); } table1.Sort = i + 1; list.Add(table1); IList cList = Common.Services.BaseService.GetList("SelectPs_Table_110ResultByConn", conn1); // for (int j = 0; j < cList.Count; j++) // { // Ps_Table_110Result tablex = new Ps_Table_110Result(); // tablex = (Ps_Table_110Result)((Ps_Table_110Result)cList[j]).Clone(); // tablex.BuildEd = "total"; // tablex.ParentID = table1.ID; // list.Add(tablex); // } } }
private bool SaveCellValue(string year, string typeID, double value) { Ps_Table_110Result psp = new Ps_Table_110Result(); Ps_Table_110Result old = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(typeID); psp = (Ps_Table_110Result)old.Clone(); psp.GetType().GetProperty(year).SetValue(psp, Math.Round(value,1),null); try { Common.Services.BaseService.Update<Ps_Table_110Result>(psp); } catch(Exception ex) { MsgBox.Show("保存数据出错:" + ex.Message); return false; } return true; }
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!base.AddRight) { MsgBox.Show("您没有权限进行此项操作!"); return; } Ps_YearRange range = yAnge; TreeListNode focusedNode = treeList1.FocusedNode; //if (focusedNode == null) //{ // return; //} FrmAddPN frm = new FrmAddPN(); if (frm.ShowDialog() == DialogResult.OK) { Ps_Table_110Result table_yd = new Ps_Table_110Result(); table_yd.ID += "|" + GetProjectID; table_yd.Title = frm.ParentName; table_yd.ParentID = "0"; table_yd.Sort = OperTable.Get110ResultMaxSort() + 1; table_yd.ProjectID = GetProjectID; for (int i = range.BeginYear; i <= range.EndYear; i++) { table_yd.GetType().GetProperty("yf" + i.ToString()).SetValue(table_yd, null, null); table_yd.GetType().GetProperty("yk" + i.ToString()).SetValue(table_yd, null, null); } try { Common.Services.BaseService.Create("InsertPs_Table_110Result", table_yd); } catch (Exception ex) { MsgBox.Show("增加城区出错:" + ex.Message); } string[] lei = new string[6] { "一、负荷", "二、35千伏及以下地方电源出力", "三、35千伏及以下外网送入电力", "四、35千伏及以下送出外网电力", "五、220千伏变电站低压侧供电负荷", "六、110千伏供电负荷" }; for (int i = 0; i < lei.Length; i++) { Ps_Table_110Result table1 = new Ps_Table_110Result(); table1.ID += "|" + GetProjectID; table1.Title = lei[i]; table1.ParentID = table_yd.ID; table1.ProjectID = GetProjectID; table1.Col1 = Convert.ToString(i+1); if (i == 5) { table1.Col1 = "no"; table1.Col2 = table_yd.Title; } if (i == 1) AddModelChild(table1.ID,table_yd.Title); table1.Sort = i+1; try { Common.Services.BaseService.Create("InsertPs_Table_110Result", table1); } catch (Exception ex) { MsgBox.Show("增加项目出错:" + ex.Message); } } this.Cursor = Cursors.WaitCursor; treeList1.BeginUpdate(); //treeList1.ExpandAll(); LoadData1(); FoucsLocation(table_yd.ID, treeList1.Nodes); treeList1.EndUpdate(); this.Cursor = Cursors.Default; } }
private void AddArea(string Areaname) { Ps_YearRange range = yAnge; Ps_Table_110Result table_yd = new Ps_Table_110Result(); table_yd.ID += "|" + GetProjectID; table_yd.BuildYear = "1.9"; table_yd.Title = Areaname; table_yd.ParentID = "0"; table_yd.Sort = OperTable.Get110ResultMaxSort() + 1; table_yd.ProjectID = GetProjectID; for (int i = range.BeginYear; i <= range.EndYear; i++) { table_yd.GetType().GetProperty("yf" + i.ToString()).SetValue(table_yd, null, null); table_yd.GetType().GetProperty("yk" + i.ToString()).SetValue(table_yd, null, null); } try { Common.Services.BaseService.Create("InsertPs_Table_110Result", table_yd); } catch (Exception ex) { MsgBox.Show("增加城区出错:" + ex.Message); } // string[] lei = new string[7] { "一、110千伏以下负荷", "二、110千伏直供负荷","三、110千伏变电站低压侧供电负荷","四、110千伏及以下地方电源出力", "五、外网110千伏及以下送入电力", "六、外网110千伏及以下送出电力", "七、110千伏供电负荷" }; string[] lei = new string[11] { "1、全社会最高负荷", "2、110kV以下电源", "3、直供负荷", "4、外区供电", "5、区内电源出力", "6、需110kV变电供电负荷", "7、需110kV主变容量", "8、安排110kV变电容量", "9、实际110kV容载比", "10、变电容量盈亏", "11、变电站个数" }; for (int i = 0; i < lei.Length; i++) { Ps_Table_110Result table1 = new Ps_Table_110Result(); table1.ID += "|" + GetProjectID; table1.Title = lei[i]; table1.ParentID = table_yd.ID; table1.ProjectID = GetProjectID; table1.Col3 = Convert.ToString(i + 1); table1.Col1 = "no"; if (i == 0 || i == 2 || i == 3) { table1.Col1 = ""; } //2、110kV以下电源 if (i == 1 || i == 4 || i == 7 || i == 10) { table1.Col1 = "no"; } table1.Sort = i + 1; try { Common.Services.BaseService.Create("InsertPs_Table_110Result", table1); } catch (Exception ex) { MsgBox.Show("增加项目出错:" + ex.Message); } } UpdataDY(table_yd.ID); UpDataRL(table_yd.ID); UpDataBDZ(table_yd.ID); UpData(table_yd.ID); this.Cursor = Cursors.WaitCursor; treeList1.BeginUpdate(); //treeList1.ExpandAll(); LoadData1(); FoucsLocation(table_yd.ID, treeList1.Nodes); treeList1.EndUpdate(); this.Cursor = Cursors.Default; }
/// <summary> /// 更新容量 /// </summary> /// <param name="ParentID"></param> public void UpDataRL(string ParentID) { Hashtable rtable = new Hashtable(); Ps_Table_110Result pt = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(ParentID); string AreaName = pt.Title; string conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ParentID + "'"; Ps_Table_110Result col8; IList<Ps_Table_110Result> listchild = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn); for (int i = 0; i < listchild.Count; i++) { rtable.Add(listchild[i].Col3, listchild[i]); } col8 = (Ps_Table_110Result)rtable["8"]; //删除其下的 string conncol8 = "ProjectID='" + GetProjectID + "' and ParentID='" + col8.ID + "'"; IList<Ps_Table_110Result> col8list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conncol8); foreach (Ps_Table_110Result ptr in col8list) { Common.Services.BaseService.Delete<Ps_Table_110Result>(ptr); } //更新安排110kV变电容量 string conn1 = " AreaID='" + GetProjectID + "' and AreaName='" + AreaName + "' and L1=110"; IList<PSP_Substation_Info> list = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn1); int startyear = yAnge.BeginYear; int endyear = yAnge.EndYear; int startyear2 = yAnge.BeginYear; int endyear2 = yAnge.EndYear; double yf = 0; double yk = 0; for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { col8.GetType().GetProperty("yf" + i.ToString()).SetValue(col8, 0, null); col8.GetType().GetProperty("yk" + i.ToString()).SetValue(col8, 0, null); } for (int j = 0; j < list.Count; j++) { string dyid = list[j].UID; Ps_Table_110Result newdy = new Ps_Table_110Result(); newdy.ParentID = col8.ID; newdy.ProjectID = GetProjectID; newdy.Col1 = "no"; newdy.Title = list[j].Title; startyear = yAnge.BeginYear; endyear = yAnge.EndYear; if (list[j].S2 != string.Empty) { int.TryParse(list[j].S2, out startyear); } if (list[j].L29 != string.Empty) { int.TryParse(list[j].L29, out endyear); } string connjz = " where SvgUID ='" + dyid + "' and (Type='02' or Type='03')"; IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz); for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { //变电站下是否有机组容量,如果没有机组则直接用源的容量,如果有机组,将所有机组按年份计算求和 if (listatt.Count > 0) { for (int k = 0; k < listatt.Count; k++) { startyear2 = yAnge.BeginYear; endyear2 = yAnge.EndYear; if (listatt[k].OperationYear != string.Empty) { int.TryParse(listatt[k].OperationYear, out startyear2); } if (listatt[k].Date2 != string.Empty) { int.TryParse(listatt[k].Date2, out endyear2); } if (startyear2 <= i && i < endyear2) { double dyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString()); double dyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString()); if (listatt[k].Type == "02") { double tempdb = double.Parse(listatt[k].Burthen.ToString()); // 累计机组容量 newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(dyf + tempdb, 2), null); newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(dyk + tempdb, 2), null); } else { double tempdb = listatt[k].SiN; // 累计机组容量 newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(dyf + tempdb, 2), null); newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(dyk + tempdb, 2), null); } } } } else { if (startyear <= i && i < endyear) { newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(list[j].L2, 2), null); newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(list[j].L2, 2), null); } } double d8f = double.Parse(col8.GetType().GetProperty("yf" + i.ToString()).GetValue(col8, null).ToString()); double d8k = double.Parse(col8.GetType().GetProperty("yk" + i.ToString()).GetValue(col8, null).ToString()); double ddyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString()); double ddyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString()); col8.GetType().GetProperty("yf" + i.ToString()).SetValue(col8, Math.Round(d8f + ddyf, 2), null); col8.GetType().GetProperty("yk" + i.ToString()).SetValue(col8, Math.Round(d8k + ddyk, 2), null); } Common.Services.BaseService.Create<Ps_Table_110Result>(newdy); } Common.Services.BaseService.Update<Ps_Table_110Result>(col8); }
/// <summary> /// 更新电源 /// </summary> /// <param name="ParentID"></param> public void UpdataDY(string ParentID) { Hashtable rtable = new Hashtable(); Ps_Table_110Result pt = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(ParentID); string AreaName = pt.Title; string conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ParentID + "'"; Ps_Table_110Result col2, col5; IList<Ps_Table_110Result> listchild = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn); for (int i = 0; i < listchild.Count; i++) { rtable.Add(listchild[i].Col3, listchild[i]); } col2 = (Ps_Table_110Result)rtable["2"]; //删除其下的 string conncol2 = "ProjectID='" + GetProjectID + "' and ParentID='" + col2.ID + "'"; IList<Ps_Table_110Result> col2list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conncol2); foreach (Ps_Table_110Result ptr in col2list) { Common.Services.BaseService.Delete<Ps_Table_110Result>(ptr); } col5 = (Ps_Table_110Result)rtable["5"]; //更新110kV以下电源 更新 5、区内电源出力 // string conn1 = " AreaID='" + GetProjectID + "' and S9='" + AreaName + "' and cast(S1 as int)<110"; IList<PSP_PowerSubstation_Info> list = Common.Services.BaseService.GetList<PSP_PowerSubstation_Info>("SelectPSP_PowerSubstation_InfoListByWhere", conn1); int startyear = yAnge.BeginYear; int endyear = yAnge.EndYear; int startyear2 = yAnge.BeginYear; int endyear2 = yAnge.EndYear; double yf = 0; double yk = 0; for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { col2.GetType().GetProperty("yf" + i.ToString()).SetValue(col2, 0, null); col2.GetType().GetProperty("yk" + i.ToString()).SetValue(col2, 0, null); col5.GetType().GetProperty("yf" + i.ToString()).SetValue(col5, 0, null); col5.GetType().GetProperty("yk" + i.ToString()).SetValue(col5, 0, null); } for (int j = 0; j < list.Count; j++) { string dyid = list[j].UID; Ps_Table_110Result newdy = new Ps_Table_110Result(); newdy.ParentID = col2.ID; newdy.ProjectID = GetProjectID; newdy.Col1 = "no"; newdy.Title = list[j].Title; startyear = yAnge.BeginYear; endyear = yAnge.EndYear; if (list[j].S2 != string.Empty) { int.TryParse(list[j].S2, out startyear); } if (list[j].S30 != string.Empty) { int.TryParse(list[j].S30, out endyear); } string connjz = " where SvgUID ='" + dyid + "' and Type='04' "; IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz); for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { //电源下是否有机组容量,如果没有机组则直接用源的容量,如果有机组,将所有机组按年份计算求和 if (listatt.Count > 0) { for (int k = 0; k < listatt.Count; k++) { startyear2 = yAnge.BeginYear; endyear2 = yAnge.EndYear; if (listatt[k].OperationYear != string.Empty) { int.TryParse(listatt[k].OperationYear, out startyear2); } if (listatt[k].Date2 != string.Empty) { int.TryParse(listatt[k].Date2, out endyear2); } if (startyear2 <= i && i < endyear2) { double dyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString()); double dyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString()); // 累计机组容量 double tempdb = listatt[k].P0; newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(dyf + tempdb, 2), null); newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(dyk + tempdb, 2), null); double d5f = double.Parse(col5.GetType().GetProperty("yf" + i.ToString()).GetValue(col5, null).ToString()); double d5k = double.Parse(col5.GetType().GetProperty("yk" + i.ToString()).GetValue(col5, null).ToString()); // 累计机组容量*丰期机组出力率 或枯期机组出力率 col5.GetType().GetProperty("yf" + i.ToString()).SetValue(col5, Math.Round(d5f + tempdb * listatt[k].HuganTQ1, 2), null); col5.GetType().GetProperty("yk" + i.ToString()).SetValue(col5, Math.Round(d5k + tempdb * listatt[k].HuganTQ2, 2), null); } } } else { if (startyear <= i && i < endyear) { double.TryParse(list[j].S2, out yf); newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(yf, 2), null); newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(yf, 2), null); double d5f = double.Parse(col5.GetType().GetProperty("yf" + i.ToString()).GetValue(col5, null).ToString()); double d5k = double.Parse(col5.GetType().GetProperty("yk" + i.ToString()).GetValue(col5, null).ToString()); col5.GetType().GetProperty("yf" + i.ToString()).SetValue(col5, Math.Round(d5f + yf, 2), null); col5.GetType().GetProperty("yk" + i.ToString()).SetValue(col5, Math.Round(d5k + yf, 2), null); } } double d2f = double.Parse(col2.GetType().GetProperty("yf" + i.ToString()).GetValue(col2, null).ToString()); double d2k = double.Parse(col2.GetType().GetProperty("yk" + i.ToString()).GetValue(col2, null).ToString()); double ddyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString()); double ddyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString()); col2.GetType().GetProperty("yf" + i.ToString()).SetValue(col2, Math.Round(d2f + ddyf, 2), null); col2.GetType().GetProperty("yk" + i.ToString()).SetValue(col2, Math.Round(d2k + ddyk, 2), null); } Common.Services.BaseService.Create<Ps_Table_110Result>(newdy); } Common.Services.BaseService.Update<Ps_Table_110Result>(col2); Common.Services.BaseService.Update<Ps_Table_110Result>(col5); }
/// <summary> /// 更新变电站 /// </summary> /// <param name="ParentID"></param> public void UpDataBDZ(string ParentID) { Hashtable rtable = new Hashtable(); Ps_Table_110Result pt = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(ParentID); string AreaName = pt.Title; string conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ParentID + "'"; Ps_Table_110Result col11; IList<Ps_Table_110Result> listchild = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn); for (int i = 0; i < listchild.Count; i++) { rtable.Add(listchild[i].Col3, listchild[i]); } col11 = (Ps_Table_110Result)rtable["11"]; //删除其下的 string conncol11 = "ProjectID='" + GetProjectID + "' and ParentID='" + col11.ID + "'"; IList<Ps_Table_110Result> col11list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conncol11); foreach (Ps_Table_110Result ptr in col11list) { Common.Services.BaseService.Delete<Ps_Table_110Result>(ptr); } //更新变电站数量 11.变电站个数 int startyear = yAnge.BeginYear; int endyear = yAnge.EndYear; int startyear2 = yAnge.BeginYear; int endyear2 = yAnge.EndYear; Ps_Table_110Result yybdz = new Ps_Table_110Result(); yybdz.Title = "已有变电站"; yybdz.ProjectID = GetProjectID; yybdz.Col1 = "no"; yybdz.Sort = 0; yybdz.ParentID = col11.ID; Ps_Table_110Result xzbdz = new Ps_Table_110Result(); xzbdz.Title = "新增变电站"; xzbdz.ProjectID = GetProjectID; xzbdz.Col1 = "no"; xzbdz.Sort = 1; xzbdz.ParentID = col11.ID; for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { //已有变电站 string conn1 = " AreaID='" + GetProjectID + "' and AreaName='" + AreaName + "' and L1=110 and cast(S2 as int)<" + i; IList<PSP_Substation_Info> list1 = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn1); int yybdznumber = 0; for (int j = 0; j < list1.Count; j++) { string dyid = list1[j].UID; //string connjz = " RelatetableID ='" + dyid + "' and (S2='新建' or S2='扩容')"; //IList<Psp_Attachtable> listatt = Common.Services.BaseService.GetList<Psp_Attachtable>("SelectPsp_AttachtableByCont", connjz); string connjz = " where SvgUID ='" + dyid + "' and (Type='02' or Type='03')"; IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz); //如果变站下没有机组,则变电站有效 if (listatt.Count > 0) { int jznumber = 0; //找到是否有指定年份还在使用的机组,如果有则变电站有效 for (int k = 0; k < listatt.Count; k++) { startyear2 = yAnge.BeginYear; endyear2 = yAnge.EndYear; if (listatt[k].OperationYear != string.Empty) { int.TryParse(listatt[k].OperationYear, out startyear2); } if (listatt[k].Date2 != string.Empty) { int.TryParse(listatt[k].Date2, out endyear2); } if (startyear2 <= i && i <= endyear2) { jznumber++; break; } } if (jznumber > 0) { yybdznumber++; } } else { yybdznumber++; } } yybdz.GetType().GetProperty("yf" + i.ToString()).SetValue(yybdz, yybdznumber, null); yybdz.GetType().GetProperty("yk" + i.ToString()).SetValue(yybdz, yybdznumber, null); //新增变电站 string conn2 = " AreaID='" + GetProjectID + "' and AreaName='" + AreaName + "' and L1=110 and cast(S2 as int)=" + i; IList<PSP_Substation_Info> list2 = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn2); int xzbdznumber = 0; for (int j = 0; j < list2.Count; j++) { string dyid = list2[j].UID; //string connjz = " RelatetableID ='" + dyid + "' and (S2='新建' or S2='扩容')"; //IList<Psp_Attachtable> listatt = Common.Services.BaseService.GetList<Psp_Attachtable>("SelectPsp_AttachtableByCont", connjz); string connjz = " where SvgUID ='" + dyid + "' and (Type='02' or Type='03')"; IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz); //如果变站下没有机组,则变电站有效 if (listatt.Count > 0) { int jznumber = 0; //找到是否有指定年份还在使用的机组,如果有则变电站有效 for (int k = 0; k < listatt.Count; k++) { startyear2 = yAnge.BeginYear; endyear2 = yAnge.EndYear; if (listatt[k].OperationYear != string.Empty) { int.TryParse(listatt[k].OperationYear, out startyear2); } if (listatt[k].Date2 != string.Empty) { int.TryParse(listatt[k].Date2, out endyear2); } if (startyear2 <= i && i <= endyear2) { jznumber++; break; } } if (jznumber > 0) { xzbdznumber++; } } else { xzbdznumber++; } } xzbdz.GetType().GetProperty("yf" + i.ToString()).SetValue(xzbdz, xzbdznumber, null); xzbdz.GetType().GetProperty("yk" + i.ToString()).SetValue(xzbdz, xzbdznumber, null); col11.GetType().GetProperty("yf" + i.ToString()).SetValue(col11, yybdznumber + xzbdznumber, null); col11.GetType().GetProperty("yk" + i.ToString()).SetValue(col11, yybdznumber + xzbdznumber, null); } Common.Services.BaseService.Create<Ps_Table_110Result>(yybdz); Common.Services.BaseService.Create<Ps_Table_110Result>(xzbdz); Common.Services.BaseService.Update<Ps_Table_110Result>(col11); }