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; } FrmAddTzgs frm = new FrmAddTzgs(); frm.Text = "增加" + focusedNode.GetValue("Title") + "的子分类"; frm.Stat = focusedNode.GetValue("Col2").ToString(); // frm.SetLabelName = "子分类名称"; if(frm.ShowDialog() == DialogResult.OK) { Ps_Table_TZGS table1 = new Ps_Table_TZGS(); 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 = "0"; 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(yAnge.StartYear + 1)).SetValue(table1, frm.AllVol, null); //table1.Col2 = treeList1.FocusedNode.GetValue("Col1").ToString(); table1.Sort = OperTable.GetTZGSMaxSort()+1; table1.Col3 = frm.Col3; table1.Col1 = frm.BieZhu; try { Common.Services.BaseService.Create("InsertPs_Table_TZGS", 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 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") { 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_TZGS table1 = new Ps_Table_TZGS(); table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_TZGS>(treeList1.FocusedNode.GetValue("ID")); table1.Title = frm.ParentName; table1.Col2 = "no"; try { Common.Services.BaseService.Update<Ps_Table_TZGS>(table1); treeList1.FocusedNode.SetValue("Title", frm.ParentName); } catch { } //catch(Exception ex) //{ // MsgBox.Show("修改出错:" + ex.Message); //} } } else { FrmAddTzgs frm = new FrmAddTzgs(); Ps_Table_TZGS table = new Ps_Table_TZGS(); table = Common.Services.BaseService.GetOneByKey<Ps_Table_TZGS>(treeList1.FocusedNode.GetValue("ID")); frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString(); 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; 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; table.GetType().GetProperty("y" + Convert.ToString(yAnge.StartYear + 1)).SetValue(table, temp + double.Parse(table.GetType().GetProperty("y" + Convert.ToString(yAnge.StartYear + 1)).GetValue(table,null).ToString()), null); table.Col1 = frm.BieZhu; table.Col3 = frm.Col3; table.BianInfo = frm.BianInfo; table.LineInfo = frm.LineInfo; try { Common.Services.BaseService.Update<Ps_Table_TZGS>(table); AddChildVol(table, true); LoadData1(); FoucsLocation(table.ID, treeList1.Nodes); } catch { } } } }