UIM010250.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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. using System.Collections;
  11. using System.Text.RegularExpressions;
  12. namespace Core.LZMes.Client.UIM
  13. {
  14. public partial class UIM010250 : FrmBase
  15. {
  16. public UIM010250()
  17. {
  18. InitializeComponent();
  19. }
  20. //垛位分析用字符掩码
  21. private const string _numPattern = @"^\d+$";
  22. private const string _layerPattern = @"^[ABCabc]?$";
  23. private const string _yardPattern = @"^[3-5]?$";
  24. //当前输入垛位是否有效
  25. private bool bolYard1 = false;
  26. private bool bolYard2 = false;
  27. private Infragistics.Win.ValueListItem[] areaList3
  28. {
  29. get
  30. {
  31. return new Infragistics.Win.ValueListItem[]
  32. {
  33. new Infragistics.Win.ValueListItem("1-10","一区(1-10)"),
  34. new Infragistics.Win.ValueListItem("11-20","二区(11-20)"),
  35. new Infragistics.Win.ValueListItem("21-30","三区(21-30)"),
  36. new Infragistics.Win.ValueListItem("31-40","四区(31-40)"),
  37. new Infragistics.Win.ValueListItem("41-57","五区(41-57)"),
  38. new Infragistics.Win.ValueListItem("58-74","六区(58-74)"),
  39. new Infragistics.Win.ValueListItem("75-91","七区(75-91)"),
  40. new Infragistics.Win.ValueListItem("92-108","八区(92-108)")
  41. };
  42. }
  43. }
  44. private Infragistics.Win.ValueListItem[] areaList5
  45. {
  46. get
  47. {
  48. return new Infragistics.Win.ValueListItem[]
  49. {
  50. new Infragistics.Win.ValueListItem("1-15","一区(1-15)"),
  51. new Infragistics.Win.ValueListItem("16-35","二区(16-35)"),
  52. new Infragistics.Win.ValueListItem("36-50","三区(36-50)"),
  53. new Infragistics.Win.ValueListItem("51-65","四区(51-65)"),
  54. new Infragistics.Win.ValueListItem("66-80","五区(66-80)"),
  55. new Infragistics.Win.ValueListItem("81-102","六区(81-102)")
  56. };
  57. }
  58. }
  59. private Infragistics.Win.ValueListItem[] areaList4
  60. {
  61. get
  62. {
  63. return new Infragistics.Win.ValueListItem[]
  64. {
  65. new Infragistics.Win.ValueListItem("1-10","一区(1-10)"),
  66. new Infragistics.Win.ValueListItem("11-21","二区(11-21)"),
  67. new Infragistics.Win.ValueListItem("22-32","三区(22-32)"),
  68. new Infragistics.Win.ValueListItem("33-43","四区(33-43)"),
  69. new Infragistics.Win.ValueListItem("44-54","五区(44-54)"),
  70. new Infragistics.Win.ValueListItem("55-65","六区(55-65)"),
  71. new Infragistics.Win.ValueListItem("66-76","七区(66-76)"),
  72. new Infragistics.Win.ValueListItem("77-87","八区(77-87)"),
  73. new Infragistics.Win.ValueListItem("88-100","九区(88-100)"),
  74. };
  75. }
  76. }
  77. public override void ToolBar_Click(object sender, string ToolbarKey)
  78. {
  79. switch (ToolbarKey)
  80. {
  81. case "Query":
  82. this.DoQuerryLoad(0);
  83. break;
  84. case "Save":
  85. this.DoSave();
  86. break;
  87. case "Exit":
  88. this.Close();
  89. break;
  90. }
  91. }
  92. /// <summary>
  93. /// 等待移垛卷列表
  94. /// </summary>
  95. List<MoveYardListNode> moveYardList = new List<MoveYardListNode>();
  96. /// <summary>
  97. /// 查询垛位状态
  98. /// </summary>
  99. private void DoQuerryLoad(int status)
  100. {
  101. this.moveYardList.Clear();
  102. if (status != 2)
  103. {
  104. string[] area = this.ddlKUarea1.Value.ToString().Split('-');
  105. string ku = this.ddlKU1.Value.ToString();
  106. dataSet1.Tables[0].Clear();
  107. CoreClientParam ccp = new CoreClientParam();
  108. ccp.ServerName = "UIM.UIM010250";
  109. ccp.MethodName = "queryLoad";
  110. ccp.ServerParams = new object[] { ku, area[0], area[1] };
  111. ccp.SourceDataTable = dataSet1.Tables[0];
  112. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  113. }
  114. if (status != 1)
  115. {
  116. string[] area2 = this.ddlKUarea2.Value.ToString().Split('-');
  117. string ku2 = this.ddlKU2.Value.ToString();
  118. dataSet2.Tables[0].Clear();
  119. CoreClientParam ccp2 = new CoreClientParam();
  120. ccp2.ServerName = "UIM.UIM010250";
  121. ccp2.MethodName = "queryLoad";
  122. ccp2.ServerParams = new object[] { ku2, area2[0], area2[1] };
  123. ccp2.SourceDataTable = dataSet2.Tables[0];
  124. this.ExecuteQueryToDataTable(ccp2, CoreInvokeType.Internal);
  125. }
  126. this.ShowMoveList();
  127. }
  128. /// <summary>
  129. /// 保存
  130. /// </summary>
  131. private void DoSave()
  132. {
  133. foreach (MoveYardListNode item in moveYardList)
  134. {
  135. this.DoMove(new List<string>() { item.coilNo }, item.yardNow, item.yardTo);
  136. }
  137. this.moveYardList.Clear();
  138. this.DoQuerryLoad(0);
  139. }
  140. /// <summary>
  141. /// 通过钢卷号查询垛位
  142. /// </summary>
  143. private void DoLoadLocQuerry()
  144. {
  145. try
  146. {
  147. string strLoadLoc = "";
  148. string strStat = "";
  149. string coilNo = this.txtCoilNoQuerry.Text.Trim();
  150. //如果未输入,一切还原,并不做查询
  151. if (coilNo == "")
  152. {
  153. this.txtCoilNoOUT.Text = "";
  154. this.txtCoilNoStat.Text = "";
  155. return;
  156. }
  157. CoreClientParam ccp = new CoreClientParam();
  158. ccp.ServerName = "UIM.UIM010250";
  159. ccp.MethodName = "queryLoadLoc";
  160. ccp.ServerParams = new object[] { coilNo };
  161. this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  162. Hashtable temp = HashTableReadTest.GetHastabinArrayNoEx(ccp.ReturnObject, 0);
  163. //如果temp为null 说明没有查询到这个钢卷号
  164. if (temp == null)
  165. {
  166. this.txtCoilNoOUT.Text = "此钢卷无记录";
  167. this.txtCoilNoStat.Text = "";
  168. return;
  169. }
  170. strLoadLoc = HashTableReadTest.GetValueinHasTab(temp, "CUR_LOAD_LOC").ToString();
  171. strStat = HashTableReadTest.GetValueinHasTab(temp, "COIL_STAT").ToString();
  172. this.txtCoilNoOUT.Text = strLoadLoc;
  173. this.txtCoilNoStat.Text = strStat;
  174. }
  175. catch
  176. {
  177. MessageBox.Show("如果你看到了这个警告窗,请联系开发人员.\n 错误于DoLoadLocQuerry()");
  178. }
  179. }
  180. /// <summary>
  181. /// 通过钢卷号查询垛位 for LOG
  182. /// </summary>
  183. private void DoLoadLocLOGQuerry()
  184. {
  185. try
  186. {
  187. string strLoadLoc = "";
  188. string strStat = "";
  189. string coilNo = this.ddlCoilNoQuerry_LOG.Text.Trim();
  190. //如果未输入,一切还原,并不做查询
  191. if (coilNo == "")
  192. {
  193. this.txtCoilNoOUT_LOG.Text = "";
  194. this.txtCoilNoStat_LOG.Text = "";
  195. return;
  196. }
  197. CoreClientParam ccp = new CoreClientParam();
  198. ccp.ServerName = "UIM.UIM010250";
  199. ccp.MethodName = "queryLoadLoc";
  200. ccp.ServerParams = new object[] { coilNo };
  201. this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  202. Hashtable temp = HashTableReadTest.GetHastabinArrayNoEx(ccp.ReturnObject, 0);
  203. //如果temp为null 说明没有查询到这个钢卷号
  204. if (temp == null)
  205. {
  206. this.txtCoilNoOUT_LOG.Text = "此钢卷无记录";
  207. this.txtCoilNoStat_LOG.Text = "";
  208. return;
  209. }
  210. strLoadLoc = HashTableReadTest.GetValueinHasTab(temp, "CUR_LOAD_LOC").ToString();
  211. strStat = HashTableReadTest.GetValueinHasTab(temp, "COIL_STAT").ToString();
  212. this.txtCoilNoOUT_LOG.Text = strLoadLoc;
  213. this.txtCoilNoStat_LOG.Text = strStat;
  214. }
  215. catch
  216. {
  217. MessageBox.Show("如果你看到了这个警告窗,请联系开发人员.\n 错误于DoLoadLocLOGQuerry()");
  218. }
  219. }
  220. /// <summary>
  221. /// 查询移垛记录
  222. /// </summary>
  223. private void DoCoilNoLOGQuerry()
  224. {
  225. string coilNo = this.ddlCoilNoQuerry_LOG.Text.Trim();
  226. dataSet3.Tables[0].Clear();
  227. CoreClientParam ccp = new CoreClientParam();
  228. ccp.ServerName = "UIM.UIM010250";
  229. ccp.MethodName = "queryCoilNoLOG";
  230. ccp.ServerParams = new object[] { coilNo };
  231. ccp.SourceDataTable = dataSet3.Tables[0];
  232. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  233. }
  234. /// <summary>
  235. /// 移垛
  236. /// </summary>
  237. /// <param name="coilNosList">要移动的钢卷清单</param>
  238. /// <param name="yardNOW">目前垛位</param>
  239. /// <param name="yardTO">目标垛位</param>
  240. private void DoMove(List<string> coilNosList,string yardNOW,string yardTO)
  241. {
  242. try
  243. {
  244. string[] coilNo = new string[coilNosList.Count];
  245. for (int i = 0; i < coilNosList.Count; i++)
  246. {
  247. coilNo[i] = coilNosList[i];
  248. }
  249. string regID = this.UserInfo.GetUserID();
  250. string regShift = this.UserInfo.GetUserOrder();
  251. string regGroup = this.UserInfo.GetUserGroup();
  252. CoreClientParam ccp = new CoreClientParam();
  253. ccp.ServerName = "UIM.UIM010250";
  254. ccp.MethodName = "moveYard";//moveYard(String[], String, String, String, String, String)
  255. ccp.ServerParams = new object[] { coilNo, yardNOW, yardTO, regID, regShift, regGroup };
  256. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  257. }
  258. catch(Exception ex)
  259. {
  260. MessageBox.Show(ex.ToString());
  261. }
  262. for (int i = 0; i < coilNosList.Count; i++)
  263. {
  264. Infragistics.Win.ValueListItem temp = new Infragistics.Win.ValueListItem(coilNosList[i]);
  265. if(this.ddlCoilNoQuerry_LOG.FindString(coilNosList[i]) < 0)
  266. this.ddlCoilNoQuerry_LOG.Items.Add(temp);
  267. }
  268. return;
  269. }
  270. /// <summary>
  271. /// 把钢卷加入等待移动表中
  272. /// </summary>
  273. /// <param name="coilNo"></param>
  274. /// <param name="yardNow"></param>
  275. /// <param name="moveTo"></param>
  276. private void AddMoveList(string coilNo, string yardNow, string moveTo)
  277. {
  278. bool itInList = false;
  279. int listIndex = -1;
  280. for (int i = 0; i < moveYardList.Count; i++)
  281. {
  282. if (coilNo == moveYardList[i].coilNo)
  283. {
  284. itInList = true;//在表里
  285. listIndex = i;
  286. break;
  287. }
  288. }
  289. if (itInList == false)
  290. {
  291. //新节点
  292. this.moveYardList.Add(new MoveYardListNode(coilNo, yardNow, moveTo));
  293. return;
  294. }
  295. else
  296. {
  297. if (moveTo == moveYardList[listIndex].yardNow)
  298. {
  299. //不用移动
  300. moveYardList.RemoveAt(listIndex);
  301. }
  302. else
  303. {
  304. //改写目标
  305. moveYardList[listIndex].yardTo = moveTo;
  306. }
  307. return;
  308. }
  309. }
  310. private void ShowMoveList()
  311. {
  312. this.richTextBox1.Clear();
  313. foreach (MoveYardListNode item in moveYardList)
  314. {
  315. this.richTextBox1.AppendText(item.coilNo + "\n");
  316. }
  317. }
  318. private void btnCoilNoQuerry_Click(object sender, EventArgs e)
  319. {
  320. this.DoLoadLocQuerry();
  321. }
  322. private void txtCoilNoQuerry_TextChanged(object sender, EventArgs e)
  323. {
  324. this.txtCoilNoOUT.Text = "";
  325. this.txtCoilNoStat.Text = "";
  326. }
  327. private void button1_Click(object sender, EventArgs e)
  328. {
  329. }
  330. private void btnCoilNo_LOGQuerry_Click(object sender, EventArgs e)
  331. {
  332. this.DoLoadLocLOGQuerry();
  333. this.DoCoilNoLOGQuerry();
  334. }
  335. private void ddlCoilNoQuerry_LOG_ValueChanged(object sender, EventArgs e)
  336. {
  337. this.txtCoilNoOUT_LOG.Text = "";
  338. this.txtCoilNoStat_LOG.Text = "";
  339. this.dataSet3.Tables[0].Clear();
  340. }
  341. private void btnAtoB_Click(object sender, EventArgs e)
  342. {
  343. Infragistics.Win.UltraWinGrid.UltraGridRow rowA = null;
  344. Infragistics.Win.UltraWinGrid.UltraGridRow rowB = null;
  345. //取被选行
  346. for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)
  347. {
  348. if (((bool)this.ultraGrid1.Rows[i].Cells["BESELECT"].Value) == true)
  349. {
  350. rowA = this.ultraGrid1.Rows[i];
  351. }
  352. }
  353. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  354. {
  355. if (((bool)this.ultraGrid2.Rows[i].Cells["BESELECT"].Value) == true)
  356. {
  357. rowB = this.ultraGrid2.Rows[i];
  358. }
  359. }
  360. //数据不全 都不做处理
  361. if (rowA == null || rowB == null)
  362. {
  363. return;
  364. }
  365. if (rowA.Cells["COIL_NO"].Text == "")
  366. {
  367. return;
  368. }
  369. if (rowA.Cells["CUR_LOAD_LOC"].Text == rowB.Cells["CUR_LOAD_LOC"].Text)
  370. {
  371. return;
  372. }
  373. //加入等待移垛列表
  374. this.AddMoveList(rowA.Cells["COIL_NO"].Text, rowA.Cells["CUR_LOAD_LOC"].Text, rowB.Cells["CUR_LOAD_LOC"].Text);
  375. //显示
  376. //开启可写
  377. dataSet1.Tables[0].Columns["COIL_NO"].ReadOnly = false;
  378. dataSet1.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = false;
  379. dataSet2.Tables[0].Columns["COIL_NO"].ReadOnly = false;
  380. dataSet2.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = false;
  381. //如果表A=表B
  382. bool sameView = false;
  383. if (this.ddlKU1.Value == this.ddlKU2.Value && this.ddlKUarea1.Value == this.ddlKUarea2.Value)
  384. {
  385. sameView = true;
  386. }
  387. //表B的操作
  388. //如果是同表 把对应的行找出来 并清除
  389. if (sameView == true)
  390. {
  391. Infragistics.Win.UltraWinGrid.UltraGridRow rowBs = null;
  392. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  393. {
  394. if (this.ultraGrid2.Rows[i].Cells["COIL_NO"].Text == rowA.Cells["COIL_NO"].Text)
  395. {
  396. rowBs = this.ultraGrid2.Rows[i];
  397. break;
  398. }
  399. }
  400. string temp = rowBs.Cells["CUR_LOAD_LOC"].Text;
  401. if (rowBs.Index < this.ultraGrid2.Rows.Count - 1 && this.ultraGrid2.Rows[rowBs.Index + 1].Cells["CUR_LOAD_LOC"].Text == temp)
  402. {
  403. rowBs.Delete(false);
  404. }
  405. else if (rowBs.Index > 0 && this.ultraGrid2.Rows[rowBs.Index - 1].Cells["CUR_LOAD_LOC"].Text == temp)
  406. {
  407. rowBs.Delete(false);
  408. }
  409. else
  410. {
  411. rowBs.Cells["COIL_NO"].Value = "";
  412. }
  413. }
  414. //插入新记录
  415. if (rowB.Cells["COIL_NO"].Text == "")
  416. {
  417. rowB.Cells["COIL_NO"].Value = rowA.Cells["COIL_NO"].Text;
  418. }
  419. else
  420. {
  421. Infragistics.Win.UltraWinGrid.UltraGridRow temp = this.ultraGrid2.Rows.Band.AddNew();
  422. temp.Cells["CUR_LOAD_LOC"].Value = rowB.Cells["CUR_LOAD_LOC"].Value;
  423. temp.Cells["COIL_NO"].Value = rowA.Cells["COIL_NO"].Value;
  424. temp.Cells["BESELECT"].Value = false;
  425. this.ultraGrid2.Rows.Move(temp, rowB.Index + 1);
  426. this.ultraGrid2.ActiveRow = rowB;
  427. }
  428. //表A的操作
  429. //如果同表 添加对应位置记录
  430. if (sameView == true)
  431. {
  432. Infragistics.Win.UltraWinGrid.UltraGridRow rowAs = null;
  433. for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)
  434. {
  435. if (this.ultraGrid1.Rows[i].Cells["CUR_LOAD_LOC"].Text == rowB.Cells["CUR_LOAD_LOC"].Text)
  436. {
  437. rowAs = this.ultraGrid1.Rows[i];
  438. break;
  439. }
  440. }
  441. if (rowAs.Cells["COIL_NO"].Text == "")
  442. {
  443. rowAs.Cells["COIL_NO"].Value = rowA.Cells["COIL_NO"].Value;
  444. }
  445. else
  446. {
  447. Infragistics.Win.UltraWinGrid.UltraGridRow temp = this.ultraGrid1.Rows.Band.AddNew();
  448. temp.Cells["CUR_LOAD_LOC"].Value = rowB.Cells["CUR_LOAD_LOC"].Value;
  449. temp.Cells["COIL_NO"].Value = rowA.Cells["COIL_NO"].Value;
  450. temp.Cells["BESELECT"].Value = false;
  451. this.ultraGrid1.Rows.Move(temp, rowAs.Index + 1);
  452. this.ultraGrid1.ActiveRow = rowA;
  453. }
  454. }
  455. //清记录
  456. string tempYard = rowA.Cells["CUR_LOAD_LOC"].Text;
  457. if (rowA.Index < this.ultraGrid1.Rows.Count -1 && this.ultraGrid1.Rows[rowA.Index + 1].Cells["CUR_LOAD_LOC"].Text == tempYard)
  458. {
  459. rowA.Delete(false);
  460. }
  461. else if (rowA.Index > 0 && this.ultraGrid1.Rows[rowA.Index - 1].Cells["CUR_LOAD_LOC"].Text == tempYard)
  462. {
  463. rowA.Delete(false);
  464. }
  465. else
  466. {
  467. rowA.Cells["COIL_NO"].Value = "";
  468. }
  469. //重设只读
  470. dataSet1.Tables[0].Columns["COIL_NO"].ReadOnly = true;
  471. dataSet1.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = true ;
  472. dataSet2.Tables[0].Columns["COIL_NO"].ReadOnly = true ;
  473. dataSet2.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = true ;
  474. this.ShowMoveList();
  475. }
  476. private void btnBtoA_Click(object sender, EventArgs e)
  477. {
  478. Infragistics.Win.UltraWinGrid.UltraGridRow rowA = null;
  479. Infragistics.Win.UltraWinGrid.UltraGridRow rowB = null;
  480. //取被选行
  481. for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)
  482. {
  483. if (((bool)this.ultraGrid1.Rows[i].Cells["BESELECT"].Value) == true)
  484. {
  485. rowA = this.ultraGrid1.Rows[i];
  486. }
  487. }
  488. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  489. {
  490. if (((bool)this.ultraGrid2.Rows[i].Cells["BESELECT"].Value) == true)
  491. {
  492. rowB = this.ultraGrid2.Rows[i];
  493. }
  494. }
  495. //数据不全 都不做处理
  496. if (rowA == null || rowB == null)
  497. {
  498. return;
  499. }
  500. if (rowB.Cells["COIL_NO"].Text == "")
  501. {
  502. return;
  503. }
  504. if (rowA.Cells["CUR_LOAD_LOC"].Text == rowB.Cells["CUR_LOAD_LOC"].Text)
  505. {
  506. return;
  507. }
  508. //加入等待移垛列表
  509. this.AddMoveList(rowB.Cells["COIL_NO"].Text, rowB.Cells["CUR_LOAD_LOC"].Text, rowA.Cells["CUR_LOAD_LOC"].Text);
  510. //显示
  511. //开启可写
  512. dataSet1.Tables[0].Columns["COIL_NO"].ReadOnly = false;
  513. dataSet1.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = false;
  514. dataSet2.Tables[0].Columns["COIL_NO"].ReadOnly = false;
  515. dataSet2.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = false;
  516. //如果表A=表B
  517. bool sameView = false;
  518. if (this.ddlKU1.Value == this.ddlKU2.Value && this.ddlKUarea1.Value == this.ddlKUarea2.Value)
  519. {
  520. sameView = true;
  521. }
  522. //表A的操作
  523. //如果是同表 把对应的行找出来 并清除
  524. if (sameView == true)
  525. {
  526. Infragistics.Win.UltraWinGrid.UltraGridRow rowAs = null;
  527. for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)
  528. {
  529. if (this.ultraGrid1.Rows[i].Cells["COIL_NO"].Text == rowB.Cells["COIL_NO"].Text)
  530. {
  531. rowAs = this.ultraGrid1.Rows[i];
  532. break;
  533. }
  534. }
  535. string temp = rowAs.Cells["CUR_LOAD_LOC"].Text;
  536. if (rowAs.Index < this.ultraGrid1.Rows.Count - 1 && this.ultraGrid1.Rows[rowAs.Index + 1].Cells["CUR_LOAD_LOC"].Text == temp)
  537. {
  538. rowAs.Delete(false);
  539. }
  540. else if (rowAs.Index > 0 && this.ultraGrid1.Rows[rowAs.Index - 1].Cells["CUR_LOAD_LOC"].Text == temp)
  541. {
  542. rowAs.Delete(false);
  543. }
  544. else
  545. {
  546. rowAs.Cells["COIL_NO"].Value = "";
  547. }
  548. }
  549. if (rowA.Cells["COIL_NO"].Text == "")
  550. {
  551. rowA.Cells["COIL_NO"].Value = rowB.Cells["COIL_NO"].Text;
  552. }
  553. else
  554. {
  555. Infragistics.Win.UltraWinGrid.UltraGridRow temp = this.ultraGrid1.Rows.Band.AddNew();
  556. temp.Cells["CUR_LOAD_LOC"].Value = rowA.Cells["CUR_LOAD_LOC"].Value;
  557. temp.Cells["COIL_NO"].Value = rowB.Cells["COIL_NO"].Value;
  558. temp.Cells["BESELECT"].Value = false;
  559. this.ultraGrid1.Rows.Move(temp, rowA.Index + 1);
  560. this.ultraGrid1.ActiveRow = rowA;
  561. }
  562. //表B的操作
  563. //如果同表 添加对应位置记录
  564. if (sameView == true)
  565. {
  566. Infragistics.Win.UltraWinGrid.UltraGridRow rowBs = null;
  567. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  568. {
  569. if (this.ultraGrid2.Rows[i].Cells["CUR_LOAD_LOC"].Text == rowA.Cells["CUR_LOAD_LOC"].Text)
  570. {
  571. rowBs = this.ultraGrid2.Rows[i];
  572. break;
  573. }
  574. }
  575. if (rowBs.Cells["COIL_NO"].Text == "")
  576. {
  577. rowBs.Cells["COIL_NO"].Value = rowB.Cells["COIL_NO"].Value;
  578. }
  579. else
  580. {
  581. Infragistics.Win.UltraWinGrid.UltraGridRow temp = this.ultraGrid2.Rows.Band.AddNew();
  582. temp.Cells["CUR_LOAD_LOC"].Value = rowA.Cells["CUR_LOAD_LOC"].Value;
  583. temp.Cells["COIL_NO"].Value = rowB.Cells["COIL_NO"].Value;
  584. temp.Cells["BESELECT"].Value = false;
  585. this.ultraGrid2.Rows.Move(temp, rowBs.Index + 1);
  586. this.ultraGrid2.ActiveRow = rowB;
  587. }
  588. }
  589. string tempYard = rowB.Cells["CUR_LOAD_LOC"].Text;
  590. if (rowB.Index < this.ultraGrid2.Rows.Count - 1 && this.ultraGrid2.Rows[rowB.Index + 1].Cells["CUR_LOAD_LOC"].Text == tempYard)
  591. {
  592. rowB.Delete(false);
  593. }
  594. else if (rowB.Index > 0 && this.ultraGrid2.Rows[rowB.Index - 1].Cells["CUR_LOAD_LOC"].Text == tempYard)
  595. {
  596. rowB.Delete(false);
  597. }
  598. else
  599. {
  600. rowB.Cells["COIL_NO"].Value = "";
  601. }
  602. //重设只读
  603. dataSet1.Tables[0].Columns["COIL_NO"].ReadOnly = true;
  604. dataSet1.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = true;
  605. dataSet2.Tables[0].Columns["COIL_NO"].ReadOnly = true;
  606. dataSet2.Tables[0].Columns["CUR_LOAD_LOC"].ReadOnly = true;
  607. this.ShowMoveList();
  608. }
  609. private void ddlKU1_ValueChanged(object sender, EventArgs e)
  610. {
  611. this.ddlKUarea1.Items.Clear();
  612. if (this.ddlKU1.SelectedIndex == 0)
  613. {
  614. ddlKUarea1.Items.AddRange(this.areaList3);
  615. ddlKUarea1.SelectedIndex = 0;
  616. }
  617. else if (this.ddlKU1.SelectedIndex == 1)
  618. {
  619. ddlKUarea1.Items.AddRange(this.areaList4);
  620. ddlKUarea1.SelectedIndex = 0;
  621. }
  622. else if (this.ddlKU1.SelectedIndex == 2)
  623. {
  624. ddlKUarea1.Items.AddRange(this.areaList5);
  625. ddlKUarea1.SelectedIndex = 0;
  626. }
  627. }
  628. private void ddlKU2_ValueChanged(object sender, EventArgs e)
  629. {
  630. this.ddlKUarea2.Items.Clear();
  631. if (this.ddlKU2.SelectedIndex == 0)
  632. {
  633. ddlKUarea2.Items.AddRange(this.areaList3);
  634. ddlKUarea2.SelectedIndex = 0;
  635. }
  636. else if (this.ddlKU2.SelectedIndex == 1)
  637. {
  638. ddlKUarea2.Items.AddRange(this.areaList4);
  639. ddlKUarea2.SelectedIndex = 0;
  640. }
  641. else if (this.ddlKU2.SelectedIndex == 2)
  642. {
  643. ddlKUarea2.Items.AddRange(this.areaList5);
  644. ddlKUarea2.SelectedIndex = 0;
  645. }
  646. }
  647. private void UIM010250_Load(object sender, EventArgs e)
  648. {
  649. this.ddlKU1.SelectedIndex = 0;
  650. this.ddlKU2.SelectedIndex = 0;
  651. }
  652. private void ultraGrid1_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e)
  653. {
  654. if (e.Cell != e.Cell.Row.Cells["BESELECT"])
  655. {
  656. return;
  657. }
  658. bool temp = (bool)e.Cell.Value;
  659. for (int i = 0; i < this.ultraGrid1.Rows.Count; i++)
  660. {
  661. this.ultraGrid1.Rows[i].Cells["BESELECT"].Value = false;
  662. }
  663. e.Cell.Value = temp;
  664. return;
  665. }
  666. private void ultraGrid2_ClickCell(object sender, Infragistics.Win.UltraWinGrid.ClickCellEventArgs e)
  667. {
  668. if (e.Cell != e.Cell.Row.Cells["BESELECT"])
  669. {
  670. return;
  671. }
  672. bool temp = (bool)e.Cell.Value;
  673. for (int i = 0; i < this.ultraGrid2.Rows.Count; i++)
  674. {
  675. this.ultraGrid2.Rows[i].Cells["BESELECT"].Value = false;
  676. }
  677. e.Cell.Value = temp;
  678. return;
  679. }
  680. private void ddlKUarea1_ValueChanged(object sender, EventArgs e)
  681. {
  682. DoQuerryLoad(1);
  683. }
  684. private void ddlKUarea2_ValueChanged(object sender, EventArgs e)
  685. {
  686. DoQuerryLoad(2);
  687. }
  688. }
  689. //-----------------
  690. /// <summary>
  691. /// 移垛用的节点
  692. /// </summary>
  693. public class MoveYardListNode
  694. {
  695. public MoveYardListNode(string CoilNo, string YardNow, string YardTo)
  696. {
  697. coilNo = CoilNo;
  698. yardNow = YardNow;
  699. yardTo = YardTo;
  700. }
  701. public string coilNo;
  702. public string yardNow;
  703. public string yardTo;
  704. }
  705. //--------------------
  706. /// <summary>
  707. /// 从CCP返回值中取得数据的方法集
  708. /// FLZ 2011-8-31
  709. /// 写在UIM010250下 因为我没有权把它加到项目工程目录中
  710. /// </summary>
  711. static class HashTableReadTest
  712. {
  713. /// <summary>
  714. /// 取得包含有CCP返回对象的内容的字符串 test用
  715. /// </summary>
  716. /// <param name="obj">CCP返回对象</param>
  717. /// <returns>包含有CCP返回对象的内容的字符串</returns>
  718. static public string WhatinIt(object obj)
  719. {
  720. try
  721. {
  722. string str = obj.GetType().ToString();
  723. if (str != "System.Collections.ArrayList")
  724. {
  725. Exception e = new Exception("类型不符!");
  726. }
  727. else
  728. {
  729. str = null;
  730. }
  731. System.Collections.ArrayList lev0 = (System.Collections.ArrayList)obj;
  732. str += "level0: count:" + lev0.Count.ToString() + "\n";
  733. for (int i = 0; i < lev0.Count; i++)
  734. {
  735. str += i.ToString() + ":" + lev0[i].GetType().ToString() + "\n";
  736. str += Keys(lev0[i]);
  737. }
  738. //System.Collections.ArrayList
  739. return str;
  740. }
  741. catch (Exception e)
  742. {
  743. string str = "error!\n" + e.ToString() + "\n";
  744. return str;
  745. }
  746. //return "error!\n code:-1";
  747. }
  748. /// <summary>
  749. /// 把哈希表的KEY与VALUE输出到字符串 test用
  750. /// </summary>
  751. /// <param name="obj">哈希表</param>
  752. /// <returns>包含有哈希表内容的字符串</returns>
  753. static private string Keys(object obj)
  754. {
  755. System.Collections.Hashtable objHasTab = (System.Collections.Hashtable)obj;
  756. string str = null;
  757. foreach (System.Collections.DictionaryEntry objDE in objHasTab)
  758. {
  759. str += objDE.Key.ToString() + "\n";
  760. if (objDE.Value.GetType().ToString() == "System.Collections.Hashtable")
  761. {
  762. str += Keys(objDE.Value);
  763. }
  764. else
  765. {
  766. str += " " + objDE.Value.ToString() + "\n";
  767. }
  768. }
  769. return str;
  770. }
  771. /// <summary>
  772. /// 取得CCP返回对象的某一行数据的方法
  773. /// </summary>
  774. /// <param name="obj">CCP的返回对象</param>
  775. /// <param name="i">行号</param>
  776. /// <returns>对应行的哈希表;如果出错,抛出“error”加错误编号的异常</returns>
  777. static public System.Collections.Hashtable GetHastabinArray(object obj, int i)
  778. {
  779. try
  780. {
  781. if (obj.GetType().ToString() == "System.Collections.ArrayList")
  782. {
  783. System.Collections.ArrayList objLIST = (System.Collections.ArrayList)obj;
  784. if (i >= objLIST.Count || i < 0)
  785. {
  786. Exception e = new Exception("(0)");
  787. throw e;
  788. }
  789. object r = objLIST[i];
  790. return (System.Collections.Hashtable)r;
  791. }
  792. else
  793. {
  794. Exception e = new Exception("(-1)");
  795. throw e;
  796. }
  797. }
  798. catch (Exception e)
  799. {
  800. string str = "error" + e.ToString();
  801. Exception re = new Exception(str);
  802. }
  803. return null;
  804. }
  805. /// <summary>
  806. /// 取得CCP返回对象的某一行数据的不会抛异常的方法
  807. /// </summary>
  808. /// <param name="obj">CCP的返回对象</param>
  809. /// <param name="i">行号</param>
  810. /// <returns>对应的哈希表.如果出错,返回NULL(如果这一行为NULL,也会返回NULL.要区别这种情况请用有异常返回的方法)</returns>
  811. static public System.Collections.Hashtable GetHastabinArrayNoEx(object obj, int i)
  812. {
  813. try
  814. {
  815. if (obj.GetType().ToString() == "System.Collections.ArrayList" && obj != null)
  816. {
  817. System.Collections.ArrayList objLIST = (System.Collections.ArrayList)obj;
  818. if (i >= objLIST.Count || i < 0)
  819. {
  820. return null;
  821. }
  822. object r = objLIST[i];
  823. return (System.Collections.Hashtable)r;
  824. }
  825. else
  826. {
  827. return null;
  828. }
  829. }
  830. catch (Exception e)
  831. {
  832. string str = "error:" + e.ToString();
  833. Exception re = new Exception(str);
  834. }
  835. return null;
  836. }
  837. /// <summary>
  838. /// 得到哈希表中的某一KEY值中的内容,如果其内容为哈希表,取该表的第一项内容
  839. /// </summary>
  840. /// <param name="hastab">要分析 的哈希表</param>
  841. /// <param name="keyname">键名</param>
  842. /// <returns>内容物。如果基内容为哈希表,取该表的第一项内容;后同</returns>
  843. static public object GetValueinHasTab(System.Collections.Hashtable hastab, string keyname)
  844. {
  845. try
  846. {
  847. object r = null;
  848. if (keyname == null)
  849. {
  850. foreach (System.Collections.DictionaryEntry objDE in hastab)
  851. {
  852. r = objDE.Value;
  853. if (r.GetType().ToString() == "System.Collections.Hashtable")
  854. {
  855. r = GetValueinHasTab((System.Collections.Hashtable)r, null);
  856. }
  857. break;
  858. }
  859. }
  860. else if (hastab.Contains(keyname))
  861. {
  862. r = hastab[keyname];
  863. if (r.GetType().ToString() == "System.Collections.Hashtable")
  864. {
  865. r = GetValueinHasTab((System.Collections.Hashtable)r, null);
  866. }
  867. }
  868. else
  869. {
  870. Exception e = new Exception("0");
  871. }
  872. return r;
  873. }
  874. catch (Exception e)
  875. {
  876. string str = "error in GetValueinHasTab:error code" + e.ToString();
  877. Exception re = new Exception(str);
  878. }
  879. return null;
  880. }
  881. /// <summary>
  882. /// 得到哈希表的所有KEY的名字。
  883. /// </summary>
  884. /// <param name="hastab">要分析的哈希表</param>
  885. /// <param name="output">要把KEY名输出的链表</param>
  886. /// <returns>是否成功</returns>
  887. static public bool GetKeys(System.Collections.Hashtable hastab, List<string> output)
  888. {
  889. try
  890. {
  891. output.Clear();
  892. foreach (System.Collections.DictionaryEntry objDE in hastab)
  893. {
  894. output.Add(objDE.Key.ToString());
  895. }
  896. return true;
  897. }
  898. catch
  899. {
  900. return false;
  901. }
  902. }
  903. }
  904. }