/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_GoodKindEntity entity) { try { goodKindService.SaveEntity(keyValue, entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 保存实体数据(新增、修改) /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> public void SaveEntity(string keyValue, Mes_GoodKindEntity entity) { var db = this.BaseRepository().BeginTrans(); try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { var dp = new DynamicParameters(new { }); dp.Add("@codeType", "商品二级编码"); dp.Add("@code", "", DbType.String, ParameterDirection.Output); dp.Add("@goodsSecNo", ""); dp.Add("@stockType", ""); db.ExecuteByProc("sp_GetCode", dp); var G_Code = dp.Get <string>("@code"); //存储过程返回编号 entity.G_Code = G_Code; entity.Create(); db.Insert(entity); } db.Commit(); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }