Example #1
0
        private void UpdatePatient()
        {
            var pat = ctx.Patients.Where(c => c.p_id == patient.p_id).FirstOrDefault();

            LoadFormInPatient(pat);
            ctx.SaveChanges();
            MessageBox.Show("Зміни збережено");
        }
Example #2
0
        private void DeletePatientBut_Click(object sender, EventArgs e)
        {
            ctx.Dispose();
            ctx = new TubDataBaseEntities();
            ctx.Patients.Load();
            DialogResult d = MessageBox.Show("Ви впевнені, що бажаєте видалити цього пацієнта?", "Видалення", MessageBoxButtons.YesNo);

            if (d == DialogResult.Yes)
            {
                var p = (from c in ctx.Patients where (c.p_id == patient.p_id) select c).FirstOrDefault();
                int a = (from c in ctx.BlTest___Patient where (c.bltp_patid == patient.p_id) select c).Count() +
                        (from c in ctx.UrTest__Patient where (c.utp_patid == patient.p_id) select c).Count() +
                        (from c in ctx.HepTest___Patient where (c.htp_patid == patient.p_id) select c).Count() +
                        (from c in ctx.SputumTest___Patient where (c.sptp_patid == patient.p_id) select c).Count() +
                        (from c in ctx.Consult___Patient where (c.cp_patid == patient.p_id) select c).Count();

                if (a == 0)
                {
                    ctx.Patients.Remove(p);
                    ctx.SaveChanges();
                    MessageBox.Show("Пацієнта видалено");
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("До пацієнта прив'язані аналізи, видаляти заборонено");
                }
            }
        }
Example #3
0
        private void SetLosed()
        {
            int st    = (from c in ctx.State where (c.state_value == "заплановано") select c.state_id).FirstOrDefault();
            var query = (from c in ctx.BlTest___Patient where (c.bltp_date < DateTime.Today.Date && c.bltp_state == st) select c).ToList();

            foreach (var q in query)
            {
                q.bltp_state = (from c in ctx.State where (c.state_value == "пропущено") select c.state_id).FirstOrDefault();
            }
            ctx.SaveChanges();
        }
Example #4
0
 private void OKClicked()
 {
     try
     {
         if (m == mode.Create)
         {
             FillUrTest(ur);
             var q = (from c in ctx.UrTest__Patient where (c.utp_testid == test) select c).FirstOrDefault();
             q.utp_state = (from c in ctx.State where (c.state_value == "завершено") select c.state_id).FirstOrDefault();
             ctx.SaveChanges();
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             FillUrTest(ur);
             ctx.SaveChanges();
             this.DialogResult = DialogResult.OK;
         }
     }
     catch
     {
         MessageBox.Show("Введено неправильну інформацію");
     }
 }