示例#1
0
        public static bool Validate(Drug entity)
        {
            if (entity == null || entity.Title == null || entity.Title.Trim().Length == 0)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.DrugTitleNull);
                return false;
            }

            return true;
        }
示例#2
0
        public static bool Validate(Drug drug, string manual)
        {
            if (drug == null)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.DrugTitleNull);
                return false;
            }

            /*
            if (manual == null || manual.Trim().Length == 0)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ValidationTitle, RscError.DrugManualNull);
                return false;
            }
             */

            return true;
        }
示例#3
0
        public static bool Remove(Drug item)
        {
            EntityModelContainer context = GetContext();

            try
            {
                if (item.Id > 0)
                {
                    var count = (from prescription in GetSavedPrescriptions(true)
                                 where (from drug in prescription.SavedPrescriptionDrugs
                                        where drug.Id == item.Id
                                        select drug).Count() > 0
                                 select prescription).Count();

                    if (count > 0)
                        throw new UpdateException("");
                }

                context.DeleteObject(item);
            }
            catch (UpdateException)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ErrorTitle, RscError.DrugDelete);
                context.ObjectStateManager.ChangeObjectState(item, System.Data.EntityState.Modified);
                return false;
            }
            catch (InvalidOperationException)
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, RscError.ErrorTitle, RscError.DrugDelete);
                context.ObjectStateManager.ChangeObjectState(item, System.Data.EntityState.Modified);
                return false;
            }
            return true;
        }
示例#4
0
        public static bool HasSameEntity(Drug entity)
        {
            EntityModelContainer context = entity.Context;

            if (entity.EntityState == EntityState.Unchanged)
                return false;

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

            return false;
        }
示例#5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Drugs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDrugs(Drug drug)
 {
     base.AddObject("Drugs", drug);
 }
示例#6
0
 /// <summary>
 /// Create a new Drug object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 public static Drug CreateDrug(global::System.Int32 id, global::System.String title)
 {
     Drug drug = new Drug();
     drug.Id = id;
     drug.Title = title;
     return drug;
 }