コード例 #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_CityObjects_Insert";
            CityObjectsParamsHelper helper = new CityObjectsParamsHelper(this);

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

            return(this._id);
        }
コード例 #2
0
ファイル: MenuTemplate.cs プロジェクト: Dodgik/DocSys
        public int Insert(SqlTransaction trans)
        {
            if (!CanInsert(UserName, ObjectID))
            {
                throw new AccessException(UserName, "Insert");
            }

            AccessObject accessObject = new AccessObject(trans.Connection.ConnectionString);

            accessObject.Id            = Guid.NewGuid();
            accessObject.Name          = Name;
            accessObject.ObjectTypeId  = ObjectTypeID;
            accessObject.ObjectStateId = StateIDAll;
            ObjectID = accessObject.Insert(trans);

            SqlParameter[] prms = new SqlParameter[4];
            prms[0]           = new SqlParameter("@MenuTemplateID", SqlDbType.Int);
            prms[0].Direction = ParameterDirection.Output;

            prms[1]       = new SqlParameter("@Name", SqlDbType.NVarChar, 50);
            prms[1].Value = Name;

            prms[2]       = new SqlParameter("@SystemName", SqlDbType.NVarChar, 50);
            prms[2].Value = SystemName;

            prms[3]       = new SqlParameter("@ObjectID", SqlDbType.UniqueIdentifier);
            prms[3].Value = ObjectID;

            if (trans == null)
            {
                SPHelper.ExecuteNonQuery(SpNames.Insert, prms);
            }
            else
            {
                SPHelper.ExecuteNonQuery(trans, SpNames.Insert, prms);
            }

            ID = (int)prms[0].Value;

            return(ID);
        }
コード例 #3
0
ファイル: Department.cs プロジェクト: Dodgik/DocSys
        public int Insert(SqlTransaction trans)
        {
            AccessObject accessObject = new AccessObject(trans.Connection.ConnectionString);

            accessObject.Id            = Guid.NewGuid();
            accessObject.Name          = Name;
            accessObject.ObjectTypeId  = ObjectTypeID;
            accessObject.ObjectStateId = StateIDAll;
            ObjectID = accessObject.Insert(trans);


            SqlParameter[] prms = new SqlParameter[5];
            prms[0]           = new SqlParameter("@DepartmentID", SqlDbType.Int);
            prms[0].Direction = ParameterDirection.Output;

            prms[1]       = new SqlParameter("@Name", SqlDbType.NVarChar, 100);
            prms[1].Value = Name;

            prms[2]       = new SqlParameter("@ShortName", SqlDbType.NVarChar, 50);
            prms[2].Value = ShortName;

            prms[3]       = new SqlParameter("@ObjectID", SqlDbType.UniqueIdentifier);
            prms[3].Value = ObjectID;

            prms[4]       = new SqlParameter("@ParrentDepartmentID", SqlDbType.Int);
            prms[4].Value = ParrentDepartmentID;

            if (trans == null)
            {
                SPHelper.ExecuteNonQuery(SpNames.Insert, prms);
            }
            else
            {
                SPHelper.ExecuteNonQuery(trans, SpNames.Insert, prms);
            }

            ID = (int)prms[0].Value;

            return(ID);
        }
コード例 #4
0
        public int Insert(SqlTransaction trans)
        {
            /*if (!CanInsert(UserName, DepartmentID))
             * {
             *  throw new AccessException(UserName, "Insert");
             * }
             */
            AccessObject accessObject = new AccessObject(trans.Connection.ConnectionString);

            accessObject.Id            = Guid.NewGuid();
            accessObject.Name          = Number;
            accessObject.ObjectTypeId  = ObjectTypeID;
            accessObject.ObjectStateId = StateIDAll;
            ObjectID = accessObject.Insert(trans);

            SqlParameter[] prms = new SqlParameter[15];
            prms[0]           = new SqlParameter("@DocumentID", SqlDbType.Int);
            prms[0].Direction = ParameterDirection.Output;

            prms[1]       = new SqlParameter("@DocumentCodeID", SqlDbType.Int);
            prms[1].Value = CodeID;

            prms[2]       = new SqlParameter("@CreationDate", SqlDbType.DateTime);
            prms[2].Value = CreationDate;

            prms[3]       = new SqlParameter("@OriginatorID", SqlDbType.UniqueIdentifier);
            prms[3].Value = OriginatorID;

            prms[4]       = new SqlParameter("@RequestDate", SqlDbType.DateTime);
            prms[4].Value = RequestDate;

            prms[5]       = new SqlParameter("@RequestorID", SqlDbType.UniqueIdentifier);
            prms[5].Value = RequestorID;

            prms[6]       = new SqlParameter("@OwnerID", SqlDbType.UniqueIdentifier);
            prms[6].Value = OwnerID;

            prms[7]       = new SqlParameter("@ObjectID", SqlDbType.UniqueIdentifier);
            prms[7].Value = ObjectID;

            prms[8]       = new SqlParameter("@Number", SqlDbType.NVarChar, 50);
            prms[8].Value = Number;

            prms[9]       = new SqlParameter("@Notes", SqlDbType.NVarChar, -1);
            prms[9].Value = Notes;

            prms[10]       = new SqlParameter("@DocStatusID", SqlDbType.Int);
            prms[10].Value = DocStatusID;

            prms[11]       = new SqlParameter("@DepartmentID", SqlDbType.Int);
            prms[11].Value = DepartmentID;

            prms[12]       = new SqlParameter("@TemplateId", SqlDbType.Int);
            prms[12].Value = TemplateId;

            prms[13]            = new SqlParameter("@ParentDocumentID", SqlDbType.Int);
            prms[13].IsNullable = true;
            if (ParentDocumentID > 0)
            {
                prms[13].Value = ParentDocumentID;
            }
            else
            {
                prms[13].Value = DBNull.Value;
            }

            prms[14]       = new SqlParameter("@DocStateID", SqlDbType.Int);
            prms[14].Value = DocStateID;

            if (trans == null)
            {
                SPHelper.ExecuteNonQuery(SpNames.Insert, prms);
            }
            else
            {
                SPHelper.ExecuteNonQuery(trans, SpNames.Insert, prms);
            }

            ID = (int)prms[0].Value;

            return(ID);
        }