This commit is contained in:
tongfei
2023-10-30 16:07:31 +08:00
2 changed files with 27 additions and 5 deletions

View File

@@ -52,5 +52,27 @@ namespace WMS.Web.Domain.Entitys
this.CreatorId = creatorId;
this.Date = DateTime.Now;
}
/// <summary>
/// 生成单据号
/// </summary>
public void GenerateNo()
{
//用户手动输入了 就不自动生成了
if (!string.IsNullOrEmpty(this.BillNo)) return;
if (this.Id.ToString().Length >= 8)
{
this.BillNo = "PD" + this.Id.ToString();
return;
}
string idStr = this.Id.ToString();
while (true)
{
idStr = "0" + idStr;
if (idStr.Length >= 8) break;
}
this.BillNo = "PD" + idStr;
}
}
}

View File

@@ -52,11 +52,11 @@ namespace WMS.Web.Repositories
await _context.TakeStock.AddAsync(entity);
await _context.SaveChangesAsync();
//if (string.IsNullOrEmpty(entity.OutSourcFeedNo))
//{
// entity.GenerateNo();
// await _context.SaveChangesAsync();
//}
if (string.IsNullOrEmpty(entity.BillNo))
{
entity.GenerateNo();
await _context.SaveChangesAsync();
}
if (_transaction != null)
_transaction.Commit();