Exemplo n.º 1
0
        public void MakeRelationsBtwnDocs(Dictionary <string, IDBObject> children, IDBObject parent)
        {
            IDBRelationCollection coll = Session.GetRelationCollection(1014);

            IDBObject objectParentChecked = parent.CheckOut(true); //  asm
            IDBObject newChildChecked;

            foreach (var child in children)
            {
                newChildChecked = child.Value.CheckOut(true);                                               //  prt
                IDBRelation relation = coll.Create(objectParentChecked.ObjectID, newChildChecked.ObjectID); // создаем связь между изделием и документом
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Создает изделие
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="parentID">ID документа на который создаеться изделие</param>//prt
        private void CreateProduct(ref IDBObject DocObj, MyStruct _object)
        {
            IDBObjectCollection coll   = Session.GetObjectCollection((int)_object.IPsProductType);
            IDBObject           newObj = coll.Create((int)_object.IPsProductType);

            //берем аттрибуты объекта
            IDBAttribute atrDesignation = newObj.GetAttributeByGuid(new Guid(SystemGUIDs.attributeDesignation)); //обозначение
            IDBAttribute atrName        = newObj.GetAttributeByGuid(new Guid(SystemGUIDs.attributeName));        //наименование

            atrDesignation.Value = _object.Designition;
            atrName.Value        = _object.Name;
            newObj.CommitCreation(true);

            IDBObject newObjChecked = newObj.CheckOut();

            IDBRelationCollection colRel   = Session.GetRelationCollection(1004);
            IDBRelation           relation = colRel.Create(newObjChecked.ObjectID, DocObj.ID); // создаем связь между изделием и докумиентом,

            if (relation == null)
            {
                MessageBox.Show("Failed create the relation of type " + colRel.RelationTypeID.ToString());
            }
        }