예제 #1
0
        public int Insert(SqlTransaction trans)
        {
            if (!CanInsert(this.UserName))
            {
                throw new AccessException(this.UserName, "Insert");
            }

            AccessObject aObject = new AccessObject(ConstantCode.CONNECTION_STRING);

            aObject.Id            = Guid.NewGuid();
            aObject.Name          = this._name;
            aObject.ObjectTypeId  = ObjectTypeID;
            aObject.ObjectStateId = StateIDAll;
            this._objectID        = aObject.Insert(trans);

            string spName = "usp_CityObjectTypes_Insert";
            CityObjectTypesParamsHelper helper = new CityObjectTypesParamsHelper(this);

            helper.InitParamsForSP(spName);
            SqlParameter[] parameters = helper.ParamList.Params;
            SPHelper.ExecuteNonQuery(trans, spName, parameters);
            helper.SetPropValues();

            return(this._id);
        }
예제 #2
0
        public void Update(SqlTransaction trans)
        {
            if (!CanUpdate(this.UserName))
            {
                throw new AccessException(this.UserName, "Update");
            }

            AccessObject aObject = new AccessObject(trans, this._objectID);

            aObject.Name = this._name;
            aObject.Update(trans);

            string spName = "usp_CityObjectTypes_Update";
            CityObjectTypesParamsHelper helper = new CityObjectTypesParamsHelper(this);

            helper.InitParamsForSP(spName);
            SqlParameter[] parameters = helper.ParamList.Params;
            SPHelper.ExecuteNonQuery(trans, spName, parameters);
            helper.SetPropValues();
        }
예제 #3
0
        private void Init(SqlTransaction trans, int id)
        {
            if (!CanView(this.UserName))
            {
                throw new AccessException(this.UserName, "Init");
            }
            this.ID = id;
            string spName = "usp_CityObjectTypes_Get";
            CityObjectTypesParamsHelper helper = new CityObjectTypesParamsHelper(this);

            helper.InitParamsForSP(spName);
            SqlParameter[] parameters = helper.ParamList.Params;
            if (trans == null)
            {
                SPHelper.ExecuteNonQuery(spName, parameters);
            }
            else
            {
                SPHelper.ExecuteNonQuery(trans, spName, parameters);
            }
            helper.SetPropValues();
            this._accessObject = new AccessObject(ConstantCode.CONNECTION_STRING, this._objectID);
        }