Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue == null)
            {
                MessageBox.Show("Need to select a doctor.");
            }
            else
            {
                MessagesTable myMessage = new MessagesTable();
                string        ourUser   = User.Identity.Name;
                myDbcon1.PatientsTables.Load();
                myDbcon2.DoctorsTables.Load();

                PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local
                                           where x.UserLoginName.Trim().Equals(ourUser)
                                           select x).First();

                myMessage.MessageFROM = myPatient.UserLoginName.Trim();
                myMessage.MessageTO   = DropDownList1.SelectedValue.Trim();
                myMessage.Date        = DateTime.Now;
                myMessage.Message     = TextBox1.Text.Trim();

                //Add data to the table
                myDbcon1.MessagesTables.Add(myMessage);
                myDbcon1.SaveChanges();
            }
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            myDbcon1.DoctorsTables.Load();

            var currentDoctor = (from x in myDbcon1.DoctorsTables.Local
                                 where x.UserLoginName.Trim() == User.Identity.Name.Trim()
                                 select x).First();

            MessagesTable myMessage = new MessagesTable();

            myMessage.MessageFROM = currentDoctor.UserLoginName.Trim();
            myMessage.MessageTO   = DropDownList1.SelectedItem.Text.Trim();
            myMessage.Date        = DateTime.Now;
            myMessage.Message     = TextBox1.Text.Trim();

            myDbcon1.MessagesTables.Add(myMessage);
            myDbcon1.SaveChanges();
        }
Exemplo n.º 3
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            HA3_DataBaseV1Entities3 myDbcon4 = new HA3_DataBaseV1Entities3();

            myDbcon4.MessagesTables.Load();
            MessagesTable delMessage = (from x in myDbcon4.MessagesTables.Local
                                        where x.MessageID == Convert.ToInt32(Label3.Text)
                                        select x).First();

            myDbcon4.MessagesTables.Remove(delMessage);
            myDbcon4.SaveChanges();
            GridView1.DataBind();
            MessageBox.Show("Message successfully deleted.");
        }
Exemplo n.º 4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            myDbcon1.AppointmentsTables.Load();

            var selectedItem = GridView1.SelectedDataKey[0];

            if (selectedItem != null)
            {
                int appointmentID = Convert.ToInt32(selectedItem);

                var appointment = (from x in myDbcon1.AppointmentsTables.Local
                                   where x.AppointmentID == appointmentID
                                   select x).First();

                myDbcon1.AppointmentsTables.Remove(appointment);
                myDbcon1.SaveChanges();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Calendar1.SelectedDate <= DateTime.Now)
            {
                MessageBox.Show("Date has to be after current day!");
            }
            else
            {
                AppointmentsTable myAppointment = new AppointmentsTable();
                string            ourUser       = User.Identity.Name;
                myDbcon1.PatientsTables.Load();
                myDbcon2.DoctorsTables.Load();

                PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local
                                           where x.UserLoginName.Trim().Equals(ourUser)
                                           select x).First();

                int patID = myPatient.PatientsID;

                /* myDbcon2.DoctorsTables.Load();
                 *
                 * var myApp = from x in myDbcon2.DoctorsTables.Local
                 *           where x.Department == DropDownList2.SelectedValue
                 *           select x;
                 *
                 * DropDownList3.DataSource = myApp.ToList();
                 * DropDownList3.DataBind(); */

                /*myDbcon3.DoctorsTables.Load();
                 * DoctorsTable myDoc = (from x in myDbcon3.DoctorsTables.Local
                 *                         where (x.FirstName + x.LastName) == DropDownList3.SelectedValue
                 *                         select x).First();*/

                myAppointment.PatientID    = patID;
                myAppointment.Purpose      = TextBox1.Text;
                myAppointment.DoctorID     = Convert.ToInt32(DropDownList3.SelectedValue);
                myAppointment.VisitSummary = TextBox2.Text;
                myAppointment.Date         = Calendar1.SelectedDate;
                int hours = Convert.ToInt32(TextBox3.Text);
                int mins  = Convert.ToInt32(DropDownList1.SelectedValue);
                myAppointment.Time = new TimeSpan(hours, mins, 0);

                //Check for conflicting appointments
                bool timeconflict = false;
                foreach (var x in myDbcon1.AppointmentsTables)
                {
                    if (myAppointment.Date == x.Date && myAppointment.Time == x.Time)
                    {
                        timeconflict = true;
                    }
                }

                if (timeconflict == true)
                {
                    //Display error message
                    MessageBox.Show("Time conflicts with an existing appointment.");
                }
                else
                {
                    //Add data to the table
                    myDbcon1.AppointmentsTables.Add(myAppointment);
                    myDbcon1.SaveChanges();
                    MessageBox.Show("Appointment successfully created.");
                }
            }
        }