ucCarMeterInfoJisco.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. setMsgInfo(txtMETER_TYPE, first.meterTypeName, "0");
  67. setMsgInfo(txtPREDICTION_NO, first.predictionNo, "0");
  68. setMsgInfo(txtMATTER_NAME, first.matterName, "0");
  69. setMsgInfo(txtFORWARDING_UNIT_NAME, first.forwardingUnitName, "0");
  70. setMsgInfo(txtRECEIVING_UINT_NAME, first.receivingUintName, "0");
  71. setMsgInfo(txtCONTRACT_NO, predictionTypeName, "0");
  72. //txtSHIPMENT_WEIGHT.Text = "毛/净:" + first.shipmentGrossWeight / 1000 + " T / " + first.shipmentNetWeight / 1000 + " T"; //预报毛重
  73. //txtLOAD_POINT_NAME.Text = first.loadPointName;
  74. string strMemo = first.memo;
  75. if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
  76. {
  77. strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
  78. }
  79. // txtMEMO.Text = strMemo;
  80. //txtMETER_PIER_NAME.Text = first.meterPierName;
  81. if (txtMETER_TYPE.Text.Contains("外购"))
  82. {
  83. setWgtBackColor(false);
  84. }
  85. }
  86. public PreTrackScale _preTrack { get; set; }
  87. public void setFormControlValue(PreTrackScale preTrack)
  88. {
  89. _preTrack = preTrack;
  90. txtMETER_TYPE.Text = preTrack.meterTypeName;
  91. txtPREDICTION_NO.Text = preTrack.predictionNo;
  92. txtMATTER_NAME.Text = preTrack.matterName;
  93. txtFORWARDING_UNIT_NAME.Text = preTrack.forwardingUnitName;
  94. txtRECEIVING_UINT_NAME.Text = preTrack.receivingUintName;
  95. txtCONTRACT_NO.Text = preTrack.predictionType;
  96. //txtSHIPMENT_WEIGHT.Text = "毛/净:" + preTrack.shipmentGrossWeight / 1000 + " T / " + preTrack.shipmentNetWeight / 1000 + " T"; //预报毛重
  97. //txtLOAD_POINT_NAME.Text = preTrack.loadPointName;
  98. //string strMemo = preTrack.memo;
  99. //if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
  100. //{
  101. // strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
  102. //}
  103. //txtMEMO.Text = strMemo;
  104. //txtMETER_PIER_NAME.Text = preTrack.meterPierName;
  105. if (PbCache.limit != null && PbCache.limit.Count > 0)
  106. {
  107. List<MeterBaseLimitChemical> mblc = PbCache.limit.Where(s => s.matterNo == preTrack.matterNo).ToList();
  108. }
  109. if (txtMETER_TYPE.Text.Contains("外购"))
  110. {
  111. setWgtBackColor(false);
  112. }
  113. }
  114. public void setMeterType(string meterType)
  115. {
  116. txtMETER_TYPE.Text = meterType;
  117. }
  118. private delegate void UpdateUIEventHander(object sender, UpdateUIArgs args); //自定义事件用来从线程中更新控件的值
  119. public class UpdateUIArgs : EventArgs
  120. {
  121. public string textValue { get; private set; }
  122. public UpdateUIArgs(string textValue)
  123. {
  124. this.textValue = textValue;
  125. }
  126. }
  127. /// <summary>
  128. /// 设置重量字体的背景颜色:Lime及NotShow(不显示)
  129. /// </summary>
  130. /// <param name="db"></param>
  131. public void setWgtBackColor(bool bControlText)
  132. {
  133. if (!PbCache.isLockWgt)
  134. {
  135. if (txtFORWARDING_UNIT_NAME.IsHandleCreated)
  136. {
  137. string sValue = bControlText ? "ControlText" : "NotShow";
  138. txtFORWARDING_UNIT_NAME.Invoke(new UpdateUIEventHander(UpdateUIBackColor_Method), txtFORWARDING_UNIT_NAME, new UpdateUIArgs(sValue));
  139. }
  140. }
  141. }
  142. /// <summary>
  143. /// 设置显示的字体为背景色
  144. /// </summary>
  145. /// <param name="sender"></param>
  146. /// <param name="args"></param>
  147. private void UpdateUIBackColor_Method(object sender, UpdateUIArgs args)
  148. {
  149. if (sender is Label)
  150. {
  151. if (args.textValue == "ControlText")
  152. {
  153. //Color.Coral
  154. ((Label)sender).ForeColor = Color.Black;
  155. }
  156. else
  157. {
  158. //System.Drawing.Color.Transparent;跟随背景色
  159. ((Label)sender).ForeColor = Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(244)))), ((int)(((byte)(252)))));
  160. //((Label)sender).ForeColor = Color.Transparent;
  161. }
  162. }
  163. }
  164. #region 信息提示框
  165. public void setMsgInfo(Control control, string ResultMessage, string sType)
  166. {
  167. setMsgMsg(control, ResultMessage, sType);
  168. }
  169. private void setMsgMsg(Control control, string ResultMessage, string sType)
  170. {
  171. if (control.InvokeRequired)
  172. {
  173. Action<Control, string, string> action = new Action<Control, string, string>(setMsgInfo);
  174. Invoke(action, new object[] { control, ResultMessage, sType });
  175. }
  176. else
  177. {
  178. switch (sType)
  179. {
  180. case "0":
  181. control.Text = ResultMessage;
  182. ; break;
  183. case "1":
  184. control.Enabled = ResultMessage == "true" ? true : false;
  185. ; break;
  186. case "2":
  187. control.Visible = ResultMessage == "true" ? true : false;
  188. ; break;
  189. case "3":
  190. ((RadioButton)control).Checked = ResultMessage == "true" ? true : false;
  191. break;
  192. case "4":
  193. ((ComboBox)control).SelectedValue = ResultMessage;
  194. break;
  195. case "5":
  196. ((RadioButton)control).Visible = ResultMessage == "true" ? true : false;
  197. break;
  198. case "6":
  199. ((CheckBox)control).Checked = ResultMessage == "true" ? true : false;
  200. break;
  201. case "7":
  202. ((Button)control).PerformClick();
  203. break;
  204. default: break;
  205. }
  206. }
  207. }
  208. #endregion 信息提示框
  209. }
  210. }