QcmJudgeLockRecordCtrl.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Tool;
  3. using Core.StlMes.Client.Judge.Commons;
  4. using CoreFS.CA06;
  5. using Infragistics.Win;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Windows.Forms;
  11. namespace Core.StlMes.Client.Judge.Controls
  12. {
  13. public partial class QcmJudgeLockRecordCtrl : UserControl
  14. {
  15. private Dal _d;
  16. private string _userId;
  17. public QcmJudgeLockRecordCtrl(Control container, OpeBase ob, string userId)
  18. {
  19. InitializeComponent();
  20. _d = new Dal(ob);
  21. _userId = userId;
  22. container.Controls.Add(this);
  23. this.Dock = DockStyle.Fill;
  24. ValueList lockFlagList = new ValueList();
  25. lockFlagList.ValueListItems.Add("0", "未锁定");
  26. lockFlagList.ValueListItems.Add("1", "已锁定");
  27. ultraGrid1.DisplayLayout.Bands[0].Columns["lockFlag"].ValueList = lockFlagList;
  28. }
  29. private string _judgeStoveNo = "";
  30. private string _lockTimeB = "";
  31. private string _lockTimeE = "";
  32. private string _user = "";
  33. private string _orderNo = "";
  34. private string _lockFlag = "";
  35. public void Query(string judgeStoveNo, string lockTimeB, string lockTimeE, string user, string orderNo, string lockFlag)
  36. {
  37. _judgeStoveNo = judgeStoveNo;
  38. _lockTimeB = lockTimeB;
  39. _lockTimeE = lockTimeE;
  40. _user = user;
  41. _orderNo = orderNo;
  42. _lockFlag = lockFlag;
  43. DataTable dt = _d.GetTableByXmlId("JdgQcmJudgeLock.getLockRecord", judgeStoveNo, lockTimeB, lockTimeE, user, orderNo, lockFlag);
  44. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  45. GridHelper.RefreshAndAutoSize(ultraGrid1);
  46. }
  47. public void Unlock()
  48. {
  49. var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("chk") == "True");
  50. if (chkRows.Count() == 0)
  51. {
  52. MessageUtil.ShowWarning("请选择一行记录!");
  53. return;
  54. }
  55. if (MessageUtil.ShowYesNoAndQuestion("是否确认解锁?") == DialogResult.No)
  56. {
  57. return;
  58. }
  59. List<string> jsons = new List<string>();
  60. string lockId = ultraGrid1.ActiveRow.GetValue("lockId");
  61. foreach (var row in chkRows)
  62. {
  63. jsons.Add(JsonHelper.ToJson(row));
  64. }
  65. var ccp = _d.Set("com.steering.pss.judge.Bll.BllQcmJudgeLock.unlock", jsons, _userId);
  66. if (ccp.ReturnInfo.ToString2() != "")
  67. {
  68. MessageUtil.ShowWarning(ccp.ReturnInfo.ToString2());
  69. }
  70. else
  71. {
  72. MessageUtil.ShowTips("操作成功!");
  73. Relocate(lockId);
  74. }
  75. }
  76. private void Relocate(string lockId)
  77. {
  78. Query(_judgeStoveNo, _lockTimeB, _lockTimeE, _user, _orderNo, _lockFlag);
  79. var row = ultraGrid1.Rows.Where(a => a.GetValue("lockId") == lockId).FirstOrDefault();
  80. if (row != null)
  81. {
  82. row.Activate();
  83. }
  84. }
  85. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  86. {
  87. e.Cell.Row.Update();
  88. }
  89. }
  90. }