323 lines
12 KiB
C#
323 lines
12 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using System.Text.RegularExpressions;
|
||
using System.Collections;
|
||
using System.IO;
|
||
using System.Xml;
|
||
|
||
using Telerik.WinControls.UI;
|
||
using DAL;
|
||
using UserControlClass;
|
||
using BaseFunction;
|
||
|
||
namespace NSAnalysis
|
||
{
|
||
public partial class FEH3RightCarData : Telerik.WinControls.UI.ShapedForm
|
||
{
|
||
#region 全局变量
|
||
|
||
private TMeasureMSSQLDAL tmdal = new TMeasureMSSQLDAL();
|
||
private DataTable dtVINData = new DataTable();
|
||
private string strLastVIN = "";
|
||
CenterControl gCC = null;
|
||
#endregion 全局变量
|
||
|
||
#region 初始化控件
|
||
|
||
#endregion 初始化控件
|
||
|
||
public FEH3RightCarData(CenterControl cc)
|
||
{
|
||
InitializeComponent();
|
||
gCC = cc;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 指定屏幕显示
|
||
/// </summary>
|
||
public void SpecifyScreenDisplay1()
|
||
{
|
||
try
|
||
{
|
||
Screen[] screens = Screen.AllScreens;
|
||
// 指定显示在第二个显示器
|
||
Screen secondScreen = screens[1]; //1
|
||
|
||
// 设置窗体位置和大小
|
||
this.StartPosition = FormStartPosition.Manual;
|
||
this.Left = secondScreen.WorkingArea.Left;
|
||
this.Top = secondScreen.WorkingArea.Top;
|
||
this.Width = secondScreen.WorkingArea.Width;
|
||
this.Height = secondScreen.WorkingArea.Height;
|
||
this.Show();
|
||
}
|
||
catch { }
|
||
}
|
||
#region 初始化控件
|
||
|
||
|
||
private void InitNextSenseControl()
|
||
{
|
||
string strNSName = "";
|
||
UCVWNextSense ucns = null;
|
||
for (int i = 1; i <= 25; i++)
|
||
{
|
||
strNSName = "";//L0" + i.ToString();
|
||
if (i <= 9)
|
||
strNSName = "R0" + i.ToString();
|
||
else
|
||
{
|
||
strNSName = "R" + i.ToString();
|
||
}
|
||
ucns = ((UCVWNextSense)MyBase.GetChildControl(this, strNSName));
|
||
if (ucns != null)
|
||
{
|
||
ucns.tlpBackColor = Color.White;
|
||
ucns.tlpFBackColor = Color.White;
|
||
ucns.tlpGBackColor = Color.White;
|
||
ucns.labFVal = "";
|
||
ucns.labFLowerUpper = "";
|
||
ucns.labGVal = "";
|
||
ucns.labGLowerUpper = "";
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion 初始化控件
|
||
|
||
private void FEH3RightCarData_Load(object sender, EventArgs e)
|
||
{
|
||
//InitNextSenseOneItemControl();
|
||
InitNextSenseControl();
|
||
labVIN.Text = "";
|
||
tmrRefreshData.Interval = 1100;
|
||
tmrRefreshData.Start();
|
||
SpecifyScreenDisplay1();
|
||
}
|
||
|
||
private void btnRefresh_Click(object sender, EventArgs e)
|
||
{
|
||
SpecifyScreenDisplay1();
|
||
string strVIN = tmdal.SelectMaintenanceStation7VIN();
|
||
if (strVIN.ToLower().Contains("empty"))
|
||
{
|
||
labVIN.Text = "VIN码为空";
|
||
InitNextSenseControl();
|
||
}
|
||
else
|
||
{
|
||
if (strVIN.Length==17)
|
||
{
|
||
string strSubVIN = strVIN;// strVIN.Substring(0, strVIN.Length - 2);
|
||
dtVINData.Clear();
|
||
labVIN.Text = strSubVIN;
|
||
string strCarType = tmdal.SelectCarTypeByVIN(strSubVIN);
|
||
MyBase.TraceWriteLine("Right EH3 UI Refresh Button (strVIN.Length==17):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||
if (strCarType.ToUpper().Contains("EH3"))
|
||
{
|
||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||
if (dtVINData.Rows.Count > 0)
|
||
{
|
||
refreshCarUIData(dtVINData);
|
||
analysisTitleColor();
|
||
}
|
||
else
|
||
{
|
||
InitNextSenseControl();
|
||
}
|
||
}
|
||
}
|
||
if (strVIN.Length == 21)
|
||
{
|
||
string strSubVIN = strVIN.Substring(0, strVIN.Length - 4);
|
||
dtVINData.Clear();
|
||
labVIN.Text = strSubVIN;
|
||
string strCarType = strVIN.Substring(strVIN.Length - 3, 3);
|
||
MyBase.TraceWriteLine("Right EH3 UI Refresh Button (strVIN.Length==21):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||
if (strCarType.ToUpper().Contains("EH3"))
|
||
{
|
||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||
if (dtVINData.Rows.Count > 0)
|
||
{
|
||
refreshCarUIData(dtVINData);
|
||
analysisTitleColor();
|
||
}
|
||
else
|
||
{
|
||
InitNextSenseControl();
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
private void tmrRefreshData_Tick(object sender, EventArgs e)
|
||
{
|
||
tmrRefreshData.Stop();
|
||
string strVIN = tmdal.SelectMaintenanceStation7VIN();
|
||
if (strLastVIN != strVIN)
|
||
{
|
||
if (strVIN.ToLower().Contains("empty"))
|
||
{
|
||
labVIN.Text = "VIN码为空";
|
||
//InitNextSenseOneItemControl();
|
||
InitNextSenseControl();
|
||
}
|
||
else
|
||
{
|
||
if (strVIN.Length == 17)
|
||
{
|
||
string strSubVIN = strVIN;//.Substring(0, strVIN.Length - 2);
|
||
dtVINData.Clear();
|
||
labVIN.Text = strSubVIN;
|
||
string strCarType = tmdal.SelectCarTypeByVIN(strSubVIN);
|
||
MyBase.TraceWriteLine("Right EH3 UI Refresh tmrRefreshData (strVIN.Length==17):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||
if (strCarType.ToUpper().Contains("EH3"))
|
||
{
|
||
SpecifyScreenDisplay1();
|
||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||
if (dtVINData.Rows.Count > 0)
|
||
{
|
||
refreshCarUIData(dtVINData);
|
||
analysisTitleColor();
|
||
}
|
||
else
|
||
{
|
||
InitNextSenseControl();
|
||
}
|
||
gCC.ShowCarMeasureDataByCarType(1);
|
||
}
|
||
}
|
||
if (strVIN.Length == 21)
|
||
{
|
||
string strSubVIN = strVIN.Substring(0, 17);
|
||
dtVINData.Clear();
|
||
labVIN.Text = strSubVIN;
|
||
string strCarType = strVIN.Substring(18, 3);
|
||
MyBase.TraceWriteLine("Right EH3 UI Refresh tmrRefreshData (strVIN.Length==21):CarType:" + strCarType + " ;VIN: " + strSubVIN);
|
||
if (strCarType.ToUpper().Contains("EH3"))
|
||
{
|
||
SpecifyScreenDisplay1();
|
||
dtVINData = tmdal.SelectTMeasureDataByCarIDAndMPN(strSubVIN, "R");
|
||
if (dtVINData.Rows.Count > 0)
|
||
{
|
||
refreshCarUIData(dtVINData);
|
||
analysisTitleColor();
|
||
}
|
||
else
|
||
{
|
||
InitNextSenseControl();
|
||
}
|
||
gCC.ShowCarMeasureDataByCarType(1);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
strLastVIN = strVIN;
|
||
tmrRefreshData.Start();
|
||
}
|
||
|
||
private Color analysisColorbyStatus(string strStatus)
|
||
{
|
||
Color colStatus = new Color();
|
||
switch (strStatus.ToLower())
|
||
{
|
||
case "best":
|
||
colStatus = Color.Lime;
|
||
break;
|
||
|
||
case "good":
|
||
colStatus = Color.Lime;
|
||
break;
|
||
|
||
case "ng1":
|
||
colStatus = Color.Yellow;
|
||
break;
|
||
|
||
case "ng2":
|
||
colStatus = Color.Red;
|
||
break;
|
||
|
||
default:
|
||
colStatus = Color.LightGray;
|
||
break;
|
||
}
|
||
return colStatus;
|
||
}
|
||
|
||
private void analysisTitleColor()
|
||
{
|
||
string strNSName = "";
|
||
UCVWNextSense ucns = null;
|
||
for (int i = 1; i <= 25; i++)
|
||
{
|
||
if (i <= 9)
|
||
strNSName = "R0" + i.ToString();
|
||
else
|
||
{
|
||
strNSName = "R" + i.ToString();
|
||
}
|
||
ucns = ((UCVWNextSense)MyBase.GetChildControl(this, strNSName));
|
||
if (ucns != null)
|
||
{
|
||
if (ucns.tlpFBackColor == Color.Red || ucns.tlpGBackColor == Color.Red)
|
||
{
|
||
ucns.tlpBackColor = Color.Red;
|
||
}
|
||
else if (ucns.tlpFBackColor == Color.LightGray && ucns.tlpGBackColor == Color.LightGray)
|
||
{
|
||
ucns.tlpBackColor = Color.LightGray;
|
||
}
|
||
else if (ucns.tlpFBackColor == Color.Yellow && ucns.tlpGBackColor == Color.Yellow)
|
||
{
|
||
ucns.tlpBackColor = Color.Yellow;
|
||
}
|
||
else
|
||
{
|
||
ucns.tlpBackColor = Color.Lime;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void refreshCarUIData(DataTable dtData)
|
||
{
|
||
string strNSName = "";
|
||
string strFGName = "";
|
||
UCVWNextSense ucns = null;
|
||
for (int i = 0; i < dtData.Rows.Count; i++)
|
||
{
|
||
strNSName = dtData.Rows[i]["MeasPointName"].ToString().Replace("-", "");
|
||
strFGName = dtData.Rows[i]["DimensionName"].ToString();
|
||
ucns = ((UCVWNextSense)MyBase.GetChildControl(this, strNSName));
|
||
if (ucns != null)
|
||
{
|
||
if (strFGName == "F")
|
||
{
|
||
ucns.labFVal = dtData.Rows[i]["MeasureValue"].ToString();
|
||
ucns.labFLowerUpper = dtData.Rows[i]["LowerTolVal"].ToString() + "/" + dtData.Rows[i]["UpperTolVal"].ToString();
|
||
ucns.tlpFBackColor = analysisColorbyStatus(dtData.Rows[i]["MeasureItemResult"].ToString());
|
||
}
|
||
else
|
||
{
|
||
ucns.labGVal = dtData.Rows[i]["MeasureValue"].ToString();
|
||
ucns.labGLowerUpper = dtData.Rows[i]["LowerTolVal"].ToString() + "/" + dtData.Rows[i]["UpperTolVal"].ToString();
|
||
ucns.tlpGBackColor = analysisColorbyStatus(dtData.Rows[i]["MeasureItemResult"].ToString());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void FEH3RightCarData_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
e.Cancel = true;
|
||
this.Hide();
|
||
}
|
||
}
|
||
} |