private void btnSearch_Click(object sender, EventArgs e) { patient = new Card_Patients(); sick_leave = new Sick_leaves(); ref_analyze = new Ref_Analyzes(); SearchForm f = new SearchForm(patient, sick_leave, ref_analyze); f.ShowDialog(); }
//Registration_patientsEntities bd = null; public SearchForm(Card_Patients p, Sick_leaves s, Ref_Analyzes a) { InitializeComponent(); this.patient = p; this.sick_leave = s; this.analyze = a; bd = new Registration_patientsEntities2(); comboBoxSurname.DataSource = null; comboBoxAdress.DataSource = null; comboBoxCard_num.DataSource = null; comboBoxAnalyz.DataSource = null; }
private void добавитьАнализыToolStripMenuItem2_Click(object sender, EventArgs e) { bd.Ref_Analyzes.Load(); ref_analyze = new Ref_Analyzes(); Ref_AnalyzesForm an = new Ref_AnalyzesForm(ref_analyze); if (an.ShowDialog() == DialogResult.OK) { Ref_Analyzes tmp = bd.Ref_Analyzes.Local.Where(x => x.Id_Patient == ref_analyze.Id_Patient && x.Id_Therapist == ref_analyze.Id_Therapist && x.Id_Analyze == ref_analyze.Id_Analyze && x.Date_analyze == ref_analyze.Date_analyze).FirstOrDefault(); if (tmp == null) { bd.Ref_Analyzes.Add(ref_analyze); bd.SaveChanges(); MessageBox.Show("Анализ успешно добавлен!"); } else { MessageBox.Show("Не удалось добавить данные!"); } } }
private void удалитАнализыToolStripMenuItem2_Click(object sender, EventArgs e) { if (dataGridViewMain.SelectedRows.Count == 1) { //bd = new Registration_patientsEntities2(); int index = dataGridViewMain.SelectedRows[0].Index; int Id = 0; bool converted = Int32.TryParse(dataGridViewMain[0, index].Value.ToString(), out Id); if (converted == false) { return; } ref_analyze = bd.Ref_Analyzes.Find(Id); bd.Ref_Analyzes.Remove(ref_analyze); bd.SaveChanges(); dataGridViewMain.Update(); dataGridViewMain.Refresh(); MessageBox.Show("Обьект удален!"); } else { MessageBox.Show("Не удалось удалить данные!"); } }
public Ref_AnalyzesForm(Ref_Analyzes an) { InitializeComponent(); this.ref_analyze = an; bd = new Registration_patientsEntities2(); //bd = new Registration_patientsEntities(); comboBoxPatient.DataSource = null; bd.Card_Patients.Load(); comboBoxPatient.DataSource = bd.Card_Patients.Local.ToList(); comboBoxPatient.DisplayMember = "Surname"; comboBoxPatient.ValueMember = "Id"; comboBoxTherapist.DataSource = null; bd.Therapists.Load(); comboBoxTherapist.DataSource = bd.Therapists.Local.ToList(); comboBoxTherapist.DisplayMember = "Surname"; comboBoxTherapist.ValueMember = "Id"; comboBoxAnalyz.DataSource = null; bd.Analyzes.Load(); comboBoxAnalyz.DataSource = bd.Analyzes.Local.ToList(); comboBoxAnalyz.DisplayMember = "Name_analyze"; comboBoxAnalyz.ValueMember = "Id"; }