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]; ma_code.TableName = " make left join product on ma_prodcode=pr_code"; ma_code.SelectField = "ma_code # 工单编号,ma_prodcode # 产品编号,pr_spec # 型号"; ma_code.FormName = Name; ma_code.SetValueField = new string[] { "ma_code" }; ma_code.Condition = "ma_statuscode='STARTED'"; ma_code.DbChange += pr_code_DbChange; st_code.FormName = Name; st_code.TableName = "step"; st_code.SetValueField = new string[] { "st_code", "st_name" }; st_code.SelectField = "st_code # 工序编号 ,st_name # 工序名称"; st_code.DBTitle = "执行工序"; st_code.DbChange += pr_code_DbChange; } DataTable Dbfind; private void pr_code_DbChange(object sender, EventArgs e) { Dbfind = ma_code.ReturnData; BaseUtil.SetFormValue(this.Controls, Dbfind); } 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("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_sncode='" + sn_code.Text + "'"); 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 + "未输入下地原因\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); } private void BatchFreeze_Click(object sender, EventArgs e) { string condition = "1=1"; if (stcode.Checked) { if (!macode.Checked && !date.Checked) { MessageBox.Show("勾选工序条件时必须勾选工单或者时间范围"); return; } condition += " and sp_stepcode='" + st_code.Text + "' "; } if (macode.Checked) { condition += " and sp_makecode='" + ma_code.Text + "'"; } if (date.Checked) { condition += " and sp_date between to_date('" + BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss')"; } 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) select MAKEDOWN_seq.nextval,'" + User.UserLineCode + "','" + User.UserSourceCode + "',"); sql.Append("'" + st_code.Text + "',sp_sncode,sp_prodcode,sp_makecode,'" + inputreson.Text + "','" + mdcode.Text + "',sysdate,'" + User.UserCode + "','-1' "); sql.Append(" from steppassed where " + condition); dh.ExecuteSql(sql.GetString(), "insert"); loadGrid(); } } }