SetectManByDept.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Infragistics.Win.UltraWinTree;
  10. using com.hnshituo.core.vo;
  11. using CoreFS.CA06;using Pur.Entity;using Pur.Entity;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.Mes.Client.Comm.Control;
  14. using Pur.Entity.Core;
  15. namespace Pur.configure
  16. {
  17. public partial class SetectManByDept : FrmPmsBase
  18. {
  19. public string strTips = "0";
  20. public string StrUserID = "";
  21. public string StrUserName = "";
  22. public string StrDeptId = "";
  23. public string StrDeptName = "";
  24. public SetectManByDept()
  25. {
  26. InitializeComponent();
  27. }
  28. public SetectManByDept(OpeBase ob)
  29. {
  30. this.ob = ob;
  31. InitializeComponent();
  32. }
  33. public SetectManByDept(OpeBase ob, string strDeptName)
  34. {
  35. this.ob = ob;
  36. InitializeComponent();
  37. StrDeptName = strDeptName;
  38. }
  39. private void SetectManByDept_Load(object sender, EventArgs e)
  40. {
  41. DataTable dt = new DataTable();
  42. try
  43. {
  44. dt = this.execute<DataTable>("com.hnshituo.core.service.AppDepartmentService", "findAll", new object[] { });
  45. }
  46. catch (Exception ex)
  47. {
  48. MessageBox.Show("查询部门信息失败:"+ex.Message, "提示");
  49. return;
  50. }
  51. if (dt != null || dt.Rows.Count > 0)
  52. {
  53. AppUser man = new AppUser();
  54. dt_Purmanclass = dt;//保存部门信息
  55. getultree(dt);//绑定部门信息
  56. getMan(man);//查询人员
  57. //激活部门科室
  58. UltraTreeNode utnd = ultraTreeDept.GetNodeByKey(StrDeptName);
  59. ultraTreeDept.ActiveNode = utnd;
  60. StrDeptName = "";
  61. }
  62. else
  63. {
  64. MessageBox.Show("没有查询到任何部门信息", "提示");
  65. return;
  66. }
  67. }
  68. /// <summary>
  69. /// 获取物料分类树形结构
  70. /// </summary>
  71. DataTable dt_Purmanclass = null;
  72. public void getultree(DataTable dt)
  73. {
  74. ultraTreeDept.Nodes.Clear();
  75. if (dt == null || dt.Rows.Count < 1)
  76. {
  77. return;
  78. }
  79. dt_Purmanclass = dt;//保存部门分类全局变量
  80. DataTable dt_A = new DataTable();//部门分类
  81. //筛选出根节点
  82. DataRow[] rows = dt.Select("PID='' or PID is null");
  83. dt_A = dt.Clone(); //克隆A的结构
  84. foreach (DataRow row in rows)
  85. {
  86. dt_A.ImportRow(row);//复制行数据
  87. }
  88. //添加物料大类
  89. for (int j = 0; j < dt_A.Rows.Count; j++)
  90. {
  91. UltraTreeNode Ultnode = ultraTreeDept.Nodes.Add(dt_A.Rows[j]["DEPARTID"].ToString(), dt_A.Rows[j]["DEPARTNAME"].ToString());
  92. getChildNodes(Ultnode);
  93. }
  94. }
  95. /// <summary>
  96. /// 递归查询父节点下的所有子节点
  97. /// </summary>
  98. /// <param name="Tnode"></param>
  99. public void getChildNodes(UltraTreeNode Tnode)
  100. {
  101. DataTable dt_A = dt_Purmanclass.Clone();//物料分类
  102. DataRow[] rows = dt_Purmanclass.Select("PID='" + Tnode.Key + "'");
  103. foreach (DataRow row in rows)
  104. {
  105. dt_A.ImportRow(row);//复制行数据
  106. }
  107. //添加物料分类
  108. for (int j = 0; j < dt_A.Rows.Count; j++)
  109. {
  110. UltraTreeNode Ultnode = Tnode.Nodes.Add(dt_A.Rows[j]["DEPARTID"].ToString(), dt_A.Rows[j]["DEPARTNAME"].ToString());
  111. getChildNodes(Ultnode);//利用递归将当前节点的子节点添加进去
  112. }
  113. }
  114. /// <summary>
  115. /// 查询物料
  116. /// </summary>
  117. private void getMan(AppUser man)
  118. {
  119. try
  120. {
  121. //man.Username = tbxUserNameQ.Text.Trim();
  122. //man.Userid = tbxUserIdQ.Text.Trim();
  123. DataTable dt_man = this.execute<DataTable>("com.hnshituo.core.service.AppUserService", "pageQueryChatManList1", new object[] { man });
  124. //DataTable dt_man = this.execute<DataTable>("com.hnshituo.core.service.AppUserService", "find", new object[] { man, 0, 0 });
  125. if(dt_man !=null||dt_man.Rows.Count>0)
  126. {
  127. dataTable1.Rows.Clear();
  128. GridHelper.CopyDataToDatatable(ref dt_man, ref dataTable1, true);
  129. GridHelper.RefreshAndAutoSize(ultraGrid1);
  130. }
  131. }
  132. catch (Exception ex)
  133. {
  134. MessageBox.Show("查询人员信息失败:" + ex.Message, "提示");
  135. return;
  136. }
  137. }
  138. private void QueryButton_Click(object sender, EventArgs e)
  139. {
  140. AppUser man = new AppUser();
  141. man.Userid =tbxUserIdQ.Text.ToString().Trim();
  142. man.Username = tbxUserNameQ.Text.ToString().Trim();
  143. getMan(man);
  144. }
  145. UltraTreeNode qUltraNode = null;
  146. private void ultraTreeDept_AfterSelect(object sender, SelectEventArgs e)
  147. {
  148. }
  149. private void SureButton_Click(object sender, EventArgs e)
  150. {
  151. returnMan();
  152. }
  153. private void returnMan()
  154. {
  155. UltraGridRow row = ultraGrid1.ActiveRow;
  156. if (row == null)
  157. {
  158. MessageBox.Show("请选择人员", "提示");
  159. }
  160. StrUserID = row.Cells["userid"].Value.ToString();
  161. StrUserName = row.Cells["username"].Value.ToString();
  162. StrDeptId = row.Cells["deptid"].Value.ToString();
  163. StrDeptName = row.Cells["duty"].Value.ToString();
  164. strTips = "1";
  165. this.Close();
  166. }
  167. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  168. {
  169. ultraGrid1.UpdateData();
  170. if (Convert.ToBoolean(e.Cell.Row.Cells["isSelect"].Value)==false)
  171. {
  172. foreach (UltraGridRow row in ultraGrid1.Rows)
  173. {
  174. row.Cells["isSelect"].Value=false;
  175. }
  176. e.Cell.Row.Cells["isSelect"].Value = true;
  177. }
  178. }
  179. private void ultraTreeDept_AfterActivate(object sender, NodeEventArgs e)
  180. {
  181. AppUser eMan = new AppUser();
  182. ultraTreeDept.ActiveNode.Expanded = true;
  183. qUltraNode = ultraTreeDept.ActiveNode;
  184. eMan.Deptid = qUltraNode.Key;
  185. getMan(eMan);
  186. }
  187. private void ultraGrid1_DoubleClickRow(object sender, DoubleClickRowEventArgs e)
  188. {
  189. returnMan();
  190. }
  191. }
  192. }