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; }
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; }
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; }
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; }
/// <summary> /// Deprecated Method for adding a new object to the Drugs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDrugs(Drug drug) { base.AddObject("Drugs", drug); }
/// <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; }