/// <summary>
 /// 用于向 Prescriptions EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToPrescriptions(Prescription prescription)
 {
     base.AddObject("Prescriptions", prescription);
 }
Пример #2
0
        public string CreatePrescription(PrescriptionInfoEntity prescriptionInfoEntity) {
            Prescription  newPrescription = new Prescription();
            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            newPrescription.Detail = "";
            for (int i = 0; i < prescriptionInfoEntity.Count; i++) {
                string sPhysicID = prescriptionInfoEntity.physicID[i];
                Physic physic = (from p in DEntities.Physics
                                 where p.PhysicID == sPhysicID
                                 select p).FirstOrDefault();
                if (physic == null) {
                    return "Invalid PhysicID! @Data";
                }
                newPrescription.Detail += prescriptionInfoEntity.physicID[i] + ":" + prescriptionInfoEntity.number[i].ToString() + ";";
            }
            newPrescription.PrescriptionID = Guid.NewGuid();

            try {
                DEntities.Prescriptions.AddObject(newPrescription);
                DEntities.SaveChanges();
            }
            catch {
                return "Invalid Case! @Data";
            }

            return String.Format("EA{0}", newPrescription.PrescriptionID.ToString());
        }
 /// <summary>
 /// 创建新的 Prescription 对象。
 /// </summary>
 /// <param name="prescriptionID">PrescriptionID 属性的初始值。</param>
 public static Prescription CreatePrescription(global::System.Guid prescriptionID)
 {
     Prescription prescription = new Prescription();
     prescription.PrescriptionID = prescriptionID;
     return prescription;
 }