123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548 |
- using System;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES_NEW.CustomControl.TextBoxWithIcon;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- using System.Drawing;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using UAS_MES_NEW.PublicForm;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_FeedingCollection : Form
- {
- //MakeSerial表主键
- string ms_id;
- //制造单号
- string make_code;
- //产品编号
- string make_prodcode;
- //工序编号
- string nextstepcode;
- //完工状态
- string ms_status;
- //工艺路线编号
- //Bom版本
- string mabomversion;
- string ErrorMessage = "";
- List<string> TSN = new List<string>();
- Dictionary<string, string> CheckBarcode = new Dictionary<string, string>();
- //用于提醒的序列B
- string[] RemainList = new string[0];
- //提醒序列的索引
- int RemainIndex = 0;
- string oMakeCode = "";
- string oMsid = "";
- string ms_firstsn = "";
- DataHelper dh;
- LogStringBuilder sql = new LogStringBuilder();
- DataTable DBFind;
- DataTable dt;
- //保存ListB中的数据
- DataTable dt1;
- AutoSizeFormClass asc = new AutoSizeFormClass();
- List<string> CollectData = new List<string>();
- List<string> CollectDataSonCode = new List<string>();
- List<string> SPID = new List<string>();
- public Make_FeedingCollection()
- {
- InitializeComponent();
- }
- private void Make_FeedingCollection_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- LockMakeCode.GetMakeCodeCtl(ma_code);
- ma_code.SetLockCheckBox(LockMakeCode);
- //工单号放大镜配置
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,ma_craftcode # 途程编号,pr_spec # 产品名称,ma_bomversion # Bom版本,ma_softversion # 软件版本,ma_ecncode # ECN号";
- ma_code.FormName = Name;
- ma_code.DBTitle = "工单查询";
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_spec", "ma_craftcode", "ma_bomversion", "ma_softversion", "ma_ecncode" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- ma_code.DbChange += Ma_code_DBChange;
- code.Focus();
- dh = SystemInf.dh;
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- private void Ma_code_DBChange(object sender, EventArgs e)
- {
- DBFind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, DBFind);
- string ifforsn = dh.getFieldDataByCondition("make left join stepbom on ma_prodcode=sb_prodcode left join stepproduct on sb_id=sp_sbid", "nvl(sp_ifforsn,0) sp_ifforsn", "ma_code='" + ma_code.Text + "' and sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' and sb_bomversion='" + ma_bomversion.Text + "' order by sp_detno").ToString();
- if (ifforsn != "" && ifforsn != "0")
- iflastsn.Checked = true;
- else
- iflastsn.Checked = false;
- }
- private void Make_FeedingCollection_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void Clean_Click(object sender, EventArgs e)
- {
- OperateResult.Clear();
- }
- private void Confirm_Click(object sender, EventArgs e)
- {
- KeyEventArgs e2 = new KeyEventArgs(Keys.Enter);
- code_KeyDown(sender, e2);
- }
- private void code_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
- {
- if (Loading.Checked)
- {
- if (code.Text.Replace(" ", "") == "")
- {
- OperateResult.AppendText(">>采集数据不可为空\n", Color.Red);
- return;
- }
- //如果录入框和工单号均有输入
- if (code.Text != "" && ma_code.Text != "" && sn_code.Text == "")
- {
- GetCollectItem();
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
- }
- //输入框有值但未选择工单号
- else if (code.Text != "" && ma_code.Text == "" && sn_code.Text == "")
- {
- GetCollectItem();
- BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
- }
- else if (sn_code.Text != "")
- {
- //索引超出长度表示内容均已提醒
- if (RemainIndex >= RemainList.Length)
- {
- OperateResult.AppendText(">>当前序列号" + sn_code.Text + "不在本道工序,请采集其它序列号\n", Color.Black);
- sn_code.Text = "";
- code.Text = "";
- return;
- }
- string sp_soncode = dt1.Rows[RemainIndex]["sp_soncode"].ToString();
- string sp_fsoncode = dt1.Rows[RemainIndex]["sp_fsoncode"].ToString();
- string sp_prefix = dt1.Rows[RemainIndex]["sp_prefix"].ToString();
- string sp_regex = dt1.Rows[RemainIndex]["sp_regex"].ToString();
- string length = dt1.Rows[RemainIndex]["sp_length"].ToString();
- string sp_id = dt1.Rows[RemainIndex]["sp_id"].ToString();
- string sp_ifrepeat = dt1.Rows[RemainIndex]["sp_ifrepeat"].ToString();
- string sp_ifforsn = dt1.Rows[RemainIndex]["sp_ifforsn"].ToString();
- string sp_barcoderule = dt1.Rows[RemainIndex]["sp_barcoderule"].ToString();
- string sp_checkbarcode = dt1.Rows[RemainIndex]["sp_checkbarcode"].ToString();
- string sp_checksalecode = dt1.Rows[RemainIndex]["sp_checksalecode"].ToString();
- if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, out ErrorMessage))
- {
- //判断采集的条码和本次采集的也不能重复
- if (CollectData.Contains(code.Text) && sp_ifrepeat != "-1")
- {
- OperateResult.AppendText(">>条码" + code.Text + "已经上料\n", Color.Red, code);
- return;
- }
- if (sp_checkbarcode != "")
- {
- if (CheckBarcode.ContainsKey(sp_checkbarcode))
- {
- if (CheckBarcode[sp_checkbarcode] != code.Text)
- {
- OperateResult.AppendText(">>条码" + code.Text + "需要检查物料,未匹配到之前上料数据\n", Color.Red, code);
- return;
- }
- }
- else
- {
- OperateResult.AppendText(">>条码" + code.Text + "需要检查物料,未匹配到之前上料数据\n", Color.Red, code);
- return;
- }
- }
- TSN.Add(code.Text.Substring(0, code.Text.Length > 80 ? 80 : code.Text.Length));
- if (sp_barcoderule == "BARCODE")
- {
- sp_soncode = ErrorMessage;
- }
- Save_OtherCode(sp_fsoncode, sp_soncode, make_code, sn_code.Text, sp_id);
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- SetCheck set = new SetCheck("NG", Color.Red);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- }
- }
- }
- //勾选了下料的时候
- else if (UnLoading.Checked)
- {
- if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, code.Text, User.UserCode, out oMakeCode, out oMsid, out ErrorMessage))
- {
- sql.Clear();
- sql.Append("select ms_firstsn,cm_makecode,cm_craftcode,nvl(cm_status,0)cm_status,cm_id,cm_stepcode,");
- sql.Append("ms_makecode,cm_mccode,cm_materialtype from craftmaterial left join makeserial on cm_makecode");
- sql.Append("=ms_makecode and cm_sncode=ms_sncode where cm_sncode='" + code.Text + "' and cm_makecode='" + oMakeCode + "'");
- sql.Append("and cm_materialtype=1");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- string ms_macode = dt.Rows[0]["ms_makecode"].ToString();
- string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
- string cm_stepcode = dt.Rows[0]["cm_stepcode"].ToString();
- string cm_mccode = dt.Rows[0]["cm_mccode"].ToString();
- string cm_materialtype = dt.Rows[0]["cm_materialtype"].ToString();
- string cm_status = dt.Rows[0]["cm_status"].ToString();
- string cm_makecode = dt.Rows[0]["cm_makecode"].ToString();
- string cm_craftcode = dt.Rows[0]["cm_craftcode"].ToString();
- //清除已被使用的序列号
- sql.Clear();
- sql.Append("update makeserial set ms_nextmacode='' where ms_sncode in(select cm_barcode from craftmaterial where ");
- sql.Append("cm_makecode='" + cm_makecode + "' and cm_sncode='" + code.Text + "' and cm_stepcode='" + cm_stepcode + "' and cm_craftcode='" + cm_craftcode + "' ");
- sql.Append("and cm_materialtype=1 and nvl(cm_status,0) =0) and ms_nextmacode='" + oMakeCode + "'");
- dh.ExecuteSql(sql.GetString(), "update");
- //进行下料
- sql.Clear();
- sql.Append("delete from craftmaterial where (cm_sncode in (select sn from makesnrelation where firstsn");
- sql.Append("='" + ms_firstsn + "') or cm_sncode = '" + ms_firstsn + "') and cm_makecode = '" + oMakeCode + "' ");
- sql.Append("and cm_status = 0 and cm_stepcode='" + User.CurrentStepCode + "' and cm_materialtype=1");
- dh.ExecuteSql(sql.GetString(), "delete");
- LogicHandler.InsertMakeProcess(ms_macode, code.Text, User.UserSourceCode, "上料采集操作", "下料成功", User.UserCode);
- //刷新界面值
- sql.Clear();
- sql.Append("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty ");
- sql.Append("from make left join makecraftdetail_view on mcd_macode=ma_code where ");
- sql.Append("ma_code='" + oMakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.SetFormValue(Controls, dt);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "上料采集", "下料成功", code.Text, "");
- OperateResult.AppendText(">>序列号" + code.Text + "下料成功\n", Color.Green, code);
- }
- else OperateResult.AppendText(">>序列号" + code.Text + "未上料,无需下料\n", Color.Red, code);
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- }
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- }
- }
- //获取采集的项目
- private void GetCollectItem()
- {
- bool NoteAlready = LogicHandler.CheckDiffMakeCodeBeforeStepCheck(code.Text, ma_code.Text, NoteForChange.Checked, out oMakeCode, out ErrorMessage);
- if (!NoteAlready)
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- return;
- }
- if (LogicHandler.CheckStepSNAndMacode(oMakeCode, User.UserSourceCode, code.Text, User.UserCode, out oMakeCode, out oMsid, out ErrorMessage))
- {
- if (!LogicHandler.CheckDiffMakeCodeAfterStepCheck(code.Text, oMakeCode, NoteForChange.Checked, NoteAlready, ma_code, out ErrorMessage))
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- return;
- }
- //将录入框的值给序列号
- sn_code.Text = code.Text;
- sql.Clear();
- sql.Append("select ma_prodcode,ma_ecncode,ma_softversion,ms_firstsn,ma_bomversion,ma_qty,ma_code,pr_spec,ms_status,ms_id,ms_craftcode,ms_nextstepcode");
- sql.Append(",ms_prodcode,ms_makecode,ms_code,ms_stepname from makeserial left join make on ma_code=ms_makecode ");
- sql.Append("left join product on ms_prodcode=pr_code where ms_sncode='" + code.Text + "' order by ms_id desc");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- ms_id = dt.Rows[0]["ms_id"].ToString();
- make_code = dt.Rows[0]["ma_code"].ToString();
- mabomversion = dt.Rows[0]["ma_bomversion"].ToString();
- make_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
- nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- ms_status = dt.Rows[0]["ms_status"].ToString();
- ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString();
- BaseUtil.SetFormValue(this.Controls, dt);
- string ifforsn = dh.getFieldDataByCondition("make left join stepbom on ma_prodcode=sb_prodcode left join stepproduct on sb_id=sp_sbid", "nvl(sp_ifforsn,0) sp_ifforsn", "ma_code='" + ma_code.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' and sp_craftcode='" + ms_craftcode.Text + "' and sb_bomversion='" + ma_bomversion.Text + "' order by sp_detno").ToString();
- if (ifforsn != "" && ifforsn != "0")
- iflastsn.Checked = true;
- else
- iflastsn.Checked = false;
- LockMakeCode.Checked = true;
- //勾选了前一工单
- if (iflastsn.Checked)
- {
- dt = (DataTable)dh.ExecuteSql("select ms_id,ms_makecode,ms_craftcode,ms_status,ms_nextstepcode,ms_prodcode,ms_code from makeserial where ms_sncode='" + code.Text + "' and ms_makecode<>'" + ma_code.Text + "' order by ms_id desc", "select");
- string make_code = "";
- string make_prodcode = "";
- string nextstepcode = "";
- string ms_status = "";
- if (dt.Rows.Count > 0)
- {
- ms_id = dt.Rows[0]["ms_id"].ToString();
- make_code = dt.Rows[0]["ms_makecode"].ToString();
- make_prodcode = dt.Rows[0]["ms_prodcode"].ToString();
- nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- ms_status = dt.Rows[0]["ms_status"].ToString();
- //判断序列号的前一工单是否已经完工
- if (dt.Rows[0]["ms_makecode"].ToString() != ma_code.Text && dt.Rows[0]["ms_status"].ToString() == "2")
- {
- sql.Clear();
- sql.Append("select sp_id,sp_soncode from make inner join stepbom on ma_prodcode=sb_prodcode and ma_bomversion=sb_bomversion left ");
- sql.Append("join stepproduct on sp_sbid=sb_id where ma_code='" + ma_code.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' ");
- sql.Append("and sp_stepcode='" + User.CurrentStepCode + "' and nvl(sp_ifforsn,0)<>0");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- string sp_id = dt.Rows[0]["sp_id"].ToString();
- string sp_soncode = dt.Rows[0]["sp_soncode"].ToString();
- if (!dh.CheckExist("Craftmaterial", "cm_makecode='" + ma_code.Text + "' and cm_soncode='" + make_prodcode + "' and cm_sncode='" + code.Text + "' and cm_status=0"))
- {
- CollectDataSonCode.Add(sp_soncode);
- SPID.Add(sp_id);
- CollectData.Add(code.Text.Substring(0, code.Text.Length > 80 ? 80 : code.Text.Length));
- sn_code.Text = code.Text;
- OperateResult.AppendText(">>序列号" + code.Text + ",物料" + sp_soncode + "上料成功\n", Color.Green);
- RemainIndex = RemainIndex + 1;
- GetItem();
- return;
- }
- else
- {
- GetItem();
- }
- }
- else OperateResult.AppendText(">>序列号" + code.Text + "无生产信息\n", Color.Red, code);
- }
- else OperateResult.AppendText(">>序列号" + code.Text + "已被工单" + dt.Rows[0]["ms_makecode"].ToString() + "绑定,尚未完工\n", Color.Red, code);
- }
- else OperateResult.AppendText(">>序列号" + code.Text + "无生产信息\n", Color.Red, code);
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql("select ms_status,ms_stepcode,ms_nextstepcode from makeserial where ms_sncode='" + code.Text + "' and ms_makecode='" + ma_code.Text + "' order by ms_id desc", "select");
- nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
- ms_status = dt.Rows[0]["ms_status"].ToString();
- sn_code.Text = code.Text;
- sql.Clear();
- sql.Append("select ma_code,ma_softversion,ma_ecncode,ma_prodcode,pr_spec,ma_qty from makeserial left join product ");
- sql.Append(" on ms_prodcode=pr_code left join make on ms_makecode=ma_code left join ");
- sql.Append("makecraftdetail on mcd_macode=ms_makecode where ms_id='" + oMsid + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.SetFormValue(this.Controls, dt);
- OperateResult.AppendText(">>获取序列号" + code.Text + "成功\n", Color.Green);
- GetItem();
- }
- }
- else
- {
- OperateResult.AppendText(">>序列号" + code.Text + "不存在\n", Color.Red, code);
- code.Text = "";
- sn_code.Text = "";
- }
- }
- else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- }
- private void GetItem()
- {
- //单独用一个DataTable存储一个
- dt1 = new DataTable();
- sql.Clear();
- sql.Append("select max(sp_id)sp_id,max(sp_detno)sp_detno,min(sp_ifrepeat)sp_ifrepeat,max(sp_checkbarcode)sp_checkbarcode,min(sp_checksalecode)sp_checksalecode,");
- sql.Append("sp_fsoncode,max(sp_barcoderule)sp_barcoderule,wm_concat(sp_soncode) sp_soncode,max(sp_ifuseregex)sp_ifuseregex,max(sp_ifforsn)");
- sql.Append("sp_ifforsn,max(sp_length)sp_length,max(sp_type)sp_type,replace(wm_concat(sp_prefix),',','|')sp_prefix,max(sp_regex)");
- sql.Append("sp_regex,max(pr_detail)pr_detail,max(substr(pr_spec,0,20))pr_spec from stepproduct left join product on pr_code=sp_fsoncode where ");
- sql.Append("sp_bomversion='" + ma_bomversion.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
- sql.Append("And sp_mothercode ='" + ma_prodcode.Text + "' and sp_tracekind=1 and not exists(select 1 from craftmaterial where ");
- sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual) and cm_makecode='" + ma_code.Text + "' and cm_fsoncode=");
- sql.Append("sp_fsoncode and cm_status=0) group by sp_fsoncode order by SP_DETNO asc");
- dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- code.Clear();
- //用于记录提醒的数据长度
- RemainList = new string[dt1.Rows.Count];
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- string soncode = dt1.Rows[i]["sp_soncode"].ToString();
- string prdetail = dt1.Rows[i]["pr_detail"].ToString();
- RemainList[i] = soncode + "(" + prdetail + ")";
- }
- if (dt1.Rows.Count > 0)
- {
- try
- {
- string soncode = dt1.Rows[RemainIndex]["sp_soncode"].ToString();
- string prdetail = dt1.Rows[RemainIndex]["pr_detail"].ToString();
- OperateResult.AppendText("<<请采集" + soncode + "(" + prdetail + ")的物料数据\n", Color.Black);
- }
- catch (Exception)
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "上料采集完成!\n", Color.Green);
- code.Text = "";
- sn_code.Text = "";
- }
- }
- else
- {
- OperateResult.AppendText(">>序列号" + sn_code.Text + "不在本道工序,请采集其它序列号\n", Color.Black);
- if (!LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, sn_code.Text, "上料采集", "上料成功", User.UserCode, out ErrorMessage))
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
- else
- {
- //提示正确返回时传递的信息
- if (ErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + ErrorMessage + "\n");
- OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成功!\n", Color.Green);
- }
- code.Text = "";
- sn_code.Text = "";
- }
- }
- //此类中通用的保存逻辑
- private void Save_OtherCode(string sp_fsoncode, string sp_soncode, string ma_code, string ms_sncode, string sp_id)
- {
- CollectDataSonCode.Add(sp_soncode);
- //采集成功提示
- CollectData.Add(code.Text.Substring(0, code.Text.Length > 80 ? 80 : code.Text.Length));
- if (!CheckBarcode.ContainsKey(sp_fsoncode))
- {
- CheckBarcode.Add(sp_fsoncode, code.Text.Substring(0, code.Text.Length > 80 ? 80 : code.Text.Length));
- }
- SPID.Add(sp_id);
- OperateResult.AppendText(">>物料" + sp_soncode + "采集成功,条码" + code.Text + "\n", Color.Green);
- LabelDataGridView.Rows[RemainIndex].Cells["BarCode"].Value = code.Text;
- if (code.Text.Length > 80)
- OperateResult.AppendText(">>采集条码" + code.Text + "程度超过长度限制80,内容截取前80位进行采集\n", Color.Red);
- code.Clear();
- RemainIndex = RemainIndex + 1;
- //如果+1后不小于B序列的长度,则已采集完成,不需要进行提示了
- if (RemainIndex < RemainList.Length)
- {
- OperateResult.AppendText("<<请采集" + RemainList[RemainIndex] + "的物料数据\n", Color.Black);
- }
- else
- {
- sql.Clear();
- sql.Append("insert into Craftmaterial (cm_id ,cm_makecode,cm_maid,cm_maprodcode, cm_soncode, cm_mscode, cm_sncode, cm_stepcode, cm_stepname,cm_fsoncode,");
- sql.Append("cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid,cm_status,cm_materialtype,cm_firstsn)");
- sql.Append("select Craftmaterial_seq.nextval, ma_code, ma_id, ma_prodcode,:soncode,ms_code,ms_sncode,mcd_stepcode,");
- sql.Append("mcd_stepname,sp_fsoncode,ms_craftcode,ms_craftname,:barcode,1,sysdate,'" + User.UserCode + "','" + User.UserLineCode + "',ma_wccode,");
- sql.Append("'" + User.UserSourceCode + "',:sp_id,0,1,ms_firstsn from make left join makecraftdetail on mcd_macode=ma_code left join stepproduct on sp_stepcode=mcd_stepcode ");
- sql.Append(" and sp_mothercode = ma_prodcode left join makeserial on ms_makecode=ma_code and sp_craftcode=ms_craftcode ");
- sql.Append("where ma_code='" + make_code + "'and sp_id=:sp_id1 and mcd_stepcode = '" + User.CurrentStepCode + "' and ms_sncode='" + ms_sncode + "'");
- dh.BatchInsert(sql.GetString(), new string[] { "soncode", "barcode", "sp_id", "sp_id1" }, CollectDataSonCode.ToArray(), CollectData.ToArray(), SPID.ToArray(), SPID.ToArray());
- try
- {
- string Log = "";
- for (int i = 0; i < CollectDataSonCode.Count; i++)
- {
- Log += CollectDataSonCode.ToArray()[i] + " " + CollectData.ToArray()[i] + " " + SPID.ToArray()[i];
- }
- LogManager.DoLog(Log);
- }
- catch (Exception)
- {
- }
- //更新序列号半成品已被使用
- dh.BatchInsert("update makeserial set ms_nextmacode='" + ma_code + "' where ms_id=(select max(ms_id) from makeserial where ms_sncode=:sncode and ms_nextmacode is null and ms_makecode<>'" + ma_code + "')", new string[] { "sncode" }, TSN.ToArray());
- if (ma_ecncode_label.Checked || ma_softversion_label.Checked)
- {
- string ecnText = ma_ecncode_label.Checked ? ma_ecncode.Text : "";
- string softversionText = ma_softversion_label.Checked ? ma_softversion.Text : "";
- string remark = sir_remark_label.Checked ? sir_remark.Text : "";
- sql.Clear();
- sql.Append("insert into SNRELATIONINFORECORD(SIR_ID,SIR_SNCODE,SIR_MSCODE,SIR_ECNCODE,SIR_SOFTVER,");
- sql.Append("SIR_LINECODE,SIR_SOURCECODE,SIR_STEPCODE,SIR_MACODE,SIR_PRODCODE,SIR_INMAN,SIR_INDATE,sir_firstsn,sir_remark) select ");
- sql.Append("SNRELATIONINFORECORD_SEQ.nextval,'" + sn_code.Text + "',ms_code,'" + ecnText + "','" + softversionText + "',");
- sql.Append("'" + User.UserLineCode + "','" + User.UserSourceCode + "','" + User.CurrentStepCode + "','" + ma_code + "','" + ma_prodcode.Text + "',");
- sql.Append("'" + User.UserCode + "',sysdate,ms_firstsn,'" + remark + "' from makeserial where ms_sncode='" + sn_code.Text + "' and ms_makecode='" + ma_code + "'");
- dh.ExecuteSql(sql.GetString(), "insert");
- }
- CollectData.Clear();
- TSN.Clear();
- SPID.Clear();
- CheckBarcode.Clear();
- CollectDataSonCode.Clear();
- //采集成功,设置序列号栏目为空
- RemainIndex = 0;
- OperateResult.AppendText(">>序列号" + sn_code.Text + "上料采集完成!\n", Color.Green);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "上料采集", "上料成功", sn_code.Text, "");
- if (LogicHandler.SetStepResult(ma_code, User.UserSourceCode, sn_code.Text, "上料采集", "上料成功", User.UserCode, out ErrorMessage))
- {
- //提示正确返回时传递的信息
- if (ErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + ErrorMessage + "\n");
- sn_code.Text = "";
- //刷新数据
- EventArgs e = new EventArgs();
- object sender = null;
- ma_code_UserControlTextChanged(sender, e);
- }
- else
- {
- OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
- }
- }
- }
- private void ClearSn_code_Click(object sender, EventArgs e)
- {
- sn_code.Clear();
- SPID.Clear();
- TSN.Clear();
- CheckBarcode.Clear();
- CollectData.Clear();
- CollectDataSonCode.Clear();
- if (dt1 != null)
- BaseUtil.CleanDataTableData(dt1);
- RemainIndex = 0;
- BaseUtil.CleanDGVData(LabelDataGridView);
- OperateResult.AppendText(">>请采集序列号\n", Color.Black);
- }
- private void ma_code_UserControlTextChanged(object sender, EventArgs e)
- {
- if (ma_code.Text.Length > 5)
- {
- string ErrMessage = "";
- if (LogicHandler.CheckMakeStatus(ma_code.Text, out ErrMessage))
- {
- mcd_inqty.Text = "";
- mcd_remainqty.Text = "";
- sql.Clear();
- sql.Append("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty ");
- sql.Append("from make left join makecraftdetail_view on mcd_macode=ma_code where ");
- sql.Append("ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- BaseUtil.SetFormValue(Controls, dt);
- }
- }
- }
- }
- }
|