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