ucCarMeterInfoJisco.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. string predictionTypeName = "";
  33. switch (first.predictionType)
  34. {
  35. case "0":
  36. predictionTypeName = "批次预报";
  37. break;
  38. case "1":
  39. predictionTypeName = "单次预报";
  40. break;
  41. case "2":
  42. predictionTypeName = "联运预报";
  43. break;
  44. case "3":
  45. predictionTypeName = "分检预报";
  46. break;
  47. case "4":
  48. predictionTypeName = "集装箱预报";
  49. break;
  50. case "5":
  51. predictionTypeName = "双委托";
  52. break;
  53. case "6":
  54. predictionTypeName = "一车多卸";
  55. break;
  56. case "7":
  57. predictionTypeName = "混装";
  58. break;
  59. }
  60. txtMETER_TYPE.Text = first.meterTypeName;
  61. txtPREDICTION_NO.Text = first.predictionNo;
  62. txtMATTER_NAME.Text = first.matterName;
  63. txtFORWARDING_UNIT_NAME.Text = first.forwardingUnitName;
  64. txtRECEIVING_UINT_NAME.Text = first.receivingUintName;
  65. txtCONTRACT_NO.Text = predictionTypeName;
  66. //txtSHIPMENT_WEIGHT.Text = "毛/净:" + first.shipmentGrossWeight / 1000 + " T / " + first.shipmentNetWeight / 1000 + " T"; //预报毛重
  67. //txtLOAD_POINT_NAME.Text = first.loadPointName;
  68. string strMemo = first.memo;
  69. if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
  70. {
  71. strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
  72. }
  73. // txtMEMO.Text = strMemo;
  74. //txtMETER_PIER_NAME.Text = first.meterPierName;
  75. if (txtMETER_TYPE.Text.Contains("外购"))
  76. {
  77. setWgtBackColor(false);
  78. }
  79. }
  80. public PreTrackScale _preTrack { get; set; }
  81. public void setFormControlValue(PreTrackScale preTrack)
  82. {
  83. _preTrack = preTrack;
  84. txtMETER_TYPE.Text = preTrack.meterTypeName;
  85. txtPREDICTION_NO.Text = preTrack.predictionNo;
  86. txtMATTER_NAME.Text = preTrack.matterName;
  87. txtFORWARDING_UNIT_NAME.Text = preTrack.forwardingUnitName;
  88. txtRECEIVING_UINT_NAME.Text = preTrack.receivingUintName;
  89. txtCONTRACT_NO.Text = preTrack.predictionType;
  90. //txtSHIPMENT_WEIGHT.Text = "毛/净:" + preTrack.shipmentGrossWeight / 1000 + " T / " + preTrack.shipmentNetWeight / 1000 + " T"; //预报毛重
  91. //txtLOAD_POINT_NAME.Text = preTrack.loadPointName;
  92. //string strMemo = preTrack.memo;
  93. //if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
  94. //{
  95. // strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
  96. //}
  97. //txtMEMO.Text = strMemo;
  98. //txtMETER_PIER_NAME.Text = preTrack.meterPierName;
  99. if (PbCache.limit != null && PbCache.limit.Count > 0)
  100. {
  101. List<MeterBaseLimitChemical> mblc = PbCache.limit.Where(s => s.matterNo == preTrack.matterNo).ToList();
  102. }
  103. if (txtMETER_TYPE.Text.Contains("外购"))
  104. {
  105. setWgtBackColor(false);
  106. }
  107. }
  108. public void setMeterType(string meterType)
  109. {
  110. txtMETER_TYPE.Text = meterType;
  111. }
  112. private delegate void UpdateUIEventHander(object sender, UpdateUIArgs args); //自定义事件用来从线程中更新控件的值
  113. public class UpdateUIArgs : EventArgs
  114. {
  115. public string textValue { get; private set; }
  116. public UpdateUIArgs(string textValue)
  117. {
  118. this.textValue = textValue;
  119. }
  120. }
  121. /// <summary>
  122. /// 设置重量字体的背景颜色:Lime及NotShow(不显示)
  123. /// </summary>
  124. /// <param name="db"></param>
  125. public void setWgtBackColor(bool bControlText)
  126. {
  127. if (!PbCache.isLockWgt)
  128. {
  129. if (txtFORWARDING_UNIT_NAME.IsHandleCreated)
  130. {
  131. string sValue = bControlText ? "ControlText" : "NotShow";
  132. txtFORWARDING_UNIT_NAME.Invoke(new UpdateUIEventHander(UpdateUIBackColor_Method), txtFORWARDING_UNIT_NAME, new UpdateUIArgs(sValue));
  133. }
  134. }
  135. }
  136. /// <summary>
  137. /// 设置显示的字体为背景色
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="args"></param>
  141. private void UpdateUIBackColor_Method(object sender, UpdateUIArgs args)
  142. {
  143. if (sender is Label)
  144. {
  145. if (args.textValue == "ControlText")
  146. {
  147. //Color.Coral
  148. ((Label)sender).ForeColor = Color.Black;
  149. }
  150. else
  151. {
  152. //System.Drawing.Color.Transparent;跟随背景色
  153. ((Label)sender).ForeColor = Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(244)))), ((int)(((byte)(252)))));
  154. //((Label)sender).ForeColor = Color.Transparent;
  155. }
  156. }
  157. }
  158. }
  159. }