123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- 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_MakeDown : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataTable dt;
- DataTable dt1;
- DataTable dtbar;
- LogStringBuilder sql = new LogStringBuilder();
- DataHelper dh;
- //页面Caller
- string caller;
- //事件号变量
- string _macode;
- //数量记录
- int count;
- //记录当前序列号ms_id
- string ms_id;
- public Make_MakeDown()
- {
- InitializeComponent();
- caller = "MakeDown";
- count = 0;
- _macode = "";
- }
- private void Make_MakeDown_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- dh = SystemInf.dh;
- sn_code.Focus();
- make_count.Text = count.ToString();
- string[] param = new string[] { caller, make_count.Text, _macode };
- dh.CallProcedure("SP_GETMAXNUMBER", ref param);
- mdcode.Text = param[2];
- }
- private void Make_MakeDown_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void sn_code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (inputreson.Text.Trim() != "")
- {
- sql.Clear();
- sql.Append("select max(ms_id) from makeserial where ms_sncode='" + sn_code.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- ms_id = dt.Rows[0][0].ToString();
- if (ms_id != "")
- {
- //界面赋值
- dtbar = (DataTable)dh.ExecuteSql("select ms_makecode,pr_code,pr_detail from makeserial left join product on MS_PRODCODE=pr_code where ms_id='" + ms_id + "'", "select");
- BaseUtil.SetFormValue(this.Controls, dtbar);
- sql.Clear();
- sql.Append("select ms_outboxcode, ms_downstatus,ms_outno,nvl(ms_iostatus,0) ms_iostatus,ms_prodcode from makeserial where ms_id ='" + ms_id + "' ");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- string ms_downstatus = dt.Rows[0]["ms_downstatus"].ToString();
- string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString();
- string ms_iostatus = dt.Rows[0]["ms_iostatus"].ToString();
- string ms_outno = dt.Rows[0]["ms_outno"].ToString();
- if (ms_downstatus == "0")
- {
- if (ms_outno == ""&& ms_iostatus =="0")
- {
- if (ms_outboxcode == null || ms_outboxcode == "")
- {
- //进行下地操作,插入下地记录
- sql.Clear();
- sql.Append("INSERT INTO MAKEDOWN (MD_ID,MD_LINECODE,MD_SCCODE,MD_STEPCODE,");
- sql.Append("MD_SNCODE,MD_PRODCODE,MD_MACODE, MD_DOWNREASON, MD_CODE,");
- sql.Append("MD_DOWNDATE,MD_DOWNMAN,MD_STATUS) values (MAKEDOWN_seq.nextval,'" + User.UserLineCode + "','" + User.UserSourceCode + "',");
- sql.Append("'" + User.CurrentStepCode + "','" + sn_code.Text + "','" + pr_code.Text + "','" + ms_makecode.Text + "','" + inputreson.Text + "','" + mdcode.Text + "',sysdate,'" + User.UserCode + "','-1')");
- //执行
- dh.ExecuteSql(sql.GetString(), "insert");
- //更新序列号状态为下地
- dh.UpdateByCondition("makeserial", "ms_downstatus='-1'", "ms_id='" + ms_id + "'");
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "下地成功\n", Color.Green);
- //更新数量
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "下地操作", "序列号" + sn_code.Text + "下地成功", sn_code.Text, "");
- count++;
- make_count.Text = count + "";
- sn_code.Text = "";
- loadGrid();
- }
- else
- {
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "已装箱:" + ms_outboxcode + ",不允许下地,如需下地请先解除装箱\n", Color.Red, sn_code);
- sn_code.Focus();
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "已进行出入库操作,不允许下地\n", Color.Red, sn_code);
- sn_code.Focus();
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "目前已经是下地状态,无需重复下地\n", Color.Red, sn_code);
- sn_code.Focus();
- return;
- }
- }
- else
- {
- ms_id = null;
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
- sn_code.Focus();
- }
- }
- else
- {
- OperateResult.AppendText(">>>序列号" + sn_code.Text + "未输入下地原因\n", Color.Red, sn_code);
- sn_code.Focus();
- return;
- }
- }
- }
- private void loadGrid()
- {
- sql.Clear();
- sql.Append("select md_macode,md_sncode,md_prodcode,pr_detail from makedown left join product on pr_code = md_prodcode where md_code = '" + mdcode.Text + "'");
- dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
- }
- }
- }
|