Beispiel #1
0
        private void Schedule_AppointmentEditorClosed(object sender, AppointmentEditorClosedEventArgs e)
        {
            MeetingsDBDataContext scheduleMeetings = new MeetingsDBDataContext();
            Meeting_Table         meeting;


            if (e.Action == EditorClosedAction.Save)
            {
                var editedAppointment = (e.EditedAppointment as ScheduleMeeting);
                var appointmentID     = Convert.ToInt32(editedAppointment.AppointmentID);

                if (!e.IsNew)
                {
                    meeting = (from data in scheduleMeetings.Meeting_Tables
                               where data.ID == appointmentID
                               select data).First() as Meeting_Table;

                    meeting.Subject   = editedAppointment.MappedSubject;
                    meeting.StartTime = editedAppointment.MappedStartTime.ToString();
                    meeting.EndTime   = editedAppointment.MappedEndTime.ToString();
                    meeting.Color     = editedAppointment.MappedColor.ToString();
                    meeting.IsAllDay  = editedAppointment.MappedIsAllDay.ToString();
                    meeting.ID        = appointmentID;
                }
                else
                {
                    meeting = new Meeting_Table();

                    meeting.Subject   = editedAppointment.MappedSubject;
                    meeting.StartTime = editedAppointment.MappedStartTime.ToString();
                    meeting.EndTime   = editedAppointment.MappedEndTime.ToString();
                    meeting.Color     = editedAppointment.MappedColor.ToString();
                    meeting.IsAllDay  = editedAppointment.MappedIsAllDay.ToString();
                    meeting.ID        = appointmentID;

                    scheduleMeetings.Meeting_Tables.InsertOnSubmit(meeting);
                }
                scheduleMeetings.SubmitChanges();
            }

            if (e.Action == EditorClosedAction.Delete)
            {
                var editedAppointment = (e.OriginalAppointment as ScheduleMeeting);
                var appointmentID     = Convert.ToInt32(editedAppointment.AppointmentID);

                meeting = (from data in scheduleMeetings.Meeting_Tables
                           where data.ID == appointmentID
                           select data).First() as Meeting_Table;

                scheduleMeetings.Meeting_Tables.DeleteOnSubmit(meeting);
                scheduleMeetings.SubmitChanges();
            }
        }
Beispiel #2
0
        public ScheduleViewModel()
        {
            Meetings = new ObservableCollection <ScheduleMeeting>();

            MeetingsDBDataContext = new MeetingsDBDataContext();
            var MeetingsList = (from data in MeetingsDBDataContext.Meeting_Tables
                                select data).ToList();

            for (int i = 0; i < MeetingsList.Count; i++)
            {
                Meetings.Add(new ScheduleMeeting()
                {
                    MappedSubject   = MeetingsList[i].Subject,
                    MappedStartTime = Convert.ToDateTime(MeetingsList[i].StartTime),
                    MappedEndTime   = Convert.ToDateTime(MeetingsList[i].EndTime),
                    MappedColor     = new SolidColorBrush((Color)ColorConverter.ConvertFromString(MeetingsList[i].Color)),
                    MappedIsAllDay  = Convert.ToBoolean(MeetingsList[i].IsAllDay),
                    AppointmentID   = MeetingsList[i].ID.ToString()
                });
            }
        }