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.

69 lines
1.5 KiB

using EC.Entity.Transport;
using EC.Service.Base;
using System;
namespace EC.Service.Transport
{
public class IniService : MvcService<IniEntity>
{
public IniService()
{
}
#region BLL
public IniEntity GetIniBySerialNumber(string serialNumber)
{
return SelectEntityByWhere($"SerialNumber='{serialNumber}'");
}
/// <summary>
/// 任务单号
/// </summary>
/// <returns></returns>
public string GetNewBillSerialNo()
{
var yearMonth = DateTime.Now.ToString("yyyyMM");//SerialNumber
var iniEntity = GetIniBySerialNumber(yearMonth) ?? new IniEntity
{
SerialNumber = yearMonth,
PlanNumber = 0,
BillNumber = 0
};
iniEntity.BillNumber += 1;
iniEntity.BillNumber %= 10000;
SaveForm(iniEntity);
return yearMonth + FormatCom.LeftzeroStr(iniEntity.BillNumber.ToString(), 4);
}
#endregion BLL
#region Save
/// <summary>
/// 保存表单(新增、修改)
/// </summary>
/// <param name="keyValue">主键值</param>
/// <param name="entity">实体对象</param>
/// <returns></returns>
public int SaveForm(IniEntity entity)
{
var oldEntity = (entity.Id > 0) ? SelectEntityByWhere($"Id='{entity.Id}'") : null;
if (oldEntity == null)
{
entity.CreateTime = DateTime.Now;
entity.UpdateTime = entity.CreateTime;
return db.Insert(entity);
}
else
{
entity.UpdateTime = DateTime.Now;
oldEntity = EntityNewToOld(oldEntity, entity);
return db.Update(oldEntity);
}
}
#endregion Save
}
}