using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicForm; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Make { public partial class Make_ReadWriteInfo : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; LogStringBuilder sql; string oErrorMessage = ""; string omakeCode = ""; string oMsid = ""; public Make_ReadWriteInfo() { InitializeComponent(); } private void Make_LabelCheck_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); //聚焦SN号 sncode.Focus(); //打开界面提示用户:请输入SN OperateResult.AppendText(">>请输入SN\n", Color.Black); sql = new LogStringBuilder(); dh = SystemInf.dh; StepCount.StepCode = User.CurrentStepCode; StepCount.Source = User.UserSourceCode; StepCount.LineCode = User.UserLineCode; StepCount.Dh = dh; StepCount.Start(); } private void Make_LabelCheck_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } string FullPath = ""; private void Watcher_Created(object sender, FileSystemEventArgs e) { string BARCODE = ""; string MAC = ""; string BT = ""; string IMEI0 = ""; string IMEI1 = ""; if (e.FullPath.Contains("MetaCore")) { return; } BaseUtil.GetWriteInfo(e.FullPath, out BARCODE, out MAC, out BT, out IMEI0, out IMEI1); FullPath = e.FullPath; sncode.Text = BARCODE; sncode_KeyDown(sender, new KeyEventArgs(Keys.Enter)); } private void sncode_KeyDown(object sender, KeyEventArgs e) { //判断是enter事件 if (e.KeyCode == Keys.Enter) { if (sncode.Text == "") { OperateResult.AppendText("<<输入不能为空\n", Color.Red); return; } if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage)) { //判断序列号下一工序(CHECKSTEPSNANDMACODE) if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage)) { string BARCODE = ""; string MAC = ""; string BT = ""; string IMEI0 = ""; string IMEI1 = ""; BaseUtil.GetWriteInfo(FullPath, out BARCODE, out MAC, out BT, out IMEI0, out IMEI1); DataTable dt = new DataTable(); dt.Columns.Add("ms_item"); dt.Columns.Add("ms_info"); if (BARCODE != "") { DataRow dr = dt.NewRow(); dr["ms_item"] = "SN"; dr["ms_info"] = BARCODE; dt.Rows.Add(dr); } if (MAC != "") { DataRow dr = dt.NewRow(); dr["ms_item"] = "MAC"; dr["ms_info"] = MAC; dt.Rows.Add(dr); } if (BT != "") { DataRow dr = dt.NewRow(); dr["ms_item"] = "BT"; dr["ms_info"] = BT; dt.Rows.Add(dr); } if (IMEI0 != "") { DataRow dr = dt.NewRow(); dr["ms_item"] = "IMEI0"; dr["ms_info"] = IMEI0; dt.Rows.Add(dr); } if (IMEI1 != "") { DataRow dr = dt.NewRow(); dr["ms_item"] = "IMEI1"; dr["ms_info"] = IMEI1; dt.Rows.Add(dr); } CheckItemDGV.DataSource = dt; //烧写信息 if (LogicHandler.snBurn(sncode.Text, sncode.Text, User.UserSourceCode, User.UserCode, omakeCode, 0, IMEI0, IMEI1, "", "", "", "", "", "", "", MAC, BT, "", "", "", out oErrorMessage)) { sql.Clear(); sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,"); sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) remain_qty,nvl(ma_unlimitin,0) ma_unlimitin from make left join makecraftdetail on "); sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (dt.Rows.Count > 0) { BaseUtil.SetFormValue(this.Controls, dt); } OperateResult.AppendText(">>SN:" + sncode.Text + "烧写信息绑定成功\n", Color.Green, sncode); } else { OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); } } else { OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); } } else { OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); } } } private void StepCount_Load(object sender, EventArgs e) { } private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { //系统值和 if (e.ColumnIndex >= 0) { if (CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_systemvalue" || CheckItemDGV.Columns[e.ColumnIndex].Name == "psr_localvalue") { if (e.RowIndex >= 0) { if (CheckItemDGV.Rows[e.RowIndex].Cells["psr_systemvalue"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["psr_systemvalue"].Value.ToString() == CheckItemDGV.Rows[e.RowIndex].Cells["psr_localvalue"].Value.ToString())) { e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds); Rectangle border = e.CellBounds; border.Width -= 1; e.Graphics.DrawRectangle(Pens.Black, border); e.PaintContent(e.CellBounds); e.Handled = true; } else { e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds); Rectangle border = e.CellBounds; border.Width -= 1; e.Graphics.DrawRectangle(Pens.Black, border); e.PaintContent(e.CellBounds); e.Handled = true; } } } } } private void Watch_Click(object sender, EventArgs e) { FileWatcher.Path = WatchPath.Text; FileWatcher.Filter = "*.log"; FileWatcher.EnableRaisingEvents = true; FileWatcher.Created += new FileSystemEventHandler(Watcher_Created); } } }