123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Special
- {
- public partial class Special_Oksn : Form
- {
- DataHelper dh;
- LogStringBuilder sql = new LogStringBuilder();
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataTable Dbfind;
- public Special_Oksn()
- {
- InitializeComponent();
- }
- private void Confirm_Click(object sender, EventArgs e)
- {
-
- }
- private void Clean_Click(object sender, EventArgs e)
- {
- OperateResult.Clear();
- }
- private void Special_CancelCollection_Load(object sender, EventArgs e)
- {
- dh = SystemInf.dh;
- // asc.controllInitializeSize(this);
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量, pr_orispeccode # 型号, ma_wccode # 车间,ma_inqty # 投入数,pr_spec # 产品规格";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_orispeccode" };
- ma_code.Condition = "ma_statuscode='STARTED' order by ma_auditdate desc";
- ma_code.DbChange += Ma_code_DbChange;
- ma_code.SetLockCheckBox(Lock);
- Lock.GetMakeCodeCtl(ma_code);
- }
- private void Ma_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- getqty.Text = dh.getFieldDataByCondition("makeserial", "count(1) cn ", "MS_LASTSTEP is not null and ms_makecode = '"+ma_code.Text+"' ").ToString();
- }
- private void sn_code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (!checkBox1.Checked)
- {
- //获取序列号的途程
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_nextstepcode,ms_outboxcode,ms_makecode,ms_status,ms_laststep,ms_craftcode,ms_prodcode,ms_stepcode from makeserial where ms_sncode='" + sn_code.Text + "' and ms_makecode = '"+ma_code.Text+"' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- string pr_code = dt.Rows[0]["ms_prodcode"].ToString();
- string cr_code = dt.Rows[0]["ms_craftcode"].ToString();
- string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
- string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- string ms_laststep = dt.Rows[0]["ms_laststep"].ToString();
- string ms_status = dt.Rows[0]["ms_status"].ToString();
- string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
- string ms_id = dt.Rows[0]["ms_id"].ToString();
- if (ms_nextstepcode == "")
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "非在制状态,无法采集\n", Color.Red, sn_code);
- return;
- }
- if (ms_outboxcode != "")
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "已装箱"+ms_outboxcode+",无法采集\n", Color.Red, sn_code);
- return;
- }
- if (dh.CheckExist("step", "st_code = '" + ms_nextstepcode + "' and nvl(st_ifoqc,0) <> -1 and nvl(st_ifover,0) = -1 "))
- {
- if (dh.CheckExist("makedown", "md_msid = " + ms_id + " and md_status = 0"))
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "被锁定,无法采集\n", Color.Red, sn_code);
- return;
- }
- dh.ExecuteSql("update makeserial set ms_status = 2,ms_laststep = ms_nextstepcode,ms_nextstepcode = '' where ms_id = " + ms_id + " ", "update");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "完工采集", "完工采集成功", sn_code.Text, "");
- OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成完工\n", Color.Green, sn_code);
- getqty.Text = dh.getFieldDataByCondition("makeserial", "count(1) cn ", "MS_LASTSTEP is not null and ms_makecode = '" + ma_code.Text + "' ").ToString();
- }
- else
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "所处工序" + ms_nextstepcode + ",无法采集\n", Color.Red, sn_code);
- return;
- }
- }
- else OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
- }
- else
- {
- //获取序列号的途程
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_nextstepcode,ms_currentstepcode,ms_makecode,ms_status,ms_laststep,ms_craftcode,ms_prodcode,ms_stepcode from makeserial where ms_sncode='" + sn_code.Text + "' and ms_makecode = '"+ma_code.Text+"' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- string pr_code = dt.Rows[0]["ms_prodcode"].ToString();
- string cr_code = dt.Rows[0]["ms_craftcode"].ToString();
- string ms_nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
- string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- string ms_laststep = dt.Rows[0]["ms_laststep"].ToString();
- string ms_status = dt.Rows[0]["ms_status"].ToString();
- string ms_currentstepcode = dt.Rows[0]["ms_currentstepcode"].ToString();
- string ms_id = dt.Rows[0]["ms_id"].ToString();
- if (ms_status != "2")
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "非完工,无法撤销\n", Color.Red, sn_code);
- return;
- }
- if (ms_laststep == "")
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "未采集过,无法撤销\n", Color.Red, sn_code);
- return;
- }
- dh.ExecuteSql("update makeserial set ms_status = 1,ms_nextstepcode = ms_laststep,ms_laststep = '' where ms_id = " + ms_id + "", "update");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "撤销完工采集", "撤销完工采集成功", sn_code.Text, "");
- OperateResult.AppendText(">>序列号" + sn_code.Text + "撤销完工\n", Color.Green, sn_code);
- getqty.Text = dh.getFieldDataByCondition("makeserial", "count(1) cn ", "MS_LASTSTEP is not null and ms_makecode = '" + ma_code.Text + "' ").ToString();
- }
- else OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
- }
- }
- }
- private void Special_Oksn_SizeChanged(object sender, EventArgs e)
- {
- // asc.controlAutoSize(this);
- }
- }
- }
|