|
|
@@ -21,9 +21,9 @@ namespace UAS_MES.Make
|
|
|
|
|
|
DataHelper dh;
|
|
|
//原序列号
|
|
|
- string TSN="";
|
|
|
+ string TSN = "";
|
|
|
//转换后序列号
|
|
|
- string SN="";
|
|
|
+ string SN = "";
|
|
|
//错误信息
|
|
|
string errorMessage;
|
|
|
//存放productsnrelation表中的数据
|
|
|
@@ -31,7 +31,7 @@ namespace UAS_MES.Make
|
|
|
//存放工单信息
|
|
|
DataTable dt;
|
|
|
//step 记录检验规则的进度
|
|
|
- int step=0;
|
|
|
+ int step = 0;
|
|
|
//存放关联信息类型
|
|
|
string type;
|
|
|
//存放包含IMEI的规则的值,方便拼接
|
|
|
@@ -66,7 +66,7 @@ namespace UAS_MES.Make
|
|
|
|
|
|
private void code_KeyDown(object sender, KeyEventArgs e)
|
|
|
{
|
|
|
- if (e.KeyCode==Keys.Enter)
|
|
|
+ if (e.KeyCode == Keys.Enter)
|
|
|
{
|
|
|
if (code.Text != "")
|
|
|
{
|
|
|
@@ -159,12 +159,12 @@ namespace UAS_MES.Make
|
|
|
if (!dh.CheckExist("makeserial", "ms_sncode='" + code.Text + "'"))
|
|
|
{
|
|
|
//判断用户是否锁定输入SN长度,
|
|
|
- if (!checkLengthOrPre(SNLength_checkBox, SNLength, "长度","SN"))
|
|
|
+ if (!checkLengthOrPre(SNLength_checkBox, SNLength, "长度", "SN"))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
//判断用户是否锁定输入SN前缀,
|
|
|
- if (!checkLengthOrPre(SNPre_checkBox, SNPre, "前缀","SN"))
|
|
|
+ if (!checkLengthOrPre(SNPre_checkBox, SNPre, "前缀", "SN"))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
@@ -204,7 +204,8 @@ namespace UAS_MES.Make
|
|
|
code.Text = "";
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
OperateResult.AppendText(">>输入不能为空\n", Color.Red);
|
|
|
}
|
|
|
}
|
|
|
@@ -253,128 +254,136 @@ namespace UAS_MES.Make
|
|
|
/// <param name="step"></param>
|
|
|
private bool checkRules(int step)
|
|
|
{
|
|
|
- type = ListA.Rows[step - 2]["psr_type"].ToString()=="WIFI"?"MAC": ListA.Rows[step - 2]["psr_type"].ToString();
|
|
|
+ type = ListA.Rows[step - 2]["psr_type"].ToString() == "WIFI" ? "MAC" : ListA.Rows[step - 2]["psr_type"].ToString();
|
|
|
//如果前缀和长度都满足的话
|
|
|
- if ((ListA.Rows[step-2]["psr_length"].ToString() == "" ? true : code.Text.Length == int.Parse(ListA.Rows[step-2]["psr_length"].ToString())) && (ListA.Rows[step - 2]["psr_prefix"].ToString() == "" ? true : code.Text.StartsWith(ListA.Rows[step - 2]["psr_prefix"].ToString())))
|
|
|
+ if ((ListA.Rows[step - 2]["psr_length"].ToString() == "" ? true : code.Text.Length != int.Parse(ListA.Rows[step - 2]["psr_length"].ToString())))
|
|
|
{
|
|
|
- switch (type)
|
|
|
- {
|
|
|
- case "IMEI1":
|
|
|
- case "IMEI2":
|
|
|
- case "IMEI3":
|
|
|
- if (checkExist("ms_imei1='" + code.Text + "' or ms_imei2 = '" + code.Text + "' or ms_imei3 = '" + code.Text + "'"))
|
|
|
- {
|
|
|
- OperateResult.AppendText(">>" + type + ":" + code.Text + "错误,不允许重复\n", Color.Red);
|
|
|
- OperateResult.AppendText(">>请输入"+type+"\n", Color.Green);
|
|
|
- code.Text = "";
|
|
|
- return false;
|
|
|
- }
|
|
|
- else
|
|
|
+ OperateResult.AppendText(">>" + ListA.Rows[step - 2]["psr_type"] + "长度校验不通过,请重新输入\n", Color.Red);
|
|
|
+ OperateResult.AppendText(">>请重新输入" + ListA.Rows[step - 2]["psr_type"] + "\n", Color.Green);
|
|
|
+ code.Text = "";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!(ListA.Rows[step - 2]["psr_prefix"].ToString() == "" ? true : code.Text.StartsWith(ListA.Rows[step - 2]["psr_prefix"].ToString())))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>" + ListA.Rows[step - 2]["psr_type"] + "前缀校验不通过,请重新输入\n", Color.Red);
|
|
|
+ OperateResult.AppendText(">>请重新输入" + ListA.Rows[step - 2]["psr_type"] + "\n", Color.Green);
|
|
|
+ code.Text = "";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ switch (type)
|
|
|
+ {
|
|
|
+ case "IMEI1":
|
|
|
+ case "IMEI2":
|
|
|
+ case "IMEI3":
|
|
|
+ if (checkExist("ms_imei1='" + code.Text + "' or ms_imei2 = '" + code.Text + "' or ms_imei3 = '" + code.Text + "'"))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>" + type + ":" + code.Text + "错误,不允许重复\n", Color.Red);
|
|
|
+ OperateResult.AppendText(">>请输入" + type + "\n", Color.Green);
|
|
|
+ code.Text = "";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //判断IMEI1,IMEI2,IMEI3中是否已经有这个号了
|
|
|
+ if (imei.ToString().Contains(code.Text))
|
|
|
{
|
|
|
- //判断IMEI1,IMEI2,IMEI3中是否已经有这个号了
|
|
|
- if (imei.ToString().Contains(code.Text)) {
|
|
|
- OperateResult.AppendText(">>" + type + ":" + code.Text + "已录,请重新输入\n", Color.Red);
|
|
|
- OperateResult.AppendText(">>请输入" + type + "\n", Color.Green);
|
|
|
- code.Text = "";
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- //通过校验,将包含IMEI的值拼接
|
|
|
- imei.Append("'"+code.Text+"',");
|
|
|
- s1.Append("MS_" + type + " = '" + code.Text + "',");
|
|
|
- break;
|
|
|
- case "BT":
|
|
|
- case "MAC":
|
|
|
- case "NETCODE":
|
|
|
- if (checkExist("MS_"+type+"='"+code.Text+"'")) {
|
|
|
- OperateResult.AppendText(">>" + type + ":" + code.Text + "错误,不允许重复\n", Color.Red);
|
|
|
+ OperateResult.AppendText(">>" + type + ":" + code.Text + "已录,请重新输入\n", Color.Red);
|
|
|
OperateResult.AppendText(">>请输入" + type + "\n", Color.Green);
|
|
|
code.Text = "";
|
|
|
return false;
|
|
|
}
|
|
|
- //通过校验,将包含IMEI的值拼接
|
|
|
- s1.Append("MS_" + type + " = '" + code.Text + "',");
|
|
|
- break;
|
|
|
- }
|
|
|
- //满足规则,则采集
|
|
|
- hs.Add(type,code.Text);
|
|
|
- //说明已经是最后一个校验规则
|
|
|
- if (step == ListA.Rows.Count+1)
|
|
|
+ }
|
|
|
+ //通过校验,将包含IMEI的值拼接
|
|
|
+ imei.Append("'" + code.Text + "',");
|
|
|
+ s1.Append("MS_" + type + " = '" + code.Text + "',");
|
|
|
+ break;
|
|
|
+ case "BT":
|
|
|
+ case "MAC":
|
|
|
+ case "NETCODE":
|
|
|
+ if (checkExist("MS_" + type + "='" + code.Text + "'"))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>" + type + ":" + code.Text + "错误,不允许重复\n", Color.Red);
|
|
|
+ OperateResult.AppendText(">>请输入" + type + "\n", Color.Green);
|
|
|
+ code.Text = "";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //通过校验,将包含IMEI的值拼接
|
|
|
+ s1.Append("MS_" + type + " = '" + code.Text + "',");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //满足规则,则采集
|
|
|
+ hs.Add(type, code.Text);
|
|
|
+ //说明已经是最后一个校验规则
|
|
|
+ if (step == ListA.Rows.Count + 1)
|
|
|
+ {
|
|
|
+ //校验已经完成,此时要再次校验之前的SN和关联采集信息
|
|
|
+ //再次校验SN
|
|
|
+ if (!dh.CheckExist("makeserial", "ms_sncode='" + SN + "'"))
|
|
|
{
|
|
|
- //校验已经完成,此时要再次校验之前的SN和关联采集信息
|
|
|
- //再次校验SN
|
|
|
- if (!dh.CheckExist("makeserial", "ms_sncode='" + SN + "'"))
|
|
|
+ bool flag = true;
|
|
|
+ //遍历判断已采集的信息是否已存在
|
|
|
+ foreach (DictionaryEntry de in hs)
|
|
|
{
|
|
|
- bool flag = true;
|
|
|
- //遍历判断已采集的信息是否已存在
|
|
|
- foreach (DictionaryEntry de in hs)
|
|
|
+ if (dh.CheckExist("makeserial", "MS_" + de.Key + "='" + de.Value + "'"))
|
|
|
{
|
|
|
- if (dh.CheckExist("makeserial", "MS_" + de.Key + "='" + de.Value + "'"))
|
|
|
- {
|
|
|
- flag = false;
|
|
|
- OperateResult.AppendText(">>"+de.Key+"已被使用,请重新输入TSN,重新转换\n", Color.Green);
|
|
|
- //清空信息
|
|
|
- clearInfo();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //根据flag判断关联采集信息二次校验结果
|
|
|
- if (flag==true) {
|
|
|
- //说明SN和关联采集信息二次校验通过,则进行转换和采集信息绑定
|
|
|
- //查询ms_firstsn
|
|
|
- string firstsn = dh.getFieldDataByCondition("makeserial", "ms_firstsn", "ms_sncode='" + TSN + "'").ToString();
|
|
|
- //记录本次修改,存入makesnrelation表中
|
|
|
- string updateSql = "update makeserial set ms_sncode='" + SN + "', ms_beforesn='" + TSN + "',"+ s1.Remove(s1.Length - 1, 1).ToString() + " where ms_sncode='" + TSN + "'";
|
|
|
- string insertSql = "insert into makesnrelation (BEFORESN,SN,FIRSTSN,MAKECODE,msr_indate, msr_inman)values('" + TSN + "','" + SN + "','" + firstsn + "','" + ms_macode.Text + "', sysdate ,'" + User.UserCode + "')";
|
|
|
- dh.ExecuteSQLTran(updateSql, insertSql);
|
|
|
- OperateResult.AppendText(">>序列号转换成功\n", Color.Green);
|
|
|
- //写入日志
|
|
|
- LogManager.DoLog("修改序列号:" + TSN + "为" + SN + "成功!" + "操作人:" + User.UserCode);
|
|
|
- //完成该道工序 setFinish
|
|
|
- LogicHandler.UpdateMakeMessage(SN, ms_macode.Text, "序列烧录转换", User.UserSourceCode, User.UserCode, "序列烧录转换成功", out errorMessage);
|
|
|
-
|
|
|
- //输出提示用户“>>序列号转换成功”,“>>关联采集成功”
|
|
|
- OperateResult.AppendText(">>关联采集成功\n", Color.Green);
|
|
|
- //获取剩余数,刷新页面
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select mcd_inqty from makecraftdetail where mcd_macode='"+ms_macode.Text+"' and mcd_stepcode='"+ User.CurrentStepCode + "'");
|
|
|
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", SN);
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- remain_qty.Text = ma_qty -int.Parse(dt.Rows[0]["mcd_inqty"].ToString())+"";
|
|
|
- }
|
|
|
- //更新页面计数+1
|
|
|
- count.Text = int.Parse(count.Text) + 1 + "";
|
|
|
- //完成之后,清除信息
|
|
|
+ flag = false;
|
|
|
+ OperateResult.AppendText(">>" + de.Key + "已被使用,请重新输入TSN,重新转换\n", Color.Green);
|
|
|
+ //清空信息
|
|
|
clearInfo();
|
|
|
- OperateResult.AppendText(">>请输入TSN号\n", Color.Green);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ //根据flag判断关联采集信息二次校验结果
|
|
|
+ if (flag == true)
|
|
|
{
|
|
|
- OperateResult.AppendText(">>序列号" + SN + "已存在\n", Color.Red);
|
|
|
- OperateResult.AppendText(">>请重新输入TSN\n", Color.Green);
|
|
|
- code.Text = "";
|
|
|
- //清空信息
|
|
|
+ //说明SN和关联采集信息二次校验通过,则进行转换和采集信息绑定
|
|
|
+ //查询ms_firstsn
|
|
|
+ string firstsn = dh.getFieldDataByCondition("makeserial", "ms_firstsn", "ms_sncode='" + TSN + "'").ToString();
|
|
|
+ //记录本次修改,存入makesnrelation表中
|
|
|
+ string updateSql = "update makeserial set ms_sncode='" + SN + "', ms_beforesn='" + TSN + "'," + s1.Remove(s1.Length - 1, 1).ToString() + " where ms_sncode='" + TSN + "'";
|
|
|
+ string insertSql = "insert into makesnrelation (BEFORESN,SN,FIRSTSN,MAKECODE,msr_indate, msr_inman)values('" + TSN + "','" + SN + "','" + firstsn + "','" + ms_macode.Text + "', sysdate ,'" + User.UserCode + "')";
|
|
|
+ dh.ExecuteSQLTran(updateSql, insertSql);
|
|
|
+ OperateResult.AppendText(">>序列号转换成功\n", Color.Green);
|
|
|
+ //写入日志
|
|
|
+ LogManager.DoLog("修改序列号:" + TSN + "为" + SN + "成功!" + "操作人:" + User.UserCode);
|
|
|
+ //完成该道工序 setFinish
|
|
|
+ LogicHandler.UpdateMakeMessage(SN, ms_macode.Text, "序列烧录转换", User.UserSourceCode, User.UserCode, "序列烧录转换成功", out errorMessage);
|
|
|
+
|
|
|
+ //输出提示用户“>>序列号转换成功”,“>>关联采集成功”
|
|
|
+ OperateResult.AppendText(">>关联采集成功\n", Color.Green);
|
|
|
+ //获取剩余数,刷新页面
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select mcd_inqty from makecraftdetail where mcd_macode='" + ms_macode.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", SN);
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ remain_qty.Text = ma_qty - int.Parse(dt.Rows[0]["mcd_inqty"].ToString()) + "";
|
|
|
+ }
|
|
|
+ //更新页面计数+1
|
|
|
+ count.Text = int.Parse(count.Text) + 1 + "";
|
|
|
+ //完成之后,清除信息
|
|
|
clearInfo();
|
|
|
+ OperateResult.AppendText(">>请输入TSN号\n", Color.Green);
|
|
|
}
|
|
|
- code.Text = "";
|
|
|
- return false;
|
|
|
}
|
|
|
- else {
|
|
|
- OperateResult.AppendText("<<请输入"+ ListA.Rows[step-1]["psr_type"] + "\n", Color.Green);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(">>序列号" + SN + "已存在\n", Color.Red);
|
|
|
+ OperateResult.AppendText(">>请重新输入TSN\n", Color.Green);
|
|
|
code.Text = "";
|
|
|
- return true;
|
|
|
+ //清空信息
|
|
|
+ clearInfo();
|
|
|
}
|
|
|
- }
|
|
|
- else {
|
|
|
- //重新输入
|
|
|
- OperateResult.AppendText(">>" + ListA.Rows[step-2]["psr_type"] + "校验不通过,请重新输入\n", Color.Red);
|
|
|
- OperateResult.AppendText(">>请重新输入" + ListA.Rows[step - 2]["psr_type"] + "\n", Color.Green);
|
|
|
code.Text = "";
|
|
|
return false;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("<<请输入" + ListA.Rows[step - 1]["psr_type"] + "\n", Color.Green);
|
|
|
+ code.Text = "";
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 工单号变化时,带出校验规则
|
|
|
@@ -481,19 +490,22 @@ namespace UAS_MES.Make
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private bool checkExist(string fields) {
|
|
|
+
|
|
|
+ private bool checkExist(string fields)
|
|
|
+ {
|
|
|
//不存在
|
|
|
if (!dh.CheckExist("makeserial", fields))
|
|
|
{
|
|
|
//则记录
|
|
|
return false;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
- private void clearInfo() {
|
|
|
+ private void clearInfo()
|
|
|
+ {
|
|
|
//步骤重置为0
|
|
|
step = 0;
|
|
|
//关联采集信息清空
|