UIM010020.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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 CoreFS.CA06;
  10. namespace Core.LZMes.Client.UIM
  11. {
  12. public partial class UIM010020 : FrmBase
  13. {
  14. private string NODE_ID = "";
  15. public UIM010020()
  16. {
  17. InitializeComponent();
  18. }
  19. public override void ToolBar_Click(object sender, string ToolbarKey)
  20. {
  21. switch (ToolbarKey)
  22. {
  23. case "Query":
  24. //this.DoQuery();
  25. break;
  26. case "Add":
  27. this.DoAdd();
  28. break;
  29. case "Update":
  30. this.DoUpdate();
  31. break;
  32. case "Delete":
  33. this.DoDelete();
  34. break;
  35. }
  36. }
  37. /// <summary>
  38. /// 根据树节点查询垛位信息
  39. /// </summary>
  40. /// <param name="nodeId"></param>
  41. private void DoQuery(string nodeId)
  42. {
  43. try
  44. {
  45. this.dataSet1.Tables[0].Clear();
  46. //节点类型 0为根节点,1为区域类型节点,2为区域节点
  47. int nodeType = 2;
  48. if ("-1".Equals(nodeId))
  49. {
  50. nodeType = 0;
  51. }
  52. else if (0 <= nodeId.IndexOf("type"))
  53. {
  54. nodeType = 1;
  55. }
  56. CoreClientParam ccp = new CoreClientParam();
  57. ccp.ServerName = "UIM.UIM010020";
  58. ccp.MethodName = "queryYard";
  59. ccp.ServerParams = new object[] { nodeType,nodeId };
  60. ccp.SourceDataTable = this.dataSet1.Tables[0];
  61. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  62. }
  63. catch (Exception EX)
  64. {
  65. MessageBox.Show(EX.ToString());
  66. }
  67. }
  68. /// <summary>
  69. /// 生成区域信息树
  70. /// </summary>
  71. protected void bindtree()
  72. {
  73. this.ultraTree1.Nodes.Clear();
  74. this.dataSet2.Tables[0].Clear();
  75. //创建根节点
  76. Infragistics.Win.UltraWinTree.UltraTreeNode rootNode = new Infragistics.Win.UltraWinTree.UltraTreeNode();
  77. //Infragistics.WebUI.UltraWebNavigator.Node rootnode1 = new Infragistics.WebUI.UltraWebNavigator.Node();
  78. //添加根节点
  79. rootNode.Text = "区域信息";
  80. rootNode.Tag = "-1";
  81. rootNode.Expanded = true;
  82. ultraTree1.Nodes.Add(rootNode);
  83. //获取树的数据
  84. GetTrees();
  85. //调用递归方法添加树节点
  86. CreateChildNode(rootNode, "-1", this.dataSet2.Tables[0]);
  87. }
  88. /// <summary>
  89. /// 递归添加节点
  90. /// </summary>
  91. /// <param name="parentnode"></param>
  92. /// <param name="taskid"></param>
  93. /// <param name="dt"></param>
  94. public void CreateChildNode(Infragistics.Win.UltraWinTree.UltraTreeNode parentnode, string parentId, DataTable dt)
  95. {
  96. DataRow[] rows = dt.Select("parentid='" + parentId + "'");
  97. foreach (DataRow dr in rows)
  98. {
  99. Infragistics.Win.UltraWinTree.UltraTreeNode nd = new Infragistics.Win.UltraWinTree.UltraTreeNode();
  100. nd.Tag = dr["treeid"].ToString();
  101. nd.Text = dr["treename"].ToString();
  102. nd.Expanded = true;
  103. parentnode.Nodes.Add(nd);
  104. CreateChildNode(nd, dr["treeid"].ToString(), dt);
  105. }
  106. }
  107. /// <summary>
  108. /// 获取数据
  109. /// </summary>
  110. public void GetTrees()
  111. {
  112. CoreClientParam ccp = new CoreClientParam();
  113. //ccp.InvokeID = "C06010103";
  114. ccp.ServerName = "UIM.UIM010020";
  115. ccp.MethodName = "quereAreaTree";
  116. ccp.SourceDataTable = this.dataSet2.Tables[0];
  117. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  118. }
  119. /// <summary>
  120. /// 删除垛位信息
  121. /// </summary>
  122. private void DoDelete()
  123. {
  124. try
  125. {
  126. long clfNo = -1;
  127. Infragistics.Win.UltraWinGrid.SelectedRowsCollection rows = this.ultraGrid1.Selected.Rows;
  128. string delParam = "";
  129. for (int i = 0; i < rows.Count; i++)
  130. {
  131. string clfNoStr = rows[i].Cells["clf_no"].Text;
  132. string coilNoStr = rows[i].Cells["coil_no"].Text;
  133. if (null != clfNoStr && !"".Equals(clfNoStr))
  134. {
  135. clfNo = long.Parse(clfNoStr);
  136. delParam += clfNo + "|";
  137. }
  138. if (null != coilNoStr && !"".Equals(coilNoStr))
  139. {
  140. MessageBox.Show("垛位下放置有钢卷,请先将钢卷移出。");
  141. return;
  142. }
  143. }
  144. if (rows.Count < 1)
  145. {
  146. MessageBox.Show("请选择要删除的垛位。");
  147. return;
  148. }
  149. if (MessageBox.Show(this, "是否确认删除?", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
  150. {
  151. if (!"".Equals(delParam))
  152. {
  153. CoreClientParam ccp = new CoreClientParam();
  154. ccp.ServerName = "UIM.UIM010020";
  155. ccp.MethodName = "delYard";
  156. ccp.ServerParams = new object[] { delParam };
  157. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  158. if (ccp.ReturnCode != 0) return;
  159. }
  160. this.ultraGrid1.DeleteSelectedRows(false);
  161. MessageBox.Show("删除成功!");
  162. }
  163. }
  164. catch (Exception EX)
  165. {
  166. MessageBox.Show(EX.ToString());
  167. }
  168. }
  169. /// <summary>
  170. /// 添加垛位
  171. /// </summary>
  172. private void DoAdd()
  173. {
  174. try
  175. {
  176. string clfName = this.textBox1.Text;
  177. string clfRow = this.textBox2.Text;
  178. string clfCol = this.textBox3.Text;
  179. string clfFl = this.textBox5.Text;
  180. string remark = this.textBox4.Text;
  181. string areaNo = this.ultraComboEditor1.Value.ToString();
  182. string regId = this.UserInfo.GetUserID();
  183. if (null == clfName || "".Equals(clfName))
  184. {
  185. MessageBox.Show("请输入垛位名称!");
  186. this.textBox1.Focus();
  187. return;
  188. }
  189. if (null == clfRow || "".Equals(clfRow))
  190. {
  191. MessageBox.Show("请输入行!");
  192. this.textBox2.Focus();
  193. return;
  194. }
  195. if (null == clfCol || "".Equals(clfCol))
  196. {
  197. MessageBox.Show("请输入列!");
  198. this.textBox3.Focus();
  199. return;
  200. }
  201. if (null == clfFl || "".Equals(clfFl))
  202. {
  203. MessageBox.Show("请输入层!");
  204. }
  205. if (-1 == this.ultraComboEditor1.SelectedIndex)
  206. {
  207. MessageBox.Show("请选择所属区域!");
  208. this.ultraComboEditor1.Focus();
  209. return;
  210. }
  211. CoreClientParam ccp = new CoreClientParam();
  212. ccp.ServerName = "UIM.UIM010020";
  213. ccp.MethodName = "addYard";
  214. ccp.ServerParams = new object[] { clfName, clfRow, clfCol, clfFl, remark, areaNo, regId};
  215. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  216. if (0 != ccp.ReturnCode) return;
  217. this.DoQuery(NODE_ID);
  218. }
  219. catch (Exception EX)
  220. {
  221. MessageBox.Show(EX.ToString());
  222. }
  223. }
  224. /// <summary>
  225. /// 修改垛位信息
  226. /// </summary>
  227. private void DoUpdate()
  228. {
  229. string clfNo = this.ultraGrid1.ActiveRow.Cells["clf_no"].Text;
  230. string clfName = this.textBox1.Text;
  231. string clfRow = this.textBox2.Text;
  232. string clfCol = this.textBox3.Text;
  233. string clfFl = this.textBox5.Text;
  234. string remark = this.textBox4.Text;
  235. string areaNo = this.ultraComboEditor1.Value.ToString();
  236. string regId = this.UserInfo.GetUserID();
  237. if (null == clfName || "".Equals(clfName))
  238. {
  239. MessageBox.Show("请输入垛位名称!");
  240. this.textBox1.Focus();
  241. return;
  242. }
  243. if (null == clfRow || "".Equals(clfRow))
  244. {
  245. MessageBox.Show("请输入行!");
  246. this.textBox2.Focus();
  247. return;
  248. }
  249. if (null == clfCol || "".Equals(clfCol))
  250. {
  251. MessageBox.Show("请输入列!");
  252. this.textBox3.Focus();
  253. return;
  254. }
  255. if (null == clfFl || "".Equals(clfFl))
  256. {
  257. MessageBox.Show("请输入层!");
  258. }
  259. if (-1 == this.ultraComboEditor1.SelectedIndex)
  260. {
  261. MessageBox.Show("请选择所属区域!");
  262. this.ultraComboEditor1.Focus();
  263. return;
  264. }
  265. CoreClientParam ccp = new CoreClientParam();
  266. ccp.ServerName = "UIM.UIM010020";
  267. ccp.MethodName = "updateYard";
  268. ccp.ServerParams = new object[] { clfNo, clfName, clfRow, clfCol, clfFl, remark, areaNo,regId};
  269. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  270. if (0 != ccp.ReturnCode) return;
  271. this.DoQuery(NODE_ID);
  272. }
  273. /// <summary>
  274. /// 页面加载时获取区域树结构数据
  275. /// </summary>
  276. /// <param name="sender"></param>
  277. /// <param name="e"></param>
  278. private void UIM010020_Load(object sender, EventArgs e)
  279. {
  280. bindtree();
  281. }
  282. /// <summary>
  283. /// 选取节点查询垛位信息
  284. /// </summary>
  285. /// <param name="sender"></param>
  286. /// <param name="e"></param>
  287. private void ultraTree1_AfterSelect(object sender, Infragistics.Win.UltraWinTree.SelectEventArgs e)
  288. {
  289. Infragistics.Win.UltraWinTree.UltraTree tree = (Infragistics.Win.UltraWinTree.UltraTree)sender;
  290. string ndId = tree.SelectedNodes[0].Tag.ToString();
  291. NODE_ID = ndId;
  292. this.DoQuery(ndId);
  293. }
  294. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  295. {
  296. Infragistics.Win.UltraWinGrid.UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  297. this.textBox1.Text = uRow.Cells["clf_name"].Text;
  298. this.textBox2.Text = uRow.Cells["clf_row"].Text;
  299. this.textBox3.Text = uRow.Cells["clf_col"].Text;
  300. this.textBox4.Text = uRow.Cells["remark"].Text;
  301. this.textBox5.Text = uRow.Cells["clf_fl"].Text;
  302. this.ultraComboEditor1.Text = uRow.Cells["area_name"].Text;
  303. this.getAreaInfo(uRow.Cells["area_no"].Text.Trim());
  304. }
  305. /// <summary>
  306. /// 获取区域信息
  307. /// </summary>
  308. private void getAreaInfo(string areaNo)
  309. {
  310. this.dataSet3.Tables[0].Clear();
  311. this.ultraComboEditor1.Items.Clear();
  312. CoreClientParam ccp = new CoreClientParam();
  313. ccp.ServerName = "UIM.UIM010020";
  314. ccp.MethodName = "queryAreaInfo";
  315. ccp.ServerParams = new object[] { areaNo };
  316. ccp.SourceDataTable = this.dataSet3.Tables[0];
  317. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  318. foreach (DataRow dr in dataSet3.Tables[0].Rows)
  319. {
  320. ultraComboEditor1.Items.Add(dr["area_no"].ToString(), dr["area_name"].ToString());
  321. }
  322. }
  323. }
  324. }