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 UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Make { public partial class Make_CollectElec : Form { DataHelper dh; AutoSizeFormClass asc = new AutoSizeFormClass(); LogStringBuilder sql = new LogStringBuilder(); DataTable dt; //当前序列号记录 string sn_code; //制造单号 string macode; //采集网标号 float net_code; //网标查询条件ms_id string oMsID; //判断是否输入网标 Boolean isnetcode = false; //打印计数 int printcount = 0; int ma_unlimitin; public Make_CollectElec() { InitializeComponent(); } private void Make_CollectNetCode_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); sncode.Focus(); dh = SystemInf.dh; StepCount.StepCode = User.CurrentStepCode; StepCount.Source = User.UserSourceCode; StepCount.LineCode = User.UserLineCode; StepCount.Dh = dh; StepCount.Start(); } private void sncode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string ErrorMessage2; string oMakeCode; //采集序列号 if (!isnetcode) { if (sncode.Text == "") { OperateResult.AppendText(">>序列号不能为空\n", Color.Red); return; } if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage2)) { //判断界面工单是否为空时的序列号是否自动归属工单 string oStatus = ""; if (!LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out oStatus, out ErrorMessage2)) { if (ms_makecode.Text == "") { OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode); return; } } OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black); // 获取工单归属工单下一工序是否正确 if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2)) { sql.Clear(); sql.Append("select ms_makecode,ms_prodcode,pr_detail,nvl(pr_electricmax,0)pr_electricmax,nvl(pr_electricmin,0)pr_electricmin from makeserial left join product on "); sql.Append(" ms_prodcode = pr_code where ms_id = '"+oMsID+"'"); dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); BaseUtil.SetFormValue(this.Controls, dt); OperateResult.AppendText(">>请输入电量\n", Color.Black); sn_code = sncode.Text; sncode.Text = ""; isnetcode = true; return; } else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode); } else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode); } //采集netcode else { if (sncode.Text == "") { OperateResult.AppendText(">>电量信息不能为空\n", Color.Red); return; } OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black); string ErrorMessage = ""; try { net_code = float.Parse(sncode.Text); if (!(net_code <= float.Parse(pr_electricmax.Text) && (net_code >= float.Parse(pr_electricmin.Text)))) { sncode.Text = ""; OperateResult.AppendText("<<输入值" + sncode.Text + "不符合维护范围,重新输入\n", Color.Red); return; } } catch (Exception ex) { sncode.Text = ""; OperateResult.AppendText("<<输入值" + sncode.Text + "错误,重新输入\n", Color.Red); return; } if (LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sn_code, "电量采集", "电量采集完成", User.UserCode, out ErrorMessage)) { //提示正确返回时传递的信息 if (ErrorMessage.Contains("AFTERSUCCESS")) OperateResult.AppendText(">>" + ErrorMessage + "\n"); dh.BatchInsert("update makeserial set MS_ELEC = :netcode where ms_id = :oMsId", new String[] { "netcode", "oMsId" }, new string[] { sncode.Text }, new string[] { oMsID.ToString() }); OperateResult.AppendText(">>电量信息采集完成\n", Color.Green); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "电量采集", "采集成功", sn_code, ""); isnetcode = false; sncode.Text = ""; sncode.Focus(); } else { OperateResult.AppendText(">>更新错误" + ErrorMessage + "\n", Color.Red); } OperateResult.AppendText(">>请输入SN\n", Color.Black); } } } private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void Make_CollectNetCode_Activated(object sender, EventArgs e) { sncode.Focus(); } private void deleteButton1_Click(object sender, EventArgs e) { if (isnetcode) { BaseUtil.CleanForm(this); OperateResult.AppendText(">>清除完成,清重新输入SN号\n", Color.Green); isnetcode = false; sncode.Focus(); } } } }