想用DotNetbar的CalendarView做一个日程表,但是不知道如何进行和数据库的绑定,官网上貌似也没有说明,有人知道吗?

解决方案 »

  1.   

     #region 新建日程的方法 将信息--->到日程控件中
            /// <summary>
            /// Adds the specified appointment to the model
            /// </summary>
            /// <param name="subject">Appointment subject</param>
            /// <param name="startTime">Appointment start time</param>
            /// <param name="endTime">Appointment end time</param>
            /// <param name="color">Appointment color</param>
            /// <param name="er">Appointment er</param>
            private Appointment AddAppointment(string subject, string description, string address, DateTime startTime, DateTime endTime, string color, string er, string tag,string RemindTime)
            {
                Appointment appointment = new Appointment();
                appointment.StartTime = startTime;
                appointment.EndTime = endTime;
                appointment.Subject = subject;
                appointment.Description = description;
                appointment.OwnerKey = address;
                appointment.CategoryColor = color;
                appointment.TimeMarkedAs = er;
                appointment.Tooltip = description;
                appointment.Tag = tag;
                appointment.Recurrence = new AppointmentRecurrence();
                if (RemindTime.Trim() != "")
                {
                    appointment.Reminders.Add(new Reminder(Convert.ToDateTime(RemindTime)));
                }
                appointment.StartTimeAction = eStartTimeAction.StartTimeReachedEvent;
                appointment.StartTimeReached += new EventHandler(appointment_StartTimeReached);
                // Set recurrence type to weekly
                 
                appointment.Recurrence.RecurrenceType = eRecurrencePatternType.Daily;
                appointment.Recurrence.Daily.RepeatOnDaysOfWeek = eDailyRecurrenceRepeat.All;
                appointment.Recurrence.Daily.RepeatInterval = 10;
                appointment.Recurrence.RangeLimitType = eRecurrenceRangeLimitType.RangeEndDate;
                //--------------------
                SchedulecalendarView.CalendarModel.Appointments.Add(appointment);
                return (appointment);
            }        void appointment_StartTimeReached(object sender, EventArgs e)
            {
               /* TipForm tf = new TipForm();
                tf.Show();*/
            }
            private void SchedulecalendarView_AppointmentReminder(object sender, DevComponents.Schedule.Model.ReminderEventArgs e)
            {
                if (e.Reminder.Appointment != null)
                {
                    DateTime dt = e.Reminder.Appointment.Reminders[0].ReminderTime;
                    if (dt.Year == System.DateTime.Now.Year && dt.Month == System.DateTime.Now.Month && dt.Day == System.DateTime.Now.Day && dt.Hour == System.DateTime.Now.Hour && dt.Minute == System.DateTime.Now.Minute)
                    {
                        TipForm tf = new TipForm(e.Reminder.Appointment.Subject, e.Reminder.Appointment.Description);
                        tf.Show();
                    }
                }
            }
            #endregion