using Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace MeterModuleLibrary
{
public partial class ucCarMeterInfoJisco : UserControl
{
/**
* 2022/1/13 周俊伶创建 酒泉版本
*/
public ucCarMeterInfoJisco()
{
InitializeComponent();
}
///
/// 默认加载事件
///
///
///
private void ucCarMeterInfoJXJG_Load(object sender, EventArgs e)
{
//设置框线
tableLayoutPanelMsg.CellBorderStyle = (TableLayoutPanelCellBorderStyle)BorderStyle.FixedSingle;
}
public void setFormControlValue(MeterWorkCarActualFirst first)
{
txtMETER_TYPE.Text = first.meterTypeName;
txtPREDICTION_NO.Text = first.predictionNo;
txtMATTER_NAME.Text = first.matterName;
txtFORWARDING_UNIT_NAME.Text = first.forwardingUnitName;
txtRECEIVING_UINT_NAME.Text = first.receivingUintName;
txtCONTRACT_NO.Text = first.contractNo;
txtSHIPMENT_WEIGHT.Text = "毛/净:" + first.shipmentGrossWeight / 1000 + " T / " + first.shipmentNetWeight / 1000 + " T"; //预报毛重
//txtLOAD_POINT_NAME.Text = first.loadPointName;
string strMemo = first.memo;
if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
{
strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
}
// txtMEMO.Text = strMemo;
txtMETER_PIER_NAME.Text = first.meterPierName;
if (txtMETER_TYPE.Text.Contains("外购"))
{
setWgtBackColor(false);
}
}
public PreTrackScale _preTrack { get; set; }
public void setFormControlValue(PreTrackScale preTrack)
{
_preTrack = preTrack;
txtMETER_TYPE.Text = preTrack.meterTypeName;
txtPREDICTION_NO.Text = preTrack.predictionNo;
txtMATTER_NAME.Text = preTrack.matterName;
txtFORWARDING_UNIT_NAME.Text = preTrack.forwardingUnitName;
txtRECEIVING_UINT_NAME.Text = preTrack.receivingUintName;
txtCONTRACT_NO.Text = preTrack.contractNo;
txtSHIPMENT_WEIGHT.Text = "毛/净:" + preTrack.shipmentGrossWeight / 1000 + " T / " + preTrack.shipmentNetWeight / 1000 + " T"; //预报毛重
//txtLOAD_POINT_NAME.Text = preTrack.loadPointName;
//string strMemo = preTrack.memo;
//if (!string.IsNullOrEmpty(strMemo) && strMemo.Contains("发运:"))
//{
// strMemo = Regex.Split(strMemo, "发运:", RegexOptions.IgnoreCase)[1];
//}
//txtMEMO.Text = strMemo;
txtMETER_PIER_NAME.Text = preTrack.meterPierName;
if (PbCache.limit != null && PbCache.limit.Count > 0)
{
List mblc = PbCache.limit.Where(s => s.matterNo == preTrack.matterNo).ToList();
}
if (txtMETER_TYPE.Text.Contains("外购"))
{
setWgtBackColor(false);
}
}
public void setMeterType(string meterType)
{
txtMETER_TYPE.Text = meterType;
}
private delegate void UpdateUIEventHander(object sender, UpdateUIArgs args); //自定义事件用来从线程中更新控件的值
public class UpdateUIArgs : EventArgs
{
public string textValue { get; private set; }
public UpdateUIArgs(string textValue)
{
this.textValue = textValue;
}
}
///
/// 设置重量字体的背景颜色:Lime及NotShow(不显示)
///
///
public void setWgtBackColor(bool bControlText)
{
if (!PbCache.isLockWgt)
{
if (txtFORWARDING_UNIT_NAME.IsHandleCreated)
{
string sValue = bControlText ? "ControlText" : "NotShow";
txtFORWARDING_UNIT_NAME.Invoke(new UpdateUIEventHander(UpdateUIBackColor_Method), txtFORWARDING_UNIT_NAME, new UpdateUIArgs(sValue));
}
}
}
///
/// 设置显示的字体为背景色
///
///
///
private void UpdateUIBackColor_Method(object sender, UpdateUIArgs args)
{
if (sender is Label)
{
if (args.textValue == "ControlText")
{
//Color.Coral
((Label)sender).ForeColor = Color.Black;
}
else
{
//System.Drawing.Color.Transparent;跟随背景色
((Label)sender).ForeColor = Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(244)))), ((int)(((byte)(252)))));
//((Label)sender).ForeColor = Color.Transparent;
}
}
}
}
}