private Appointment AddNewAppointment(DateTime dtInicio, DateTime dtFin, string strDescripcion) { Appointment appointment = new Appointment(); appointment.Id = numId; appointment.StartTime = dtInicio; appointment.EndTime = dtFin; appointment.Subject = "LIBRE"; appointment.Description = ""; appointment.Tooltip = ""; appointment.CategoryColor = Appointment.CategoryBlue; appointment.TimeMarkedAs = Appointment.TimerMarkerFree; appointment.Locked = true; cvCalendario.CalendarModel.Appointments.Add(appointment); clsDetalleDisponibilidad objDetalleDisponibilidad = new clsDetalleDisponibilidad(); objDetalleDisponibilidad._IdDisponibilidad = numIdDisponibilidad; objDetalleDisponibilidad._IdDetalleDisponibilidad = appointment.Id; objDetalleDisponibilidad._Fecha = appointment.StartTime.Date; objDetalleDisponibilidad._HoraInicio = appointment.StartTime; objDetalleDisponibilidad._HoraFin = appointment.EndTime; lstDetalleDisponibilidad.Add(objDetalleDisponibilidad); numId = numId - 1; return (appointment); }
protected virtual bool IsAppointmentVisible(Appointment app) { if (app.Visible == false) return (false); if (string.IsNullOrEmpty(_DisplayOwnerKey)) return (true); return (app.OwnerKey == _DisplayOwnerKey); }
/// <summary> /// Constructor /// </summary> /// <param name="baseView"></param> /// <param name="appointment"></param> public AppointmentView(BaseView baseView, Appointment appointment) { _BaseView = baseView; _Appointment = appointment; MouseUpNotification = true; StartTime = appointment.StartTime; EndTime = appointment.EndTime; ModelItem = appointment; IsRecurring = (appointment.IsRecurringInstance == true || appointment.Recurrence != null); RootItem = (appointment.IsRecurringInstance == true) ? appointment.RootAppointment : appointment; StartTimeChanged += AppointmentView_StartTimeChanged; EndTimeChanged += AppointmentView_EndTimeChanged; }
private void LoadBookings() { if (cmBookings.Appointments.Count > 0) { cmBookings.Appointments.Clear(); } gBookings.PrimaryGrid.Rows.Clear(); DataSet d, ds = Program.DB.SelectAll("SELECT ID,Job,BName,BCompany,BRoom,BRoomLayout,BDates,BTimes,BPhone,BEmail FROM Jobs WHERE BName IS NOT NULL AND BUser IS NOT NULL ORDER BY Job DESC"); d = Program.DB.SelectAll("SELECT ID,Name,IsZone FROM Rooms;"); Dictionary<int, string> zones = new Dictionary<int, string>(); Dictionary<int, string> rooms = new Dictionary<int, string>(); if (d.Tables.Count > 0) { foreach (DataRow r in d.Tables[0].Rows) { if (r["IsZone"] != DBNull.Value && r["IsZone"].Equals("Y")) { zones.Add(Convert.ToInt32(r["ID"]), r["Name"].ToString()); continue; } string sZone = ""; foreach (KeyValuePair<int, string> zone in zones) { if (r["Name"] != DBNull.Value && Convert.ToInt32(r["ID"]) == zone.Key) { sZone = zone.Value.Replace("|", " - ") + " - "; break; } } rooms.Add(Convert.ToInt32(r["ID"]), sZone + r["Name"].ToString()); } } d = Program.DB.SelectAll("SELECT ID,Name FROM Companies;"); Dictionary<int, string> companies = new Dictionary<int, string>(); List<ComboItem> companiesCombo = new List<ComboItem>(); companiesCombo.Add(new ComboItem() { }); if (d.Tables.Count > 0) { foreach (DataRow r in d.Tables[0].Rows) { companies.Add(Convert.ToInt32(r["ID"]), r["Name"].ToString()); companiesCombo.Add(new ComboItem() { Value = Convert.ToInt32(r["ID"]), Text = r["Name"].ToString() }); } } d = Program.DB.SelectAll("SELECT ID,NameFirst,NameLast FROM Contacts;"); Dictionary<int, string> contacts = new Dictionary<int, string>(); if (d.Tables.Count > 0) { foreach (DataRow r in d.Tables[0].Rows) { string contact = (r["NameFirst"] != DBNull.Value ? r["NameFirst"].ToString() : "") + r["NameLast"].ToString(); contacts.Add(Convert.ToInt32(r["ID"]), contact); } } if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { Appointment appointment = new Appointment(); string sDate = ""; string[] sDates = new string[] { }; if (row["BDates"] != DBNull.Value) { sDates = row["BDates"].ToString().Split('|'); if (sDates.Length == 2) { sDates[0] = sDates[0].Replace(" 00:00:00", ""); sDates[1] = sDates[1].Replace(" 00:00:00", ""); sDate = sDates[0] + " - " + sDates[1]; } } string sStart = "", sFinish = ""; if (row["BTimes"] != DBNull.Value) { string[] sTimes = row["BTimes"].ToString().Split('|'); if (sTimes.Length == 2 && sDates.Length == 2) { sDates[0] += " " + sTimes[0] + ":00"; sDates[1] += " " + sTimes[1] + ":00"; sStart = sTimes[0]; sFinish = sTimes[1]; DateTime now = DateTime.Now; int iYear = now.Year, iMonth = now.Month, iDay = now.Day; string[] d1 = sDates[0].Split('/'); string[] t1 = sTimes[0].Split(':'); iYear = Convert.ToInt32(d1[2].Substring(0, d1[2].IndexOf(' '))); iMonth = Convert.ToInt32(d1[1]); iDay = Convert.ToInt32(d1[0]); appointment.StartTime = new DateTime(iYear, iMonth, iDay, Convert.ToInt32(t1[0]), Convert.ToInt32(t1[1]), 0); string[] d2 = sDates[1].Split('/'); string[] t2 = sTimes[1].Split(':'); iYear = Convert.ToInt32(d2[2].Substring(0, d2[2].IndexOf(' '))); iMonth = Convert.ToInt32(d2[1]); iDay = Convert.ToInt32(d2[0]); appointment.EndTime = new DateTime(iYear, iMonth, iDay, Convert.ToInt32(t2[0]), Convert.ToInt32(t2[1]), 0); } } string sCompany = ""; if (companies.Count > 0) { foreach (KeyValuePair<int, string> company in companies) { if (company.Key > -1 && row["BCompany"] != DBNull.Value && company.Key == Convert.ToInt32(row["BCompany"])) { sCompany = company.Value; break; } } } string sRoom = ""; if (rooms.Count > 0 && row["BRoom"] != DBNull.Value) { string[] sRooms = row["BRoom"].ToString().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (KeyValuePair<int, string> room in rooms) { if (room.Key > -1 && sRooms.Contains(room.Key.ToString())) { sRoom = room.Value; break; } } } appointment.Subject = row["BName"].ToString(); appointment.CategoryColor = Appointment.CategoryGreen; appointment.TimeMarkedAs = Appointment.TimerMarkerBusy; appointment.Tag = row["ID"].ToString(); appointment.Locked = true; cmBookings.Appointments.Add(appointment); GridRow r = new GridRow(new object[] { row["Job"].ToString(), sDate, sStart, sFinish, row["BName"].ToString(), sRoom, sCompany, row["BPhone"].ToString(), row["BEmail"].ToString(), row["BRoomLayout"].ToString() }); r.Tag = row["ID"]; gBookings.PrimaryGrid.Rows.Add(r); } } cvBookings.CalendarModel = cmBookings; string sCount = "Total bookings: " + gBookings.PrimaryGrid.Rows.Count(); lblCountBookingsCalendar.Text = sCount; lblCountBookingsGrid.Text = sCount; lblCountBookingsList.Text = sCount; }
private bool IsRecurringOnDay(DateTime currentDay, DateTime rangeStart, DateTime rangeEnd, Appointment rootAppointment) { TimeSpan duration = rootAppointment.EndTime.Subtract(rootAppointment.StartTime); DateTime startTime = rootAppointment.GetValidDateTime(new DateTime(currentDay.Year, currentDay.Month, currentDay.Day, rootAppointment.StartTime.Hour, rootAppointment.StartTime.Minute, 0)); DateTime endTime = rootAppointment.GetValidDateTime(startTime.Add(duration)); DateTime localStartTime = rootAppointment.GetLocalDateTime(rootAppointment.GetUTCDateTime(startTime)); DateTime localEndTime = rootAppointment.GetLocalDateTime(rootAppointment.GetUTCDateTime(endTime)); // If time-zone is not used return false if (startTime == localStartTime) return currentDay >= rangeStart; return DateTimeHelper.TimePeriodsOverlap(localStartTime, localEndTime, rangeStart, rangeEnd); }
/// <summary> /// Gets a new appointment view /// </summary> /// <param name="appointment">Appointment</param> /// <returns>New view</returns> private AppointmentTimeLineView GetNewView(Appointment appointment) { AppointmentTimeLineView view = new AppointmentTimeLineView(_View, appointment); view.Tooltip = appointment.Tooltip; return (view); }
private void mBookingsAdd_Click(object sender, EventArgs e) { Form frmBooking = new frmBooking(); DialogResult dlg = frmBooking.ShowDialog(); if (dlg == DialogResult.OK && SharedData.iBookingID > 0 && SharedData.dSchedule.Count > 0) { Appointment appointment = new Appointment(); string[] sDates = SharedData.dSchedule["dates"].Split('|'); string[] sTimes = new string[] { }; if (SharedData.dSchedule["times"].Length > 0) { sTimes = SharedData.dSchedule["times"].Split('|'); } DateTime now = DateTime.Now; int iYear = now.Year, iMonth = now.Month, iDay = now.Day; string[] d1 = sDates[0].Split('/'); string[] t1 = new string[] { }; if (sTimes.Length == 2) { t1 = sTimes[0].Split(':'); } iYear = Convert.ToInt32(d1[2].Substring(0, d1[2].IndexOf(' '))); iMonth = Convert.ToInt32(d1[1]); iDay = Convert.ToInt32(d1[0]); appointment.StartTime = new DateTime(iYear, iMonth, iDay, (t1.Length == 2 ? Convert.ToInt32(t1[0]) : 0), (t1.Length == 2 ? Convert.ToInt32(t1[0]) : 0), 0); string[] d2 = sDates[1].Split('/'); string[] t2 = new string[] { }; if (sTimes.Length == 2) { t2 = sTimes[1].Split(':'); } iYear = Convert.ToInt32(d2[2].Substring(0, d2[2].IndexOf(' '))); iMonth = Convert.ToInt32(d2[1]); iDay = Convert.ToInt32(d2[0]); appointment.EndTime = new DateTime(iYear, iMonth, iDay, (t2.Length == 2 ? Convert.ToInt32(t2[0]) : 0), (t1.Length == 2 ? Convert.ToInt32(t2[0]) : 0), 0); appointment.Subject = SharedData.dSchedule["name"]; appointment.CategoryColor = Appointment.CategoryGreen; appointment.TimeMarkedAs = Appointment.TimerMarkerBusy; appointment.Locked = true; appointment.Tag = SharedData.iBookingID; cmBookings.Appointments.Add(appointment); cvBookings.CalendarModel = cmBookings; } SharedData.iBookingID = 0; LoadBookings(); LoadBookingsGrid(); }
/// <summary> /// Initializes a new instance of the AppointmentEventArgs class. /// </summary> /// <param name="appointment"></param> public AppointmentEventArgs(Appointment appointment) { Appointment = appointment; }
/// <summary> /// Adds the specified appointment to the model /// </summary> /// <param name="s">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="marker">Appointment marker</param> private bool AddAppointment(string s, DateTime startTime, DateTime endTime, string color, string marker) { Appointment appointment = new Appointment(); appointment.Subject = s; appointment.StartTime = startTime; appointment.EndTime = endTime; calendarView.CalendarModel.Appointments.Add(appointment); return true; }
internal void InternalAppointmentRemoved(Appointment item, bool isClearing) { item.SubPropertyChanged -= this.ChildPropertyChangedEventHandler; if (!item.IsRecurringInstance && !isClearing) InvalidateAppointmentCache(item); if (!isClearing) OnAppointmentRemoved(new AppointmentEventArgs(item)); }
private void InvalidateAppointmentCache(Appointment app) { if (IsUpdateSuspended) return; if (app.Recurrence != null) { // Invalidate all InvalidateAppointmentCache(); } else if (_Years.ContainsKey(app.LocalStartTime.Year)) { DateTime d = DateTimeHelper.BeginningOfDay(app.LocalStartTime); DateTime end = app.LocalEndTime; int year = d.Year; while (d < end) { _Years[d.Year].InvalidateAppointments(d.Month, d.Day); d = d.AddDays(1); if (d.Year != year && !_Years.ContainsKey(d.Year)) break; } } AccessToday(); OnPropertyChanged(new PropertyChangedEventArgs(AppointmentsPropertyName)); }
private void updateAppointment(Appointment appointment, Asignacion asignacion) { String subject; String description; String toolTip; String categoryColor; DateTime inicio = asignacion.Inicio; DateTime fin = asignacion.Fin; String separator = "<br />"; if (asignacion is AsignacionClase) { AsignacionClase asignacionClase = (AsignacionClase)asignacion; categoryColor = asignacionClase.Grupo.Asignatura.Facultad; separator="<br />"; if (asignacionClase.Reprogramada) { appointment.ImageKey = "disabled"; appointment.ImageAlign = eImageContentAlignment.BottomRight; categoryColor += "Disabled"; appointment.DisplayTemplate = "<strike>[Subject]</strike><br /><strike>[Description]</strike>"; } else { appointment.ImageKey = null; appointment.DisplayTemplate = "[Subject]<br />[Description]"; } subject = String.Format("{0} - {1}(G{2})", asignacionClase.Grupo.Asignatura.Referencia, asignacionClase.Grupo.Asignatura.Nombre, asignacionClase.Grupo.NumeroGrupo); description = String.Format("{0}{3}({1}/{2})", asignacionClase.Grupo.NombreDocente, asignacionClase.Grupo.CantidadEstudiantes, asignacionClase.Aula.Capacidad,separator); toolTip = String.Format("Inicio:{0}{5}Fin:{1}{5}Duración:{2}{5}{3}{5}Periodo:{4}", asignacion.Inicio.ToShortTimeString(), asignacion.Fin.ToShortTimeString(), PeriodoTiempo.GetDuracion(asignacion.Inicio, asignacion.Fin), "Clase", asignacionClase.Grupo.Periodo.Descripcion,separator); } else { AsignacionVarios asignacionVarios = (AsignacionVarios)asignacion; subject = String.Format("{0}", asignacionVarios.TipoUso.Descripcion); toolTip = String.Format("Inicio:{0}{4}Fin:{1}{4}Duración:{2}{4}{3}", asignacion.Inicio.ToShortTimeString(), asignacion.Fin.ToShortTimeString(), PeriodoTiempo.GetDuracion(asignacion.Inicio, asignacion.Fin), asignacionVarios.TipoUso.Descripcion,separator); description = String.Format("{0}", asignacionVarios.Observaciones); categoryColor = Appointment.CategoryDefault; appointment.DisplayTemplate = "[Subject]<br />[Description]"; } if (asignacion.Serie != null) toolTip += "<br />Pertenece a una serie"; appointment.StartTime = inicio; appointment.EndTime = fin; appointment.Subject = subject; appointment.Description = description; appointment.Tooltip = toolTip; appointment.OwnerKey = asignacion.Aula.Referencia; appointment.Tag = asignacion; appointment.CategoryColor = categoryColor; appointment.Locked = true; }
/// <summary> /// Returns true if appointment overlapps with one or more of the appointments in the model. /// </summary> /// <param name="app">Appointment to check overlap for.</param> /// <returns>true if there are appointments overlapping appointment otherwise false.</returns> public bool ContainsOverlappingAppointments(Appointment app) { int duration = (int)Math.Max(1, app.EndTime.Subtract(app.StartTime).TotalDays); for (int i = 0; i < duration; i++) { DateTime date = app.StartTime.Date.AddDays(i); Day day = GetDay(date); foreach (Appointment item in day.Appointments) { if (item != app && DateTimeHelper.TimePeriodsOverlap(item.StartTime, item.EndTime, app.StartTime, app.EndTime)) return true; } } return false; }
public void AddNewAppointment(Asignacion owner,DateTime startDate, DateTime endDate, String subject, String description, String toolTip) { Appointment appointment = new Appointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; appointment.Subject = subject; appointment.Description = description; appointment.Tooltip = toolTip; appointment.OwnerKey = owner.Aula.Referencia; appointment.Tag = owner; appointment.Locked = true; calendarView.CalendarModel.Appointments.Add(appointment); }
public void AddNewAppointment(DateTime startDate, DateTime endDate, String subject, String description, String toolTip) { Appointment appointment = new Appointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; appointment.Subject = subject; appointment.Description = description; appointment.Tooltip = toolTip; appointment.OwnerKey = calendarView.SelectedOwner; calendarView.CalendarModel.Appointments.Add(appointment); }
public void AddAsignacion(Asignacion asignacion) { Appointment appointment = new Appointment(); updateAppointment(appointment, asignacion); calendarView.CalendarModel.Appointments.Add(appointment); }
/// <summary> /// Constructor /// </summary> /// <param name="baseView"></param> /// <param name="appointment"></param> public AppointmentMonthView(BaseView baseView, Appointment appointment) : base(baseView, appointment) { }
/// <summary> /// Creates an copy of the appointment. /// </summary> /// <returns>Appointment copy.</returns> public Appointment Copy() { Appointment copy = new Appointment(); copy.OwnerKey = this.OwnerKey; copy.Description = this.Description; copy.EndTime = this.EndTime; copy.CategoryColor = this.CategoryColor; copy.DisplayTemplate = this.DisplayTemplate; copy.ImageAlign = this.ImageAlign; copy.ImageKey = this.ImageKey; copy.Locked = this.Locked; copy.TimeMarkedAs = this.TimeMarkedAs; copy.TimeZone = this.TimeZone; copy.Tooltip = this.Tooltip; if (_Reminders != null) { foreach (Reminder rem in _Reminders) copy.Reminders.Add(rem.Copy()); } copy.StartTime = this.StartTime; copy.StartTimeAction = this.StartTimeAction; if (StartTimeReached != null) copy.StartTimeReached = (EventHandler)this.StartTimeReached.Clone(); copy.Subject = this.Subject; copy.Tag = this.Tag; return copy; }
/// <summary> /// Finds appointments that overlap with the parameter appointment. /// </summary> /// <param name="app">Appointment to use to find overlapps</param> /// <returns>Array of appointments that overlap parameter.</returns> public Appointment[] FindOverlappingAppointments(Appointment app) { List<Appointment> overlaps = new List<Appointment>(); int duration = (int)Math.Max(1, app.EndTime.Subtract(app.StartTime).TotalDays); for (int i = 0; i < duration; i++) { DateTime date = app.StartTime.Date.AddDays(i); Day day = GetDay(date); foreach (Appointment item in day.Appointments) { if (item != app && DateTimeHelper.TimePeriodsOverlap(item.StartTime, item.EndTime, app.StartTime, app.EndTime)) overlaps.Add(item); } } return overlaps.ToArray(); }
private Appointment CreateRecurringAppointmentInstance(DateTime currentDay, Appointment rootAppointment) { Appointment app = rootAppointment.Copy(); TimeSpan duration = rootAppointment.EndTime.Subtract(rootAppointment.StartTime); DateTime startTime = app.GetValidDateTime(new DateTime(currentDay.Year, currentDay.Month, currentDay.Day, rootAppointment.StartTime.Hour, rootAppointment.StartTime.Minute, 0)); DateTime endTime = app.GetValidDateTime(startTime.Add(duration)); app.StartTime = startTime; app.EndTime = endTime; app.IsRecurringInstance = true; app.RootAppointment = rootAppointment; app.Tooltip = rootAppointment.Tooltip; if (rootAppointment.Recurrence == null || !rootAppointment.Recurrence.IndependentVisibility) app.Visible = rootAppointment.Visible; foreach (Reminder reminder in app.Reminders) { //reminder.ReminderTime = app.StartTime.Add(reminder.ReminderTime.Subtract(rootAppointment.StartTime)); reminder.IsActive = true; } return app; }
internal void InternalAppointmentAdded(Appointment item) { item.SubPropertyChanged += this.ChildPropertyChangedEventHandler; if (!item.IsRecurringInstance) InvalidateAppointmentCache(item); OnAppointmentAdded(new AppointmentEventArgs(item)); }
/// <summary> /// Gets all appointment AppointmentMonthViews /// </summary> /// <param name="app"></param> /// <returns></returns> private List<AppointmentMonthView> GetViewsFromAll(Appointment app) { List<AppointmentMonthView> list = new List<AppointmentMonthView>(); for (int i = 0; i < _View.MonthWeeks.Length; i++) { AppointmentMonthView view = GetViewFromWeek(_View.MonthWeeks[i], app); if (view != null) list.Add(view); } return (list); }
internal void InvokeAppointmentStartTimeReached(Appointment appointment) { OnAppointmentStartTimeReached(new AppointmentEventArgs(appointment)); }
/// <summary> /// Gets the view from the MonthWeek list /// </summary> /// <param name="monthWeek">MonthWeek</param> /// <param name="appointment">Appointment</param> /// <returns>Appointment view</returns> private AppointmentMonthView GetViewFromWeek(MonthWeek monthWeek, Appointment appointment) { foreach (CalendarItem item in monthWeek.CalendarItems) { AppointmentMonthView view = item as AppointmentMonthView; if (view != null && view.Appointment == appointment) return (view); } return (null); }
/// <summary> /// Constructor /// </summary> /// <param name="baseView"></param> /// <param name="appointment"></param> public AppointmentWeekDayView(BaseView baseView, Appointment appointment) : base(baseView, appointment) { SetViewEnds(); }
/// <summary> /// Gets the view from the cached list /// </summary> /// <param name="appointment">Appointment</param> /// <param name="cachedViews">Cached views</param> /// <returns>Appointment view</returns> private AppointmentMonthView GetViewFromCache(Appointment appointment, List<AppointmentMonthView> cachedViews) { if (cachedViews != null && cachedViews.Count > 0) { foreach (AppointmentMonthView appView in cachedViews) { if (appView.Appointment == appointment) { cachedViews.Remove(appView); return (appView); } } } return (null); }
/// <summary> /// Gets the AppointmentView from the timeline /// </summary> /// <param name="appointment"></param> /// <returns>AppointmentView or null</returns> private AppointmentTimeLineView GetViewFromTimeLine(Appointment appointment) { foreach (CalendarItem item in _View.CalendarItems) { AppointmentTimeLineView view = item as AppointmentTimeLineView; if (view != null && view.Appointment == appointment) return (view); } return (null); }
/// <summary> /// Gets a new appointment view /// </summary> /// <param name="appointment">Appointment</param> /// <returns>New view</returns> private AppointmentMonthView GetNewView(Appointment appointment) { AppointmentMonthView view = new AppointmentMonthView(_View, appointment); view.Tooltip = appointment.Tooltip; // Set the selected state to match any current // views that are present for this appointment for (int i = 0; i < _View.MonthWeeks.Length; i++) { AppointmentMonthView viewPart = GetViewFromWeek(_View.MonthWeeks[i], appointment); if (viewPart != null) { view.IsSelected = viewPart.IsSelected; break; } } return (view); }
/// <summary> /// Determines if an appointment is visible /// for the given DisplayOwner /// </summary> /// <param name="app"></param> /// <returns></returns> private bool IsAppointmentVisible(Appointment app) { if (string.IsNullOrEmpty(DisplayedOwnerKey)) return (true); return (app.OwnerKey == DisplayedOwnerKey); }
private void cargarDisponibilidad() { clsDetalleDisponibilidad objDetalleDisponibilidad = new clsDetalleDisponibilidad(); objDetalleDisponibilidad.FechaElegida = mcCalendario.SelectionStart; objDetalleDisponibilidad.IdDisponibilidadDoctor = numIdDisponibilidad; objDetalleDisponibilidad.DetalleXML = clsComun.Serializar(lstDetalleDisponibilidad); DataTable dtDetalleDisponibilidad = new DataTable(); dtDetalleDisponibilidad = ctrDisponibilidad.seleccionarDetallesDisponibilidad(objDetalleDisponibilidad); for (int i = 0; i < dtDetalleDisponibilidad.Rows.Count; i++) { Appointment appointment = new Appointment(); appointment.Id = Int32.Parse(dtDetalleDisponibilidad.Rows[i]["IdDetalleDisponibilidad"].ToString()); appointment.StartTime = DateTime.Parse(dtDetalleDisponibilidad.Rows[i]["HoraInicio"].ToString()); appointment.EndTime = DateTime.Parse(dtDetalleDisponibilidad.Rows[i]["HoraFin"].ToString()); appointment.Subject = "LIBRE"; appointment.Description = ""; appointment.Tooltip = ""; appointment.CategoryColor = Appointment.CategoryBlue; appointment.TimeMarkedAs = Appointment.TimerMarkerFree; appointment.Locked = true; cvCalendario.CalendarModel.Appointments.Add(appointment); } }