NewProjrctPage.xaml.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 Page_Loaded(object sender, RoutedEventArgs e)
  37. {
  38. //初始化业态数据
  39. List<string> business = new List<string>() { "住宅", "公寓", "宿舍", "医疗", "商业", "学校", "其他" };
  40. cb_staus.ItemsSource = business;
  41. cb_staus.SelectedItem = business.FirstOrDefault();
  42. //初始化项目地址
  43. List<string> paths = new List<string>() { "山东","山西", "河北","河南", "江苏","浙江",
  44. "辽宁","吉林", "黑龙江","安徽", "福建","江西",
  45. "湖北","湖南", "广东","海南", "四川","贵州",
  46. "云南","陕西", "甘肃","青海", "台湾","内蒙古", "广西",
  47. "西藏", "宁夏","新疆","北京","天津","上海","重庆",
  48. "香港","澳门"};
  49. cb_Path.ItemsSource = paths;
  50. cb_Path.SelectedItem = paths.FirstOrDefault();
  51. }
  52. /// <summary>
  53. /// 青蓝小助手提示关闭事件
  54. /// </summary>
  55. /// <param name="sender"></param>
  56. /// <param name="e"></param>
  57. private void close_Click(object sender, RoutedEventArgs e)
  58. {
  59. gd_top.Visibility = Visibility.Collapsed;
  60. }
  61. /// <summary>
  62. /// 新增楼栋
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void bt_build_Click(object sender, RoutedEventArgs e)
  67. {
  68. string buildName = tb_buildName.Text.ToString();
  69. if (buildName == null || buildName == "")
  70. {
  71. MessageBox.Show("请输入新增楼栋名称");
  72. return;
  73. }
  74. TextBox textBox = new TextBox();
  75. textBox.Width = 100;
  76. textBox.Text = buildName;
  77. DockPanel dockPanel = new DockPanel();
  78. dockPanel.Margin = new Thickness(30, 10, 0, 0);
  79. dockPanel.HorizontalAlignment = HorizontalAlignment.Left;
  80. dockPanel.Children.Add(textBox);
  81. sp_buildNames.Children.Add(dockPanel);
  82. tb_buildName.Text = "";
  83. }
  84. /// <summary>
  85. /// 提交项目
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void bt_addPorject_Click(object sender, RoutedEventArgs e)
  90. {
  91. //项目名称
  92. string projectName = tb_projectName.Text.ToString();
  93. if (projectName == null || projectName == "")
  94. {
  95. MessageBox.Show("请输入项目名称");
  96. return;
  97. }
  98. //项目业态
  99. string businessName = cb_staus.SelectedItem.ToString();
  100. if (businessName == null || businessName == "")
  101. {
  102. MessageBox.Show("请输入项目业态");
  103. return;
  104. }
  105. //项目地址
  106. string pathName = cb_Path.SelectedItem.ToString();
  107. if (pathName == null || pathName == "")
  108. {
  109. MessageBox.Show("请输入项目地址");
  110. return;
  111. }
  112. //楼栋名称
  113. BuildNames = new List<string>();
  114. GetBuildNames(sp_buildNames);
  115. //项目信息
  116. ProjectEntity projectEntity = new ProjectEntity(projectName, businessName, pathName);
  117. List<ProjectEntity> buildDatas = new List<ProjectEntity>();
  118. foreach (var buildName in BuildNames)
  119. {
  120. //项目信息
  121. ProjectEntity subData1 = new ProjectEntity("项目信息", projectEntity);
  122. //团队成员
  123. Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
  124. keyValuePairs.Add("主管", "");
  125. keyValuePairs.Add("建筑", "");
  126. keyValuePairs.Add("结构", "");
  127. keyValuePairs.Add("给排水", "");
  128. keyValuePairs.Add("暖通", "");
  129. keyValuePairs.Add("电气", "");
  130. ProjectEntity subData2 = new ProjectEntity("团队成员", keyValuePairs);
  131. //工作台
  132. OperatingFloorData operatingFloorData = new OperatingFloorData(projectName);
  133. ProjectEntity subData3 = new ProjectEntity("工作台", operatingFloorData);
  134. //自定义
  135. ProjectEntity subData4 = new ProjectEntity("自定义", new List<ProjectEntity>());
  136. //添加数据
  137. buildDatas.Add(new ProjectEntity(buildName, new List<ProjectEntity>() { subData1, subData2, subData3, subData4 }));
  138. }
  139. ProjectEntity projectInfo = new ProjectEntity(projectName, buildDatas);
  140. //存储消息数据
  141. if (!projectName.Contains("项目")) projectName = projectName + " 项目";
  142. //二级菜单
  143. string seconNode = projectName + "建筑" + "图纸更新";
  144. bool isExisteSecon = false;
  145. for (int i = 0; i < SeconMessagePage.MessageDatas.Count; i++)
  146. {
  147. MessageData existMessageData = SeconMessagePage.MessageDatas[i];
  148. if (existMessageData.SeconNode.Equals(seconNode))
  149. {
  150. foreach (var item in BuildNames)
  151. {
  152. string addStringName = projectName + item + "更新";
  153. bool isExisteThree = false;
  154. foreach (var threeNode in SeconMessagePage.MessageDatas[i].ThreeNodes)
  155. {
  156. if (addStringName.Equals(threeNode))
  157. {
  158. isExisteThree = true;
  159. }
  160. }
  161. if (!isExisteThree)
  162. {
  163. SeconMessagePage.MessageDatas[i].ThreeNodes.Add(addStringName);
  164. }
  165. }
  166. isExisteSecon = true;
  167. break;
  168. }
  169. }
  170. if (!isExisteSecon)
  171. {
  172. MessageData newMessageData = new MessageData();
  173. newMessageData.SeconNode = seconNode;
  174. foreach (var item in BuildNames)
  175. {
  176. newMessageData.ThreeNodes.Add(projectName + "建筑" + item + "更新");
  177. }
  178. SeconMessagePage.MessageDatas.Add(newMessageData);
  179. }
  180. //messageData
  181. SeconProjectPage.ProjectEntities.Add(projectInfo);
  182. SeconProjectPage.FlushData();
  183. }
  184. /// <summary>
  185. /// 所有的楼栋名称
  186. /// </summary>
  187. public List<string> BuildNames = new List<string>();
  188. /// <summary>
  189. /// 获取所有的楼栋名称
  190. /// </summary>
  191. /// <param name="obj"></param>
  192. public void GetBuildNames(DependencyObject obj)
  193. {
  194. for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
  195. {
  196. DependencyObject child = VisualTreeHelper.GetChild(obj, i);
  197. if (child is TextBox textBox)
  198. {
  199. BuildNames.Add(textBox.Text.ToString());
  200. }
  201. GetBuildNames(child);
  202. }
  203. }
  204. }
  205. }