コード例 #1
0
        protected void ButtonDeleteMessage_Click(object sender, EventArgs e)
        {
            HospitalSystemEntities1 entities = new HospitalSystemEntities1();
            List <Message>          messages = getMessages();

            Message selected = messages[DropDownListMessages.SelectedIndex];

            entities.Messages.Attach(selected);
            entities.Messages.Remove(selected);
            entities.SaveChanges();

            ListBoxMessages.Items.Clear();
            DropDownListMessages.Items.Clear();
            if (messages.Count < 1)
            {
                ListBoxMessages.Items.Add("You have no messages.");
                DropDownListMessages.Items.Add("You have no messages.");
            }
            else
            {
                foreach (Message message in messages)
                {
                    ListBoxMessages.Items.Add(
                        message.MessageFROM + ": " + message.Message1
                        );
                    DropDownListMessages.Items.Add(
                        message.MessageFROM + ": " + message.Message1
                        );
                }
            }

            ListBoxMessages.DataBind();
            DropDownListMessages.DataBind();
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Response.Redirect("~/Logon.aspx");
            }

            List <Patient> patients = getPatients();
            List <Message> messages = getMessages();

            ListBoxMessages.Items.Clear();
            DropDownListMessages.Items.Clear();
            if (messages.Count < 1)
            {
                ListBoxMessages.Items.Add("You have no messages.");
                DropDownListMessages.Items.Add("You have no messages.");
            }
            else
            {
                foreach (Message message in messages)
                {
                    ListBoxMessages.Items.Add(
                        message.MessageFROM + ": " + message.Message1
                        );
                    DropDownListMessages.Items.Add(
                        message.MessageFROM + ": " + message.Message1
                        );
                }
            }

            ListBoxMessages.DataBind();
            DropDownListMessages.DataBind();

            DropDownListPatient.Items.Clear();
            if (patients.Count < 1)
            {
                DropDownListPatient.Items.Add("This hospital has no patients on record.");
            }
            else
            {
                foreach (Patient patient in patients)
                {
                    DropDownListPatient.Items.Add(
                        patient.FirstName + " " + patient.LastName
                        );
                }
            }
        }