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 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; } }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } //FindNodes(treeList1.FocusedNode); string nodestr = treeList1.FocusedNode.GetValue("Col1").ToString(); string parentid = treeList1.FocusedNode["ParentID"].ToString(); if (!base.EditRight) { MsgBox.Show("您没有权限进行此项操作!"); return; } if (nodestr == "1" || nodestr == "2" || nodestr == "3" || nodestr == "4" || nodestr == "5" || nodestr == "6" || nodestr == "no") { MsgBox.Show("固定分类不许修改!"); return; } FrmAddPN frm = new FrmAddPN(); //frm.TypeTitle = treeList1.FocusedNode.GetValue("Title").ToString(); frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString(); frm.Text = "修改分类名"; frm.SetLabelName = "分类名称"; if (frm.ShowDialog() == DialogResult.OK) { Ps_Table_500Result table1 = new Ps_Table_500Result(); table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_500Result>(treeList1.FocusedNode.GetValue("ID")); table1.Title = frm.ParentName; try { Common.Services.BaseService.Update<Ps_Table_500Result>(table1); treeList1.FocusedNode.SetValue("Title", frm.ParentName); } catch { } //catch(Exception ex) //{ // MsgBox.Show("修改出错:" + ex.Message); //} } }
private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } if (!base.DeleteRight) { MsgBox.Show("您没有权限进行此项操作!"); return; } string nodestr = treeList1.FocusedNode.GetValue("Col1").ToString(); if (nodestr == "1" || nodestr == "2" || nodestr == "3" || nodestr == "4" || nodestr == "5" || nodestr == "6" || nodestr == "no") { MsgBox.Show("固定分类不许删除!"); return; } string parentid = treeList1.FocusedNode["ParentID"].ToString(); if (treeList1.FocusedNode.HasChildren) { MsgBox.Show("此分类下有子分类,请先删除子分类!"); return; } if(MsgBox.ShowYesNo("是否删除分类 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes) { Ps_Table_500Result table1 = new Ps_Table_500Result(); // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode); table1.ID = treeList1.FocusedNode.GetValue("ID").ToString(); try { //DeletePSP_ValuesByType里面删除数据和分类 Common.Services.BaseService.Delete <Ps_Table_500Result>(table1);//("DeletePs_Table_500Result", table1); TreeListNode brotherNode = null; if(treeList1.FocusedNode.ParentNode.Nodes.Count > 1) { brotherNode = treeList1.FocusedNode.PrevNode; if(brotherNode == null) { brotherNode = treeList1.FocusedNode.NextNode; } } treeList1.DeleteNode(treeList1.FocusedNode); //删除后,如果同级还有其它分类,则重新计算此类的所有年份数据 if(brotherNode != null) { foreach(TreeListColumn column in treeList1.Columns) { if (column.Caption.IndexOf("年") > 0) { CalculateSum(brotherNode, column); } } } } catch (Exception ex) { //MsgBox.Show("删除出错:" + ex.Message); this.Cursor = Cursors.WaitCursor; treeList1.BeginUpdate(); LoadData(); treeList1.EndUpdate(); this.Cursor = Cursors.Default; } } }
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 (treeList1.FocusedNode.GetValue("Col1").ToString() == "no" || focusedNode.GetValue("ParentID").ToString()=="0") { MsgBox.Show( focusedNode.GetValue("Title").ToString()+"不允许添加子分类!"); return; } FrmAddPN frm = new FrmAddPN(); frm.Text = "增加" + focusedNode.GetValue("Title") + "的子分类"; frm.SetLabelName = "子分类名称"; if (focusedNode.GetValue("Title").ToString() == "二、220千伏直供负荷") frm.SetCheckVisible(); if(frm.ShowDialog() == DialogResult.OK) { Ps_Table_500Result table1 = new Ps_Table_500Result(); table1.ID += "|" + GetProjectID; table1.Title = frm.ParentName; table1.ParentID = focusedNode.GetValue("ID").ToString(); table1.ProjectID = GetProjectID; table1.Col1 = "child"; table1.Col2 = treeList1.FocusedNode.GetValue("Col1").ToString(); table1.Sort = OperTable.Get500ResultMaxSort()+1; if (frm.BCheck == true) table1.Col3 = "check"; try { Common.Services.BaseService.Create("InsertPs_Table_500Result", table1); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow())); } catch(Exception ex) { MsgBox.Show("增加子分类出错:" + ex.Message); } } }
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 DelAll(string suid) { string conn = "ParentId='" + suid + "'"; IList<Ps_Table_500Result> list = Common.Services.BaseService.GetList<Ps_Table_500Result>("SelectPs_Table_500ResultByConn", conn); if (list.Count > 0) { foreach (Ps_Table_500Result var in list) { string child = var.ID; DelAll(child); Ps_Table_500Result ny = new Ps_Table_500Result(); ny.ID = child; Common.Services.BaseService.Delete(ny); } } else return; }
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; }
private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode == null) { return; } if (!base.DeleteRight) { MsgBox.Show("您没有权限进行此项操作!"); return; } if (treeList1.FocusedNode.GetValue("ParentID").ToString() != "0") { MsgBox.Show("此分类不是总分类!"); return; } if (MsgBox.ShowYesNo("总分类及其下属分类都将删除,是否删除总分类 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes) { Ps_Table_500Result table1 = new Ps_Table_500Result(); // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode); table1.ID = treeList1.FocusedNode.GetValue("ID").ToString(); DelAll(table1.ID); try { //DeletePSP_ValuesByType里面删除数据和分类 Common.Services.BaseService.Delete<Ps_Table_500Result>(table1);//("DeletePs_Table_500Result", table1); treeList1.DeleteNode(treeList1.FocusedNode); //treeList1.ExpandAll(); //删除后,如果同级还有其它分类,则重新计算此类的所有年份数据 } catch (Exception ex) { //MsgBox.Show("删除出错:" + ex.Message); this.Cursor = Cursors.WaitCursor; treeList1.BeginUpdate(); LoadData(); treeList1.EndUpdate(); this.Cursor = Cursors.Default; } } }