/// <summary> /// Method used to add the selected period as an appointment to the database /// </summary> /// <param name="sender">The Object Sender</param> /// <param name="e">The EventArgs</param> private void AddAppointmentButton_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(LessonTypecomboBox.Text) && !String.IsNullOrEmpty(StartTimecomboBox.Text) && !String.IsNullOrEmpty(lessonsComboBox.Text)) { TimeSpan startTime = TimeSpan.Parse(StartTimecomboBox.Text); DateTime dateToAdd = date.Date + startTime; bool appointmentAdded = DatabaseParser.AddAppointment(LessonTypecomboBox.Text, dateToAdd, (int)lessonsComboBox.SelectedItem, Session.LoggedInUser.Id.ToString()); if (appointmentAdded) { CustomMsgBox.ShowOk("Succes", "Appointment succesfully added", CustomMsgBoxIcon.Complete); AppointmentStructure appointmentStructure = new AppointmentStructure(-1, Session.LoggedInUser.Id, dateToAdd, (int)lessonsComboBox.SelectedItem, LessonTypecomboBox.Text, false, Session.LoggedInUser.Fullname); _appointments.Add(new Appointment(appointmentStructure)); this.Dispose(); } else { CustomMsgBox.ShowOk("Failure", "Appointment failed to upload", CustomMsgBoxIcon.Error); } } else { CustomMsgBox.ShowOk("Failure", "Some fields need to be filled", CustomMsgBoxIcon.Warrning); } }
public Appointment(AppointmentStructure appointmentStructure) : base(appointmentStructure) { GenerateLabel(); if (Session.LoggedInUser.Sysmin) { InstructorLabelData(); } else { UserLabelData(); } SubscribeToEvent(); }
/// <summary> /// get all appointments belonging to an instructor user /// </summary> /// <param name="id">the id of the instructor</param> /// <param name="appointmentTable">Optional* The table to execute on</param> /// <returns>list of the found appointments</returns> public static List <AppointmentStructure> GetAppointmentsByInstructorId(int id, string appointmentTable = AppointmentTable) { DataTable result = MySql.GetAllAppointmentsByInstructorId(id, appointmentTable); List <AppointmentStructure> instructorAppointments = new List <AppointmentStructure>(); foreach (DataRow appointment in result.Rows) { AppointmentStructure appointmentToAdd = new AppointmentStructure( Convert.ToInt32(appointment[0]), Convert.ToInt32(appointment[1]), Convert.ToDateTime(appointment[2]), Convert.ToInt32(appointment[3]), appointment[4].ToString(), Convert.ToBoolean(appointment[5]) ); instructorAppointments.Add(appointmentToAdd); } return(instructorAppointments); }
/// <summary> /// Adds an appointment to all appoinments /// </summary> /// <param name="appointment">Appointment that should be added</param> private void AddAppointment(AppointmentStructure appointment) { Appointment newAppointment = new Appointment(appointment); appointments.Add(newAppointment); }