Exemplo n.º 1
0
        private void View_Button_Click(object sender, EventArgs e)
        {
            try
            {
                using (var context = new Cabinet_MedicalEntities())
                {
                    string cell   = PacientsData.SelectedRows[0].Cells[0].Value.ToString();
                    var    query2 = (from pat in context.Patients
                                     where pat.Nume.Equals(cell)
                                     select pat).First();



                    if (PacientsData.SelectedRows.Count == 0)
                    {
                        throw new Exception("Selectati un pacient!");
                    }


                    else
                    {
                        this.Hide();

                        View_Form view = new View_Form(query2, this, Abouts);
                        view.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Message",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void Accept_Button_Click(object sender, EventArgs e)
 {
     try
     {
         if (PatientsData.SelectedRows.Count == 0)
         {
             throw new Exception("Selectati o programare!");
         }
         if (PatientsData.SelectedCells[2].Value.ToString().Equals("Consultat"))
         {
             throw new Exception("Pacientul a fost deja consultat!");
         }
         if (PatientsData.SelectedCells[2].Value.ToString().Equals("Refuzat"))
         {
             throw new Exception("Pacientul a fost deja refuzat!");
         }
         Patient P;
         using (var context = new Cabinet_MedicalEntities())
         {
             string name  = PatientsData.SelectedCells[0].Value.ToString();
             var    query = (from app in context.Appointments
                             join pat in context.Patients
                             on app.ID_Pacient equals pat.ID
                             where pat.Nume.Equals(name)
                             select new
             {
                 app.Accepted,
                 pat.ID
             }).First();
             PatientsData.SelectedCells[2].Value = "Consultat";
             // var query2 = (from app in context.Appointments
             //              where app.ID_Pacient == query.ID
             //              select app).First();
             var query3 = (from pat in context.Patients
                           where pat.Nume.Equals(name)
                           select pat).First();
             context.SetData(name, 2);
             context.SaveChanges();
             P = query3;
         }
         Form p = new View_Form(P, this, Abouts);
         p.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }