コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["USER_ID"] == null)
                {
                    Response.Redirect("~/View/Home/index.aspx", false);
                }
                else
                {
                    String idSession = Session["USER_ID"].ToString();
                    int    id        = Convert.ToInt32(idSession);
                    psychoConsult = new Psychologist(id);

                    diagnosticConsult = new Diagnostic(psychoConsult);

                    ConsultDiagnosticIDPsychoCommand cmdDiagnostic = new ConsultDiagnosticIDPsychoCommand(diagnosticConsult);
                    ConsultPatientsCommand           cmdPatient    = new ConsultPatientsCommand();

                    try
                    {
                        cmdPatient.execute();
                        patientList = cmdPatient.getAnswer();

                        cmdDiagnostic.execute();
                        diagnosticList = cmdDiagnostic.getAnswer();

                        foreach (Diagnostic _diagnostic in diagnosticList)
                        {
                            int patientFK = _diagnostic._Patient._ID;

                            foreach (Patient _patient in patientList)
                            {
                                int patientID = _patient._ID;

                                if (patientFK == _patient._ID)
                                {
                                    patientListDuplicates.Add(_patient);
                                }
                            }
                        }

                        patientListConfirmed    = patientListDuplicates.GroupBy(i => i._ID).Select(g => g.First()).ToList();
                        listPatients.DataSource = patientListConfirmed;
                        listPatients.DataBind();

                        if (listPatients.Items.Count < 1)
                        {
                            listPatients.Visible = false;
                            NoRecord.Visible     = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["USER_ID"] == null)
                {
                    Response.Redirect("~/View/Home/index.aspx", false);
                }
                else
                {
                    String idSession = Session["USER_ID"].ToString();
                    int    id        = Convert.ToInt32(idSession);
                    psychoConsult = new Psychologist(id);

                    diagnosticConsult = new Diagnostic(psychoConsult);

                    ConsultDiagnosticIDPsychoCommand cmdDiagnostic = new ConsultDiagnosticIDPsychoCommand(diagnosticConsult);
                    ConsultPatientsCommand           cmd           = new ConsultPatientsCommand();

                    try
                    {
                        cmd.execute();
                        listOfPatientsConsulted = cmd.getAnswer();

                        cmdDiagnostic.execute();
                        diagnosticList = cmdDiagnostic.getAnswer();

                        foreach (Diagnostic _diagnostic in diagnosticList)
                        {
                            int patientFK = _diagnostic._Patient._ID;

                            foreach (Patient _patient in listOfPatientsConsulted)
                            {
                                if (patientFK == _patient._ID)
                                {
                                    patientListDuplicates.Add(_patient);
                                }
                            }
                        }

                        patientListConfirmed = patientListDuplicates.GroupBy(i => i._ID).Select(g => g.First()).ToList();

                        if (patientListConfirmed.Count < 1)
                        {
                            NoRecord.Visible               = true;
                            NoRecordList.Enabled           = false;
                            Record.Visible                 = false;
                            date_appointment.Disabled      = true;
                            hour_appointment.Enabled       = false;
                            reasonTXT.Enabled              = false;
                            btnRegisterAppointment.Enabled = false;
                        }
                        else
                        {
                            foreach (Patient _patient in patientListConfirmed)
                            {
                                int    idPatient      = _patient._ID;
                                String patientName    = _patient._Name;
                                String patientSurname = _patient._Surname;


                                patient_List.Items.Add(idPatient + " " + patientName + " " + patientSurname);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }