예제 #1
0
 /// <summary>
 /// Записывает CorrectiveAction в отклонения в завсимоти от существования данного(this) обекта в базе данных
 /// </summary>
 /// <param name="correctiveAction"></param>
 private void SetCorrectiveAction(CorrectiveAction correctiveAction)
 {
     if (ItemId > 0)
     {
         if (_correctiveAction != null)
         {
             if (CorrectiveActionCollection != null)
             {
                 if (correctiveAction != null)
                 {
                     if (CorrectiveActionCollection.Contains(correctiveAction))
                     {
                         CorrectiveActionCollection.Remove(correctiveAction);
                     }
                     CorrectiveActionCollection.Add(_correctiveAction);
                     _correctiveAction = correctiveAction;
                 }
             }
         }
     }
     else
     {
         _correctiveAction = correctiveAction;
     }
 }
예제 #2
0
        /// <summary>
        /// Возвращает CorrectiveAction в зависимоти от условия существоваяния в базе данных
        /// </summary>
        /// <returns></returns>
        private CorrectiveAction GetCorrectiveAction()
        {
            //if (ItemID > 0)
            //{
            //    if (correctiveActionCollection != null)
            //    {
            //        if (correctiveAction == null)
            //        {
            //            if (correctiveActionCollection.Count == 0)
            //            {
            //                correctiveAction = new CorrectiveAction();
            //                correctiveActionCollection.Add(correctiveAction);
            //            }
            //            else
            //            {
            //                correctiveAction = correctiveActionCollection[0];
            //            }
            //            return correctiveAction;
            //        }
            //        else
            //        {
            //            return correctiveAction;
            //        }
            //    }
            //}
            //else
            //{
            //    if (correctiveAction == null)
            //        correctiveAction = new CorrectiveAction();
            //    return correctiveAction;
            //}

            //return null;

            if (CorrectiveActionCollection == null)
            {
                CorrectiveActionCollection = new CorrectiveActionCollection(this);
            }
            if (_correctiveAction == null)
            {
                if (CorrectiveActionCollection.Count == 0)
                {
                    _correctiveAction = new CorrectiveAction();
                    CorrectiveActionCollection.Add(_correctiveAction);
                }
                else
                {
                    _correctiveAction = CorrectiveActionCollection[0];
                }
            }
            return(_correctiveAction);
        }