/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(int?keyValue, dm_dauomai_plan_manageEntity entity) { try { if (keyValue > 0) { entity.Modify(keyValue); this.BaseRepository("dm_data").Update(entity); } else { entity.Create(); this.BaseRepository("dm_data").Insert(entity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
public void StartPlan(int plan_id) { IRepository db = null; try { dm_dauomai_plan_manageEntity dm_Dauomai_Plan_ManageEntity = GetEntity(plan_id); if (dm_Dauomai_Plan_ManageEntity.IsEmpty()) { throw new Exception("推广计划不存在!"); } dm_Dauomai_Plan_ManageEntity.use_status = 1; dm_Dauomai_Plan_ManageEntity.Modify(dm_Dauomai_Plan_ManageEntity.id); dm_decoration_fun_manageEntity dm_Decoration_Fun_ManageEntity = this.BaseRepository("dm_data").FindEntity <dm_decoration_fun_manageEntity>(t => t.fun_param == plan_id.ToString()); db = this.BaseRepository("dm_data").BeginTrans(); ///功能中不存在该计划 if (dm_Decoration_Fun_ManageEntity.IsEmpty()) { dm_Decoration_Fun_ManageEntity = new dm_decoration_fun_manageEntity(); dm_Decoration_Fun_ManageEntity.fun_name = dm_Dauomai_Plan_ManageEntity.ads_name; dm_Decoration_Fun_ManageEntity.fun_param = dm_Dauomai_Plan_ManageEntity.id.ToString(); dm_Decoration_Fun_ManageEntity.fun_remark = dm_Dauomai_Plan_ManageEntity.commission; dm_Decoration_Fun_ManageEntity.fun_type = 2; dm_Decoration_Fun_ManageEntity.Create(); db.Insert(dm_Decoration_Fun_ManageEntity); } else { dm_Decoration_Fun_ManageEntity.fun_name = dm_Dauomai_Plan_ManageEntity.ads_name; dm_Decoration_Fun_ManageEntity.fun_param = dm_Dauomai_Plan_ManageEntity.id.ToString(); dm_Decoration_Fun_ManageEntity.fun_remark = dm_Dauomai_Plan_ManageEntity.commission; dm_Decoration_Fun_ManageEntity.Modify(dm_Decoration_Fun_ManageEntity.id); db.Update(dm_Decoration_Fun_ManageEntity); } db.Update(dm_Dauomai_Plan_ManageEntity); db.Commit(); } catch (Exception ex) { if (db != null) { db.Rollback(); } if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
public void StopPlan(int plan_id) { IRepository db = null; try { dm_dauomai_plan_manageEntity dm_Dauomai_Plan_ManageEntity = GetEntity(plan_id); if (dm_Dauomai_Plan_ManageEntity.IsEmpty()) { throw new Exception("推广计划不存在!"); } dm_Dauomai_Plan_ManageEntity.use_status = 0; dm_Dauomai_Plan_ManageEntity.Modify(dm_Dauomai_Plan_ManageEntity.id); db = this.BaseRepository("dm_data").BeginTrans(); db.Delete <dm_decoration_fun_manageEntity>(t => t.fun_param == plan_id.ToString()); db.Delete <dm_decoration_template_module_itemEntity>(t => t.module_fun_id == plan_id); db.Update(dm_Dauomai_Plan_ManageEntity); db.Commit(); } catch (Exception ex) { if (db != null) { db.Rollback(); } if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }