public void UpdateFuHe(string pid,string col1,Ps_Table_BuildPro oldrs,Ps_Table_BuildPro newrs) { string conn = tong + "ProjectID='" + GetProjectID + "' and Col1='" + col1 + "' and ParentID='" + pid + "'"; IList list = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", 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_BuildPro>((Ps_Table_BuildPro)list[0]); } }
private bool SaveCellValue(string year, string typeID, double value) { Ps_Table_BuildPro psp = new Ps_Table_BuildPro(); Ps_Table_BuildPro old = Common.Services.BaseService.GetOneByKey<Ps_Table_BuildPro>(typeID); psp = (Ps_Table_BuildPro)old.Clone(); psp.GetType().GetProperty(year).SetValue(psp, Math.Round(value,1),null); try { Common.Services.BaseService.Update<Ps_Table_BuildPro>(psp); } catch(Exception ex) { MsgBox.Show("保存数据出错:" + ex.Message); return false; } return true; }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } //FindNodes(treeList1.FocusedNode); string parentid = treeList1.FocusedNode["ParentID"].ToString(); if (!base.EditRight) { MsgBox.Show("您没有权限进行此项操作!"); return; } if (parentid == "0") { FrmAddBuild frm = new FrmAddBuild(); //frm.TypeTitle = treeList1.FocusedNode.GetValue("Title").ToString(); frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString(); frm.Text = "修改分类名"; frm.SetLabelName = "分类名称"; frm.GetV = treeList1.FocusedNode.GetValue("FromID").ToString(); frm.Conn = tong + "ParentID='0' and ProjectID='" + GetProjectID + "' and FromID="; frm.BEdit = true; if (frm.ShowDialog() == DialogResult.OK) { Ps_Table_BuildPro table1 = new Ps_Table_BuildPro(); table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_BuildPro>(treeList1.FocusedNode.GetValue("ID")); table1.Title = frm.ParentName; table1.FromID = frm.GetV; table1.Col2 = "no"; try { Common.Services.BaseService.Update<Ps_Table_BuildPro>(table1); treeList1.FocusedNode.SetValue("Title", frm.ParentName); } catch { } //catch(Exception ex) //{ // MsgBox.Show("修改出错:" + ex.Message); //} } } else { FrmAddTzgsBBPW frm = new FrmAddTzgsBBPW(); frm.buildprortzgsflag = false; Ps_Table_BuildPro table = new Ps_Table_BuildPro(); table = Common.Services.BaseService.GetOneByKey<Ps_Table_BuildPro>(treeList1.FocusedNode.GetValue("ID")); frm.StrType = table.Col4; frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString(); frm.operatorflag = false; try { frm.V = int.Parse(treeList1.FocusedNode.GetValue("FromID").ToString()); } catch { } frm.AreaName = treeList1.FocusedNode.GetValue("AreaName").ToString(); frm.ProjectID = ProjectUID; if (treeList1.FocusedNode.GetValue("Col4") != null) { if (treeList1.FocusedNode.GetValue("Col4").ToString() == "line") frm.Line = true; } frm.Text = "修改工程"; frm.Stat = treeList1.FocusedNode.ParentNode.GetValue("Col2").ToString(); frm.BianInfo = table.BianInfo; frm.LineInfo = table.LineInfo; frm.StartYear = table.BuildYear; frm.FinishYear = table.BuildEd; frm.LineLen = table.Length; frm.BieZhu = table.Col1; frm.Col3 = table.Col3; frm.Vol = table.Volumn; frm.TzgsXs = double.Parse(yAngeXs.Col1); if (frm.ShowDialog() == DialogResult.OK) { AddChildVol(table, false); table.Title = frm.ParentName; table.BuildYear = frm.StartYear; table.BuildEd = frm.FinishYear; table.Length = frm.LineLen; table.Volumn = frm.Vol; double temp = frm.AllVol - table.AllVolumn; table.AllVolumn = frm.AllVol; table.AftVolumn += temp; for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++) { table.GetType().GetProperty("y" + i).SetValue(table, 0, null); } double temp1 = 0.0; if (g_col4 == "bian") temp1 = frm.Vol; else if (g_col4 == "line") temp1 = frm.LineLen; table.GetType().GetProperty("y" + Convert.ToString(frm.StartYear)).SetValue(table, temp1, null); table.Col1 = frm.BieZhu; table.Col3 = frm.Col3; table.BianInfo = frm.BianInfo; table.LineInfo = frm.LineInfo; table.Flag = frm.GetFlag; table.FromID = frm.GetFromID; table.AreaName = frm.AreaName; try { Common.Services.BaseService.Update<Ps_Table_BuildPro>(table); AddChildVol(table, true); LoadData1(); FoucsLocation(table.ID, treeList1.Nodes); } catch { } } } }
//更新线路 private void barButtonItem20_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Hashtable area_key_id = new Hashtable(); //初始化哈希表 string areaall = " ProjectID='" + GetProjectID + "'"; IList<PS_Table_AreaWH> tempPTA = Common.Services.BaseService.GetList<PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", areaall); if (tempPTA.Count != 0) { for (int i = 0; i < tempPTA.Count; i++) { area_key_id.Add(tempPTA[i].ID, tempPTA[i].Title); } } int year = yAnge.StartYear; string con = "Col4='line' and ProjectID='" + GetProjectID + "' and ParentID='0'"; IList list = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con); DataTable dt = Itop.Common.DataConverter.ToDataTable(list, typeof(Ps_Table_BuildPro)); string con2 = "Col4='line' and ProjectID='" + GetProjectID + "'"; IList list2 = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con2); DataTable dt2 = Itop.Common.DataConverter.ToDataTable(list2, typeof(Ps_Table_BuildPro)); WaitDialogForm wait = new WaitDialogForm("", "正在更新线路数据,请稍后..."); for (int i = 0; i < dt.Rows.Count; i++) { string parentid = dt.Rows[i]["ID"].ToString(); string dy = dt.Rows[i]["FromID"].ToString(); string connjz = " where ProjectID ='" + GetProjectID + "' and Type='05' and RateVolt=" + dy + " and Cast(Date1 as int)>" + year; IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz); int mm = 0; foreach (PSPDEV psi in listatt) { mm++; int perent = (i + 1) * 100 * mm / listatt.Count / dt.Rows.Count; wait.SetCaption(perent + "%"); Ps_Table_BuildPro table1 = new Ps_Table_BuildPro(); table1.ID += "|" + GetProjectID; table1.Title = psi.Name; table1.ParentID = parentid; table1.ProjectID = GetProjectID; table1.BuildYear = psi.Date1; table1.BuildEd = psi.OperationYear; table1.FromID = dy; table1.Length = psi.LineLength+psi.Length2; // table1.BefVolumn = frm.AllVol; table1.GetType().GetProperty("y" + psi.Date1).SetValue(table1, table1.Length, null); table1.Col4 = "line"; table1.Sort = OperTable.GetBuildProMaxSort() + 1; table1.Col10 = psi.SUID; table1.Col3 = "新建"; if (area_key_id[psi.AreaID]!=null) { table1.AreaName = area_key_id[psi.AreaID].ToString(); } try { if (DTHave(dt2, psi.SUID)) { UPDateOldXl(dt2, psi.SUID, table1); } else { Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow())); AddChildVol(table1, true); } } catch (Exception ee) { wait.Close(); } } } LoadData1(); wait.Close(); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode focusedNode = treeList1.FocusedNode; if (focusedNode == null) { return; } if (!base.AddRight) { MsgBox.Show("您没有权限进行此项操作!"); return; } FindNodes(treeList1.FocusedNode); string nodestr = treenode.GetValue("Title").ToString(); if ( focusedNode.GetValue("ParentID").ToString()!="0") { //MsgBox.Show( focusedNode.GetValue("Title").ToString()+"不允许添加子分类!"); //return; focusedNode = focusedNode.ParentNode; } FrmAddTzgsBBPW frm = new FrmAddTzgsBBPW(); frm.Text = "增加" + focusedNode.GetValue("Title") + "的变电工程"; frm.Stat = focusedNode.GetValue("Col2").ToString(); frm.buildprortzgsflag = false; frm.Line = false; frm.StrType = "bian"; frm.operatorflag = true; frm.TzgsXs = double.Parse(yAngeXs.Col1); frm.AreaName = focusedNode.GetValue("AreaName").ToString(); try { frm.V = int.Parse(focusedNode.GetValue("FromID").ToString()); } catch { } frm.ProjectID = ProjectUID; // frm.SetLabelName = "子分类名称"; if(frm.ShowDialog() == DialogResult.OK) { Ps_Table_BuildPro table1 = new Ps_Table_BuildPro(); table1.ID += "|" + GetProjectID; table1.Title = frm.ParentName; table1.ParentID = focusedNode.GetValue("ID").ToString(); table1.ProjectID = GetProjectID; table1.BuildYear = frm.StartYear; table1.BuildEd = frm.FinishYear; table1.FromID = frm.GetFromID; table1.Length = frm.LineLen; table1.Volumn = frm.Vol; table1.AllVolumn = frm.AllVol; // table1.BefVolumn = frm.AllVol; table1.AftVolumn = frm.AllVol; table1.LineInfo = frm.LineInfo; table1.BianInfo = frm.BianInfo; table1.GetType().GetProperty("y" + Convert.ToString(frm.StartYear)).SetValue(table1, frm.Vol, null); table1.Col4 = "bian"; table1.Sort = OperTable.GetBuildProMaxSort()+1; table1.Col3 = frm.Col3; table1.Col1 = frm.BieZhu; table1.AreaName = frm.AreaName; try { Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow())); AddChildVol(table1, true); LoadData1(); FoucsLocation(table1.ID, treeList1.Nodes); } catch (Exception ex) { MsgBox.Show("增加变电站出错:" + ex.Message); } } }
//更新变电站 private void barButtonItem19_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { int year = yAnge.StartYear; string con = "Col4='bian' and ProjectID='" + GetProjectID + "' and ParentID='0'"; IList list = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con); DataTable dt = Itop.Common.DataConverter.ToDataTable(list, typeof(Ps_Table_BuildPro)); string con2 = "Col4='bian' and ProjectID='" + GetProjectID + "'"; IList list2 = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", con2); DataTable dt2 = Itop.Common.DataConverter.ToDataTable(list2, typeof(Ps_Table_BuildPro)); WaitDialogForm wait = new WaitDialogForm("", "正在更新变电站数据,请稍后..."); for (int i = 0; i < dt.Rows.Count; i++) { string parentid = dt.Rows[i]["ID"].ToString(); string dy = dt.Rows[i]["FromID"].ToString(); string conn1 = " AreaID='" + GetProjectID + "' and L1=" + dy; IList<PSP_Substation_Info> listbdz = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn1); int mm = 0; foreach (PSP_Substation_Info psi in listbdz) { mm++; int perent=(i+1) * 100*mm/listbdz.Count / dt.Rows.Count; wait.SetCaption( perent+ "%"); string dyid = psi.UID; string connjz = " where SvgUID ='" + dyid + "' and Type='03'"; IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz); DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listatt, typeof(PSPDEV)); if (listatt.Count>0) { DataRow[] xyrow=dataTable.Select(" Date1<="+year); DataRow[] dyrow=dataTable.Select(" Date1>"+year ,"Date1"); if (dyrow.Length>0) { if (xyrow.Length>0) { int start=int.Parse(dyrow[0]["Date1"].ToString()); int end=int.Parse(dyrow[dyrow.Length-1]["Date1"].ToString()); //扩建 for (int j = start; j <= end; j++) { DataRow[] curow=dataTable.Select(" Date1="+j ); if (curow.Length==0) { continue; } Ps_Table_BuildPro table1 = new Ps_Table_BuildPro(); table1.ID += "|" + GetProjectID; table1.Title = psi.Title; table1.ParentID = parentid; table1.ProjectID = GetProjectID; table1.BuildYear =j.ToString(); table1.BuildEd = curow[0]["OperationYear"].ToString(); table1.FromID = dy; table1.Volumn = double .Parse( curow[0]["SiN"].ToString()); table1.Col4 = "bian"; table1.Sort = OperTable.GetBuildProMaxSort() + 1; table1.Col10 = curow[0]["SUID"].ToString(); table1.Col3="扩建"; table1.AreaName = psi.AreaName; for (int k = 1; k < curow.Length; k++) { table1.Volumn += double .Parse( curow[k]["SiN"].ToString()); } table1.GetType().GetProperty("y" + j).SetValue(table1, table1.Volumn, null); try { if (DTHave(dt2,curow[0]["SUID"].ToString())) { UPDateOldBDZ(dt2,curow[0]["SUID"].ToString(),table1); } else { Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow())); AddChildVol(table1, true); } } catch (Exception ee) { wait.Close(); } } } else { //新建+扩建 int start=int.Parse(dyrow[0]["Date1"].ToString()); int end=int.Parse(dyrow[dyrow.Length-1]["Date1"].ToString()); for (int j = start; j <= end; j++) { DataRow[] curow=dataTable.Select(" Date1="+j ); if (curow.Length==0) { continue; } if (j==start)//只有第一年需要新建,其后的都是扩建 { Ps_Table_BuildPro table1 = new Ps_Table_BuildPro(); table1.ID += "|" + GetProjectID; table1.Title = psi.Title; table1.ParentID = parentid; table1.ProjectID = GetProjectID; table1.BuildYear = j.ToString(); table1.BuildEd = curow[0]["OperationYear"].ToString(); table1.FromID = dy; table1.Volumn = double .Parse( curow[0]["SiN"].ToString()); table1.Col4 = "bian"; table1.Sort = OperTable.GetBuildProMaxSort() + 1; table1.Col10 = curow[0]["SUID"].ToString(); table1.Col3="新建"; table1.AreaName = psi.AreaName; for (int k = 1; k < curow.Length; k++) { table1.Volumn += double.Parse(curow[k]["SiN"].ToString()); } table1.GetType().GetProperty("y" + j).SetValue(table1, table1.Volumn, null); try { if (DTHave(dt2,curow[0]["SUID"].ToString())) { UPDateOldBDZ(dt2,curow[0]["SUID"].ToString(),table1); } else { Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow())); AddChildVol(table1, true); } } catch (Exception ee) { wait.Close(); } } else { Ps_Table_BuildPro table2 = new Ps_Table_BuildPro(); table2.ID += "|" + GetProjectID; table2.Title = psi.Title; table2.ParentID = parentid; table2.ProjectID = GetProjectID; table2.BuildYear = j.ToString(); table2.BuildEd = curow[0]["OperationYear"].ToString(); table2.FromID = dy; table2.Volumn = double .Parse( curow[0]["SiN"].ToString()); table2.Col4 = "bian"; table2.Sort = OperTable.GetBuildProMaxSort() + 1; table2.Col10 = curow[0]["SUID"].ToString(); table2.Col3="扩建"; table2.AreaName = psi.AreaName; for (int k = 1; k < curow.Length; k++) { table2.Volumn += double .Parse( curow[k]["SiN"].ToString()); } table2.GetType().GetProperty("y" + j).SetValue(table2, table2.Volumn, null); try { if (DTHave(dt2,curow[0]["SUID"].ToString())) { UPDateOldBDZ(dt2,curow[0]["SUID"].ToString(),table2); } else { Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table2); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table2, dataTable.NewRow())); AddChildVol(table2, true); } } catch (Exception ee) { wait.Close(); } } } } } } else { int curyear = 0; int.TryParse(psi.L28, out curyear); if (curyear> year) { Ps_Table_BuildPro table1 = new Ps_Table_BuildPro(); table1.ID += "|" + GetProjectID; table1.Title = psi.Title; table1.ParentID = parentid; table1.ProjectID = GetProjectID; table1.BuildYear = psi.L28; table1.BuildEd = psi.S2; table1.FromID = dy; table1.Volumn = psi.L2; // table1.BefVolumn = frm.AllVol; table1.GetType().GetProperty("y" + psi.L28).SetValue(table1, psi.L2, null); table1.Col4 = "bian"; table1.Sort = OperTable.GetBuildProMaxSort() + 1; table1.Col10 = psi.UID; table1.Col3="新建"; table1.AreaName = psi.AreaName; try { if (DTHave(dt2,psi.UID)) { UPDateOldBDZ(dt2,psi.UID,table1); } else { Common.Services.BaseService.Create("InsertPs_Table_BuildPro", table1); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow())); AddChildVol(table1, true); } } catch (Exception ee) { wait.Close(); } } } } } LoadData1(); wait.Close(); }