天津投入产出系统后端
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.
 
 
 
 
 
 

40 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QMAPP.FJC.TRACING.CodeGenerators
{
public class ProductCodeGenerator:DAInterface.ICodeGenerator
{
public string Generate(string materialcode, DateTime time, dynamic parameters)
{
MD.DAL.MaterialDAL mdal = new MD.DAL.MaterialDAL();
var material= mdal.Get(new MD.Entity.Material { MATERIAL_CODE = materialcode });
if (material == null)
{
throw new Exception("查找物料信息失败!");
}
DAL.Basic.MaterialCodeInitDAL mcdal = new DAL.Basic.MaterialCodeInitDAL();
var materialinit= mcdal.GetByCondition(new Entity.Basic.MaterialCodeInit{ MATERIAL_TYPE=material.MATERIAL_TYPE_CODE});
string prefix="";
if(materialinit!=null)
{
prefix=materialinit.PRODUCT_TYPES;
}
var productdal=new DAL.Produce.ProductDAL();
string maxcode=productdal.GetMaxCode(material.MATERIAL_TYPE_CODE,time);
string newcode = "1";
if (!string.IsNullOrEmpty(maxcode))
{
newcode = (Convert.ToInt32(maxcode) + 1) + "";
}
newcode = prefix+time.ToString("yyyyMMdd") + newcode.PadLeft(6, '0');
return newcode;
}
}
}