InstructionCardControl.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using com.steering.mes.mcp.entity;
  6. using Core.Mes.Client.Comm.Server;
  7. using Core.Mes.Client.Comm.Tool;
  8. using Core.StlMes.Client.Mcp.Control.Entity;
  9. using Infragistics.Win.UltraWinGrid;
  10. namespace Core.StlMes.Client.Mcp.Control.Machining
  11. {
  12. public partial class InstructionCardControl : MchControlBase
  13. {
  14. public InstructionCardControl()
  15. {
  16. InitializeComponent();
  17. EntityHelper.ShowGridCaption<MchLoadingResultEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  18. gx = "701301";
  19. Value = null;
  20. }
  21. protected override void ultraGrid1_CellChange(object sender, CellEventArgs e)
  22. {
  23. try
  24. {
  25. if (e.Cell.Column.Key.Equals("LoadTime"))
  26. {
  27. return;
  28. }
  29. ultraGrid1.UpdateData();
  30. if (e.Cell.Column.Key.Equals("ProNum"))
  31. {
  32. DataTable dt =
  33. ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMcpLoading.getQueryWeight",
  34. new object[]
  35. {
  36. e.Cell.Value.ToString(),
  37. PlnZyJgxCEntity.FeedHeatNo,
  38. PlnZyJgxCEntity.BatchNo,
  39. PlnZyJgxCEntity.BatchGroudNo
  40. }, this.Ob);
  41. if (dt.Rows.Count > 0)
  42. {
  43. decimal weigt;
  44. decimal.TryParse(dt.Rows[0]["ACT_WEIGHT"].ToString(), out weigt);
  45. e.Cell.Row.Cells["ProWt"].Value = weigt;
  46. }
  47. }
  48. if (e.Cell.Column.Key.Equals("LoadGroup") && Value.LoadGroup != null)
  49. {
  50. name.DataSource = Names.Where(p => p.ColGroup == Value.LoadGroup).ToList();
  51. }
  52. ultraGrid1.Refresh();
  53. }
  54. catch (Exception ex)
  55. {
  56. }
  57. }
  58. public MchLoadingResultEntity Value
  59. {
  60. get
  61. {
  62. var list =
  63. mchLoadingResultEntityBindingSource.DataSource as List<MchLoadingResultEntity>;
  64. return (list == null) || !list.Any() ? new MchLoadingResultEntity() : list.FirstOrDefault();
  65. }
  66. set
  67. {
  68. if (value == null)
  69. {
  70. mchLoadingResultEntityBindingSource.DataSource = new List<MchLoadingResultEntity>
  71. {
  72. new MchLoadingResultEntity()
  73. };
  74. ScrappedList = new List<MchBugDEntity>();
  75. }
  76. else
  77. {
  78. mchLoadingResultEntityBindingSource.DataSource = new List<MchLoadingResultEntity> { value.Clone() };
  79. if ((ob == null) || (ob.MainUrl == "")) return;
  80. if (_plineCode != Value.PlineCode)
  81. {
  82. Names = EntityHelper.GetData<HttSignatureEntity>(
  83. "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign",
  84. new object[] { Value.PlineCode, "0" }, Ob);
  85. name.DisplayMember = "UserName";
  86. name.ValueMember = "UserName";
  87. YdmBaseClass.SetComboItemHeight(name);
  88. _plineCode = Value.PlineCode;
  89. }
  90. name.DataSource = Names.Where(p => p.ColGroup == value.LoadGroup).ToList();
  91. if (value.FailNum == 0)
  92. ScrappedList = new List<MchBugDEntity>();
  93. ultraGrid1.DisplayLayout.Bands[0].Columns["ProNum"].MaxValue = value.ProNum;
  94. }
  95. }
  96. }
  97. protected override void EditScrapped()
  98. {
  99. Value.FailNum = ScrappedList.Sum(p=>p.FailNum);
  100. Value.FailWt = ScrappedList.Sum(p => p.FailWt);
  101. ultraGrid1.Refresh();
  102. }
  103. }
  104. }