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) { for (int i = 0; i < treeList1.Nodes.Count; i++) { if (treeList1.Nodes[i].GetValue("Title").ToString() == frm.ParentName && treeList1.Nodes[i].GetValue("ParentID").ToString()=="0") { MessageBox.Show(frm.ParentName + " 地区已存在!"); return; } } Ps_Table_500Result table_yd = new Ps_Table_500Result(); table_yd.ID += "|" + GetProjectID; table_yd.Title = frm.ParentName; table_yd.ParentID = "0"; table_yd.Sort = OperTable.Get220ResultMaxSort() + 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_500Result", table_yd); } catch (Exception ex) { MsgBox.Show("增加城区出错:" + ex.Message); } //河池 string[] lei = new string[6] { "一、220千伏供电负荷", "二、220千伏直供负荷", "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷", "六、500千伏供电负荷" }; // string[] lei = new string[5] { "一、220千伏供电负荷", "二、220千伏直供负荷", "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷" }; for (int i = 0; i < lei.Length; i++) { Ps_Table_500Result table1 = new Ps_Table_500Result(); table1.ID += "|" + GetProjectID; table1.Title = lei[i]; table1.ParentID = table_yd.ID; table1.ProjectID = GetProjectID; table1.Col1 = Convert.ToString(i+1); if (i == 4) table1.Col1 = "no"; if (i == 5) table1.Col1 = "no1"; table1.Sort = i+1; try { Common.Services.BaseService.Create("InsertPs_Table_500Result", 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; } }
public void UpdateFuHe(string pid, string col1, Ps_Table_500Result oldrs, Ps_Table_500Result newrs) { string conn = "ProjectID='" + GetProjectID + "' and Col1='" + col1 + "' and ParentID='" + pid + "'"; IList list = Common.Services.BaseService.GetList("SelectPs_Table_500ResultByConn", 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_500Result>((Ps_Table_500Result)list[0]); } }
public void AddTotalRow(ref IList list) { //合计 string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'"; int[] year = GetYears(); Ps_Table_500Result parent = new Ps_Table_500Result(); parent.ID += "|" + GetProjectID; parent.ParentID = "0"; parent.Title = "500千伏合计"; parent.Sort = 1000;// OperTable.GetMaxSort() + 1; list.Add(parent); totoalParent = parent.ID; string[] lei = new string[5] { "一、220千伏供电负荷合计", "二、220千伏直供负荷", "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷"}; 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 == 4) { conn = "Col1='no' and ProjectID='" + GetProjectID + "'"; conn1 = "ProjectID='" + GetProjectID + "' and Col2='no'"; } Ps_Table_500Result table1 = new Ps_Table_500Result(); 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 == 4) table1.Col1 = "no"; IList tList = Common.Services.BaseService.GetList("SelectPs_Table_500ResultByConn", 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_500Result)tList[k]).GetType().GetProperty("yf" + j).GetValue((Ps_Table_500Result)tList[k], null).ToString()); sec += double.Parse(((Ps_Table_500Result)tList[k]).GetType().GetProperty("yk" + j).GetValue((Ps_Table_500Result)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_500ResultByConn", conn1); //for (int j = 0; j < cList.Count; j++) //{ // Ps_Table_500Result tablex = new Ps_Table_500Result(); // tablex = (Ps_Table_500Result)((Ps_Table_500Result)cList[j]).Clone(); // tablex.BuildEd = "total"; // tablex.ParentID = table1.ID; // list.Add(tablex); //} } }
private bool SaveCellValue(string year, string typeID, string value) { Ps_Table_500Result psp = new Ps_Table_500Result(); Ps_Table_500Result old = Common.Services.BaseService.GetOneByKey<Ps_Table_500Result>(typeID); psp = (Ps_Table_500Result)old.Clone(); psp.GetType().GetProperty(year).SetValue(psp, value, null); try { Common.Services.BaseService.Update<Ps_Table_500Result>(psp); } catch (Exception ex) { MsgBox.Show("保存数据出错:" + ex.Message); return false; } return true; }