コード例 #1
0
        protected void ChangeAvailabilityButton_Click(object sender, EventArgs e)
        {
            using (userDB)
            {
                AppointmentTable appointment = new AppointmentTable();
                appointment.AdvisorID         = Convert.ToInt32(Session["advisorID"]);
                appointment.ApointmentTime    = TimeSpan.Parse(TextBox1.Text);
                appointment.AppointmentDate   = DateTime.Parse(DateTime.Today.Month + "/" + TextBox2.Text);
                appointment.AppointmentReason = "UNAVAILABLE";
                appointment.StudentID         = Convert.ToInt32("000000");

                if ((from app in userDB.AppointmentTables where (app.AppointmentDate.Equals(appointment.AppointmentDate)) && (app.ApointmentTime.Equals(appointment.ApointmentTime)) select app).First() != null)
                {
                    throw new Exception("There is already an appointment with that date and time!");
                }

                userDB.AppointmentTables.Add(appointment);
                userDB.SaveChanges();
            }

            // resets the fields to blank and binds the new data to the gridview, thus refreshing the page
            TextBox1.Text = "";
            TextBox2.Text = "";

            unavailableStatus.Text = "Success!";

            BindAppointments();
            LoadStudentDropDownList();
        }
コード例 #2
0
        protected void RescheduleButton_Click(object sender, EventArgs e)
        {
            using (userDB)
            {
                AppointmentTable selectedAppointment =
                    (from app in userDB.AppointmentTables
                     where app.AppointmentID == Convert.ToInt32(AppointmentsGridView.SelectedDataKey.Value)
                     select app).First();

                selectedAppointment.ApointmentTime  = TimeSpan.Parse(TextBox10.Text);
                selectedAppointment.AppointmentDate = DateTime.Parse(DateTime.Today.Month + "/" + TextBox9.Text);

                string sqlCommand =
                    "UPDATE [AppointmentTables]" +
                    "SET [ApointmentTime] = '" + selectedAppointment.ApointmentTime.ToString() + "', [AppointmentDate = '" + selectedAppointment.AppointmentDate.ToString() + "'" +
                    "WHERE [AppointmentID] = " + selectedAppointment.AppointmentID + ";";

                BindAppointments(sqlCommand);
            }
        }
コード例 #3
0
        protected void CancelMeetingButton_Click(object sender, EventArgs e)
        {
            using (userDB)
            {
                if (AppointmentsGridView.SelectedDataKey.Value != null)
                {
                    int appointmentID            = Convert.ToInt32(AppointmentsGridView.SelectedDataKey.Value.ToString());
                    AppointmentTable appointment =
                        (from app in userDB.AppointmentTables
                         where app.AppointmentID == appointmentID
                         select app).FirstOrDefault();
                    userDB.AppointmentTables.Remove(appointment);

                    userDB.SaveChanges();
                }
            }

            //Reload all relevant controls
            BindAppointments();
            LoadStudentDropDownList();
        }