Пример #1
0
        public void ClearFilter()
        {
            foreach (Control c in this.Controls)
            {
                if (c is TextBox)
                {
                    c.Text    = "";
                    c.Enabled = false;
                }
                else if (c is ComboBox)
                {
                    ((ComboBox)c).SelectedIndex = 0;
                    c.Enabled = false;
                }

                else if (c is DateTimePicker)
                {
                    ((DateTimePicker)c).Value = DateTime.Today.Date;
                    c.Enabled = false;
                }
            }
            ctx.Dispose();
            ctx = new TubDataBaseEntities();
            ctx.Patients.Load();

            bind.DataSource = ctx.Patients.Local.ToBindingList();
        }
Пример #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("До пацієнта прив'язані аналізи, видаляти заборонено");
                }
            }
        }
Пример #3
0
 protected override void OnClosing(CancelEventArgs e)
 {
     base.OnClosing(e);
     ctx.Dispose();
 }