/// <summary> /// 当TextBox失去焦点时发生此事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renametextbox_LostFous(object sender, RoutedEventArgs e) { tempTextBox.Visibility = Visibility.Collapsed; if (this.tv_Category.SelectedItem == null)//检查是否有节点选中 { } else {//有节点选中,添加当前选中节点的子节点 ActivityGuaranteeType orgInfo = tv_Category.SelectedItem as ActivityGuaranteeType; if (string.IsNullOrEmpty(orgInfo.NAME)) { MessageBox.Show("名称不能为空", "消息提示", MessageBoxButton.OK); orgInfo.NAME = tempName; //getGuaranteeTypeList(); return; } if (orgInfo != null) { //保存到数据库 PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.ActivitySummarize.I_CO_IA_ActivitySummarize>(channel => { //更新当前节点 channel.UpdateActivityGuaranteeType(orgInfo); }); } } this.isRename = false; }
private void AddTreeViewItem_Click(object sender, RoutedEventArgs e) { //添加树 if (tv_Category.Items.Count > 0) { ActivityGuaranteeType info = tv_Category.Items[0] as ActivityGuaranteeType; if (info != null) { ActivityGuaranteeType tempInfo = new ActivityGuaranteeType(); tempInfo.GUID = CO_IA.Client.Utility.NewGuid(); tempInfo.ACTIVITYGUID = info.ACTIVITYGUID; tempInfo.PARENTGUID = info.GUID; tempInfo.NAME = "分类名称"; info.Children.Add(tempInfo); //保存到数据库 PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.ActivitySummarize.I_CO_IA_ActivitySummarize>(channel => { //更新当前节点 channel.SaveActivityGuaranteeType(tempInfo); }); this.tv_Category.ItemsSource = null; this.tv_Category.ItemsSource = itemList; //界面赋值 //SetOrgInfoDetails(tempOrgInfo); } } }
private void DelTreeViewItem_Click(object sender, RoutedEventArgs e) { if (this.tv_Category.SelectedItem == null)//检查是否有节点选中 { } else {//有节点选中,添加当前选中节点的子节点 ActivityGuaranteeType info = tv_Category.SelectedItem as ActivityGuaranteeType; if (info != null) { if (info.PARENTGUID != "") { MessageBoxResult result = MessageBox.Show("您确认要删除当前节点么?", "删除当前节点", MessageBoxButton.YesNo); if (result == MessageBoxResult.OK || result == MessageBoxResult.Yes) { RemovePPOrginfoFromeList(info.PARENTGUID, info, this.itemList); bool isAllSuccessfull = true; //从数据库删除数据 PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.ActivitySummarize.I_CO_IA_ActivitySummarize>(channel => { //删除当前节点 isAllSuccessfull = channel.DeleteActivityGuaranteeType(info.GUID); }); if (isAllSuccessfull == true) { PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.PersonSchedule.I_CO_IA_PersonSchedule>(channel => { //删除当前节点子节点 channel.DeletePP_OrgInfoByParentID(info.GUID); }); this.tv_Category.ItemsSource = null; this.tv_Category.ItemsSource = itemList; if (this.tv_Category.Items.Count > 0) { //itemOrgInfo = this.tv_Category.Items[0] as ActivityGuaranteeType; //界面赋值 //SetOrgInfoDetails(itemOrgInfo); } } else { MessageBox.Show("删除节点信息失败!"); } } } else { MessageBoxResult result = MessageBox.Show("不允许删除根节点!", "删除根节点", MessageBoxButton.OK); } } } }
//无限接循环子节点添加到根节点下面 private void ForeachPropertyNode(ActivityGuaranteeType node, string pid, List <ActivityGuaranteeType> nodes) { foreach (ActivityGuaranteeType tempNode in nodes) { if (tempNode.PARENTGUID == pid) { ForeachPropertyNode(tempNode, tempNode.GUID, nodes); node.Children.Add(tempNode); } } }
private void tv_Category_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { ActivityGuaranteeType info = ((System.Windows.Controls.TreeView)(sender)).SelectedItem as ActivityGuaranteeType; if (info != null && !string.IsNullOrEmpty(info.PARENTGUID)) { type = info.GUID; } else { type = ""; } getGuaranteeProcessList(type); }
/// <summary> /// 移除特定的节点 /// </summary> /// <param name="PARENT_GUID"></param> /// <param name="tarOrgInfo"></param> /// <param name="orgList"></param> private void RemovePPOrginfoFromeList(string PARENT_GUID, ActivityGuaranteeType tarOrgInfo, List <ActivityGuaranteeType> orgList) { foreach (ActivityGuaranteeType orginfo in orgList) { if (orginfo.GUID == PARENT_GUID) { orginfo.Children.Remove(tarOrgInfo); break; } else if (orginfo.Children.Count > 0) { RemovePPOrginfoFromeList(PARENT_GUID, tarOrgInfo, orginfo.Children); } } }
private void tabVategory_SelectionChanged(object sender, SelectionChangedEventArgs e) { ActivityGuaranteeType info = ((System.Windows.Controls.TabControl)(sender)).SelectedItem as ActivityGuaranteeType; if (info != null && !string.IsNullOrEmpty(info.PARENTGUID)) { type = info.GUID; } else { type = ""; } getGuaranteeProcessList(type); //System.Windows.Controls.ListBox listB = (System.Windows.Controls.ListBox)sender; }
private void createGuaranteeType() { ActivityGuaranteeType entity = new ActivityGuaranteeType(); entity.GUID = CO_IA.Client.Utility.NewGuid(); entity.NAME = "保障类型"; entity.ACTIVITYGUID = activityGuid; bool bl = false; PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.ActivitySummarize.I_CO_IA_ActivitySummarize>(channel => { bl = channel.SaveActivityGuaranteeType(entity); }); if (!bl) { MessageBox.Show("系统默认创建类型失败。"); } itemList.Add(entity); this.tv_Category.ItemsSource = null; this.tv_Category.ItemsSource = itemList; }
/// <summary> /// 获取/初始化保障类型 /// </summary> private void getGuaranteeTypeList() { Activity activity = CO_IA.Client.RiasPortal.ModuleContainer.Activity; if (activity == null || String.IsNullOrEmpty(activity.Guid)) { createGuaranteeType(); } else { List <ActivityGuaranteeType> nodes = new List <ActivityGuaranteeType>(); PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.ActivitySummarize.I_CO_IA_ActivitySummarize>(channel => { //更新当前节点 nodes = channel.GetActivityGuaranteeType(activityGuid); }); if (nodes.Count() == 0) { createGuaranteeType(); } else { tv_Category.ItemsSource = null; ActivityGuaranteeType temp = new ActivityGuaranteeType(); foreach (ActivityGuaranteeType type in nodes) { if (string.IsNullOrEmpty(type.PARENTGUID)) { temp = type; break; } } ForeachPropertyNode(temp, temp.GUID, nodes); itemList.Add(temp); this.tv_Category.ItemsSource = itemList; } } }
/// <summary> /// 当TextBox失去焦点时发生此事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renametextbox_LostFous(object sender, RoutedEventArgs e) { tempTextBox.Visibility = Visibility.Collapsed; if (this.tabVategory.SelectedItem == null)//检查是否有节点选中 { } else {//有节点选中,添加当前选中节点的子节点 ActivityGuaranteeType orgInfo = tabVategory.SelectedItem as ActivityGuaranteeType; if (orgInfo != null) { //保存到数据库 PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.ActivitySummarize.I_CO_IA_ActivitySummarize>(channel => { //更新当前节点 channel.UpdateActivityGuaranteeType(orgInfo); }); } } this.isRename = false; }