NewProjrctPage.xaml.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. using CollaborativePlatformMain.DFEntity.MessageSubUtil;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace CollaborativePlatformMain.Form.MessageSubPage.Project
  16. {
  17. /// <summary>
  18. /// NewProjrctPage.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class NewProjrctPage : Page
  21. {
  22. /// <summary>
  23. /// 父级窗体
  24. /// </summary>
  25. public SeconProjectPage SeconProjectPage;
  26. public NewProjrctPage(SeconProjectPage seconProjectPage)
  27. {
  28. InitializeComponent();
  29. SeconProjectPage = seconProjectPage;
  30. }
  31. /// <summary>
  32. /// 青蓝小助手提示关闭事件
  33. /// </summary>
  34. /// <param name="sender"></param>
  35. /// <param name="e"></param>
  36. private void close_Click(object sender, RoutedEventArgs e)
  37. {
  38. gd_top.Visibility = Visibility.Collapsed;
  39. }
  40. /// <summary>
  41. /// 新增楼栋
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. private void bt_build_Click(object sender, RoutedEventArgs e)
  46. {
  47. string buildName = tb_buildName.Text.ToString();
  48. if (buildName == null || buildName == "")
  49. {
  50. MessageBox.Show("请输入新增楼栋名称");
  51. return;
  52. }
  53. TextBox textBox = new TextBox();
  54. textBox.Width = 100;
  55. textBox.Text = buildName;
  56. DockPanel dockPanel = new DockPanel();
  57. dockPanel.Margin = new Thickness(30, 10, 0, 0);
  58. dockPanel.HorizontalAlignment = HorizontalAlignment.Left;
  59. dockPanel.Children.Add(textBox);
  60. sp_buildNames.Children.Add(dockPanel);
  61. tb_buildName.Text = "";
  62. }
  63. /// <summary>
  64. /// 提交项目
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void bt_addPorject_Click(object sender, RoutedEventArgs e)
  69. {
  70. //项目名称
  71. string projectName = tb_projectName.Text.ToString();
  72. if (projectName == null || projectName == "")
  73. {
  74. MessageBox.Show("请输入项目名称");
  75. return;
  76. }
  77. //项目业态
  78. string businessName = tb_staus.Text.ToString();
  79. if (businessName == null || businessName == "")
  80. {
  81. MessageBox.Show("请输入项目业态");
  82. return;
  83. }
  84. //项目地址
  85. string pathName = tb_Path.Text.ToString();
  86. if (pathName == null || pathName == "")
  87. {
  88. MessageBox.Show("请输入项目地址");
  89. return;
  90. }
  91. //楼栋名称
  92. BuildNames = new List<string>();
  93. GetBuildNames(sp_buildNames);
  94. //项目信息
  95. ProjectEntity projectEntity = new ProjectEntity(projectName, businessName, pathName);
  96. List<ProjectEntity> buildDatas = new List<ProjectEntity>();
  97. foreach (var buildName in BuildNames)
  98. {
  99. //项目信息
  100. ProjectEntity subData1 = new ProjectEntity("项目信息", projectEntity);
  101. //团队成员
  102. Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
  103. keyValuePairs.Add("主管", "");
  104. keyValuePairs.Add("建筑", "");
  105. keyValuePairs.Add("结构", "");
  106. keyValuePairs.Add("给排水", "");
  107. keyValuePairs.Add("暖通", "");
  108. keyValuePairs.Add("电气", "");
  109. ProjectEntity subData2 = new ProjectEntity("团队成员", keyValuePairs);
  110. //工作台
  111. OperatingFloorData operatingFloorData = new OperatingFloorData(projectName);
  112. ProjectEntity subData3 = new ProjectEntity("工作台", operatingFloorData);
  113. //自定义
  114. ProjectEntity subData4 = new ProjectEntity("自定义", new List<ProjectEntity>());
  115. //添加数据
  116. buildDatas.Add(new ProjectEntity(buildName, new List<ProjectEntity>() { subData1, subData2, subData3, subData4 }));
  117. }
  118. ProjectEntity projectInfo = new ProjectEntity(projectName, buildDatas);
  119. //存储消息数据
  120. if (!projectName.Contains("项目")) projectName = projectName + " 项目";
  121. //二级菜单
  122. string seconNode = projectName + "建筑" + "图纸更新";
  123. bool isExisteSecon = false;
  124. for (int i = 0; i < SeconMessagePage.MessageDatas.Count; i++)
  125. {
  126. MessageData existMessageData = SeconMessagePage.MessageDatas[i];
  127. if (existMessageData.SeconNode.Equals(seconNode))
  128. {
  129. foreach (var item in BuildNames)
  130. {
  131. string addStringName = projectName + item + "更新";
  132. bool isExisteThree = false;
  133. foreach (var threeNode in SeconMessagePage.MessageDatas[i].ThreeNodes)
  134. {
  135. if (addStringName.Equals(threeNode))
  136. {
  137. isExisteThree = true;
  138. }
  139. }
  140. if (!isExisteThree)
  141. {
  142. SeconMessagePage.MessageDatas[i].ThreeNodes.Add(addStringName);
  143. }
  144. }
  145. isExisteSecon = true;
  146. break;
  147. }
  148. }
  149. if (!isExisteSecon)
  150. {
  151. MessageData newMessageData = new MessageData();
  152. newMessageData.SeconNode = seconNode;
  153. foreach (var item in BuildNames)
  154. {
  155. newMessageData.ThreeNodes.Add(projectName + "建筑" + item + "更新");
  156. }
  157. SeconMessagePage.MessageDatas.Add(newMessageData);
  158. }
  159. //messageData
  160. SeconProjectPage.ProjectEntities.Add(projectInfo);
  161. SeconProjectPage.FlushData();
  162. }
  163. /// <summary>
  164. /// 所有的楼栋名称
  165. /// </summary>
  166. public List<string> BuildNames = new List<string>();
  167. /// <summary>
  168. /// 获取所有的楼栋名称
  169. /// </summary>
  170. /// <param name="obj"></param>
  171. public void GetBuildNames(DependencyObject obj)
  172. {
  173. for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
  174. {
  175. DependencyObject child = VisualTreeHelper.GetChild(obj, i);
  176. if (child is TextBox textBox)
  177. {
  178. BuildNames.Add(textBox.Text.ToString());
  179. }
  180. GetBuildNames(child);
  181. }
  182. }
  183. }
  184. }