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.
124 lines
3.2 KiB
124 lines
3.2 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data.Entity.Infrastructure;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
using CK.SCP.Models;
|
||
|
using CK.SCP.Utils;
|
||
|
|
||
|
namespace CK.SCP.Controller
|
||
|
{
|
||
|
public class SCP_BILLCODE_CONTROLLER
|
||
|
{
|
||
|
|
||
|
public static string MakeClaimCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("M", "TM_HYANTOLIN_REVIEW", "ReviewBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
|
||
|
public static string MakePOCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("P", "TB_PO", "PoBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakeQualityCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("Q", "TB_QUALITY", "QualityNo", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakeASNCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("N", "TB_ASN", "AsnBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakePalletCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("G", "TB_PALLET", "PalletNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakeASKCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("K", "TB_ASK", "AskBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakePLAN_ASKCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("E", "TB_ASK", "AskBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
|
||
|
public static string MakePLAN_EXTEND_ASKCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("U", "TB_ASK", "AskBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakeReviceCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("R", "TB_RECEIVE", "RecvBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakeRejectCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("J", "TB_REJECT", "RjctBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
public static string MakeInvoiceCode()
|
||
|
{
|
||
|
|
||
|
return GetTablePK("F", "TB_INVOICE", "InvcBillNum", "yyMMdd", 4);
|
||
|
|
||
|
}
|
||
|
|
||
|
public static string MakeCode(string p_Header, string p_TableName,string p_ColumnName)
|
||
|
{
|
||
|
|
||
|
return GetTablePK(p_Header, p_TableName, p_ColumnName, "yyMMdd",4);
|
||
|
|
||
|
}
|
||
|
public static string GetTablePK(string Ext, string TableName, string ColName, string Format, int len)
|
||
|
{
|
||
|
var _result = string.Empty;
|
||
|
try
|
||
|
{
|
||
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
||
|
{
|
||
|
string time = Ext + DateTime.Now.ToString(Format);
|
||
|
string sql = "select max(right(" + ColName + "," + len.ToString() + ")+1) from " + TableName + " where " + ColName + " like '" + time + "%'";
|
||
|
DbRawSqlQuery<int?> result = db.Database.SqlQuery<int?>(sql);
|
||
|
var obj = result.FirstOrDefault();
|
||
|
if (obj==null)
|
||
|
{
|
||
|
_result= time + "1".PadLeft(len, '0');
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
_result= time + result.FirstOrDefault().ToString().PadLeft(len, '0');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch(Exception e)
|
||
|
{
|
||
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BILLCODE_CONTROLLER), "GetTablePK", e.Message);
|
||
|
}
|
||
|
return _result;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|