using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//Ref:
using System.Data;
using QMAPP.BoraUpgrade.Common;
using QMAPP.BoraUpgrade.Entity;
namespace QMAPP.BoraUpgrade.DAL
{
public class ProductMaxCodeDAL
{
#region 根据工单ID提取物料列表
///
/// 根据工单ID提取物料列表
///
///
public static int GetProductMaxCode(string MATERIAL_TYPE_CODE, string GenerateDate, string ProductType)
{
int returnVal = 1;
string sqlScript =
@"
SELECT ISNULL(MAX(RIGHT(PRODUCTCODE,6)),0)
FROM T_AW_PRODUCT WHERE MATERIAL_TYPE='{0}'
AND DATEDIFF(day,CREATEDATE,'{1}')=0
AND PRODUCTCODE LIKE '{2}%';
";
sqlScript = string.Format(sqlScript, MATERIAL_TYPE_CODE,GenerateDate, ProductType);
string result =
SqlHelper.ExecuteScalar(Config.maindbConnectionString, CommandType.Text, sqlScript).ToString();
int.TryParse(result, out returnVal);
return returnVal+1;
}
#endregion
}
}