You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
2 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace MESClassLibrary.DAL.Injection
|
||
|
{
|
||
|
public class UniqueDal
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 生成流水号
|
||
|
/// </summary>
|
||
|
/// <param name="type">类型</param>
|
||
|
/// <param name="len">流水号长度</param>
|
||
|
/// <returns></returns>
|
||
|
public string GetBillNo(string type, int len)
|
||
|
{
|
||
|
string sql = $"exec p_GetBillNo '{type}'";
|
||
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
|
||
|
|
||
|
return Convert.ToInt32(dt.Rows[0]["value"]).ToString().PadLeft(len, '0');
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 生成最新的注塑条码
|
||
|
/// </summary>
|
||
|
/// <param name="stockNo"></param>
|
||
|
/// <param name="batch"></param>
|
||
|
/// <returns></returns>
|
||
|
public string GetSjBarCodeSerialNo(string stockNo, string batch)
|
||
|
{
|
||
|
//if (stockNo.Length != 10)
|
||
|
//{
|
||
|
// throw new Exception($"生成塑件条码错误,因为存货代码[{stockNo}]格式不正确,必须10位长度.");
|
||
|
//}
|
||
|
string s = GetBillNo(stockNo + batch, 4);
|
||
|
string sjBarCode = stockNo + batch + s;
|
||
|
try
|
||
|
{
|
||
|
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, $" insert into tb_BarCodeUnique(OneBarCode) values('{sjBarCode}')");
|
||
|
return sjBarCode;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
return GetSjBarCodeSerialNo(stockNo, batch);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|