예제 #1
0
 private static int SaveToDatabase <T>(T tObject)
 {
     using (MedicineContext db = new MedicineContext())
     {
         if (tObject is Diagnoses)
         {
             db.Diagnoses.Add(tObject as Diagnoses);
         }
         else if (tObject is Doctors)
         {
             db.Doctors.Add(tObject as Doctors);
         }
         else if (tObject is Patients)
         {
             db.Patients.Add(tObject as Patients);
         }
         else if (tObject is Diseases)
         {
             db.Diseases.Add(tObject as Diseases);
         }
         else
         {
             throw new TypeLoadException("Тип не распознан!");
         }
         return(db.SaveChanges());
     }
 }
예제 #2
0
        public PatientViewModel()
        {
            this.SavePatientDataCommand = new RelayCommand(this.SavePatientData);
            Months = GetMonths();

            using (MedicineContext db = new MedicineContext())
            {
                db.SocialStatuses.Load();
                db.Policies.Load();
                db.Disabilities.Load();
                SocialStatuses = db.SocialStatuses.Local.ToBindingList();
                Policies       = db.Policies.Local.ToBindingList();
                Disabilities   = db.Disabilities.Local.ToBindingList();
            }
            if (SingletonVMP.VMP.Patient == null)
            {
                Patient = new Patient();
                SingletonVMP.VMP.Patient = Patient;
            }
            else
            {
                Patient = SingletonVMP.VMP.Patient;
                GetBirthday();
                GetDisability();
                SelectedSocialStatus = SocialStatuses.FirstOrDefault(x => x.Id == Patient.SocialStatusId);
                SelectedPolicy       = Policies.FirstOrDefault(x => x.Id == Patient.PoliceId);
            }
        }
 public JsonResult GetMedicine()
 {
     using (MedicineContext db = new MedicineContext())
     {
         List <Medicine> medList = db.Medicines.ToList();
         return(Json(medList, JsonRequestBehavior.AllowGet));
     }
 }
예제 #4
0
        private static int UpdateDatabase(string p_doctor, string p_patient, string p_disease, string p_number)
        {
            int       sent = 0;
            Diagnoses diagnose;
            Doctors   doctor;
            Patients  patient;
            Diseases  disease;
            int       number = int.Parse(p_number);

            using (MedicineContext db = new MedicineContext())
            {
                diagnose = db.Diagnoses.Where(d => d.Doctors.fullname == p_doctor && d.Diseases.name == p_disease &&
                                              d.Patients.fullname == p_patient && d.number == number).FirstOrDefault();
                if (diagnose == null)
                {
                    doctor = db.Doctors.Where(d => d.fullname == p_doctor).FirstOrDefault();
                    if (doctor == null)
                    {
                        doctor = new Doctors()
                        {
                            id       = Guid.NewGuid(),
                            fullname = p_doctor
                        };
                        sent += SaveToDatabase(doctor);
                    }
                    patient = db.Patients.Where(d => d.fullname == p_patient).FirstOrDefault();
                    if (patient == null)
                    {
                        patient = new Patients()
                        {
                            id       = Guid.NewGuid(),
                            fullname = p_patient
                        };
                        sent += SaveToDatabase(patient);
                    }
                    disease = db.Diseases.Where(d => d.name == p_disease).FirstOrDefault();
                    if (disease == null)
                    {
                        disease = new Diseases()
                        {
                            id   = Guid.NewGuid(),
                            name = p_disease
                        };
                        sent += SaveToDatabase(disease);
                    }
                    diagnose = new Diagnoses()
                    {
                        id      = Guid.NewGuid(),
                        number  = number,
                        patient = patient.id,
                        disease = disease.id,
                        doctor  = doctor.id
                    };
                    sent += SaveToDatabase(diagnose);
                }
            }
            return(sent);
        }
예제 #5
0
        public MedecineViewModel()
        {
            db            = new MedicineContext();
            DeleteCommand = new DelegateCommand(DeleteCommandFun);
            FindCommand   = new DelegateCommand(FindCommandFun);

            IsNoBusy = true;

            ReloadData();
        }
 public JsonResult Delete(int id)
 {
     using (MedicineContext db = new MedicineContext())
     {
         Medicine medicine = db.Medicines.Find(id);
         if (medicine == null)
         {
             return(Json(new { success = false }));
         }
         db.Medicines.Remove(medicine);
         db.SaveChanges();
         return(Json(new { success = true }));
     }
 }
예제 #7
0
 private void AddPolice_button_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(police_textBox.Text))
     {
         using (MedicineContext db = new MedicineContext())
         {
             db.Policies.Add(new Policy()
             {
                 Name = police_textBox.Text
             });
             db.SaveChanges();
         }
         this.Close();
     }
 }
예제 #8
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            string text = "";

            using (MedicineContext db = new MedicineContext())
            {
                int deleted = 0;
                deleted += db.Database.ExecuteSqlCommand("DELETE FROM dbo.[Diagnoses]");
                deleted += db.Database.ExecuteSqlCommand("DELETE FROM dbo.[Patients]");
                deleted += db.Database.ExecuteSqlCommand("DELETE FROM dbo.[Doctors]");
                deleted += db.Database.ExecuteSqlCommand("DELETE FROM dbo.[Diseases]");
                deleted  = deleted / 3;
                text    += "Удалено: " + deleted.ToString() + " записи.";
            }
            tbInput.AppendText("\r\n" + text);
        }
 public JsonResult Insert(Medicine medicine)
 {
     if (medicine != null)
     {
         using (MedicineContext db = new MedicineContext())
         {
             db.Medicines.Add(medicine);
             db.SaveChanges();
             return(Json(new { success = true }));
         }
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
예제 #10
0
        public ObjectivelyViewModel()
        {
            SelectedDescription   = new EyeDescriptionMethod("Оба сразу", true, "0");
            EyeDescriptionMethods = new List <EyeDescriptionMethod>()
            {
                SelectedDescription,
                new EyeDescriptionMethod("По отдельности", false, "2*")
            };

            using (MedicineContext db = new MedicineContext())
            {
                db.EyeSides.Load();
                EyeSides = db.EyeSides.Local.ToBindingList();
            }

            EyeSide ODSide = EyeSides.FirstOrDefault(x => x.Side == "OD");
            EyeSide OSSide = EyeSides.FirstOrDefault(x => x.Side == "OS");

            if (SingletonVMP.VMP.Eyes == null)
            {
                ODEye = new Eye(ODSide);
                OSEye = new Eye(OSSide);
                Eyes  = new List <Eye>();
                Eyes.Add(ODEye);
                Eyes.Add(OSEye);
                SingletonVMP.VMP.Eyes = Eyes;
            }
            else
            {
                Eyes  = SingletonVMP.VMP.Eyes;
                ODEye = Eyes.FirstOrDefault(s => s.EyeSideId == ODSide.Id);
                OSEye = Eyes.FirstOrDefault(s => s.EyeSideId == OSSide.Id);
                if (ODEye.CompareTo(OSEye) == -1)
                {
                    EyeDescriptionMethods.Clear();
                    SelectedDescription   = new EyeDescriptionMethod("По отдельности", false, "2*");
                    EyeDescriptionMethods = new List <EyeDescriptionMethod>()
                    {
                        new EyeDescriptionMethod("Оба сразу", true, "0"),
                        SelectedDescription
                    };
                }
            }
        }
 public JsonResult Update(Medicine updatedMedicine)
 {
     using (MedicineContext db = new MedicineContext())
     {
         Medicine existingMedicine = db.Medicines.Find(updatedMedicine.ID);
         if (existingMedicine == null)
         {
             return(Json(new { success = false }));
         }
         else
         {
             existingMedicine.Name     = updatedMedicine.Name;
             existingMedicine.Price    = updatedMedicine.Price;
             existingMedicine.Quantity = updatedMedicine.Quantity;
             db.SaveChanges();
             return(Json(new { success = true }));
         }
     }
 }
예제 #12
0
        private async void LoadData()
        {
            await Task.Run(() =>
            {
                using (MedicineContext db = new MedicineContext())
                {
                    var data = db.VMPs.Include(x => x.Patient);

                    VMPAll = new List <VMP>();
                    foreach (var d in data)
                    {
                        VMPAll.Add(d);
                    }
                }
            });

            InfoText = string.Empty;
            foreach (var item in VMPAll)
            {
                VMPList.Add(item);
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            var contextOptionsFromDi = serviceProvider.GetRequiredService <DbContextOptions <MedicineContext> >();

            using (var context = new MedicineContext(contextOptionsFromDi))
            {
                // check if data already present
                if (context.Medicines.Any())
                {
                    return;
                }

                // Seed Data if absent
                context.Medicines.AddRange(
                    new Medicine()
                {
                    Id         = 91,
                    Name       = "Med1",
                    Brand      = "brand1",
                    Price      = (decimal)29.12,
                    Quantity   = 10,
                    ExpiryDate = new DateTime(2020, 01, 01).Date,
                    Notes      = "medicine number 1"
                },
                    new Medicine()
                {
                    Id         = 92,
                    Name       = "Med2",
                    Brand      = "brand2",
                    Price      = (decimal)29.13,
                    Quantity   = 20,
                    ExpiryDate = new DateTime(2020, 01, 02).Date,
                    Notes      = "medicine number 2"
                });

                context.SaveChangesAsync();
            }
        }
        public ActionResult Create([Bind(Include = "id,M_Name,Image,M_Company,M_Type,M_Potency,M_Details,M_Price")] Medicine medicine, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                Medicine        m  = new Medicine();
                MedicineContext db = new MedicineContext();
                m.Image     = Image.FileName.ToString();
                m.M_Name    = medicine.M_Name;
                m.M_Company = medicine.M_Company;
                m.M_Type    = medicine.M_Type;
                m.M_Potency = medicine.M_Potency;

                m.M_Details = medicine.M_Details;
                m.M_Price   = medicine.M_Price;
                var path = Server.MapPath("~/Content/img");
                Image.SaveAs(Path.Combine(path, Image.FileName.ToString()));
                db.Medicines.Add(m);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medicine));
        }
 public TreatmentController(MedicineContext context)
 {
     _db = context;
 }
예제 #16
0
 public SymptomsController([FromServices] MedicineContext context)
 {
     _context = context;
 }
 public DiagnosisController(MedicineContext context)
 {
     _db = context;
 }
예제 #18
0
 public PrescriptionController(MedicineContext context)
 {
     _db = context;
 }
예제 #19
0
 public EventInfoController(MedicineContext context)
 {
     _context = context;
 }
예제 #20
0
 public SqlMedicinesData(MedicineContext medicineContext)
 {
     _medicineContext = medicineContext;
 }
 public MedicinesController(MedicineContext context, ILoggerFactory loggerFactory)
 {
     _context = context;
     _logger  = loggerFactory.CreateLogger <MedicinesController>();
 }
 public ParameterController(MedicineContext context)
 {
     _db = context;
 }
예제 #23
0
 public PostAdminController([FromServices] MedicineContext context)
 {
     _context = context;
 }
예제 #24
0
 public MedicineInfo(MedicineContext _context)
 {
     _medicineContext = _context;
 }
예제 #25
0
 public PatientController(MedicineContext context)
 {
     _db = context;
 }
예제 #26
0
 public VisitationController([FromServices] MedicineContext context)
 {
     _context = context;
 }
 public MedicineInfoController(MedicineContext context)
 {
     _context = context;
 }
예제 #28
0
 public ImportExportController([FromServices] MedicineContext context) : this()
 {
     _context = context;
 }
 public ExaminationController(MedicineContext context)
 {
     _db = context;
 }