/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, DZ_Money_RoomEntity entity, List <DZ_Money_ItemEntity> entryList) { try { service.SaveForm(keyValue, entity, entryList); } catch (Exception) { throw; } }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, DZ_Money_RoomEntity entity, List <DZ_Money_ItemEntity> entryList) { IRepository db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { //主表 entity.Modify(keyValue); db.Update(entity); //明细 db.Delete <DZ_Money_ItemEntity>(t => t.RoomId.Equals(keyValue)); foreach (DZ_Money_ItemEntity item in entryList) { item.Create(); item.RoomId = entity.RoomId; db.Insert(item); } } else { //主表 entity.Create(); db.Insert(entity); //明细 foreach (DZ_Money_ItemEntity item in entryList) { item.Create(); item.RoomId = entity.RoomId; db.Insert(item); } } db.Commit(); } catch (Exception) { db.Rollback(); throw; } }