ucCarMeterInfoJisco.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8. using System.Windows.Forms;
  9. namespace MeterModuleLibrary
  10. {
  11. public partial class ucCarMeterInfoJisco : UserControl
  12. {
  13. /**
  14. * 2022/1/13 周俊伶创建 酒泉版本
  15. */
  16. public ucCarMeterInfoJisco()
  17. {
  18. InitializeComponent();
  19. }
  20. /// <summary>
  21. /// 默认加载事件
  22. /// </summary>
  23. /// <param name="sender"></param>
  24. /// <param name="e"></param>
  25. private void ucCarMeterInfoJXJG_Load(object sender, EventArgs e)
  26. {
  27. //设置框线
  28. tableLayoutPanelMsg.CellBorderStyle = (TableLayoutPanelCellBorderStyle)BorderStyle.FixedSingle;
  29. }
  30. public void setFormControlValue(MeterWorkCarActualFirst first)
  31. {
  32. txtMETER_TYPE.Text = first.meterTypeName;
  33. txtPREDICTION_NO.Text = first.predictionNo;
  34. txtMATTER_NAME.Text = first.matterName;
  35. txtFORWARDING_UNIT_NAME.Text = first.forwardingUnitName;
  36. txtRECEIVING_UINT_NAME.Text = first.receivingUintName;
  37. txtCONTRACT_NO.Text = first.contractNo;
  38. txtSHIPMENT_WEIGHT.Text = "毛/净:" + first.shipmentGrossWeight / 1000 + " T / " + first.shipmentNetWeight / 1000 + " T"; //预报毛重
  39. //txtLOAD_POINT_NAME.Text = first.loadPointName;
  40. string strMemo = first.memo;
  41. if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
  42. {
  43. strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
  44. }
  45. // txtMEMO.Text = strMemo;
  46. txtMETER_PIER_NAME.Text = first.meterPierName;
  47. if (txtMETER_TYPE.Text.Contains("外购"))
  48. {
  49. setWgtBackColor(false);
  50. }
  51. }
  52. public PreTrackScale _preTrack { get; set; }
  53. public void setFormControlValue(PreTrackScale preTrack)
  54. {
  55. _preTrack = preTrack;
  56. txtMETER_TYPE.Text = preTrack.meterTypeName;
  57. txtPREDICTION_NO.Text = preTrack.predictionNo;
  58. txtMATTER_NAME.Text = preTrack.matterName;
  59. txtFORWARDING_UNIT_NAME.Text = preTrack.forwardingUnitName;
  60. txtRECEIVING_UINT_NAME.Text = preTrack.receivingUintName;
  61. txtCONTRACT_NO.Text = preTrack.contractNo;
  62. txtSHIPMENT_WEIGHT.Text = "毛/净:" + preTrack.shipmentGrossWeight / 1000 + " T / " + preTrack.shipmentNetWeight / 1000 + " T"; //预报毛重
  63. //txtLOAD_POINT_NAME.Text = preTrack.loadPointName;
  64. //string strMemo = preTrack.memo;
  65. //if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
  66. //{
  67. // strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
  68. //}
  69. //txtMEMO.Text = strMemo;
  70. txtMETER_PIER_NAME.Text = preTrack.meterPierName;
  71. if (PbCache.limit != null && PbCache.limit.Count > 0)
  72. {
  73. List<MeterBaseLimitChemical> mblc = PbCache.limit.Where(s => s.matterNo == preTrack.matterNo).ToList();
  74. }
  75. if (txtMETER_TYPE.Text.Contains("外购"))
  76. {
  77. setWgtBackColor(false);
  78. }
  79. }
  80. public void setMeterType(string meterType)
  81. {
  82. txtMETER_TYPE.Text = meterType;
  83. }
  84. private delegate void UpdateUIEventHander(object sender, UpdateUIArgs args); //自定义事件用来从线程中更新控件的值
  85. public class UpdateUIArgs : EventArgs
  86. {
  87. public string textValue { get; private set; }
  88. public UpdateUIArgs(string textValue)
  89. {
  90. this.textValue = textValue;
  91. }
  92. }
  93. /// <summary>
  94. /// 设置重量字体的背景颜色:Lime及NotShow(不显示)
  95. /// </summary>
  96. /// <param name="db"></param>
  97. public void setWgtBackColor(bool bControlText)
  98. {
  99. if (!PbCache.isLockWgt)
  100. {
  101. if (txtFORWARDING_UNIT_NAME.IsHandleCreated)
  102. {
  103. string sValue = bControlText ? "ControlText" : "NotShow";
  104. txtFORWARDING_UNIT_NAME.Invoke(new UpdateUIEventHander(UpdateUIBackColor_Method), txtFORWARDING_UNIT_NAME, new UpdateUIArgs(sValue));
  105. }
  106. }
  107. }
  108. /// <summary>
  109. /// 设置显示的字体为背景色
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="args"></param>
  113. private void UpdateUIBackColor_Method(object sender, UpdateUIArgs args)
  114. {
  115. if (sender is Label)
  116. {
  117. if (args.textValue == "ControlText")
  118. {
  119. //Color.Coral
  120. ((Label)sender).ForeColor = Color.Black;
  121. }
  122. else
  123. {
  124. //System.Drawing.Color.Transparent;跟随背景色
  125. ((Label)sender).ForeColor = Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(244)))), ((int)(((byte)(252)))));
  126. //((Label)sender).ForeColor = Color.Transparent;
  127. }
  128. }
  129. }
  130. }
  131. }