using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using hqgl.user;
public partial class CalendarManage_MyCalendar : System.Web.UI.Page
{

    public string str_NoticeMsg;
    protected void Page_Load(object sender, EventArgs e)
    {
        userchuli uch = new userchuli();
        uch.user_yanzheng();
        if (!IsPostBack)
        {
            string name = uch.user_loginname();
            string UserName = name;
            Sqlselete sl = new Sqlselete();
            string id = sl.SelectTeacherID(UserName);
            SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["Connection"]);
            con.Open();
            string sql = "select * from Calendar where id='" + id + "'";
            SqlCommand com = new SqlCommand(sql, con);
            SqlDataReader dr = com.ExecuteReader();
            if (dr.Read())
            {
                str_NoticeMsg = "onload=\"javascript:window.open('ScheduleNotice.aspx?id=" + id + "','','top=1000,left=1000')\"";
            }
            con.Close();
        }
    }
    protected void calSchedule_SelectionChanged(object sender, EventArgs e)
    {

    }
    protected void calSchedule_DayRender(object sender, DayRenderEventArgs e)
    {

        CalendarDay d = ((DayRenderEventArgs)e).Day;

        TableCell c = ((DayRenderEventArgs)e).Cell;

        if (d.IsOtherMonth)
        {
            c.Controls.Clear();
        }
        else
        {
            try
            {
                // ImageButton hl = new ImageButton();
                //AddSchaddup.aspx?reurl=&day=" + d.Date.ToShortDateString();
                //
                // hl.Text="<span style='cursor:hand'    onclick=\"window.open('AddSchaddup.aspx?reurl=MyCalendar.aspx&day=" + d.Date.ToShortDateString()+"','test','width=400,height=300')\">添加日程</span>";
                //底下这3句以后会用的到`~~
                //  Label hl = new Label();
                //hl.Text = "<span style='cursor:hand' onclick=\"window.open('AddSchaddup.aspx?reurl=MyCalendar.aspx&day=" + d.Date.ToShortDateString() + "','test','width=400,height=300,top=250,left=280')\"><image src= '../img/add_small.gif' ></image></span>";
                //hl.ToolTip = "新增个人日程";


                HyperLink hl = new HyperLink();
                hl.ImageUrl = "~/images/img/add_small.gif";
                hl.ToolTip = "新增个人日程";
                hl.NavigateUrl = "AddSchaddup.aspx?reurl=MyCalendar.aspx&day=" + d.Date.ToShortDateString();
                hl.Target = "main";
                c.Controls.Add(new LiteralControl("&nbsp;" + "&nbsp;" + "&nbsp;" + "&nbsp;"));

                c.Controls.Add(hl);


            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }

            userchuli uch = new userchuli();
            string name = uch.user_loginname();
            string UserName = name;

            string Date = d.Date.ToString("d");
            Sqlselete sl = new Sqlselete();
            string ID = sl.SelectTeacherID(UserName);

            SqlDataReader dr = new Sqlselete().SelectCalendar(ID, Date);

            while (dr.Read())
            {

                HtmlAnchor a = new HtmlAnchor();
                a.InnerText = dr["Motif"].ToString();

                // a.ServerClick = "window.open('AddMessage.aspx?id=" + ID + "&day="+d.Date.ToShortDateString()+"','','width=350,height=280,top=250,left=280');";
                a.HRef = "AddSchaddup.aspx?reurl=MyCalendar.aspx&id=" + ID + "&day=" + d.Date.ToShortDateString();
                c.Controls.Add(new LiteralControl("&nbsp;" + "&nbsp;" + "&nbsp;" + "&nbsp;"));
                c.Controls.Add(new LiteralControl("<br>"));
                c.Controls.Add(new LiteralControl("<br>"));
                c.Controls.Add(a);
                c.Controls.Add(new LiteralControl("<br>"));
            }
            dr.Close();
        }
    }
    public DateTime GetDate()
    {
        return DateTime.Now;
    }
    protected void cmdMonth_Click(object sender, EventArgs e)
    {

    }
    protected void cmdWeek_Click(object sender, EventArgs e)
    {

    }
    protected void cmdDay_Click(object sender, EventArgs e)
    {

    }
    protected void cmdQuery_Click(object sender, ImageClickEventArgs e)
    {

    }

    protected void LinkButton1_Click(object sender, EventArgs e)
    {

    }
}
