先建一个类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
//using cSFC061.Beans;
using System.Data;
using System.Management;
namespace USBFUN
{
public struct USBControllerDevice
{
/// <summary>
/// USB控制器??ID
/// </summary>
public String Antecedent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
//using cSFC061.Beans;
using System.Data;
using System.Management;
namespace USBFUN
{
public struct USBControllerDevice
{
/// <summary>
/// USB控制器??ID
/// </summary>
public String Antecedent;
/// <summary>
/// USB即插即用??ID
/// </summary>
public String Dependent;
}
/// USB即插即用??ID
/// </summary>
public String Dependent;
}
public partial class USB
{
/// <summary>
/// USB插入事件??
/// </summary>
private ManagementEventWatcher insertWatcher = null;
/// <summary>
/// USB拔出事件??
/// </summary>
private ManagementEventWatcher removeWatcher = null;
/// <summary>
/// 添加USB事件??器
/// </summary>
/// <param name="usbInsertHandler">USB插入事件?理器</param>
/// <param name="usbRemoveHandler">USB拔出事件?理器</param>
/// <param name="withinInterval">?送通知允?的?后??</param>
public Boolean AddUSBEventWatcher(EventArrivedEventHandler usbInsertHandler, EventArrivedEventHandler usbRemoveHandler, TimeSpan withinInterval)
{
try
{
ManagementScope Scope = new ManagementScope("root\\CIMV2");
Scope.Options.EnablePrivileges = true;
// USB插入??
if (usbInsertHandler != null)
{
WqlEventQuery InsertQuery = new WqlEventQuery("__InstanceCreationEvent",
withinInterval,
"TargetInstance isa 'Win32_USBControllerDevice'");
if (usbInsertHandler != null)
{
WqlEventQuery InsertQuery = new WqlEventQuery("__InstanceCreationEvent",
withinInterval,
"TargetInstance isa 'Win32_USBControllerDevice'");
insertWatcher = new ManagementEventWatcher(Scope, InsertQuery);
insertWatcher.EventArrived += usbInsertHandler;
insertWatcher.Start();
}
insertWatcher.EventArrived += usbInsertHandler;
insertWatcher.Start();
}
// USB拔出??
if (usbRemoveHandler != null)
{
WqlEventQuery RemoveQuery = new WqlEventQuery("__InstanceDeletionEvent",
withinInterval,
"TargetInstance isa 'Win32_USBControllerDevice'");
if (usbRemoveHandler != null)
{
WqlEventQuery RemoveQuery = new WqlEventQuery("__InstanceDeletionEvent",
withinInterval,
"TargetInstance isa 'Win32_USBControllerDevice'");
removeWatcher = new ManagementEventWatcher(Scope, RemoveQuery);
removeWatcher.EventArrived += usbRemoveHandler;
removeWatcher.Start();
}
removeWatcher.EventArrived += usbRemoveHandler;
removeWatcher.Start();
}
return true;
}
catch (Exception)
{
RemoveUSBEventWatcher();
return false;
}
}
/// <summary>
/// 移去USB事件??器
/// </summary>
public void RemoveUSBEventWatcher()
{
if (insertWatcher != null)
{
insertWatcher.Stop();
insertWatcher = null;
}
if (removeWatcher != null)
{
removeWatcher.Stop();
removeWatcher = null;
}
}
/// <summary>
/// 定位?生插拔的USB??
/// </summary>
/// <param name="e">USB插拔事件??</param>
/// <returns>?生插拔?象的USB控制??ID</returns>
public static USBControllerDevice[] WhoUSBControllerDevice(EventArrivedEventArgs e)
{
ManagementBaseObject mbo = e.NewEvent["TargetInstance"] as ManagementBaseObject;
if (mbo != null && mbo.ClassPath.ClassName == "Win32_USBControllerDevice")
{
String Antecedent = (mbo["Antecedent"] as String).Replace("\"", String.Empty).Split(new Char[] { '=' })[1];
String Dependent = (mbo["Dependent"] as String).Replace("\"", String.Empty).Split(new Char[] { '=' })[1];
return new USBControllerDevice[1] { new USBControllerDevice { Antecedent = Antecedent, Dependent = Dependent } };
}
return null;
}
}
}
}
catch (Exception)
{
RemoveUSBEventWatcher();
return false;
}
}
/// <summary>
/// 移去USB事件??器
/// </summary>
public void RemoveUSBEventWatcher()
{
if (insertWatcher != null)
{
insertWatcher.Stop();
insertWatcher = null;
}
if (removeWatcher != null)
{
removeWatcher.Stop();
removeWatcher = null;
}
}
/// <summary>
/// 定位?生插拔的USB??
/// </summary>
/// <param name="e">USB插拔事件??</param>
/// <returns>?生插拔?象的USB控制??ID</returns>
public static USBControllerDevice[] WhoUSBControllerDevice(EventArrivedEventArgs e)
{
ManagementBaseObject mbo = e.NewEvent["TargetInstance"] as ManagementBaseObject;
if (mbo != null && mbo.ClassPath.ClassName == "Win32_USBControllerDevice")
{
String Antecedent = (mbo["Antecedent"] as String).Replace("\"", String.Empty).Split(new Char[] { '=' })[1];
String Dependent = (mbo["Dependent"] as String).Replace("\"", String.Empty).Split(new Char[] { '=' })[1];
return new USBControllerDevice[1] { new USBControllerDevice { Antecedent = Antecedent, Dependent = Dependent } };
}
return null;
}
}
}
主程式区应用类
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MESFORM;
using MESFORM.QSS;
using cSFC061.Core;
using cSFC061.Beans;
using System.Net;
using System.Reflection;
using cSFC061.Utils;
using cSFC061.DataGetWay;
using MES_Public_Class;
using MES_Public_Class.PC;
using DBDataCenter;
using DBDataCenter.QSS;
using System.IO;
using System.Management;
using USBFUN;
namespace cSFC061
{
public partial class fmSFC061 : fmMESFORM
{
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MESFORM;
using MESFORM.QSS;
using cSFC061.Core;
using cSFC061.Beans;
using System.Net;
using System.Reflection;
using cSFC061.Utils;
using cSFC061.DataGetWay;
using MES_Public_Class;
using MES_Public_Class.PC;
using DBDataCenter;
using DBDataCenter.QSS;
using System.IO;
using System.Management;
using USBFUN;
namespace cSFC061
{
public partial class fmSFC061 : fmMESFORM
{
USB ezUSB = new USB();
public string sourcepath = "";
//定义常量 xianliang 2017/05/16
CoreBridge core = new CoreBridge();
MESFORM.QSS.PublicClass PC = new MESFORM.QSS.PublicClass();
BaseInfoTemp baseinfo = new BaseInfoTemp();
DBOP dbop = new DBOP();
XMLDoc xmlDoc = new XMLDoc();
string xmlPathDoc = @"C:\SFC\XMLDoc";
string XMLPath = @"C:\SFC\XMLDoc\PACKING.xml";
// Utils ut = new Utils();
public fmSFC061()
{
InitializeComponent();
}
{
InitializeComponent();
}
private void fmSFC061_Load(object sender, EventArgs e)
{
StreamReader sr = new StreamReader(@"C:" + "//MES//setting.txt", false);
sourcepath = sr.ReadLine().ToString();
sr.Close();
{
StreamReader sr = new StreamReader(@"C:" + "//MES//setting.txt", false);
sourcepath = sr.ReadLine().ToString();
sr.Close();
ezUSB.AddUSBEventWatcher(USBEventHandler, USBEventHandler, new TimeSpan(0, 0, 3));
BaseInfoTemp.User = this.PC.getUserName();
BaseInfoTemp.UserEMPNo = this.PC.GetUserEMPNO();
BaseInfoTemp.GroupName = "PACKING";
BaseInfoTemp.UserEMPNo = this.PC.GetUserEMPNO();
BaseInfoTemp.GroupName = "PACKING";
this.core.getLineName(this.cbb_LineName,"N");
this.lab_emp.Text = BaseInfoTemp.UserEMPNo;
this.lab_Name.Text = BaseInfoTemp.User;
this.lab_GroupName.Text = BaseInfoTemp.GroupName;
this.lab_ComputerName.Text = Dns.GetHostName().ToUpper();
this.lab_emp.Text = BaseInfoTemp.UserEMPNo;
this.lab_Name.Text = BaseInfoTemp.User;
this.lab_GroupName.Text = BaseInfoTemp.GroupName;
this.lab_ComputerName.Text = Dns.GetHostName().ToUpper();
this.Lab_PrgVer.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
BaseInfoTemp.PrgVer = this.Lab_PrgVer.Text;
// this.lab_PrintLibVer.Text = this.core.GetPrintLibVersion();
BaseInfoTemp.PrgVer = this.Lab_PrgVer.Text;
// this.lab_PrintLibVer.Text = this.core.GetPrintLibVersion();
baseinfo = xmlDoc.ReadyXML(XMLPath, xmlPathDoc);
this.npd_Top.Value = Convert.ToInt32(baseinfo.Npd_Top);
this.npd_left.Value = Convert.ToInt32(baseinfo.Npd_Left);
this.cbb_LineName.Text = baseinfo.LineName;
this.tb_PrintDriver.Text = baseinfo.PrintDriver;
this.lab_PrintDriver.Text = "PrintDriver:" + baseinfo.PrintDriver;
this.npd_left.Value = Convert.ToInt32(baseinfo.Npd_Left);
this.cbb_LineName.Text = baseinfo.LineName;
this.tb_PrintDriver.Text = baseinfo.PrintDriver;
this.lab_PrintDriver.Text = "PrintDriver:" + baseinfo.PrintDriver;
this.lab_Time.Text = "480";
//this.core.CloseLppa();
//this.core.CloseLppa();
this.cbb_PackingType.Text = "N:正常包裝";
this.tb_MO.Focus();
this.tb_MO.SelectAll();
}
this.tb_MO.Focus();
this.tb_MO.SelectAll();
}
private void tb_MO_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
ExecutionSet exeRes = new ExecutionSet();
MoInfo moInfo = new Beans.MoInfo();
string MO, PackingType, Line, UserId,StationName;
tb_MO.Text = tb_MO.Text.Trim();
MO = this.tb_MO.Text.Trim();
Line = baseinfo.LineName;
UserId = BaseInfoTemp.UserEMPNo;
StationName = lab_GroupName.Text;
PackingType = this.cbb_PackingType.Text.Substring(0,1);
exeRes = this.core.CheckMOLogic(MO, Line, this.groupBox3.Enabled, UserId, PackingType, this.tb_CartonNO,this.chb_BigtoSmall.Checked,"N",lblroute_id,lblroute_ver);
if (exeRes.Status)
{
moInfo = (MoInfo)exeRes.Anything;
this.lab_maxQty.Text = this.TBMAXQTY_D.Text;
moInfo = (MoInfo)exeRes.Anything;
this.lab_Customer.Text = moInfo.ShiptoCustomer;
this.lab_MainModel.Text = moInfo.MainModel;
this.lab_PN.Text = moInfo.ModelName;
this.lab_maxQty.Text = moInfo.BoxMaxQty;
this.lab_ModelFamily.Text = moInfo.ModelFamily;
this.Lab_TotalQty.Text = moInfo.Mototal;
this.lab_InputQty.Text = this.core.GetPackingQty(moInfo.MoNumber,"N");
this.lab_LineQtyName.Text = baseinfo.LineName + "線產能/班:";
this.lab_LineQty.Text = this.core.getOutQtyByLine(baseinfo.LineName, BaseInfoTemp.GroupName,"N");
if(PackingType.Substring(0, 1).Equals("T"))
{
this.gb_SpecialInfo.Visible = true;
this.core.getSpecialPACKINGInfo(moInfo.RouteCode,this.cbb_Station,"N");
}
{
if (e.KeyCode == Keys.Enter)
{
ExecutionSet exeRes = new ExecutionSet();
MoInfo moInfo = new Beans.MoInfo();
string MO, PackingType, Line, UserId,StationName;
tb_MO.Text = tb_MO.Text.Trim();
MO = this.tb_MO.Text.Trim();
Line = baseinfo.LineName;
UserId = BaseInfoTemp.UserEMPNo;
StationName = lab_GroupName.Text;
PackingType = this.cbb_PackingType.Text.Substring(0,1);
exeRes = this.core.CheckMOLogic(MO, Line, this.groupBox3.Enabled, UserId, PackingType, this.tb_CartonNO,this.chb_BigtoSmall.Checked,"N",lblroute_id,lblroute_ver);
if (exeRes.Status)
{
moInfo = (MoInfo)exeRes.Anything;
this.lab_maxQty.Text = this.TBMAXQTY_D.Text;
moInfo = (MoInfo)exeRes.Anything;
this.lab_Customer.Text = moInfo.ShiptoCustomer;
this.lab_MainModel.Text = moInfo.MainModel;
this.lab_PN.Text = moInfo.ModelName;
this.lab_maxQty.Text = moInfo.BoxMaxQty;
this.lab_ModelFamily.Text = moInfo.ModelFamily;
this.Lab_TotalQty.Text = moInfo.Mototal;
this.lab_InputQty.Text = this.core.GetPackingQty(moInfo.MoNumber,"N");
this.lab_LineQtyName.Text = baseinfo.LineName + "線產能/班:";
this.lab_LineQty.Text = this.core.getOutQtyByLine(baseinfo.LineName, BaseInfoTemp.GroupName,"N");
if(PackingType.Substring(0, 1).Equals("T"))
{
this.gb_SpecialInfo.Visible = true;
this.core.getSpecialPACKINGInfo(moInfo.RouteCode,this.cbb_Station,"N");
}
}
else
{
errorMSG(exeRes.Message);
this.tb_MO.SelectAll();
return;
}
exeRes = this.dbop.checkpackingbom(moInfo.ModelName, "N");
if (exeRes.Status)
{
}
else
{
errorMSG(exeRes.Message);
this.tb_MO.SelectAll();
return;
}
var ORTQTYMO = this.dbop.GetORTFLAGMO(MO, "N");
var ORTQTY = this.dbop.GetORTFLAG(MO, "N");
if (moInfo.GroupModel == "GC-IWT" && moInfo.ModelFamily == "ESS")
{
this.ORTFLAG.Text = Convert.ToString(ORTQTY);
}
else
{
this.ORTFLAG.Text = Convert.ToString(ORTQTYMO);
}
else
{
errorMSG(exeRes.Message);
this.tb_MO.SelectAll();
return;
}
exeRes = this.dbop.checkpackingbom(moInfo.ModelName, "N");
if (exeRes.Status)
{
}
else
{
errorMSG(exeRes.Message);
this.tb_MO.SelectAll();
return;
}
var ORTQTYMO = this.dbop.GetORTFLAGMO(MO, "N");
var ORTQTY = this.dbop.GetORTFLAG(MO, "N");
if (moInfo.GroupModel == "GC-IWT" && moInfo.ModelFamily == "ESS")
{
this.ORTFLAG.Text = Convert.ToString(ORTQTY);
}
else
{
this.ORTFLAG.Text = Convert.ToString(ORTQTYMO);
}
lblBigLine.Text = this.dbop.GetBigLine(Line, "N");
this.core.get_temporary_sn(tb_MO.Text, lab_ComputerName.Text, List_SN);
lab_Qty.Text = "" + List_SN.Items.Count;
exeRes = core.GET_STATION_CODE_FROM_STATION_NAME(StationName, lblroute_id.Text, lblroute_ver.Text, "N");
if (exeRes.Status)
{
lbl_StationCode.Text = exeRes.Message;
this.rescanbtn.Enabled = true;
this.tb_SN.Enabled = true;
this.tb_SN.Focus();
this.tb_SN.SelectAll();
this.tb_MO.Enabled = false;
SuccessMSG("WO OK,Please scan SN");
}
else
{
errorMSG(exeRes.Message);
this.tb_MO.SelectAll();
return;
}
}
}
this.core.get_temporary_sn(tb_MO.Text, lab_ComputerName.Text, List_SN);
lab_Qty.Text = "" + List_SN.Items.Count;
exeRes = core.GET_STATION_CODE_FROM_STATION_NAME(StationName, lblroute_id.Text, lblroute_ver.Text, "N");
if (exeRes.Status)
{
lbl_StationCode.Text = exeRes.Message;
this.rescanbtn.Enabled = true;
this.tb_SN.Enabled = true;
this.tb_SN.Focus();
this.tb_SN.SelectAll();
this.tb_MO.Enabled = false;
SuccessMSG("WO OK,Please scan SN");
}
else
{
errorMSG(exeRes.Message);
this.tb_MO.SelectAll();
return;
}
}
}
private void tb_SN_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
string inPutSN, inPutWO, TopMargin, LeftMargin, SpecialPACKING, strErrorCode, strStation;
{
if (e.KeyCode == Keys.Enter)
{
string inPutSN, inPutWO, TopMargin, LeftMargin, SpecialPACKING, strErrorCode, strStation;
int ORTQTY, TTLCID;
ExecutionSet exeRes = new ExecutionSet();
MoInfo moInfo = new Beans.MoInfo();
//moInfo = (MoInfo)exeRes.Anything;
SNInfo snInfo = new SNInfo();
MoInfo moInfo = new Beans.MoInfo();
//moInfo = (MoInfo)exeRes.Anything;
SNInfo snInfo = new SNInfo();
TopMargin = this.npd_Top.Value.ToString();
LeftMargin = this.npd_left.Value.ToString();
this.tb_SN.Text = this.tb_SN.Text.Trim();
inPutSN = this.tb_SN.Text.Trim();
inPutWO = this.tb_MO.Text.Trim();
LeftMargin = this.npd_left.Value.ToString();
this.tb_SN.Text = this.tb_SN.Text.Trim();
inPutSN = this.tb_SN.Text.Trim();
inPutWO = this.tb_MO.Text.Trim();
snInfo = this.dbop.getSNInfo(inPutSN, "N");
exeRes = this.dbop.CheckMOExist(inPutWO, "N");
DataSet ds = (DataSet)exeRes.Anything;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
ORTQTY = Convert.ToInt32(ds.Tables[0].Rows[0]["ORT_QTY"].ToString());
moInfo.MoNumber = ds.Tables[0].Rows[0]["WORK_ORDER"].ToString();
moInfo.ModelName = ds.Tables[0].Rows[0]["PART_NO"].ToString();
moInfo.MainModel = ds.Tables[0].Rows[0]["MAIN_MODEL1"].ToString();
moInfo.ShiptoCustomer = ds.Tables[0].Rows[0]["END_CUSTOMER"].ToString();
moInfo.BoxMaxQty = this.dbop.GetCIDMaxQty(moInfo.ModelName, "N");//"140";
moInfo.ModelFamily = ds.Tables[0].Rows[0]["PRODUCT_FAMILY"].ToString();
if (ds.Tables[0].Rows[0]["TTL_CID"].ToString() == "")
{
TTLCID = 0;
}
else
{
TTLCID = Convert.ToInt32(ds.Tables[0].Rows[0]["TTL_CID"].ToString());
}
moInfo.MayPackingQty = TTLCID;
moInfo.FirmWare = ds.Tables[0].Rows[0]["FW_VERSION"].ToString();
moInfo.Mototal = ds.Tables[0].Rows[0]["WO_SIZE"].ToString();
moInfo.InputQty = "0";
moInfo.MoType2 = ds.Tables[0].Rows[0]["WO_type2"].ToString();
//moInfo.GroupModel = ds.Tables[0].Rows[0]["MAIN_MODEL2"].ToString();
moInfo.GroupModel = ds.Tables[0].Rows[0]["PRODUCT_LEVEL"].ToString();
moInfo.ShippingFAI = ds.Tables[0].Rows[0]["shipping_fai"].ToString();
moInfo.SmtMO = ds.Tables[0].Rows[0]["CUST_ORDER"].ToString();
moInfo.RouteCode = ds.Tables[0].Rows[0]["ROUTE_CODE"].ToString();
moInfo.MoType1 = ds.Tables[0].Rows[0]["WO_type1"].ToString();
moInfo.MoLevel = ds.Tables[0].Rows[0]["PRODUCT_LEVEL"].ToString();
moInfo.Cust_Part_NO = ds.Tables[0].Rows[0]["CUST_PART_NO"].ToString();
moInfo.Route_Ver = ds.Tables[0].Rows[0]["ROUTE_VER"].ToString();
moInfo.BarcodeInfo = this.dbop.getListBarcodeInfo(moInfo.ModelName, "N");
moInfo.MoFlag = true;
}
else
{
moInfo.MoFlag = false;
moInfo.MSG = "NO MO, please Check";
}
// moinfo = this.Core.getMOInfo(inPutWO, "N");
// moinfo = this.core.getMOInfo(MoInfo.strMO, "N");
exeRes = this.dbop.CheckMOExist(inPutWO, "N");
DataSet ds = (DataSet)exeRes.Anything;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
ORTQTY = Convert.ToInt32(ds.Tables[0].Rows[0]["ORT_QTY"].ToString());
moInfo.MoNumber = ds.Tables[0].Rows[0]["WORK_ORDER"].ToString();
moInfo.ModelName = ds.Tables[0].Rows[0]["PART_NO"].ToString();
moInfo.MainModel = ds.Tables[0].Rows[0]["MAIN_MODEL1"].ToString();
moInfo.ShiptoCustomer = ds.Tables[0].Rows[0]["END_CUSTOMER"].ToString();
moInfo.BoxMaxQty = this.dbop.GetCIDMaxQty(moInfo.ModelName, "N");//"140";
moInfo.ModelFamily = ds.Tables[0].Rows[0]["PRODUCT_FAMILY"].ToString();
if (ds.Tables[0].Rows[0]["TTL_CID"].ToString() == "")
{
TTLCID = 0;
}
else
{
TTLCID = Convert.ToInt32(ds.Tables[0].Rows[0]["TTL_CID"].ToString());
}
moInfo.MayPackingQty = TTLCID;
moInfo.FirmWare = ds.Tables[0].Rows[0]["FW_VERSION"].ToString();
moInfo.Mototal = ds.Tables[0].Rows[0]["WO_SIZE"].ToString();
moInfo.InputQty = "0";
moInfo.MoType2 = ds.Tables[0].Rows[0]["WO_type2"].ToString();
//moInfo.GroupModel = ds.Tables[0].Rows[0]["MAIN_MODEL2"].ToString();
moInfo.GroupModel = ds.Tables[0].Rows[0]["PRODUCT_LEVEL"].ToString();
moInfo.ShippingFAI = ds.Tables[0].Rows[0]["shipping_fai"].ToString();
moInfo.SmtMO = ds.Tables[0].Rows[0]["CUST_ORDER"].ToString();
moInfo.RouteCode = ds.Tables[0].Rows[0]["ROUTE_CODE"].ToString();
moInfo.MoType1 = ds.Tables[0].Rows[0]["WO_type1"].ToString();
moInfo.MoLevel = ds.Tables[0].Rows[0]["PRODUCT_LEVEL"].ToString();
moInfo.Cust_Part_NO = ds.Tables[0].Rows[0]["CUST_PART_NO"].ToString();
moInfo.Route_Ver = ds.Tables[0].Rows[0]["ROUTE_VER"].ToString();
moInfo.BarcodeInfo = this.dbop.getListBarcodeInfo(moInfo.ModelName, "N");
moInfo.MoFlag = true;
}
else
{
moInfo.MoFlag = false;
moInfo.MSG = "NO MO, please Check";
}
// moinfo = this.Core.getMOInfo(inPutWO, "N");
// moinfo = this.core.getMOInfo(MoInfo.strMO, "N");
SpecialPACKING = this.cbb_PackingType.Text.Substring(0, 1);
strErrorCode = this.tb_ErrorCode.Text;
strErrorCode = this.tb_ErrorCode.Text;
strStation = this.cbb_Station.Text;
if (SpecialPACKING.Equals("N"))
{
strErrorCode = "";
strStation = "";
}
if (SpecialPACKING.Equals("N"))
{
strErrorCode = "";
strStation = "";
}
if (inPutSN.ToUpper().Equals("UNDO"))
{
this.Undo();
return;
}
{
this.Undo();
return;
}
//刷最後一個SN的時候,檢查包裝至稱重之前最多只能有1箱在產線.
int iMaxCidQty = 0;
if (Int32.TryParse(lab_maxQty.Text.ToString(), out iMaxCidQty))
{
}
else
{
errorMSG("獲取最大包裝數量失敗,請重新刷工單!");
this.tb_SN.SelectAll();
return;
}
int iMaxCidQty = 0;
if (Int32.TryParse(lab_maxQty.Text.ToString(), out iMaxCidQty))
{
}
else
{
errorMSG("獲取最大包裝數量失敗,請重新刷工單!");
this.tb_SN.SelectAll();
return;
}
if (inPutSN.Equals("END"))
{
exeRes = this.core.CheckPackingType(this.List_SN, SpecialPACKING);
if (exeRes.Status)
{
//若是尾數箱,檢查輸入的數量和已掃描數量是否相符.
if (List_SN.Items.Count < iMaxCidQty) //已掃描數量掃描標準數量
{
int iKeyQty = 0;
if (Int32.TryParse(txtQty.Text, out iKeyQty))
{
if (iKeyQty != List_SN.Items.Count)
{
this.tb_SN.SelectAll();
errorMSG("輸入數量和系統記錄數量不符!");
return;
}
}
else
{
this.tb_SN.SelectAll();
errorMSG("尾數箱請輸入已包裝數量!");
return;
}
}
{
exeRes = this.core.CheckPackingType(this.List_SN, SpecialPACKING);
if (exeRes.Status)
{
//若是尾數箱,檢查輸入的數量和已掃描數量是否相符.
if (List_SN.Items.Count < iMaxCidQty) //已掃描數量掃描標準數量
{
int iKeyQty = 0;
if (Int32.TryParse(txtQty.Text, out iKeyQty))
{
if (iKeyQty != List_SN.Items.Count)
{
this.tb_SN.SelectAll();
errorMSG("輸入數量和系統記錄數量不符!");
return;
}
}
else
{
this.tb_SN.SelectAll();
errorMSG("尾數箱請輸入已包裝數量!");
return;
}
}
exeRes = this.core.CheckENDLogic(this.lab_Carton, this.List_SN, baseinfo.LineName, TopMargin,
LeftMargin, "", "", tb_CartonNO, SpecialPACKING, strErrorCode, strStation, this.chb_BigtoSmall.Checked, "N",
lab_GroupName.Text, lbl_StationCode.Text, lab_PN.Text, BaseInfoTemp.UserEMPNo, lblroute_id.Text, lblroute_ver.Text, tb_MO.Text,
lab_ComputerName.Text);
if (exeRes.Status)
{
this.tb_SN.Clear();
this.tb_SN.Focus();
this.List_SN.Items.Clear();
this.lab_Qty.Text = this.List_SN.Items.Count.ToString();
this.lab_InputQty.Text = Convert.ToString(Convert.ToInt32(this.core.GetPackingQty(this.tb_MO.Text, "N")) + Convert.ToInt32(this.lab_Qty.Text));
SuccessMSG(inPutSN + " OK,請掃描下一箱!");
}
else
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
}
}
else
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
}
return;
}
LeftMargin, "", "", tb_CartonNO, SpecialPACKING, strErrorCode, strStation, this.chb_BigtoSmall.Checked, "N",
lab_GroupName.Text, lbl_StationCode.Text, lab_PN.Text, BaseInfoTemp.UserEMPNo, lblroute_id.Text, lblroute_ver.Text, tb_MO.Text,
lab_ComputerName.Text);
if (exeRes.Status)
{
this.tb_SN.Clear();
this.tb_SN.Focus();
this.List_SN.Items.Clear();
this.lab_Qty.Text = this.List_SN.Items.Count.ToString();
this.lab_InputQty.Text = Convert.ToString(Convert.ToInt32(this.core.GetPackingQty(this.tb_MO.Text, "N")) + Convert.ToInt32(this.lab_Qty.Text));
SuccessMSG(inPutSN + " OK,請掃描下一箱!");
}
else
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
}
}
else
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
}
return;
}
string ret = "";
string ISTATION_CODE = lbl_StationCode.Text;
string ISTATION_NAME = lab_GroupName.Text;
string ISN = tb_SN.Text;
string ILINE = baseinfo.LineName;
string IEQP_ID = lab_ComputerName.Text;
string IOP_ID = lab_emp.Text;
string ISTATION_CODE = lbl_StationCode.Text;
string ISTATION_NAME = lab_GroupName.Text;
string ISN = tb_SN.Text;
string ILINE = baseinfo.LineName;
string IEQP_ID = lab_ComputerName.Text;
string IOP_ID = lab_emp.Text;
//把當前的CURRENT_STATION 改為 PACKING的STATION_CODE.
ret = dbop.DO_CHECK_IN_UPDATE_CURRENT_STATION(ISN, ISTATION_CODE, "ASSY", IEQP_ID, IOP_ID, "Y", SpecialPACKING);
if (SpecialPACKING == "N")
{
// DO CHECK IN
ret = dbop.DO_CHECK_IN_CHECK_STATUS(ISN, ISTATION_CODE, ISTATION_NAME, "ASSY", "Y");
if (ret != "OK")
{
this.tb_SN.SelectAll();
errorMSG(ret);
return;
}
}
if (ret != "OK")
{
this.tb_SN.SelectAll();
errorMSG(ret);
return;
}
if (SpecialPACKING == "N")
{
// DO CHECK IN
ret = dbop.DO_CHECK_IN_CHECK_STATUS(ISN, ISTATION_CODE, ISTATION_NAME, "ASSY", "Y");
if (ret != "OK")
{
this.tb_SN.SelectAll();
errorMSG(ret);
return;
}
}
if (ret != "OK")
{
this.tb_SN.SelectAll();
errorMSG(ret);
return;
}
var ORTQTYMO = this.dbop.GetORTFLAGMO(inPutWO, "N");
ORTQTY = this.dbop.GetORTFLAG(inPutWO, "N");
if (moInfo.GroupModel == "GC-IWT" && moInfo.ModelFamily == "ESS")
{
this.ORTFLAG.Text = Convert.ToString(ORTQTY);
}
else
{
this.ORTFLAG.Text = Convert.ToString(ORTQTYMO);
}
//檢查TRACKING表中的route code和route ver 不能為空.
if (this.dbop.CheckROUTEFAILLog(inPutSN, inPutWO, "N") == false)
{
errorMSG("路由错误 ,不能包裝!!!!!");
this.tb_SN.SelectAll();
return;
}
ORTQTY = this.dbop.GetORTFLAG(inPutWO, "N");
if (moInfo.GroupModel == "GC-IWT" && moInfo.ModelFamily == "ESS")
{
this.ORTFLAG.Text = Convert.ToString(ORTQTY);
}
else
{
this.ORTFLAG.Text = Convert.ToString(ORTQTYMO);
}
//檢查TRACKING表中的route code和route ver 不能為空.
if (this.dbop.CheckROUTEFAILLog(inPutSN, inPutWO, "N") == false)
{
errorMSG("路由错误 ,不能包裝!!!!!");
this.tb_SN.SelectAll();
return;
}
if (this.dbop.CheckROUTEOQRMTEST(inPutSN, inPutWO, "N") == false && SpecialPACKING.Equals("N"))
{
errorMSG("OQRM 测试 FAIL ,请特结!!!!!");
this.tb_SN.SelectAll();
return;
}
{
errorMSG("OQRM 测试 FAIL ,请特结!!!!!");
this.tb_SN.SelectAll();
return;
}
exeRes = this.dbop.CheckWipholdInfo(snInfo, inPutWO, "00", "N");
if (exeRes.Status == false)
{
errorMSG("此S/N已被QA HOLD,請特殊包裝。");
return;
}
var BB = Convert.ToInt32(this.lab_Qty.Text);
var AA = this.ORTFLAG_GC.Text;
var DD = this.LB_SCRAP_FLAG.Text;
if (BB > 0 && SpecialPACKING.Equals("T"))
{
string SCRAPFLAG = this.dbop.GetSCRAPFLAG(inPutSN, "N");
if (DD == SCRAPFLAG)
{
}
else
{
errorMSG("SN 为报废产品,请特结并单独包装!!! ");
this.tb_SN.SelectAll();
return;
}
}
else
{
string SCRAPFLAG = this.dbop.GetSCRAPFLAG(inPutSN, "N");
this.ORTFLAG_GC.Text = SCRAPFLAG;
}
var AA = this.ORTFLAG_GC.Text;
var DD = this.LB_SCRAP_FLAG.Text;
if (BB > 0 && SpecialPACKING.Equals("T"))
{
string SCRAPFLAG = this.dbop.GetSCRAPFLAG(inPutSN, "N");
if (DD == SCRAPFLAG)
{
}
else
{
errorMSG("SN 为报废产品,请特结并单独包装!!! ");
this.tb_SN.SelectAll();
return;
}
}
else
{
string SCRAPFLAG = this.dbop.GetSCRAPFLAG(inPutSN, "N");
this.ORTFLAG_GC.Text = SCRAPFLAG;
}
if (SpecialPACKING.Equals("N"))
{
if (snInfo.SCRAP_FLAG == "Y")
{
errorMSG(" SN 为报废产品,请特结并单独包装!!! ");
this.tb_SN.SelectAll();
return;
}
ORTQTY = Convert.ToInt32(this.ORTFLAG.Text);
if (moInfo.GroupModel == "GC-IWT" && moInfo.ModelFamily == "ESS" && ORTQTY > 0)
{
// var BB = Convert.ToInt32(this.lab_Qty.Text);
if (BB > 0)
{
string CC = this.dbop.GetORTFLAG_GC(inPutSN, "N");
if (AA == CC)
{
}
else
{
errorMSG(" ESS GC-IWT 的产品, 不同的 ORT FLAG 不能混包,产品良品需入库到S67/S66 R/S66 ICOR!!! ");
this.tb_SN.SelectAll();
return;
}
}
else
{
string CC = this.dbop.GetORTFLAG_GC(inPutSN, "N");
this.ORTFLAG_GC.Text = CC;
}
}
if (ORTQTYMO > 0 && Convert.ToInt32(lab_InputQty.Text) < ORTQTYMO)
{
errorMSG("请先包ORT 送OBA !!!!!");
//this.tb_SN.SelectAll();
// return;
}
}
//正常包裝會測試QC
if (this.dbop.CheckTESTMODELNUMB(inPutSN, inPutWO, "N") == false &&
SpecialPACKING.Equals("N") && moInfo.ModelFamily == "CSS" &&
inPutWO.Substring(0, 4) != "SMO5" && inPutWO.Substring(0, 4) != "SMO1")
{
errorMSG("测试MODEL NUMBER 与工单的MODEL NUMBER 不符,请确认!!");
this.tb_SN.SelectAll();
return;
}
{
errorMSG("请先包ORT 送OBA !!!!!");
//this.tb_SN.SelectAll();
// return;
}
}
//正常包裝會測試QC
if (this.dbop.CheckTESTMODELNUMB(inPutSN, inPutWO, "N") == false &&
SpecialPACKING.Equals("N") && moInfo.ModelFamily == "CSS" &&
inPutWO.Substring(0, 4) != "SMO5" && inPutWO.Substring(0, 4) != "SMO1")
{
errorMSG("测试MODEL NUMBER 与工单的MODEL NUMBER 不符,请确认!!");
this.tb_SN.SelectAll();
return;
}
//執行SN的所有檢查點
exeRes = this.core.CheckSNLogic(inPutSN, ILINE, this.List_SN, this.tb_CartonNO, SpecialPACKING, this.cbb_Station, this.lab_DispCode,
this.chb_BigtoSmall.Checked, "N", lblBigLine.Text, lblroute_id.Text, lblroute_ver.Text, lbl_StationCode.Text, lab_GroupName.Text);
if (exeRes.Status == false)
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
return;
}
exeRes = this.core.CheckSNLogic(inPutSN, ILINE, this.List_SN, this.tb_CartonNO, SpecialPACKING, this.cbb_Station, this.lab_DispCode,
this.chb_BigtoSmall.Checked, "N", lblBigLine.Text, lblroute_id.Text, lblroute_ver.Text, lbl_StationCode.Text, lab_GroupName.Text);
if (exeRes.Status == false)
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
return;
}
//
//刷最後一個SN的時候,檢查包裝至稱重之前最多只能有1箱在產線.
if (List_SN.Items.Count >= iMaxCidQty - 1)
{
exeRes = this.core.CheckStayBeforeWeight(baseinfo.LineName, "N");
if (exeRes.Status == false)
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
return;
}
}
//刷最後一個SN的時候,檢查包裝至稱重之前最多只能有1箱在產線.
if (List_SN.Items.Count >= iMaxCidQty - 1)
{
exeRes = this.core.CheckStayBeforeWeight(baseinfo.LineName, "N");
if (exeRes.Status == false)
{
errorMSG(exeRes.Message);
this.tb_SN.SelectAll();
return;
}
}
//
// update status_flag = RUNNING
ret = this.core.DO_CHECK_IN_UPDATE(inPutSN, lbl_StationCode.Text, lab_GroupName.Text, "ASSY", lab_emp.Text, lab_ComputerName.Text, tb_MO.Text, "Y", SpecialPACKING);
if (ret != "OK")
{
errorMSG(ret);
this.tb_SN.SelectAll();
return;
}
ret = this.core.DO_CHECK_IN_UPDATE(inPutSN, lbl_StationCode.Text, lab_GroupName.Text, "ASSY", lab_emp.Text, lab_ComputerName.Text, tb_MO.Text, "Y", SpecialPACKING);
if (ret != "OK")
{
errorMSG(ret);
this.tb_SN.SelectAll();
return;
}
//所以的Check都結束了,把SNInsert到DB中
List_SN.Items.Add(inPutSN);
this.List_SN.SelectedIndex = this.List_SN.Items.Count - 1;
this.tb_SN.Clear();
this.tb_SN.Focus();
this.lab_Carton.Text = this.tb_CartonNO.Text;
this.lab_Qty.Text = this.List_SN.Items.Count.ToString();
this.tb_SN.Clear();
this.tb_SN.Focus();
this.lab_Carton.Text = this.tb_CartonNO.Text;
this.lab_Qty.Text = this.List_SN.Items.Count.ToString();
SuccessMSG(inPutSN + " OK,掃描下一個SN.");
if (this.lab_Qty.Text == this.lab_maxQty.Text)
{
//掃描END條碼後執行的 function, mainly do check-out function.
exeRes = this.core.CheckENDLogic(this.lab_Carton, this.List_SN, baseinfo.LineName, TopMargin, LeftMargin, "", "",
this.tb_CartonNO, SpecialPACKING, strErrorCode, strStation, this.chb_BigtoSmall.Checked, "N",
lab_GroupName.Text, lbl_StationCode.Text, lab_PN.Text, BaseInfoTemp.UserEMPNo, lblroute_id.Text, lblroute_ver.Text, tb_MO.Text,
lab_ComputerName.Text);
if (exeRes.Status)
{
this.List_SN.Items.Clear();
this.lab_Qty.Text = this.List_SN.Items.Count.ToString();
//顯示當班,當線的產出數量.
this.lab_LineQty.Text = this.core.getOutQtyByLine(baseinfo.LineName, BaseInfoTemp.GroupName, "N");
SuccessMSG("箱號 " + tb_CartonNO.Text + " 已滿,請掃描下一箱!");
}
else
{
this.tb_SN.SelectAll();
errorMSG(exeRes.Message);
}
}
this.lab_InputQty.Text = Convert.ToString(Convert.ToInt32(this.core.GetPackingQty(this.tb_MO.Text, "N")) + Convert.ToInt32(this.lab_Qty.Text));
}
}
if (this.lab_Qty.Text == this.lab_maxQty.Text)
{
//掃描END條碼後執行的 function, mainly do check-out function.
exeRes = this.core.CheckENDLogic(this.lab_Carton, this.List_SN, baseinfo.LineName, TopMargin, LeftMargin, "", "",
this.tb_CartonNO, SpecialPACKING, strErrorCode, strStation, this.chb_BigtoSmall.Checked, "N",
lab_GroupName.Text, lbl_StationCode.Text, lab_PN.Text, BaseInfoTemp.UserEMPNo, lblroute_id.Text, lblroute_ver.Text, tb_MO.Text,
lab_ComputerName.Text);
if (exeRes.Status)
{
this.List_SN.Items.Clear();
this.lab_Qty.Text = this.List_SN.Items.Count.ToString();
//顯示當班,當線的產出數量.
this.lab_LineQty.Text = this.core.getOutQtyByLine(baseinfo.LineName, BaseInfoTemp.GroupName, "N");
SuccessMSG("箱號 " + tb_CartonNO.Text + " 已滿,請掃描下一箱!");
}
else
{
this.tb_SN.SelectAll();
errorMSG(exeRes.Message);
}
}
this.lab_InputQty.Text = Convert.ToString(Convert.ToInt32(this.core.GetPackingQty(this.tb_MO.Text, "N")) + Convert.ToInt32(this.lab_Qty.Text));
}
}
private void button1_Click(object sender, EventArgs e)
{
}
{
}
private void cbb_LineName_TextChanged(object sender, EventArgs e)
{
this.xmlDoc.UpdateXML(XMLPath, "LineName",this.cbb_LineName.Text);
baseinfo.LineName = this.cbb_LineName.Text;
}
{
this.xmlDoc.UpdateXML(XMLPath, "LineName",this.cbb_LineName.Text);
baseinfo.LineName = this.cbb_LineName.Text;
}
private void groupBox2_Enter(object sender, EventArgs e)
{
{
}
private void Undo()
{
this.tb_MO.Enabled = true;
this.tb_MO.Clear();
this.tb_MO.Focus();
this.tb_MO.SelectAll();
{
this.tb_MO.Enabled = true;
this.tb_MO.Clear();
this.tb_MO.Focus();
this.tb_MO.SelectAll();
this.tb_SN.Clear();
this.tb_SN.Enabled = false;
//this.tb_SN.Enabled = true;
this.lab_DispCode.Text = "0";
this.tb_SN.Enabled = false;
//this.tb_SN.Enabled = true;
this.lab_DispCode.Text = "0";
this.List_SN.Items.Clear();
this.tb_CartonNO.Clear();
this.tb_CartonNO.Clear();
this.gb_SpecialInfo.Visible = false;
SuccessMSG("Undo OK,Please input MO");
}
SuccessMSG("Undo OK,Please input MO");
}
private void npd_Top_ValueChanged(object sender, EventArgs e)
{
xmlDoc.UpdateXML(XMLPath, "TOP", this.npd_Top.Value.ToString());
baseinfo.Npd_Top = this.npd_Top.Value.ToString();
}
{
xmlDoc.UpdateXML(XMLPath, "TOP", this.npd_Top.Value.ToString());
baseinfo.Npd_Top = this.npd_Top.Value.ToString();
}
private void npd_left_ValueChanged(object sender, EventArgs e)
{
xmlDoc.UpdateXML(XMLPath,"Left", this.npd_left.Value.ToString());
baseinfo.Npd_Left = this.npd_left.Value.ToString();
}
{
xmlDoc.UpdateXML(XMLPath,"Left", this.npd_left.Value.ToString());
baseinfo.Npd_Left = this.npd_left.Value.ToString();
}
private void bt_Comfirm_Click(object sender, EventArgs e)
{
xmlDoc.UpdateXML(XMLPath, "MainDriver", this.tb_PrintDriver.Text);//PrintDriver
this.lab_PrintDriver.Text ="PrintDriver:" +this.tb_PrintDriver.Text;
baseinfo.PrintDriver = this.tb_PrintDriver.Text;
{
xmlDoc.UpdateXML(XMLPath, "MainDriver", this.tb_PrintDriver.Text);//PrintDriver
this.lab_PrintDriver.Text ="PrintDriver:" +this.tb_PrintDriver.Text;
baseinfo.PrintDriver = this.tb_PrintDriver.Text;
// xmlDoc.UpdateXML(XMLPath, "LineName", "LineName", this.cb_Line.Text); //MainLabelPasition
// baseinfo.LineName = this.cb_Line.Text;
//this.lab_Line.Text = baseinfo.LineName;
// baseinfo.LineName = this.cb_Line.Text;
//this.lab_Line.Text = baseinfo.LineName;
this.tabControl1.SelectedIndex = 0;
SuccessMSG("設置 OK");
}
SuccessMSG("設置 OK");
}
private void butt_Cancel_Click(object sender, EventArgs e)
{
this.tabControl1.SelectedIndex = 0;
SuccessMSG("取消 OK");
}
{
this.tabControl1.SelectedIndex = 0;
SuccessMSG("取消 OK");
}
private void tb_User_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.tb_PSD.Enabled = true;
this.tb_PSD.Focus();
this.tb_PSD.SelectAll();
}
}
{
if (e.KeyCode == Keys.Enter)
{
this.tb_PSD.Enabled = true;
this.tb_PSD.Focus();
this.tb_PSD.SelectAll();
}
}
private void tb_PSD_KeyDown(object sender, KeyEventArgs e)
{
string User, PSD;
if (e.KeyCode == Keys.Enter)
{
User = this.tb_User.Text.Trim();
PSD = this.PC.StrTransfertoMD5(this.tb_PSD.Text);
//ExecutionResult exeRes = this.core.JudgeUserAnaPassword(User, PSD);
// DataSet ds = (DataSet)exeRes.Anything;
//if (ds != null && ds.Tables[0].Rows.Count > 0)
//{
// BaseInfoTemp.ReprintUser = User;
// this.tb_User.Enabled = false;
// this.tb_PSD.Enabled = false;
// this.tb_SN_Reprint.Enabled = true;
// this.tb_SN_Reprint.Focus();
//}
//else
//{
// errorMSG("用戶名和密碼不對或沒有補印權限,請確認");
// this.tb_PSD.SelectAll();
//}
}
}
{
string User, PSD;
if (e.KeyCode == Keys.Enter)
{
User = this.tb_User.Text.Trim();
PSD = this.PC.StrTransfertoMD5(this.tb_PSD.Text);
//ExecutionResult exeRes = this.core.JudgeUserAnaPassword(User, PSD);
// DataSet ds = (DataSet)exeRes.Anything;
//if (ds != null && ds.Tables[0].Rows.Count > 0)
//{
// BaseInfoTemp.ReprintUser = User;
// this.tb_User.Enabled = false;
// this.tb_PSD.Enabled = false;
// this.tb_SN_Reprint.Enabled = true;
// this.tb_SN_Reprint.Focus();
//}
//else
//{
// errorMSG("用戶名和密碼不對或沒有補印權限,請確認");
// this.tb_PSD.SelectAll();
//}
}
}
private void cbb_PackingType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbb_PackingType.SelectedIndex == 0)
{
this.gb_SpecialInfo.Visible = false;
}
else
{
{
if (cbb_PackingType.SelectedIndex == 0)
{
this.gb_SpecialInfo.Visible = false;
}
else
{
}
Undo();
}
Undo();
}
private void cbb_Station_SelectedIndexChanged(object sender, EventArgs e)
{
this.tb_ErrorCode.Focus();
this.tb_ErrorCode.SelectAll();
}
{
this.tb_ErrorCode.Focus();
this.tb_ErrorCode.SelectAll();
}
private void TBMAXQTY_KeyDown(object sender, KeyEventArgs e)
{
this.lab_maxQty.Text = this.TBMAXQTY_D.Text;
}
{
this.lab_maxQty.Text = this.TBMAXQTY_D.Text;
}
private void fmSFC061_FormClosing(object sender, FormClosingEventArgs e)
{
core.dbtools.closeConnection();
dbop.dbtools.closeConnection();
dbop.CloseConnection();
}
{
core.dbtools.closeConnection();
dbop.dbtools.closeConnection();
dbop.CloseConnection();
}
private void rescanbtn_Click(object sender, EventArgs e)
{
if (List_SN.Items.Count > 0)
{
FormClearCID fma = new FormClearCID();
fma.editwo.Text = tb_MO.Text;
fma.lblComputerName.Text = lab_ComputerName.Text;
for (int lj = 0; lj < List_SN.Items.Count; lj++)
{
fma.listBox1.Items.Add(List_SN.Items[lj].ToString());
}
fma.ShowDialog();
this.tb_MO.Focus();
this.tb_MO.Clear();
List_SN.Items.Clear();
SuccessMSG("輸入工單!");
}
else
{
errorMSG("無可還原的SN!");
}
}
{
if (List_SN.Items.Count > 0)
{
FormClearCID fma = new FormClearCID();
fma.editwo.Text = tb_MO.Text;
fma.lblComputerName.Text = lab_ComputerName.Text;
for (int lj = 0; lj < List_SN.Items.Count; lj++)
{
fma.listBox1.Items.Add(List_SN.Items[lj].ToString());
}
fma.ShowDialog();
this.tb_MO.Focus();
this.tb_MO.Clear();
List_SN.Items.Clear();
SuccessMSG("輸入工單!");
}
else
{
errorMSG("無可還原的SN!");
}
}
// xianliang 2017/05/16
private void USBEventHandler(Object sender, EventArrivedEventArgs e)
{
if (e.NewEvent.ClassPath.ClassName == "__InstanceCreationEvent")
{
//tb_SN.Text = ("USB插入时间");
//DriveInfo[] s = DriveInfo.GetDrives();
//foreach (DriveInfo drive in s)
//{
// if (drive.DriveType == DriveType.Removable)
// {
//foreach (DriveInfo drive in s)
//{
// if (drive.DriveType == DriveType.Removable)
// {
string SN = "";
string path = "";
//this.richTextBox1.AppendText("U盘已插入,盘符是" + drive.Name.ToString() + "\r\n");
//string name = drive.Name.ToString().Trim().Substring(0, 1);
string path = "";
//this.richTextBox1.AppendText("U盘已插入,盘符是" + drive.Name.ToString() + "\r\n");
//string name = drive.Name.ToString().Trim().Substring(0, 1);
//string name = drive.Name.ToString().Trim();
//this.richTextBox1.AppendText(name);
Thread.Sleep(5000);
path = @sourcepath + "//mac_addr.txt";
StreamReader sr = new StreamReader(path, false);
SN = sr.ReadLine().ToString().Trim();
sr.Close();
StreamReader sr = new StreamReader(path, false);
SN = sr.ReadLine().ToString().Trim();
sr.Close();
tb_SN.Text = SN;
//serial_number.Text = name;
// }
//serial_number.Text = name;
// }
//}
}
else if (e.NewEvent.ClassPath.ClassName == "__InstanceDeletionEvent")
{
tb_SN.Text = "";
}
//foreach (USBControllerDevice Device in USB.WhoUSBControllerDevice(e))
//{
// this.richTextBox1.Text = ("\tAntecedent:" + Device.Antecedent + "\r\n");
// this.richTextBox1.Text = ("\tDependent:" + Device.Dependent + "\r\n");
//}
}
//{
// this.richTextBox1.Text = ("\tAntecedent:" + Device.Antecedent + "\r\n");
// this.richTextBox1.Text = ("\tDependent:" + Device.Dependent + "\r\n");
//}
}
// xianliang 2017/05/16
}
}
}