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)
{
string predictionTypeName = "";
switch (first.predictionType)
{
case "0":
predictionTypeName = "批次预报";
break;
case "1":
predictionTypeName = "单次预报";
break;
case "2":
predictionTypeName = "联运预报";
break;
case "3":
predictionTypeName = "分检预报";
break;
case "4":
predictionTypeName = "集装箱预报";
break;
case "5":
predictionTypeName = "双委托";
break;
case "6":
predictionTypeName = "一车多卸";
break;
case "7":
predictionTypeName = "混装";
break;
}
//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 = predictionTypeName;
setMsgInfo(txtMETER_TYPE, first.meterTypeName, "0");
setMsgInfo(txtPREDICTION_NO, first.predictionNo, "0");
setMsgInfo(txtMATTER_NAME, first.matterName, "0");
setMsgInfo(txtFORWARDING_UNIT_NAME, first.forwardingUnitName, "0");
setMsgInfo(txtRECEIVING_UINT_NAME, first.receivingUintName, "0");
setMsgInfo(txtCONTRACT_NO, predictionTypeName, "0");
//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.predictionType;
//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;
}
}
}
#region 信息提示框
public void setMsgInfo(Control control, string ResultMessage, string sType)
{
setMsgMsg(control, ResultMessage, sType);
}
private void setMsgMsg(Control control, string ResultMessage, string sType)
{
if (control.InvokeRequired)
{
Action action = new Action(setMsgInfo);
Invoke(action, new object[] { control, ResultMessage, sType });
}
else
{
switch (sType)
{
case "0":
control.Text = ResultMessage;
; break;
case "1":
control.Enabled = ResultMessage == "true" ? true : false;
; break;
case "2":
control.Visible = ResultMessage == "true" ? true : false;
; break;
case "3":
((RadioButton)control).Checked = ResultMessage == "true" ? true : false;
break;
case "4":
((ComboBox)control).SelectedValue = ResultMessage;
break;
case "5":
((RadioButton)control).Visible = ResultMessage == "true" ? true : false;
break;
case "6":
((CheckBox)control).Checked = ResultMessage == "true" ? true : false;
break;
case "7":
((Button)control).PerformClick();
break;
default: break;
}
}
}
#endregion 信息提示框
}
}