private void InitialVisit(object primaryKey) { using (CardContext db = new CardContext()) { visit = db.Visits.Find(primaryKey); } OutputData(visit); }
public void Delete(object primaryKey) { using (CardContext db = new CardContext()) { db.Visits.Remove(db.Visits.Find(primaryKey)); db.SaveChanges(); UpdateTable(); } }
private void Save() { using (CardContext db = new CardContext()) { visit = db.Visits.Find(visit.Id) is null?db.Visits.Add(visit) : db.Visits.Find(visit.Id); visit.DateVitis = dateVisit.SelectedDate.Value.ToString("D"); visit.IdCard = card.Id; visit.TypeVisit = primary.IsChecked.Value ? 0 : 1; visit.Diagnosis = diagnosis.Text; db.SaveChanges(); Close(); } }
public void UpdateTable() { using (CardContext db = new CardContext()) { table.Clear(); foreach (Card card in db.Cards) { DataRow row = table.NewRow(); row["Id"] = card.Id; row["ФИО"] = card.FIO; row["Пол"] = card.Gender; row["Дата рождения"] = card.Birthday; row["Адрес"] = card.Address; row["Телефон"] = card.Phone; table.Rows.Add(row); } } }
public void UpdateTable() { using (CardContext db = new CardContext()) { table.Clear(); var visits = from visit in db.Visits where visit.IdCard == Card.Id select visit; foreach (Visit visit in visits) { DataRow row = table.NewRow(); row["Id"] = visit.Id; row["Дата"] = visit.DateVitis; row["Тип"] = visit.TypeVisit == 0 ? "Первичный" : "Вторичный"; row["Диагноз"] = visit.Diagnosis; table.Rows.Add(row); } } }