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

                            //平台自动生成代码
                            foreach (EntityObject_MCE_B_ASSETS_INSTOCK obj in objs)
                            {
                                amount += HelperObject_MCE_B_ASSETS_INSTOCK.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_INSTOCK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_INSTOCK>(ServiceUri))
                {
                    return(smgr.Service.BatchSave(objs));
                }
            }
        }
Esempio n. 5
0
        public BizLogicMsg Save_Ext(JsonMCE_INSTOCK jsonMCE_INSTOCK)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_B_ASSETS_INSTOCK entity = new EntityObject_MCE_B_ASSETS_INSTOCK();


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

                                entity = HelperObject_MCE_B_ASSETS_INSTOCK.Get(entity);

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


                            entity.CODE         = jsonMCE_INSTOCK.CODE;
                            entity.WAREHOUSE_ID = jsonMCE_INSTOCK.WAREHOUSE_ID;
                            entity.PROVIDER_ID  = jsonMCE_INSTOCK.PROVIDER_ID;

                            if (!string.IsNullOrEmpty(jsonMCE_INSTOCK.CREATE_DATE))
                            {
                                entity.CREATE_DATE = DateTime.Parse(jsonMCE_INSTOCK.CREATE_DATE);
                            }
                            entity.USER_ID = jsonMCE_INSTOCK.USER_ID;

                            entity.COMMENTS     = jsonMCE_INSTOCK.COMMENTS;
                            entity.INVOICE_CODE = jsonMCE_INSTOCK.INVOICE_CODE;
                            entity.STATE        = 1;

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


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

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

                                        entity_D = HelperObject_MCE_B_ASSETS_INSTOCK_D.Get(entity_D);

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

                            if (jsonMCE_INSTOCK.children != null && jsonMCE_INSTOCK.children.Count > 0)
                            {
                                decimal decTotMoney = 0;
                                foreach (JsonMCE_INSTOCK_D item in jsonMCE_INSTOCK.children)
                                {
                                    EntityObject_MCE_B_ASSETS_INSTOCK_D entity_D = new EntityObject_MCE_B_ASSETS_INSTOCK_D();

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

                                        entity_D = HelperObject_MCE_B_ASSETS_INSTOCK_D.Get(entity_D);

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

                                    entity_D.BASE_ID       = entity.ID;
                                    entity_D.ASSET_ID      = item.ASSET_ID;
                                    entity_D.USING_DEPT_ID = item.USING_DEPT_ID;
                                    entity_D.ASSET_TYPE_ID = item.ASSET_TYPE_ID;
                                    entity_D.ASSETS_NAME   = item.ASSETS_NAME;
                                    entity_D.SPEC          = item.SPEC;


                                    if (string.IsNullOrEmpty(item.ID))
                                    {
                                        if (!string.IsNullOrEmpty(item.PRD_ID))
                                        {
                                            string strPrdID          = "";
                                            CauseObject_MDM_D_DEPT p = new CauseObject_MDM_D_DEPT();
                                            p.REF_ID = item.PRD_ID;

                                            DisplayObject_MDM_D_DEPT[] listPrd = HelperObject_MDM_D_DEPT.Query(p);
                                            if (listPrd != null && listPrd.Length > 0)
                                            {
                                                strPrdID = listPrd[0].ID;
                                            }

                                            entity_D.PRD_ID = strPrdID;
                                        }
                                        entity_D.REF_PRD_ID = item.PRD_ID;
                                    }

                                    entity_D.PRICE   = item.PRICE;
                                    entity_D.AMOUNT  = item.AMOUNT;
                                    entity_D.UNIT_ID = item.UNIT_ID;
                                    entity_D.COUNTRY = item.COUNTRY;

                                    if (!string.IsNullOrEmpty(item.DEPR_YEAR_AMOUNT))
                                    {
                                        entity_D.DEPR_YEAR_AMOUNT = decimal.Parse(item.DEPR_YEAR_AMOUNT);
                                    }

                                    entity_D.DEPR_TYPE_ID = item.DEPR_TYPE_ID;

                                    entity_D.MONEY = item.AMOUNT * item.PRICE;
                                    decTotMoney    = decTotMoney + entity_D.MONEY;

                                    entity_D.REF_TAB_ID   = item.REF_TAB_ID;
                                    entity_D.REF_TAB_NAME = item.REF_TAB_NAME;

                                    if (string.IsNullOrEmpty(item.ID))
                                    {
                                        HelperObject_MCE_B_ASSETS_INSTOCK_D.Save(entity_D, transaction);
                                    }
                                    else
                                    {
                                        HelperObject_MCE_B_ASSETS_INSTOCK_D.Update(entity_D, transaction);
                                    }
                                }
                                entity.TOTAL_MONEY = decTotMoney;

                                HelperObject_MCE_B_ASSETS_INSTOCK.Update(entity, 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_INSTOCK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_INSTOCK>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext(jsonMCE_INSTOCK));
                }
            }
        }