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_GetTestFileData : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; LogStringBuilder sql; string oErrorMessage = ""; string omakeCode = ""; string oMsid = ""; ftpOperater ftp = new ftpOperater(); public Make_GetTestFileData() { 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); } private void LoadCollectedNum() { sql.Clear(); sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,"); sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty 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 + "'"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); BaseUtil.SetFormValue(Controls, dt); } 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)) { if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage)) { ma_code.Text = omakeCode; LoadCollectedNum(); string ms_prodcode = dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_id='" + oMsid + "'").ToString(); DataTable dt = new DataTable(); BaseUtil.GetDataFromDevice("GETFILE", WatchPath.Text + " ./" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text); string[] files = Directory.GetFiles(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text, "*.csv"); BaseUtil.OpenCSVFile(ref dt, files[0]); //移除标题行 dt.Rows.RemoveAt(0); //设置列名绑定数据 dt.Columns[0].ColumnName = "std_class"; dt.Columns[1].ColumnName = "std_testresult"; dt.Columns[2].ColumnName = "std_sn"; dt.Columns[3].ColumnName = "std_mac"; dt.Columns[4].ColumnName = "std_bt"; dt.Columns[5].ColumnName = "std_imei1"; dt.Columns[6].ColumnName = "std_imei2"; dt.Columns[7].ColumnName = "std_googlekey"; dt.Columns[8].ColumnName = "std_videotest"; dt.Columns[9].ColumnName = "std_version"; dt.DefaultView.Sort = "std_testresult"; CheckItemDGV.DataSource = dt; bool Result = true; for (int i = 0; i < dt.Rows.Count; i++) { PSN.Text = dt.Rows[0]["std_sn"].ToString(); MAC.Text = dt.Rows[0]["std_mac"].ToString().Replace(":", "").ToUpper(); BT.Text = dt.Rows[0]["std_bt"].ToString().Replace(":", "").ToUpper(); IMEI1.Text = dt.Rows[0]["std_imei1"].ToString().Replace("null", "").Replace("unknow", ""); IMEI2.Text = dt.Rows[0]["std_imei2"].ToString().Replace("null", "").Replace("unknow", ""); GoogleKey.Text = dt.Rows[0]["std_googlekey"].ToString().Replace("null", "").Replace("unknow", "").ToUpper(); Aging.Text = dt.Rows[0]["std_videotest"].ToString().Replace("null", "").Replace("unknow", "").ToUpper(); Version.Text = dt.Rows[0]["std_version"].ToString().Replace("null", "").Replace("unknow", ""); if (dt.Rows[i]["std_testresult"].ToString() != "OK" || dt.Rows[i]["std_testresult"].ToString() == "NOTEST") { Result = false; } dh.ExecuteSql("insert into STEPTESTDETAIL(std_id,std_sn,std_indate,std_class,std_testtimes,std_testresult,std_badcode) values(STEPTESTDETAIL_seq.nextval,'" + sncode.Text + "',sysdate,'" + dt.Rows[i]["std_class"].ToString() + "','','" + dt.Rows[i]["std_testresult"].ToString() + "','')", "insert"); } if (Aging.Text == "") { OperateResult.AppendText(">>" + sncode.Text + "设备未进行老化测试\n"); return; } if (Result) { if (LogicHandler.snChangeAndBurn(sncode.Text, PSN.Text, User.UserSourceCode, User.UserCode, omakeCode, 0, IMEI1.Text, IMEI2.Text, "", "", "", "", "", "", "", MAC.Text, BT.Text, "", "", "", out oErrorMessage)) { //提示正确返回时传递的信息 if (oErrorMessage.Contains("AFTERSUCCESS")) OperateResult.AppendText(">>" + oErrorMessage + "\n"); //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示 sql.Clear(); sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,"); sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty 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"); BaseUtil.SetFormValue(Controls, dt); //将SN,时间,结果记录在页面 //记录日志 //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/"); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, ""); //SN核对成功 //>> 请输入SN OperateResult.AppendText("<<" + sncode.Text + "信息核对成功,转换SN" + PSN.Text + "\n", Color.Green, sncode); OperateResult.AppendText(">>请输入SN\n", Color.Black); SetCheck set = new SetCheck("OK", Color.Green); BaseUtil.SetFormCenter(set); set.ShowDialog(); if (ReSet.Checked) { BaseUtil.GetDataFromDevice("RESET"); } } else { OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); } //if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, sncode.Text, "", "OK", User.UserCode, out oErrorMessage)) //{ // //提示正确返回时传递的信息 // if (oErrorMessage.Contains("AFTERSUCCESS")) // OperateResult.AppendText(">>" + oErrorMessage + "\n"); // //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示 // sql.Clear(); // sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,"); // sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty 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"); // BaseUtil.SetFormValue(Controls, dt); // //将SN,时间,结果记录在页面 // //记录日志 // //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/"); // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, ""); // //SN核对成功 // //>> 请输入SN // OperateResult.AppendText("<<" + sncode.Text + "信息核对成功\n", Color.Green, sncode); // OperateResult.AppendText(">>请输入SN\n", Color.Black); // SetCheck set = new SetCheck("OK", Color.Green); // BaseUtil.SetFormCenter(set); // set.ShowDialog(); // if (ReSet.Checked) // { // BaseUtil.GetDataFromDevice("RESET"); // } //} //else //{ // OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode); //} } else { //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/"); OperateResult.AppendText(">>序列号" + sncode.Text + "测试不通过\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 == "std_testresult") { if (e.RowIndex >= 0) { if (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value.ToString() == "OK")) { 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; } } } } } } }