57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace Tanshu.Accounts.SqlDAO
|
|||
|
{
|
|||
|
public static class DbValues
|
|||
|
{
|
|||
|
public static DateTime Date
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
var query = session.CreateSQLQuery("SELECT Getdate();");
|
|||
|
return (DateTime)query.UniqueResult();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
public static string KotID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
string query = @"
|
|||
|
SELECT ISNULL('K-' + CAST(MAX(CAST(SUBSTRING(KotID, 3,8) AS int)) + 1 AS nvarchar(8)), 'K-1') FROM Entities_Vouchers
|
|||
|
WHERE discriminator = 'Tanshu.Accounts.Entities.SaleVoucher'";
|
|||
|
var sqlQuery = session.CreateSQLQuery(query);
|
|||
|
return (string)sqlQuery.UniqueResult();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
public static string BillID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
using (var session = SessionManager.Session)
|
|||
|
{
|
|||
|
string query = @"
|
|||
|
DECLARE @BillID nvarchar(10)
|
|||
|
SELECT @BillID = ISNULL(CAST(MAX(CAST(REPLACE(BillID, '-', '') AS int)) + 1 AS nvarchar(9)), '010001') FROM Entities_Vouchers WHERE BillID LIKE '__-____' AND discriminator = 'Tanshu.Accounts.Entities.SaleVoucher'
|
|||
|
IF LEN(@BillID) = 5
|
|||
|
SET @BillID = '0' + @BillID
|
|||
|
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-' + SUBSTRING(@BillID, 3, 7)
|
|||
|
IF SUBSTRING(@BillID,3,7) = '-0000'
|
|||
|
SET @BillID = SUBSTRING(@BillID, 1, 2) + '-0001'
|
|||
|
SELECT @BillID";
|
|||
|
var sqlQuery = session.CreateSQLQuery(query);
|
|||
|
return (string)sqlQuery.UniqueResult();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|