Example #1
0
        /////////////////


        public int CommitChanges(DataSetGHSF_CHARGEDETAIL entity, DataRowState drs)
        {
            int iRtn = 0;

            if (!entity.HasChanges(drs))
            {
                return(iRtn);
            }
            CheckData(entity);

            bool isExistTrans = db.IsInTransaction();

            if (!isExistTrans)
            {
                db.BeginTrans();
            }

            try
            {
                if (drs == DataRowState.Deleted)
                {
                    iRtn += DeleteEntity(entity.GetChangesEntity(drs));
                }
                else if (drs == DataRowState.Modified)
                {
                    iRtn += UpdateEntity(entity.GetChangesEntity(drs));
                }
                else if (drs == DataRowState.Added)
                {
                    iRtn += InsertEntity(entity.GetChangesEntity(drs));
                }
                if (!isExistTrans)
                {
                    db.CommitTrans();
                }
                return(iRtn);
            }
            catch (Exception e)
            {
                if (isExistTrans)
                {
                    db.RollbackTrans();
                }
                throw e;
            }
        }
Example #2
0
        ///
        /// 检查给定的实体是否有更改,如果有把更改的行提交到数据库。
        ///
        /// 要检验的实体



        public int CommitChanges(DataSetGHSF_CHARGEDETAIL entity)
        {
            int iRtn = 0;

            if (!entity.HasChanges())
            {
                return(iRtn);
            }
            CheckData(entity);

            bool isExistTrans = db.IsInTransaction();

            if (!isExistTrans)
            {
                db.BeginTrans();
            }

            try
            {
                //CommitChanges(entity, DataRowState.Deleted);
                //CommitChanges(entity, DataRowState.Modified);
                //CommitChanges(entity, DataRowState.Added);

                ////////// 2006-05-21
                iRtn += CommitChanges(entity, DataRowState.Deleted, null, null);
                iRtn += CommitChanges(entity, DataRowState.Modified, alUpdateColumn, alUpdateControl);
                iRtn += CommitChanges(entity, DataRowState.Added, null, null);
                /////////////

                if (!isExistTrans)
                {
                    db.CommitTrans();
                }
                return(iRtn);
            }
            catch (Exception e)
            {
                if (isExistTrans)
                {
                    db.RollbackTrans();
                }
                throw e;
            }
        }