|
@@ -1,19 +1,13 @@
|
|
|
using Seagull.BarTender.Print;
|
|
using Seagull.BarTender.Print;
|
|
|
using System;
|
|
using System;
|
|
|
-using System.Collections.Generic;
|
|
|
|
|
-using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
using System.Drawing;
|
|
|
using System.Drawing.Printing;
|
|
using System.Drawing.Printing;
|
|
|
-using System.Linq;
|
|
|
|
|
-using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms;
|
|
|
using UAS_MES_NEW.DataOperate;
|
|
using UAS_MES_NEW.DataOperate;
|
|
|
using UAS_MES_NEW.Entity;
|
|
using UAS_MES_NEW.Entity;
|
|
|
using UAS_MES_NEW.PublicMethod;
|
|
using UAS_MES_NEW.PublicMethod;
|
|
|
-using UAS_MES_NEW.Query;
|
|
|
|
|
-using static System.Runtime.CompilerServices.RuntimeHelpers;
|
|
|
|
|
|
|
|
|
|
namespace UAS_MES_NEW.Query
|
|
namespace UAS_MES_NEW.Query
|
|
|
{
|
|
{
|
|
@@ -30,6 +24,10 @@ namespace UAS_MES_NEW.Query
|
|
|
|
|
|
|
|
DataHelper dh = SystemInf.dh;
|
|
DataHelper dh = SystemInf.dh;
|
|
|
|
|
|
|
|
|
|
+ //前缀条件
|
|
|
|
|
+
|
|
|
|
|
+ //生成条码的流水号
|
|
|
|
|
+
|
|
|
DataTable Dbfind;
|
|
DataTable Dbfind;
|
|
|
public Query_SN()
|
|
public Query_SN()
|
|
|
{
|
|
{
|
|
@@ -217,7 +215,7 @@ namespace UAS_MES_NEW.Query
|
|
|
ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
|
|
ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
|
|
|
ma_code.FormName = Name;
|
|
ma_code.FormName = Name;
|
|
|
ma_code.SetValueField = new string[] { "ma_code" };
|
|
ma_code.SetValueField = new string[] { "ma_code" };
|
|
|
- ma_code.Condition = "ma_statuscode='STARTED'";
|
|
|
|
|
|
|
+ //ma_code.Condition = "ma_statuscode='STARTED'";
|
|
|
ma_code.DbChange += pr_code_DbChange;
|
|
ma_code.DbChange += pr_code_DbChange;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -225,19 +223,135 @@ namespace UAS_MES_NEW.Query
|
|
|
{
|
|
{
|
|
|
Dbfind = ma_code.ReturnData;
|
|
Dbfind = ma_code.ReturnData;
|
|
|
BaseUtil.SetFormValue(this.Controls, Dbfind);
|
|
BaseUtil.SetFormValue(this.Controls, Dbfind);
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
|
|
|
|
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
{
|
|
|
pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
|
|
pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
|
|
|
ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
|
|
ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
|
|
|
- ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
|
|
|
|
|
pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
|
|
pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void GenSN_Click(object sender, EventArgs e)
|
|
private void GenSN_Click(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
|
|
+ string Prefix = "";
|
|
|
|
|
|
|
|
|
|
+ string Suffix = "";
|
|
|
|
|
+ //获取编码规则
|
|
|
|
|
+ if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
|
|
|
|
|
+ {
|
|
|
|
|
+ MessageBox.Show("工单号不存在");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (dh.getRowCount("makesnlist", "msl_makecode='" + ma_code.Text + "'") > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ MessageBox.Show("工单号" + ma_code.Text + "已存在导入清单");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select pr_exbarcode,ma_qty from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
|
|
|
|
|
+ string pr_exbarcode = "";
|
|
|
|
|
+ string ma_qty = "";
|
|
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ pr_exbarcode = dt.Rows[0]["pr_exbarcode"].ToString();
|
|
|
|
|
+ ma_qty = dt.Rows[0]["ma_qty"].ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ DataTable Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_code='" + pr_exbarcode + "' order by nrd_detno", "select");
|
|
|
|
|
+ //如果没有则取公共规则
|
|
|
|
|
+ if (Nr.Rows.Count == 0)
|
|
|
|
|
+ Nr = (DataTable)dh.ExecuteSql("select nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null and nr_isdefault <> 0 order by nrd_detno", "select");
|
|
|
|
|
+ //用于过滤参数的正则表达式
|
|
|
|
|
+ Regex match = new Regex("{\\w+}");
|
|
|
|
|
+ //用于存放每一项的明细的数据
|
|
|
|
|
+ string[] NrData = new string[Nr.Rows.Count];
|
|
|
|
|
+ //流水号的索引
|
|
|
|
|
+ int SerialNumIndex = 0;
|
|
|
|
|
+ //流水长度
|
|
|
|
|
+ int SerialNumLength = 0;
|
|
|
|
|
+ //存放键值对
|
|
|
|
|
+ int Radix = 10;
|
|
|
|
|
+ string PrefixFixed = "";
|
|
|
|
|
+ for (int m = 0; m < Nr.Rows.Count; m++)
|
|
|
|
|
+ {
|
|
|
|
|
+ switch (Nr.Rows[m]["nrd_type"].ToString())
|
|
|
|
|
+ {
|
|
|
|
|
+ //常量直接进行拼接
|
|
|
|
|
+ case "常量":
|
|
|
|
|
+ NrData[m] = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
|
|
+ Prefix += NrData[m];
|
|
|
|
|
+ Suffix += NrData[m];
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "SQL":
|
|
|
|
|
+ string SQL = Nr.Rows[m]["nrd_sql"].ToString();
|
|
|
|
|
+ DataTable Temp;
|
|
|
|
|
+ //如果不包含参数替换
|
|
|
|
|
+ if (SQL.IndexOf("{") == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ //替换参数后重新执行SQL
|
|
|
|
|
+ foreach (Match mch in match.Matches(SQL))
|
|
|
|
|
+ {
|
|
|
|
|
+ SQL = SQL.Replace(mch.Value.Trim(), "'" + ma_code.Text + "'");
|
|
|
|
|
+ }
|
|
|
|
|
+ Temp = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Temp.Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ NrData[m] = Temp.Rows[0][0].ToString();
|
|
|
|
|
+ Prefix += NrData[m];
|
|
|
|
|
+ Suffix += NrData[m];
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ NrData[m] = "";
|
|
|
|
|
+ Prefix += NrData[m];
|
|
|
|
|
+ Suffix += NrData[m];
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ //流水需要通过MaxNumber去取
|
|
|
|
|
+ case "流水":
|
|
|
|
|
+ NrData[m] = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + pr_exbarcode + "'").ToString();
|
|
|
|
|
+ Suffix = "";
|
|
|
|
|
+ PrefixFixed = Prefix;
|
|
|
|
|
+ //设置当前流水
|
|
|
|
|
+ custserialnum = int.Parse(NrData[m] == "" ? "0" : NrData[m]);
|
|
|
|
|
+ SerialNumIndex = m;
|
|
|
|
|
+ SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
|
|
|
|
|
+ Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取最大的流水号
|
|
|
|
|
+ string maxnum = dh.getFieldDataByCondition("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + pr_exbarcode + "' and rmn_prefix='" + Prefix + "'").ToString();
|
|
|
|
|
+ //如果流水号为空则插入一条新记录,从1开始取
|
|
|
|
|
+ if (maxnum == "")
|
|
|
|
|
+ {
|
|
|
|
|
+ dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber) values(RuleMaxNum_seq.nextval,'" + pr_exbarcode + "','" + Prefix + "','1')", "insert");
|
|
|
|
|
+ custserialnum = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果流水号不为空则取当前流水
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ custserialnum = int.Parse(maxnum);
|
|
|
|
|
+ }
|
|
|
|
|
+ //遍历整个Grid,勾选的项目全部进行条码生成
|
|
|
|
|
+ ArrayList<string> custbarcode = new ArrayList<string>();
|
|
|
|
|
+ for (int i = 0; i < int.Parse(ma_qty); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ custbarcode.Add(BarcodeMethod1(PrefixFixed, Suffix, SerialNumIndex, SerialNumLength, Radix));
|
|
|
|
|
+ }
|
|
|
|
|
+ //插入条码
|
|
|
|
|
+ string sql = "insert into makesnlist(MSL_ID, MSL_INDATE, MSL_MAKECODE, MSL_SNCODE, MSL_TYPE)" +
|
|
|
|
|
+ "values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "',:custbarcode,'before')";
|
|
|
|
|
+ dh.BatchInsert(sql, new string[] { "custbarcode" }, custbarcode.ToArray(), custbarcode.ToArray());
|
|
|
|
|
+ //更新最大流水号
|
|
|
|
|
+ dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + pr_exbarcode + "' and rmn_prefix='" + Prefix + "'");
|
|
|
|
|
+ MessageBox.Show("工单" + ma_code.Text + "生成SN清单成功");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|