ucCarMeterInfoJXJG.cs 5.3 KB

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