예제 #1
0
        public static InOrderPos NewACObject(MyCompanyDB dbApp, IACObject parentACObject)
        {
            InOrderPos entity = new InOrderPos();

            entity.InOrderPosID = Guid.NewGuid();
            entity.DefaultValuesACObject();
            InOrder inOrder = parentACObject as InOrder;

            if (inOrder != null)
            {
                if (inOrder.EntityState != System.Data.EntityState.Added &&
                    inOrder.InOrderPos_InOrder != null &&
                    inOrder.InOrderPos_InOrder.Any())
                {
                    entity.Sequence = inOrder.InOrderPos_InOrder.Select(c => c.Sequence).Max() + 1;
                }
                else
                {
                    entity.Sequence = 1;
                }
                entity.InOrder = inOrder;
                inOrder.InOrderPos_InOrder.Add(entity);
            }
            entity.SetInsertAndUpdateInfo(Database.Initials, dbApp);
            return(entity);
        }
예제 #2
0
        /// <summary>
        /// Handling von Sequencenummer ist nach dem Löschen aufzurufen
        /// </summary>
        public static void RenumberSequence(InOrder inOrder, int sequence)
        {
            var elements      = from c in inOrder.InOrderPos_InOrder where c.Sequence > sequence && c.EntityState != System.Data.EntityState.Deleted orderby c.Sequence select c;
            int sequenceCount = sequence;

            foreach (var element in elements)
            {
                element.Sequence = sequence;
                sequence++;
            }
        }
예제 #3
0
        public static InOrder NewACObject(MyCompanyDB dbApp, IACObject parentACObject, string secondaryKey)
        {
            InOrder entity = new InOrder();

            entity.InOrderID = Guid.NewGuid();
            entity.DefaultValuesACObject();
            entity.InOrderDate = DateTime.Now;
            entity.InOrderNo   = secondaryKey;
            entity.SetInsertAndUpdateInfo(Database.Initials, dbApp);
            return(entity);
        }
예제 #4
0
        /// <summary>
        /// Erstellt ein neues InOrder-Objekt.
        /// </summary>
        /// <param name="inOrderID">Anfangswert der Eigenschaft InOrderID.</param>
        /// <param name="inOrderNo">Anfangswert der Eigenschaft InOrderNo.</param>
        /// <param name="inOrderDate">Anfangswert der Eigenschaft InOrderDate.</param>
        /// <param name="insertName">Anfangswert der Eigenschaft InsertName.</param>
        /// <param name="insertDate">Anfangswert der Eigenschaft InsertDate.</param>
        /// <param name="updateName">Anfangswert der Eigenschaft UpdateName.</param>
        /// <param name="updateDate">Anfangswert der Eigenschaft UpdateDate.</param>
        public static InOrder CreateInOrder(global::System.Guid inOrderID, global::System.String inOrderNo, global::System.DateTime inOrderDate, global::System.String insertName, global::System.DateTime insertDate, global::System.String updateName, global::System.DateTime updateDate)
        {
            InOrder inOrder = new InOrder();

            inOrder.InOrderID   = inOrderID;
            inOrder.InOrderNo   = inOrderNo;
            inOrder.InOrderDate = inOrderDate;
            inOrder.InsertName  = insertName;
            inOrder.InsertDate  = insertDate;
            inOrder.UpdateName  = updateName;
            inOrder.UpdateDate  = updateDate;
            return(inOrder);
        }
예제 #5
0
        /// <summary>
        /// Deletes this entity-object from the database
        /// </summary>
        /// <param name="database">Entity-Framework databasecontext</param>
        /// <param name="withCheck">If set to true, a validation happens before deleting this EF-object. If Validation fails message ís returned.</param>
        /// <param name="softDelete">If set to true a delete-Flag is set in the dabase-table instead of a physical deletion. If  a delete-Flag doesn't exit in the table the record will be deleted.</param>
        /// <returns>If a validation or deletion failed a message is returned. NULL if sucessful.</returns>
        public override MsgWithDetails DeleteACObject(IACEntityObjectContext database, bool withCheck, bool softDelete = false)
        {
            if (withCheck)
            {
                MsgWithDetails msg = IsEnabledDeleteACObject(database);
                if (msg != null)
                {
                    return(msg);
                }
            }
            int     sequence = Sequence;
            InOrder inOrder  = InOrder;

            if (inOrder.InOrderPos_InOrder.IsLoaded)
            {
                inOrder.InOrderPos_InOrder.Remove(this);
            }
            database.DeleteObject(this);
            InOrderPos.RenumberSequence(inOrder, sequence);
            return(null);
        }
예제 #6
0
 /// <summary>
 /// Veraltete Methode zum Hinzufügen eines neuen Objekts zum EntitySet 'InOrder'. Verwenden Sie stattdessen die Methode '.Add' der zugeordneten Eigenschaft 'ObjectSet&lt;T&gt;'.
 /// </summary>
 public void AddToInOrder(InOrder inOrder)
 {
     base.AddObject("InOrder", inOrder);
 }