public int SaveByTrans(EntityObject_MCE_B_ASSETS_DEPR obj, IDbTransaction transaction) { if (LocalMode) { SystemLogic.Proxy.AuditAdd(obj); int amount = HelperObject_MCE_B_ASSETS_DEPR.Save(obj, transaction); //平台自动生成代码 return(amount); } else { throw new InvalidConstraintException(); } }
public BizLogicMsg CommitUpdate(EntityObject_MCE_B_ASSETS_DEPR[] saveEntities, EntityObject_MCE_B_ASSETS_DEPR[] updateEntities, EntityObject_MCE_B_ASSETS_DEPR[] deleteEntities) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { //平台自动生成代码 foreach (EntityObject_MCE_B_ASSETS_DEPR obj in saveEntities) { SystemLogic.Proxy.AuditAdd(obj); HelperObject_MCE_B_ASSETS_DEPR.Save(obj, transaction); } foreach (EntityObject_MCE_B_ASSETS_DEPR obj in updateEntities) { SystemLogic.Proxy.AuditEdit(obj); HelperObject_MCE_B_ASSETS_DEPR.Update(obj, transaction); } foreach (EntityObject_MCE_B_ASSETS_DEPR obj in deleteEntities) { HelperObject_MCE_B_ASSETS_DEPR.Delete(obj, transaction); } transaction.Commit(); } catch (Exception expt) { transaction.Rollback(); msg = new BizLogicMsg(false, expt.Message); Error(expt); } finally { IDALProvider.IDAL.PushConnection(connection); } } } return(msg); } else { using (ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR>(ServiceUri)) { return(smgr.Service.CommitUpdate(saveEntities, updateEntities, deleteEntities)); } } }
public BizLogicMsg CommitSave(EntityObject_MCE_B_ASSETS_DEPR saveBaseEntity, EntityObject_[] saveDetailEntities) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { SystemLogic.Proxy.AuditAdd(saveBaseEntity); HelperObject_MCE_B_ASSETS_DEPR.Save(saveBaseEntity, transaction); //平台自动生成代码 foreach (EntityObject_ obj in saveDetailEntities) { obj. = saveBaseEntity.ID; SystemLogic.Proxy.AuditAdd(obj); HelperObject_.Save(obj, transaction); } PostSave(saveBaseEntity, transaction); transaction.Commit(); } catch (Exception expt) { transaction.Rollback(); msg = new BizLogicMsg(false, expt.Message); Error(expt); } finally { IDALProvider.IDAL.PushConnection(connection); } } } return(msg); } else { using (ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR>(ServiceUri)) { return(smgr.Service.CommitSave(saveBaseEntity, saveDetailEntities)); } } }
public BizLogicMsg BatchSave(EntityObject_MCE_B_ASSETS_DEPR[] objs) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { foreach (EntityObject_MCE_B_ASSETS_DEPR obj in objs) { SystemLogic.Proxy.AuditAdd(obj); } int amount = 0; //平台自动生成代码 foreach (EntityObject_MCE_B_ASSETS_DEPR obj in objs) { amount += HelperObject_MCE_B_ASSETS_DEPR.Save(obj, transaction); } transaction.Commit(); } catch (Exception expt) { transaction.Rollback(); msg = new BizLogicMsg(false, expt.Message); Error(expt); } finally { IDALProvider.IDAL.PushConnection(connection); } } } return(msg); } else { using (ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR>(ServiceUri)) { return(smgr.Service.BatchSave(objs)); } } }
public BizLogicMsg Save_Ext(JsonMCE_Depr jsonEntity) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { EntityObject_MCE_B_ASSETS_DEPR entity = new EntityObject_MCE_B_ASSETS_DEPR(); if (!string.IsNullOrEmpty(jsonEntity.ID)) { entity.ID = jsonEntity.ID; entity = HelperObject_MCE_B_ASSETS_DEPR.Get(entity); if (entity == null) { throw new Exception("获取数据出错."); } } entity.CODE = jsonEntity.CODE; entity.DEPT_ID = jsonEntity.DEPT_ID; entity.USER_ID = jsonEntity.USER_ID; if (!string.IsNullOrEmpty(jsonEntity.CREATE_DATE)) { entity.CREATE_DATE = DateTime.Parse(jsonEntity.CREATE_DATE); } entity.FINANCE_CYCLE = jsonEntity.FINANCE_CYCLE; entity.COMMENTS = jsonEntity.COMMENTS; entity.STATE = 1; if (string.IsNullOrEmpty(jsonEntity.ID)) { entity.CREATE_TIME = DateTime.Now; entity.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID; int amount = HelperObject_MCE_B_ASSETS_DEPR.Save(entity, transaction); } else { entity.MODIFY_TIME = DateTime.Now; entity.MODIFY_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID; int amount = HelperObject_MCE_B_ASSETS_DEPR.Update(entity, transaction); } if (!string.IsNullOrEmpty(jsonEntity.ID)) { CauseObject_MCE_B_ASSETS_DEPR_D pDeprDetail = new CauseObject_MCE_B_ASSETS_DEPR_D(); pDeprDetail.BASE_ID = jsonEntity.ID; HelperObject_MCE_B_ASSETS_DEPR_D.Delete(pDeprDetail, transaction); } if (jsonEntity.children != null && jsonEntity.children.Count > 0) { foreach (JsonMceDepr_D item in jsonEntity.children) { EntityObject_MCE_B_ASSETS_DEPR_D entity_D = new EntityObject_MCE_B_ASSETS_DEPR_D(); if (!string.IsNullOrEmpty(item.ID)) { entity_D.ID = item.ID; entity_D = HelperObject_MCE_B_ASSETS_DEPR_D.Get(entity_D); if (entity_D == null) { throw new Exception("获取数据出错."); } } entity_D.BASE_ID = entity.ID; entity_D.ASSETS_ID = item.ASSETS_ID; entity_D.ASSETS_CODE = item.ASSETS_CODE; entity_D.CURRENCY_ID = item.CURRENCY_ID; entity_D.ORIGINAL_VALUE = item.ORIGINAL_VALUE; entity_D.NET_VALUE = item.NET_VALUE; entity_D.MONEY = item.MONEY; entity_D.NEW_NET_VALUE = item.NEW_NET_VALUE; HelperObject_MCE_B_ASSETS_DEPR_D.Save(entity_D, transaction); } } msg.Message = entity.ID; transaction.Commit(); } catch (Exception expt) { transaction.Rollback(); msg = new BizLogicMsg(false, expt.Message); Error(expt); } finally { IDALProvider.IDAL.PushConnection(connection); } } } return(msg); } else { using (ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_DEPR>(ServiceUri)) { return(smgr.Service.Save_Ext(jsonEntity)); } } }