//删除结点 public void DeleteNode(TreeListNode tln) { if (tln.HasChildren) { for (int i = 0; i < tln.Nodes.Count; i++) { DeleteNode(tln.Nodes[i]); } DeleteNode(tln); } else { PDrelregion pf = new PDrelregion(); pf.ID = tln["ID"].ToString(); string nodestr = tln["AreaName"].ToString(); try { TreeListNode node = tln.TreeList.FindNodeByKeyID(pf.ID); if (node != null) tln.TreeList.DeleteNode(node); RemoveDataTableRow(dataTable, pf.ID); Itop.Client.Common.Services.BaseService.Delete<PDrelregion>(pf); } catch (Exception e) { MessageBox.Show(e.Message + "删除结点出错!"); } } }
//private void UcPdtype_Load(object sender, EventArgs e) { // init(); //} private void treeList1_MouseClick(object sender, MouseEventArgs e) { if (FocusedNodeChanged != null) { TreeListNode tn = treeList1.FocusedNode; if (tn==null) { return; } PDrelregion pdr = new PDrelregion(); pdr.ID = tn["ID"].ToString(); pdr = Services.BaseService.GetOneByKey<PDrelregion>(pdr); FocusedNodeChanged(treeList1, pdr); } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { PDtypefrmedit PDT = new PDtypefrmedit(); if (PDT.ShowDialog()==DialogResult.OK) { PDrelregion pdr = new PDrelregion(); pdr.ProjectID = Itop.Client.MIS.ProgUID; pdr.PeopleSum = PDT.Peplesum; pdr.AreaName = PDT.Areaname; pdr.Year = PDT.Year; Services.BaseService.Create<PDrelregion>(pdr); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(pdr, dataTable.NewRow())); //init(); } }
public void init() { try { if (dataTable != null) { dataTable.Columns.Clear(); treeList1.Columns.Clear(); } AddFixColumn(); PDrelregion pr = new PDrelregion(); pr.ProjectID = Itop.Client.MIS.ProgUID; IList<PDrelregion> listTypes = Services.BaseService.GetList<PDrelregion>("SelectPDrelregionByProjectID", pr); dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(PDrelregion)); treeList1.BeginInit(); treeList1.DataSource = dataTable; //treeList1.Columns["Sort"].SortOrder = SortOrder.Ascending; treeList1.EndInit(); Application.DoEvents(); treeList1.ExpandAll(); } catch (System.Exception ex) { } }