123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- 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_AgingOver : 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;
- //打印计数
- int printcount = 0;
- int ma_unlimitin;
- string ErrorMessage = "";
- string LastSncode;
- public Make_AgingOver()
- {
- InitializeComponent();
- }
- private void Make_CollectNetCode_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- sncode.Focus();
- dh = SystemInf.dh;
- }
- private void sncode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- //采集序列号
- if (sncode.Text == "")
- {
- OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
- return;
- }
- OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
- dt = (DataTable)dh.ExecuteSql("select ms_status,ms_id,ms_makecode,ms_nextstepcode,ms_craftcode,ms_prodcode from makeserial left join product on ms_prodcode = pr_code where ms_sncode ='" + sncode.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count == 0)
- {
- OperateResult.AppendText(">>SN:" + sncode.Text + "不存在\n", Color.Red, sncode);
- return;
- }
- DataTable dtB = (DataTable)dh.ExecuteSql("select ag_code from ageingdetail left join ageing on agd_agid = ag_id where agd_sncode = '" + sncode.Text + "' and ag_status =1", "select");
- if (dtB.Rows.Count > 0)
- {
- agcode.Text = dtB.Rows[0]["ag_code"].ToString();
- snCollectionBox1_KeyDown(this, new KeyEventArgs(Keys.Enter));
- }
- else
- {
- OperateResult.AppendText(">>SN:" + sncode.Text + "未处于老化中批次\n", Color.Red, sncode);
- return;
- }
- }
-
- }
- 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)
- {
- string Seal = MessageBox.Show(this.ParentForm, "是否确认老化?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (Seal == "Yes")
- {
- fildgv();
- if (agcode.Text != "")
- {
- dt = (DataTable)dh.ExecuteSql("select * from ageing where ag_code = '" + agcode.Text + "' and ag_status <>1 ", "select");
- if (dt.Rows.Count > 0)
- {
- OperateResult.AppendText(">>老化编号" + agcode.Text + "未处于老化中\n", Color.Red, agcode);
- return;
- }
- else
- {
- int endtime = int.Parse(dh.GetConfig("oldtime", "MESSetting").ToString());
- DataTable dg = (DataTable)dh.ExecuteSql("select round((sysdate-AG_STARTDATE)*24*60,2) overtime from ageing where ag_code = '" + agcode.Text + "' and (sysdate-AG_STARTDATE)*24*60 <" + endtime + "", "select");
- if (dg.Rows.Count > 0)
- {
- OperateResult.AppendText(">>老化编号" + agcode.Text + "已老化"+dg.Rows[0]["overtime"].ToString() +"分钟,未达到设定时长"+endtime+"分钟\n", Color.Red);
- return;
- }
- dh.ExecuteSql("update ageing set ag_enddate = sysdate,ag_status = 2 where ag_code = '" + agcode.Text + "'", "update");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "老化结束" + agcode.Text, "采集结束", agcode.Text, "");
- OperateResult.AppendText(">>" + agcode.Text + "老化批次结束\n", Color.LightGreen, agcode);
- BaseUtil.CleanControls(this.Controls);
- agcode.Focus();
- }
- }
- else
- {
- OperateResult.AppendText(">>老化编号" + agcode.Text + "不可为空\n", Color.Red, agcode);
- return;
- }
- }
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- }
- void fildgv()
- {
- DataTable dtc;
- if (agcode.Text != "")
- {
- dtc = (DataTable)dh.ExecuteSql("select * from ageingdetail left join ageing on agd_agid = ag_id where ag_code = '" + agcode.Text + "' and ag_status =1 ", "select");
- if (dtc.Rows.Count > 0)
- {
- dtc = (DataTable)dh.ExecuteSql("select * from ageingdetail left join ageing on agd_agid = ag_id where ag_code = '" + agcode.Text + "' ", "select");
- agsum.Text = dh.getFieldDataByCondition("ageingdetail", "count(1) cn", " agd_agcode = '" + agcode.Text + "'").ToString();
- }
- else
- {
- OperateResult.AppendText(">>老化编号" + agcode.Text + "未处于老化中\n", Color.Red, agcode);
- return;
- }
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dtc);
- }
- }
- private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- fildgv();
- //sncode.Focus();
- //sncode.SelectAll();
- }
- }
- }
- }
|