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