DHTMLX Scheduler,连接到数据库

时间:2019-01-03 12:23:14

标签: asp.net dhtmlx

我正在使用asp.net mvc创建一个应用程序来跟踪员工的假期。我在SQL Server中创建了两个表。一个是雇员及其信息的列表,另一个是休假申请表。

我已决定使用DHTLMX计划程序来显示员工何时休假。

到目前为止,我已经使用时间轴视图设置了调度程序,并创建了一些模拟数据,如下所示

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.Mvc;


 using DHTMLX.Scheduler;
 using DHTMLX.Common;
 using DHTMLX.Scheduler.Data;
 using DHTMLX.Scheduler.Controls;

 using LotusWorksHolidayTracker.Models;
 namespace LotusWorksHolidayTracker.Controllers
{
public class CalendarController : Controller
{
    public ActionResult Index()
    {
        var sched = new DHXScheduler(this);
        sched.Config.readonly_form = true;
        sched.Views.Clear();
        sched.InitialDate = new DateTime(2019, 1, 1);


        var unit = new UnitsView("timeline", "key");
        sched.InitialView = unit.Name;

        sched.LoadData = true;
        var dbcontext = new LotusworksHTEntities();


        var timeline = new TimelineView("timeline", "Employee Name"); // initializes the view
        timeline.FolderEventsAvailable = false;
        timeline.RenderMode = TimelineView.RenderModes.Tree;



       var section = timeline.AddOption(new TimelineUnit("1", "Full Day", true));

       section.AddOption(new TimelineUnit("2", "Conor Bloggs")); // defines the items of the folder
       section.AddOption(new TimelineUnit("3", "Joe Bloggs"));

       var section2 = timeline.AddOption(new TimelineUnit("2", "Shift C", true));

       section2.AddOption(new TimelineUnit("5", "Tom Bloggs"));
       section2.AddOption(new TimelineUnit("6", "Tim Bloggs"));

        timeline.FitEvents = false;
        timeline.SectionAutoheight = false;
        timeline.Dy = 25; 
        timeline.X_Unit = TimelineView.XScaleUnits.Day;
        timeline.X_Date = "%j";
        timeline.X_Step = 1;
        timeline.X_Size = 31;
        sched.Views.Add(timeline);





        sched.TimeSpans.Add(new DHXMarkTime() {
        Day = DayOfWeek.Saturday,
        CssClass = "green_section", 
        SpanType = DHXMarkTime.Type.Default
        });

        sched.TimeSpans.Add(new DHXMarkTime()
        {
            Day = DayOfWeek.Sunday,
            CssClass = "green_section",
            SpanType = DHXMarkTime.Type.Default
        });



return View(sched);

这为我提供了正确的格式,但是我需要使用数据库中的数据而不是模拟数据,如何使用员工姓名,左侧和假期将数据库连接到调度程序他们承担调度程序本身。

0 个答案:

没有答案