private void ChangeStateToClosed(int id) { SputumTest___Patient bp = (from q in db.SputumTest___Patient where q.sptp_testid == id select q).FirstOrDefault(); bp.sptp_state = (from q in db.State where q.state_value == "завершено" select q.state_id).FirstOrDefault(); db.SaveChanges(); }
public void PlanNewTest(DateTime date, int pid) { SputumTest___Patient bl = new SputumTest___Patient(); bl.sptp_state = (from q in db.State where q.state_value == "заплановано" select q.state_id).FirstOrDefault(); bl.sptp_date = date; SputumTest test = new SputumTest(); db.SputumTest.Add(test); bl.sptp_patid = pid; bl.sptp_testid = test.sputtest_id; db.SputumTest___Patient.Add(bl); db.SaveChanges(); }
public int DeleteTest(int id) { SputumTest___Patient bl = (from q in db.SputumTest___Patient where (q.sptp_id == id) select q).FirstOrDefault(); int testid = bl.sptp_testid; db.SputumTest___Patient.Remove(bl); db.SaveChanges(); SputumTest test = (from q in db.SputumTest where q.sputtest_id == testid select q).FirstOrDefault(); if (test != null) { db.SputumTest.Remove(test); db.SaveChanges(); } return(testid); }
public override void Plan(DateTime date) { try { SputumTest___Patient b = new SputumTest___Patient(); SputumTest test = new SputumTest(); ctx.SputumTest.Add(test); b.sptp_patid = pat.p_id; b.sptp_state = (from c in ctx.State where (c.state_value == "заплановано") select c.state_id).FirstOrDefault(); b.sptp_date = date.Date; b.sptp_testid = test.sputtest_id; ctx.SputumTest___Patient.Add(b); ctx.SaveChanges(); Renew(); } catch { MessageBox.Show("Помилка при плануванні"); } }