Example #1
0
 public BizLogicMsg CommitUpdate(EntityObject_MCE_B_ASSETS_BACK[] saveEntities, EntityObject_MCE_B_ASSETS_BACK[] updateEntities, EntityObject_MCE_B_ASSETS_BACK[] deleteEntities)
 {
     if (LocalMode)
     {
         BizLogicMsg msg = new BizLogicMsg();
         using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
         {
             using (IDbTransaction transaction = connection.BeginTransaction())
             {
                 try
                 {
                     //平台自动生成代码
                     foreach (EntityObject_MCE_B_ASSETS_BACK obj in saveEntities)
                     {
                         SystemLogic.Proxy.AuditAdd(obj);
                         HelperObject_MCE_B_ASSETS_BACK.Save(obj, transaction);
                     }
                     foreach (EntityObject_MCE_B_ASSETS_BACK obj in updateEntities)
                     {
                         SystemLogic.Proxy.AuditEdit(obj);
                         HelperObject_MCE_B_ASSETS_BACK.Update(obj, transaction);
                     }
                     foreach (EntityObject_MCE_B_ASSETS_BACK obj in deleteEntities)
                     {
                         HelperObject_MCE_B_ASSETS_BACK.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_BACK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_BACK>(ServiceUri))
         {
             return(smgr.Service.CommitUpdate(saveEntities, updateEntities, deleteEntities));
         }
     }
 }
Example #2
0
 public int SaveByTrans(EntityObject_MCE_B_ASSETS_BACK obj, IDbTransaction transaction)
 {
     if (LocalMode)
     {
         SystemLogic.Proxy.AuditAdd(obj);
         int amount = HelperObject_MCE_B_ASSETS_BACK.Save(obj, transaction);
         //平台自动生成代码
         return(amount);
     }
     else
     {
         throw new InvalidConstraintException();
     }
 }
Example #3
0
        public BizLogicMsg CommitSave(EntityObject_MCE_B_ASSETS_BACK 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_BACK.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_BACK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_BACK>(ServiceUri))
                {
                    return(smgr.Service.CommitSave(saveBaseEntity, saveDetailEntities));
                }
            }
        }
Example #4
0
        public BizLogicMsg BatchSave(EntityObject_MCE_B_ASSETS_BACK[] objs)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            foreach (EntityObject_MCE_B_ASSETS_BACK obj in objs)
                            {
                                SystemLogic.Proxy.AuditAdd(obj);
                            }
                            int amount = 0;

                            //平台自动生成代码
                            foreach (EntityObject_MCE_B_ASSETS_BACK obj in objs)
                            {
                                amount += HelperObject_MCE_B_ASSETS_BACK.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_BACK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_BACK>(ServiceUri))
                {
                    return(smgr.Service.BatchSave(objs));
                }
            }
        }
Example #5
0
        public BizLogicMsg Save_Ext(JsonMCE_BACK jsonMCE_BACK)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_B_ASSETS_BACK entity = new EntityObject_MCE_B_ASSETS_BACK();


                            if (!string.IsNullOrEmpty(jsonMCE_BACK.ID))
                            {
                                entity.ID = jsonMCE_BACK.ID;

                                entity = HelperObject_MCE_B_ASSETS_BACK.Get(entity);

                                if (entity == null)
                                {
                                    throw new Exception("获取数据出错.");
                                }
                            }


                            entity.CODE = jsonMCE_BACK.CODE;

                            if (!string.IsNullOrEmpty(jsonMCE_BACK.CREATE_DATE))
                            {
                                entity.CREATE_DATE = DateTime.Parse(jsonMCE_BACK.CREATE_DATE);
                            }
                            entity.RETURN_DEPT_ID = jsonMCE_BACK.RETURN_DEPT_ID;
                            entity.RETURN_USER_ID = jsonMCE_BACK.RETURN_USER_ID;
                            entity.DEPT_ID        = jsonMCE_BACK.DEPT_ID;
                            entity.USER_ID        = jsonMCE_BACK.USER_ID;
                            entity.STOCK_ID       = jsonMCE_BACK.STOCK_ID;

                            entity.COMMENTS = jsonMCE_BACK.COMMENTS;

                            entity.STATE = 1;

                            if (string.IsNullOrEmpty(jsonMCE_BACK.ID))
                            {
                                entity.CREATE_TIME    = DateTime.Now;
                                entity.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                int amount = HelperObject_MCE_B_ASSETS_BACK.Save(entity, transaction);
                            }
                            else
                            {
                                int amount = HelperObject_MCE_B_ASSETS_BACK.Update(entity, transaction);
                            }


                            if (jsonMCE_BACK.DELETEIDS != null && jsonMCE_BACK.DELETEIDS.Count > 0)
                            {
                                foreach (string strID in jsonMCE_BACK.DELETEIDS)
                                {
                                    EntityObject_MCE_B_ASSETS_BACK_D entity_D = new EntityObject_MCE_B_ASSETS_BACK_D();

                                    if (!string.IsNullOrEmpty(strID))
                                    {
                                        entity_D.ID = strID;

                                        entity_D = HelperObject_MCE_B_ASSETS_BACK_D.Get(entity_D);

                                        if (entity_D == null)
                                        {
                                            throw new Exception("获取数据出错.");
                                        }
                                        else
                                        {
                                            HelperObject_MCE_B_ASSETS_BACK_D.Delete(entity_D, transaction);
                                        }
                                    }
                                }
                            }

                            if (jsonMCE_BACK.children != null && jsonMCE_BACK.children.Count > 0)
                            {
                                foreach (JsonMCE_BACK_D item in jsonMCE_BACK.children)
                                {
                                    EntityObject_MCE_B_ASSETS_BACK_D entity_D = new EntityObject_MCE_B_ASSETS_BACK_D();

                                    if (!string.IsNullOrEmpty(item.ID))
                                    {
                                        entity_D.ID = item.ID;

                                        entity_D = HelperObject_MCE_B_ASSETS_BACK_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_NAME  = item.ASSETS_NAME;
                                    entity_D.ASSETS_CODE  = item.ASSETS_CODE;
                                    entity_D.REF_TAB_ID   = item.REF_TAB_ID;
                                    entity_D.REF_TAB_NAME = item.REF_TAB_NAME;
                                    entity_D.SPEC         = item.SPEC;
                                    entity_D.COMMENTS     = item.COMMENTS;

                                    if (string.IsNullOrEmpty(item.ID))
                                    {
                                        HelperObject_MCE_B_ASSETS_BACK_D.Save(entity_D, transaction);
                                    }
                                    else
                                    {
                                        HelperObject_MCE_B_ASSETS_BACK_D.Update(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_BACK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_BACK>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext(jsonMCE_BACK));
                }
            }
        }