using System;
using System.Data;
using System.Data.OleDb;
using DayPilot.Web.Ui.Events;
using DayPilot.Web.Ui.Events.Scheduler;


public partial class SchedulerFreeBusy : System.Web.UI.Page
{
    OleDbConnection bag;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Giris"] != "Yapıldı")
        {
            Response.Redirect("Giris.aspx");
        }
        if (!IsPostBack)
        {
            DayPilotScheduler1.StartDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
            DayPilotScheduler1.Days = DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month);
            Label1.Text = DayPilotScheduler1.StartDate.ToString("MMMM yyyy");
            DayPilotScheduler1.DataSource = getData();
            DataBind();
        }
    }

    protected DataTable getData()
    {
        DataTable dt;
        dt = new DataTable();
        dt.Columns.Add("start", typeof(DateTime));
        dt.Columns.Add("end", typeof(DateTime));
        dt.Columns.Add("id", typeof(string));
        dt.Columns.Add("resource", typeof(string));
        dt.Columns.Add("empty", typeof(string));

        bag = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/App_Data/BSoylu.mdb") + "");
        OleDbCommand komut2;
        string sql2;
        OleDbDataReader oku1;
        sql2 = "SELECT * FROM Veriler";
        komut2 = new OleDbCommand(sql2, bag);
        bag.Open();
        oku1 = komut2.ExecuteReader();
        while (oku1.Read())
        {
            DataRow dr;

            dr = dt.NewRow();
            dr["id"] = oku1["Adi"].ToString();
            dr["start"] = Convert.ToDateTime(oku1["Tarih"] + " " + oku1["Saat1"].ToString());
            dr["end"] = Convert.ToDateTime(oku1["Tarih2"] + " " + oku1["Saat2"].ToString());
            dr["resource"] = "A";
            dt.Rows.Add(dr);
        }

        oku1.Close();
        bag.Close();

       


        return dt;

    }

    protected void DayPilotScheduler1_OnBeforeEventRender(object sender, BeforeEventRenderEventArgs e)
    {
        e.InnerHTML = String.Empty;
    }
}
