Ejemplo n.º 1
0
        public static bool Remove(SavedPrescription item)
        {
            EntityModelContainer context = GetContext();

            try
            {
                context.DeleteObject(item);
            }
            catch
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ErrorTitle, RscError.EntityDelete);
                context.ObjectStateManager.ChangeObjectState(item, System.Data.EntityState.Modified);
                return false;
            }
            return true;
        }
Ejemplo n.º 2
0
        public static bool HasSameEntity(SavedPrescription entity)
        {
            EntityModelContainer context = entity.Context;

            if (context.ObjectStateManager.GetObjectStateEntries
                ((EntityState.Added | EntityState.Modified | EntityState.Unchanged))
                .Select(e => e.Entity).OfType<SavedPrescription>()
                .Any(x => x.Title == entity.Title
                && (x != entity)))
                return true;

            return false;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new SavedPrescription object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 public static SavedPrescription CreateSavedPrescription(global::System.Int32 id, global::System.String title)
 {
     SavedPrescription savedPrescription = new SavedPrescription();
     savedPrescription.Id = id;
     savedPrescription.Title = title;
     return savedPrescription;
 }
Ejemplo n.º 4
0
        public static bool Validate(SavedPrescription entity)
        {
            if (entity.Title == null || entity.Title.Trim().Length == 0)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.SavedPrescriptionDrugTitleNull);
                return false;
            }

            if (entity.SavedPrescriptionDrugs.Count == 0)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.SavePrescriptionDrugDrugsNull);
                return false;
            }

            return true;
            /*
                bool hasEntity = DataLayer.HasSameEntity(entity);

                if (hasEntity)
                    return
                        DialogResult.Yes == Methods.ShowStandardMsgBox(FormMessageType.Question, "هشدار تکرار نام",
                        "قبلا نسخه ای با چنین نامی ساخته شده است، آیا می خواهید اطلاعات این نسخه ثبت شود؟");

                return true;
             */
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SavedPrescriptions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSavedPrescriptions(SavedPrescription savedPrescription)
 {
     base.AddObject("SavedPrescriptions", savedPrescription);
 }