38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
|
|
namespace CRM.Core.Model.Entity
|
|
{
|
|
[Table("Bas_Aseq")]
|
|
public class Bas_Aseq
|
|
{
|
|
[Key]
|
|
public string Name { get; set; }
|
|
public long Start_Value { get; set; }
|
|
public int Increment_Value { get; set; }
|
|
|
|
public long Get(string name)
|
|
{
|
|
using (var db = new zxdContext())
|
|
{
|
|
var seq = db.Bas_Aseq.FirstOrDefault(p => p.Name == name);
|
|
var id = seq.Start_Value;
|
|
if (id.ToString().Length == 6)
|
|
{
|
|
var a = id.ToString().Substring(0, 4);
|
|
var b = int.Parse(id.ToString().Substring(4, 2)) + 1;
|
|
seq.Start_Value = int.Parse(a + b);
|
|
}
|
|
else
|
|
{
|
|
seq.Start_Value = seq.Start_Value + 1;
|
|
}
|
|
|
|
db.SaveChanges();
|
|
return id;
|
|
}
|
|
}
|
|
}
|
|
}
|