110,499
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 删除单件
/// </summary>
/// <param name="itemId"></param>
public void DeleteItem(long itemId)
{
using (var context = new AppDbContext())
using (var trans = new BlTransaction(context, IsolationLevel.ReadCommitted))
{
//使用中的单件不允许删除
var detail = context.ord_in_changedetail.FirstOrDefault(c => c.ItemId == itemId);
if (detail != null) throw new ShowErrorException("此单件已有出入库记录,不能删除!");
//删除
context.ord_ba_item.Where(c => c.ItemId == itemId).Delete();
context.ord_ba_itemcustom.Where(c => c.ItemId == itemId).Delete();
trans.Commit();
}
}