You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
450 lines
14 KiB
450 lines
14 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using mshtml;
|
|
using Stone.Common;
|
|
using Stone.Entity;
|
|
using Stone.User;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Stone.WinModule.Quality
|
|
{
|
|
public partial class frmViewQuality : Form
|
|
{
|
|
#region 构造函数
|
|
|
|
private HtmlDocument doc = null;
|
|
|
|
private HtmlElement lblTimer = null; //当前时间
|
|
private HtmlElement txtBarCode = null; //条码文本框
|
|
private HtmlElement txtProductName = null; //产品名称
|
|
private HtmlElement btnCompleteScrap = null;//报废提交
|
|
private HtmlElement btnComplete = null; //完成提交
|
|
private HtmlElement tb_reason = null; //缺陷类型
|
|
private HtmlElement tb_responsibility = null; //责任方
|
|
private HtmlElement btnQuit = null;
|
|
private HtmlElement lblMsg = null;
|
|
|
|
private string BarCode = "";
|
|
private DataSet dsBarCode = null;
|
|
private Entity_t_Product t_Product = new Entity_t_Product();
|
|
private Entity_t_CarModel t_CarModel = new Entity_t_CarModel();
|
|
|
|
private Entity_t_Quality t_Quality = new Entity_t_Quality();
|
|
private Entity_t_JIS_Assemble t_JIS_Assemble = new Entity_t_JIS_Assemble();
|
|
|
|
|
|
[DllImport("user32.dll", EntryPoint = "ShowCursor", CharSet = CharSet.Auto)]
|
|
public extern static void ShowCursor(int status);
|
|
public frmViewQuality()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public string _BarCode = "";
|
|
public string _Type = "";
|
|
|
|
|
|
private void frmViewQuality_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.webBrowser1.Navigate(Application.StartupPath + "\\html\\质量采集.html");
|
|
this.webBrowser1.ScriptErrorsSuppressed = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
}
|
|
}
|
|
|
|
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
doc = webBrowser1.Document;
|
|
|
|
|
|
Init();
|
|
|
|
this.btnQuit.Click += new HtmlElementEventHandler(btnQuit_Click);
|
|
this.txtBarCode.KeyDown += new HtmlElementEventHandler(txtBarCode_KeyDown);
|
|
this.btnComplete.Click += new HtmlElementEventHandler(btnComplete_Click);
|
|
this.btnCompleteScrap.Click += new HtmlElementEventHandler(btnCompleteScrap_Click); ;
|
|
|
|
|
|
|
|
this.timer1.Enabled = true;
|
|
|
|
|
|
//if (_BarCode != "")
|
|
//{
|
|
// this.txtBarCode.SetAttribute("value", _BarCode);
|
|
|
|
// ScanBarCode();
|
|
//}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
}
|
|
}
|
|
|
|
void btnQuit_Click(object sender, HtmlElementEventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 事件
|
|
|
|
private void txtBarCode_KeyDown(object sender, HtmlElementEventArgs e)
|
|
{
|
|
if (e.KeyPressedCode == 13)
|
|
{
|
|
ScanBarCode();
|
|
}
|
|
}
|
|
|
|
private void ScanBarCode()
|
|
{
|
|
//this.txtBarCode.Enabled = false;
|
|
try
|
|
{
|
|
Clear();
|
|
|
|
BarCode = txtBarCode.GetAttribute("value").Trim();
|
|
if (BarCode == "") throw new Exception("条码不能为空");
|
|
|
|
string productionNumber = BarCode;
|
|
string partType = "02";
|
|
|
|
dsBarCode = t_JIS_Assemble.GetData("[productionNumber]='" + productionNumber + "' and [PartType]='" + partType + "'");
|
|
if (dsBarCode.Tables[0].Rows.Count == 0) throw new Exception(BarCode + " 在系统中不存在");
|
|
|
|
txtProductName.InnerHtml = dsBarCode.Tables[0].Rows[0]["description"].ToString();
|
|
|
|
Entity_t_Quality_interface t_Quality_interface = new Entity_t_Quality_interface();
|
|
DataRow drQualityInterface = t_Quality_interface.Table.NewRow();
|
|
drQualityInterface["productionNumber"] = productionNumber;
|
|
drQualityInterface["parttype"] = partType;
|
|
t_Quality_interface.Add(drQualityInterface);
|
|
|
|
TimerLastNow = TimerLast;
|
|
timer2.Enabled = true;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
Clear();
|
|
}
|
|
finally
|
|
{
|
|
doc.InvokeScript("barcode_select");
|
|
}
|
|
}
|
|
|
|
private void btnComplete_Click(object sender, HtmlElementEventArgs e)
|
|
{
|
|
|
|
Submit();
|
|
|
|
}
|
|
|
|
private void btnCompleteScrap_Click(object sender, HtmlElementEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (dsBarCode == null) throw new Exception("请先扫描条码");
|
|
|
|
string Reason = GetReason(); //缺陷类型
|
|
string Responsibility = GetResponsibility(); //责任方
|
|
|
|
if (Reason == "") throw new Exception("请选择 缺陷类型");
|
|
if (Responsibility == "") throw new Exception("请选择 责任方");
|
|
|
|
string productionNumber = dsBarCode.Tables[0].Rows[0]["productionNumber"].ToString();
|
|
string partType = dsBarCode.Tables[0].Rows[0]["partType"].ToString();
|
|
|
|
DataSet dsQuality = t_Quality.GetData("top 1 *", "[productionNumber]='" + productionNumber + "' and [partType]='" + partType + "'", "[AddTime] desc");
|
|
if (dsQuality.Tables[0].Rows.Count > 0) t_Quality.Del("[ID]=" + dsQuality.Tables[0].Rows[0]["ID"].ToString());
|
|
|
|
DataRow drQuality = t_Quality.Table.NewRow();
|
|
drQuality["productionNumber"] = dsBarCode.Tables[0].Rows[0]["productionNumber"].ToString();
|
|
drQuality["itemNumber"] = dsBarCode.Tables[0].Rows[0]["itemNumber"].ToString();
|
|
drQuality["description"] = dsBarCode.Tables[0].Rows[0]["description"].ToString();
|
|
drQuality["CarModelCode"] = dsBarCode.Tables[0].Rows[0]["CarModelCode"].ToString();
|
|
drQuality["partType"] = dsBarCode.Tables[0].Rows[0]["partType"].ToString();
|
|
drQuality["State"] = "报废";
|
|
drQuality["Reason"] = Reason;
|
|
drQuality["Responsibility"] = Responsibility;
|
|
|
|
|
|
drQuality = t_Quality.Add(drQuality);
|
|
|
|
|
|
txtBarCode.SetAttribute("value", "");
|
|
Clear();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
this.txtBarCode.Enabled = true;
|
|
doc.InvokeScript("barcode_select");
|
|
|
|
}
|
|
}
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.lblTimer.InnerHtml = DateTime.Now.ToString("HH:mm:ss");
|
|
}
|
|
catch { }
|
|
}
|
|
|
|
|
|
private void Submit()
|
|
{
|
|
|
|
try
|
|
{
|
|
if (dsBarCode == null) throw new Exception("请先扫描条码");
|
|
|
|
string Reason = GetReason(); //缺陷类型
|
|
string Responsibility = GetResponsibility(); //责任方
|
|
|
|
string productionNumber = dsBarCode.Tables[0].Rows[0]["productionNumber"].ToString();
|
|
string partType = dsBarCode.Tables[0].Rows[0]["partType"].ToString();
|
|
|
|
DataSet dsQuality = t_Quality.GetData("top 1 *", "[productionNumber]='" + productionNumber + "' and [partType]='" + partType + "'", "[AddTime] desc");
|
|
if (dsQuality.Tables[0].Rows.Count > 0) t_Quality.Del("[ID]=" + dsQuality.Tables[0].Rows[0]["ID"].ToString());
|
|
|
|
DataRow drQuality = t_Quality.Table.NewRow();
|
|
drQuality["productionNumber"] = dsBarCode.Tables[0].Rows[0]["productionNumber"].ToString();
|
|
drQuality["itemNumber"] = dsBarCode.Tables[0].Rows[0]["itemNumber"].ToString();
|
|
drQuality["description"] = dsBarCode.Tables[0].Rows[0]["description"].ToString();
|
|
drQuality["CarModelCode"] = dsBarCode.Tables[0].Rows[0]["CarModelCode"].ToString();
|
|
drQuality["partType"] = dsBarCode.Tables[0].Rows[0]["partType"].ToString();
|
|
drQuality["State"] = (Reason != "" || Responsibility != "") ? "合格" : "一次合格";
|
|
drQuality["Reason"] = Reason;
|
|
drQuality["Responsibility"] = Responsibility;
|
|
|
|
|
|
drQuality = t_Quality.Add(drQuality);
|
|
|
|
|
|
txtBarCode.SetAttribute("value", "");
|
|
Clear();
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
}
|
|
finally
|
|
{
|
|
this.txtBarCode.Enabled = true;
|
|
doc.InvokeScript("barcode_select");
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 私有函数
|
|
|
|
private void Init()
|
|
{
|
|
|
|
|
|
lblTimer = doc.GetElementById("lblTimer");
|
|
txtBarCode = doc.GetElementById("txtBarCode");
|
|
txtProductName = doc.GetElementById("txtProductName");
|
|
|
|
btnComplete = doc.GetElementById("btnComplete");
|
|
btnCompleteScrap = doc.GetElementById("btnCompleteScrap");
|
|
tb_reason = doc.GetElementById("tb_reason");
|
|
tb_responsibility = doc.GetElementById("tb_Responsibility");
|
|
|
|
btnQuit = doc.GetElementById("btnQuit");
|
|
lblMsg = doc.GetElementById("lblMsg");
|
|
|
|
foreach (HtmlElement reason_temp in tb_reason.Children)
|
|
{
|
|
reason_temp.Click += new HtmlElementEventHandler(reason_temp_Click);
|
|
}
|
|
|
|
foreach (HtmlElement responsibility_temp in tb_responsibility.Children)
|
|
{
|
|
responsibility_temp.Click += new HtmlElementEventHandler(responsibility_temp_Click);
|
|
}
|
|
|
|
Clear();
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
TimerLastNow = TimerLast;
|
|
timer2.Enabled = false;
|
|
btnComplete.InnerText = "完成";
|
|
|
|
dsBarCode = null;
|
|
|
|
txtProductName.InnerHtml = " ";
|
|
|
|
foreach (HtmlElement reason_temp in tb_reason.Children)
|
|
{
|
|
reason_temp.SetAttribute("className", "reason_noselected");
|
|
}
|
|
|
|
foreach (HtmlElement responsibility_temp in tb_responsibility.Children)
|
|
{
|
|
responsibility_temp.SetAttribute("className", "responsibility_noselected");
|
|
}
|
|
|
|
doc.InvokeScript("barcode_set_focus");
|
|
|
|
|
|
}
|
|
|
|
private void reason_temp_Click(object sender, HtmlElementEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
HtmlElement reason_now = (HtmlElement)sender;
|
|
|
|
foreach (HtmlElement reason_temp in tb_reason.Children)
|
|
{
|
|
if (reason_temp != reason_now)
|
|
{
|
|
reason_temp.SetAttribute("className", "reason_noselected");
|
|
}
|
|
}
|
|
|
|
|
|
if (reason_now.GetAttribute("className") == "reason_noselected")
|
|
{
|
|
reason_now.SetAttribute("className", "reason_selected");
|
|
}
|
|
else
|
|
{
|
|
reason_now.SetAttribute("className", "reason_noselected");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
}
|
|
|
|
}
|
|
|
|
private void responsibility_temp_Click(object sender, HtmlElementEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
HtmlElement responsibility_now = (HtmlElement)sender;
|
|
|
|
foreach (HtmlElement responsibility_temp in tb_responsibility.Children)
|
|
{
|
|
if (responsibility_temp != responsibility_now)
|
|
{
|
|
responsibility_temp.SetAttribute("className", "responsibility_noselected");
|
|
}
|
|
}
|
|
|
|
|
|
if (responsibility_now.GetAttribute("className") == "responsibility_noselected")
|
|
{
|
|
responsibility_now.SetAttribute("className", "responsibility_selected");
|
|
}
|
|
else
|
|
{
|
|
responsibility_now.SetAttribute("className", "responsibility_noselected");
|
|
}
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
lblMsg.InnerHtml = ex.Message;
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private string GetReason()
|
|
{
|
|
string ret = "";
|
|
foreach (HtmlElement reason in tb_reason.Children)
|
|
{
|
|
if (reason.GetAttribute("className") == "reason_selected")
|
|
{
|
|
ret = reason.InnerText.Trim();
|
|
break;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
private string GetResponsibility()
|
|
{
|
|
string ret = "";
|
|
foreach (HtmlElement responsibility in tb_responsibility.Children)
|
|
{
|
|
if (responsibility.GetAttribute("className") == "responsibility_selected")
|
|
{
|
|
ret = responsibility.InnerText.Trim();
|
|
break;
|
|
}
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
private int TimerLast = Convert.ToInt32(MyAppconfig.ReadValue("质量提交倒计时"));
|
|
private int TimerLastNow = 0;
|
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
|
{
|
|
this.btnComplete.InnerText = "完成 " + TimerLastNow;
|
|
|
|
TimerLastNow--;
|
|
|
|
if(TimerLastNow < -1)
|
|
{
|
|
timer2.Enabled = false;
|
|
btnComplete.InnerText = "完成";
|
|
Submit();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|