FrmSetDepart.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using Core.Mes.IBaseInterface;
  7. using Core.Mes.ClientFrameWork;
  8. //using Core.Mes.ServerFrameWork;
  9. using System.Data;
  10. using Infragistics.Win.UltraWinTree;
  11. namespace Core.Mes.ClientPurviewManager
  12. {
  13. /// <summary>
  14. /// FrmSetDepart 的摘要说明。
  15. /// </summary>
  16. public class FrmSetDepart : System.Windows.Forms.Form
  17. {
  18. private Core.Mes.ClientPurviewManager.UcDepartment ucDepartment1;
  19. private Infragistics.Win.Misc.UltraLabel ultraLabel1;
  20. private Infragistics.Win.UltraWinEditors.UltraTextEditor ultraTextEditor1;
  21. private Infragistics.Win.Misc.UltraButton Button1;
  22. private Infragistics.Win.Misc.UltraButton Button2;
  23. /// <summary>
  24. /// 必需的设计器变量。
  25. /// </summary>
  26. private System.ComponentModel.Container components = null;
  27. public FrmSetDepart()
  28. {
  29. //
  30. // Windows 窗体设计器支持所必需的
  31. //
  32. InitializeComponent();
  33. //
  34. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  35. //
  36. }
  37. /// <summary>
  38. /// 清理所有正在使用的资源。
  39. /// </summary>
  40. protected override void Dispose( bool disposing )
  41. {
  42. if( disposing )
  43. {
  44. if(components != null)
  45. {
  46. components.Dispose();
  47. }
  48. }
  49. base.Dispose( disposing );
  50. }
  51. #region Windows 窗体设计器生成的代码
  52. /// <summary>
  53. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  54. /// 此方法的内容。
  55. /// </summary>
  56. private void InitializeComponent()
  57. {
  58. this.ucDepartment1 = new Core.Mes.ClientPurviewManager.UcDepartment();
  59. this.Button1 = new Infragistics.Win.Misc.UltraButton();
  60. this.Button2 = new Infragistics.Win.Misc.UltraButton();
  61. this.ultraLabel1 = new Infragistics.Win.Misc.UltraLabel();
  62. this.ultraTextEditor1 = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
  63. ((System.ComponentModel.ISupportInitialize)(this.ultraTextEditor1)).BeginInit();
  64. this.SuspendLayout();
  65. //
  66. // ucDepartment1
  67. //
  68. this.ucDepartment1.Dock = System.Windows.Forms.DockStyle.Top;
  69. this.ucDepartment1.Location = new System.Drawing.Point(0, 0);
  70. this.ucDepartment1.Name = "ucDepartment1";
  71. this.ucDepartment1.Size = new System.Drawing.Size(230, 311);
  72. this.ucDepartment1.TabIndex = 0;
  73. //
  74. // Button1
  75. //
  76. this.Button1.Location = new System.Drawing.Point(24, 359);
  77. this.Button1.Name = "Button1";
  78. this.Button1.Size = new System.Drawing.Size(75, 26);
  79. this.Button1.TabIndex = 1;
  80. this.Button1.Text = "确定";
  81. this.Button1.Click += new System.EventHandler(this.Button1_Click);
  82. //
  83. // Button2
  84. //
  85. this.Button2.Location = new System.Drawing.Point(128, 359);
  86. this.Button2.Name = "Button2";
  87. this.Button2.Size = new System.Drawing.Size(75, 26);
  88. this.Button2.TabIndex = 2;
  89. this.Button2.Text = "取消";
  90. this.Button2.Click += new System.EventHandler(this.Button2_Click);
  91. //
  92. // ultraLabel1
  93. //
  94. this.ultraLabel1.Location = new System.Drawing.Point(28, 330);
  95. this.ultraLabel1.Name = "ultraLabel1";
  96. this.ultraLabel1.Size = new System.Drawing.Size(56, 16);
  97. this.ultraLabel1.TabIndex = 3;
  98. this.ultraLabel1.Text = "选择部门";
  99. //
  100. // ultraTextEditor1
  101. //
  102. this.ultraTextEditor1.AutoSize = true;
  103. this.ultraTextEditor1.Location = new System.Drawing.Point(94, 325);
  104. this.ultraTextEditor1.Name = "ultraTextEditor1";
  105. this.ultraTextEditor1.Size = new System.Drawing.Size(100, 21);
  106. this.ultraTextEditor1.TabIndex = 4;
  107. //
  108. // FrmSetDepart
  109. //
  110. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  111. this.ClientSize = new System.Drawing.Size(230, 395);
  112. this.Controls.Add(this.ultraTextEditor1);
  113. this.Controls.Add(this.ultraLabel1);
  114. this.Controls.Add(this.Button2);
  115. this.Controls.Add(this.Button1);
  116. this.Controls.Add(this.ucDepartment1);
  117. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  118. this.MaximizeBox = false;
  119. this.MinimizeBox = false;
  120. this.Name = "FrmSetDepart";
  121. this.ShowInTaskbar = false;
  122. this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  123. this.Text = "选择部门";
  124. this.Load += new System.EventHandler(this.FrmSetDepart_Load);
  125. ((System.ComponentModel.ISupportInitialize)(this.ultraTextEditor1)).EndInit();
  126. this.ResumeLayout(false);
  127. }
  128. #endregion
  129. private DataSet _departmentData;
  130. private void FrmSetDepart_Load(object sender, System.EventArgs e)
  131. {
  132. GetDepartmentData();
  133. this.ucDepartment1._departmentData = _departmentData;
  134. this.ucDepartment1.RefreshTree();
  135. this.ucDepartment1.ultraTree1.ExpandAll();
  136. this.ucDepartment1.ultraTree1.AfterSelect += new Infragistics.Win.UltraWinTree.AfterNodeSelectEventHandler(ultraTree1_AfterSelect);
  137. this.ucDepartment1.ultraTree1.DoubleClick += new EventHandler(ultraTree1_DoubleClick);
  138. }
  139. //==========================================================
  140. // 获得部门数据
  141. //==========================================================
  142. private void GetDepartmentData()
  143. {
  144. try
  145. {
  146. CallingMessage par = new CallingMessage();
  147. par.ServerName = "PurviewManager";
  148. //par.AssemblyName = "Core.Mes.PurviewManager";
  149. par.ClassName = "Core.Mes.PurviewManager.PurviewManager";
  150. par.MethodName = "SelectUAM_DEPARTMENT";
  151. par.args = new object[]{" order by DEPARTMENTID "};
  152. par.ServerType = MesServerType.MesSystemBaseServer;
  153. string strOut = "";
  154. _departmentData = Core.Mes.ClientFrameWork.ClientCommon._RemotingHelp.ExecuteMethod(par, out strOut) as DataSet;
  155. }
  156. catch //(Exception ex)
  157. {
  158. // CoreMesLogger.log(this.GetType()).Error(ex.Message);
  159. }
  160. }
  161. private void ultraTree1_AfterSelect(object sender, Infragistics.Win.UltraWinTree.SelectEventArgs e)
  162. {
  163. if (e.NewSelections == null || e.NewSelections.Count == 0)
  164. {}
  165. else
  166. {
  167. ParentID = e.NewSelections[0].Key;
  168. this.ultraTextEditor1.Text = e.NewSelections[0].Text;
  169. this.ultraTextEditor1.Tag = e.NewSelections[0].Key;
  170. GetParenID(e.NewSelections[0]);
  171. string str = "'" + e.NewSelections[0].Key + "'";
  172. str = GetSelectedID(ref str, e.NewSelections[0]);
  173. this.Button1.Tag = str;
  174. }
  175. }
  176. private string GetSelectedID(ref string str, UltraTreeNode utn)
  177. {
  178. try
  179. {
  180. foreach(UltraTreeNode ut in utn.Nodes )
  181. {
  182. str += ",'" + ut.Key + "'";
  183. if (ut.Nodes.Count > 0)
  184. GetSelectedID(ref str, ut);
  185. }
  186. return str;
  187. }
  188. catch
  189. {
  190. return "";
  191. }
  192. }
  193. private void Button1_Click(object sender, System.EventArgs e)
  194. {
  195. SelectedName = "";
  196. SelectedID = "";
  197. if (GetChildIDFlag)
  198. {
  199. SelectedName = this.ultraTextEditor1.Text;
  200. SelectedID = this.Button1.Tag.ToString();
  201. }
  202. else
  203. {
  204. if (this.ultraTextEditor1.Text.Trim() != "" && this.ultraTextEditor1.Tag.ToString() != "")
  205. {
  206. SelectedName = this.ultraTextEditor1.Text;
  207. SelectedID = this.ultraTextEditor1.Tag.ToString();
  208. }
  209. }
  210. this.Close();
  211. }
  212. public string SelectedName = "";
  213. public string SelectedID = "";
  214. public string ParentID = "";
  215. public string RootID = "";
  216. public bool GetChildIDFlag = true;
  217. private void Button2_Click(object sender, System.EventArgs e)
  218. {
  219. this.Close();
  220. }
  221. private void ultraTree1_DoubleClick(object sender, System.EventArgs e)
  222. {
  223. Button1_Click(null, new EventArgs());
  224. }
  225. public void GetParenID(Infragistics.Win.UltraWinTree.UltraTreeNode TreeNode)
  226. {
  227. if (TreeNode.Parent==null)
  228. {
  229. return;
  230. }
  231. else
  232. {
  233. ParentID = ParentID + TreeNode.Key + ";";
  234. GetParenID(TreeNode.Parent);
  235. }
  236. }
  237. }
  238. }