public CalendarForm() { InitializeComponent(); calendar = new Calendar(); timer.Interval = 30000; timer.Tick += TimerElapsedHandler; }
//New Event Constructor public eventForm(SqlConnection sc, DateTime selectedDate, Calendar.txtCalendarBox myParent) { InitializeComponent(); this.myParent = myParent; btnEdit.Visible = false; btnCreate.Visible = true; beginDatePicker.CustomFormat = "dddd,MMMM d, yyyy 'at' h:mm:ss tt"; beginDatePicker.Format = DateTimePickerFormat.Custom; endDatePicker.CustomFormat = "dddd,MMMM d, yyyy 'at' h:mm:ss tt"; endDatePicker.Format = DateTimePickerFormat.Custom; selectedDate = selectedDate.AddSeconds(1); beginDatePicker.Text = selectedDate.ToString(); endDatePicker.Text = selectedDate.ToString(); this.sc = sc; this.Visible = true; }
//Edit Constructor public eventForm(SqlConnection sc, Int32 eventID, Calendar.txtCalendarBox myParent) { InitializeComponent(); this.myParent = myParent; btnCreate.Visible = false; btnEdit.Visible = true; this.eventID = eventID; beginDatePicker.CustomFormat = "dddd,MMMM d, yyyy 'at' h:mm:ss tt"; beginDatePicker.Format = DateTimePickerFormat.Custom; endDatePicker.CustomFormat = "dddd,MMMM d, yyyy 'at' h:mm:ss tt"; endDatePicker.Format = DateTimePickerFormat.Custom; this.Text = "Edit Event"; sqlCmd = new SqlCommand("SELECT event_subject as 'Event Subject', event_begin as 'Event Begin', event_end as 'Event End', event_description as 'Event Description', event_cat as 'Event Category' FROM event WHERE event_id='" + eventID.ToString() + "'", sc); sqlRdr = sqlCmd.ExecuteReader(); sqlRdr.Read(); try { txtSubject.Text = sqlRdr.GetValue(0).ToString(); beginDatePicker.Text = sqlRdr.GetValue(1).ToString(); endDatePicker.Text = sqlRdr.GetValue(2).ToString(); txtDescription.Text = sqlRdr.GetValue(3).ToString(); catCombo.Text = sqlRdr.GetValue(4).ToString(); } catch (InvalidOperationException) { } sqlRdr.Close(); this.sc = sc; this.Visible = true; }
void dayView1_ResolveAppointments(object sender, Calendar.ResolveAppointmentsEventArgs args) { List<Appointment> m_Apps = new List<Appointment>(); TimeSpan ts = args.EndDate.Subtract(args.StartDate); KS.Gantt.Calendars.Calendar calendar; if (radProjectSchedule.Checked) { //calendar = m_GanttControl.DefaultCalendar; foreach (TaskItem task in m_GanttControl.Tasks) { calendar = task.CombinedCalendar; // Milestones don't have a date extension // show them as a half hour task.. DateTime TaskEndDate; if (task.IsMilestone) TaskEndDate = task.StartDate.AddHours(0.5d); else TaskEndDate = task.EndDate; if (KS.Gantt.Helpers.DateTimeIntersect(args.StartDate, args.EndDate, task.StartDate, TaskEndDate).TotalDays > 0) { for (int i = 0; i < (int)ts.TotalDays; i++) { Appointment app = null; DateTime dtCurrent = args.StartDate.Date.AddDays(i); if (!calendar.IsWorkingDay(dtCurrent)) continue; KS.Gantt.Calendars.WorkingHourCollection whc = calendar.InheritedWorkingHours(dtCurrent); foreach (KS.Gantt.Calendars.WorkingHour wh in whc) { DateTime whStartDate = dtCurrent.Date.AddHours(wh.StartHour); DateTime whEndDate = dtCurrent.Date.AddHours(wh.EndHour); if (KS.Gantt.Helpers.DateTimeIntersect(task.StartDate, TaskEndDate, whStartDate, whEndDate).TotalDays > 0) { app = new Appointment(); if (task.StartDate >= whStartDate) app.StartDate = task.StartDate; else app.StartDate = whStartDate; if (TaskEndDate >= whEndDate) app.EndDate = whEndDate; else app.EndDate = TaskEndDate; // Делаем время 23:59:59 для отображения в рамках одного дня if (app.EndDate.Hour == 0 && app.EndDate.Minute == 0) app.EndDate = app.EndDate.AddSeconds(-1.0d); app.Color = task.FormatStyle.BackgroundStyle.Color; app.BorderColor = task.FormatStyle.BorderStyle.Color; app.Title = task.Text; app.Tag = task.Key; m_Apps.Add(app); } } } } } } else { if (GRD.CurrentRow == null || !(GRD.CurrentRow.DataBoundItem is ResourceItem)) return; ResourceItem resource = (ResourceItem)GRD.CurrentRow.DataBoundItem; if (resource == null || resource.ResourceAllocations == null) return; calendar = resource.CombinedCalendar; foreach (ResourceAllocation ra in resource.ResourceAllocations) { if (KS.Gantt.Helpers.DateTimeIntersect(args.StartDate, args.EndDate, ra.StartDate, ra.EndDate).TotalDays > 0) { for (int i = 0; i < (int)ts.TotalDays; i++) { Appointment app = null; DateTime dtCurrent = args.StartDate.Date.AddDays(i); if (!calendar.IsWorkingDay(dtCurrent)) continue; KS.Gantt.Calendars.WorkingHourCollection whc = calendar.InheritedWorkingHours(dtCurrent); foreach (KS.Gantt.Calendars.WorkingHour wh in whc) { DateTime whStartDate = dtCurrent.Date.AddHours(wh.StartHour); DateTime whEndDate = dtCurrent.Date.AddHours(wh.EndHour); if (KS.Gantt.Helpers.DateTimeIntersect(ra.StartDate, ra.EndDate, whStartDate, whEndDate).TotalDays > 0) { app = new Appointment(); if (ra.StartDate >= whStartDate) app.StartDate = ra.StartDate; else app.StartDate = whStartDate; if (ra.EndDate >= whEndDate) app.EndDate = whEndDate; else app.EndDate = ra.EndDate; TaskItem task = m_GanttControl.Tasks.FindItemByKey(ra.TaskKey); if (task != null) { app.Color = task.FormatStyle.BackgroundStyle.Color; app.BorderColor = task.FormatStyle.BorderStyle.Color; app.Title = "[" + m_GanttControl.Project.Text + "]\r\n" + task.Text + "\r\n" + ((double)(ra.Unit * 100)).ToString("n0") + "%"; app.Tag = task.Key; } else { app.Color = Color.FromArgb(40, m_GanttControl.DefaultBarFormatStyle.BackgroundStyle.Color); app.BorderColor = Color.FromArgb(40, m_GanttControl.DefaultBarFormatStyle.BorderStyle.Color); app.Title = "[" + ra.ProjectText + "]\r\n" + ra.TaskText + "\r\n" + ((double)(ra.Unit * 100)).ToString("n0") + "%"; app.Tag = ra.TaskKey; } m_Apps.Add(app); } } } } } } args.Appointments = m_Apps; }