using System;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Resources;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
public partial class MyCalendar : Base.BasePage
{
    #region Variable Declaration
    ResourceManager rm;
    cls_Common objCommon = new cls_Common();
    EmployeeEventData ObjEmployeeEventData = new EmployeeEventData();
    userRightsEventData objUserRight = new userRightsEventData();
    Dashboard objDash = new Dashboard();
    DataSet dstMyCalendar = new DataSet();
    DataSet dstMyCalendarTeam = new DataSet();
    CultureInfo ci;
    GetReports rptEmp = new GetReports();
    Rpt_Common rptcommon = new Rpt_Common();
    DataSet ds_Checkuser = new DataSet();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    string testing = null;
    #endregion
    #region PageLoad
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (Session["Session_ActiveLanguage"] == null)
            Response.Redirect("Index.aspx");
        if (!Page.IsPostBack)
        {
            objCommon.menu("Dashboard", "246");
        }

        //  string source_Language = string.Empty;
        UserRights();
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        LoadStrings(ci);
        if (Session["Session_ActiveLanguage"] != null)
        {
            source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
            rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
        }
        //dstMyCalendar = objDash.GetMyCalendarData(Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["EmpAutoID"]));
        //string MyCalendarDataString = Convert.ToString(dstMyCalendar.Tables[0].Rows[0]["MyCalendarOutput"]);
        //string strSetAlert = "";
        //strSetAlert = strSetAlert + "<script language='javascript'>";
        //strSetAlert = strSetAlert + "MyCalendarData('" + MyCalendarDataString + "');";
        //strSetAlert = strSetAlert + "</script>";
        //Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        DataSet dsIsSanction = new DataSet();
        dsIsSanction = objDash.GetIsSanctionUser(Convert.ToString(Session["EmpAutoID"]));
        if (dsIsSanction.Tables.Count > 0)
            if (dsIsSanction.Tables[0].Rows.Count > 0)
                liTeamcalendar.Visible = true;
        if (Convert.ToString(Session["UserGroupName"]) == "SuperAdmin")
        {
            liTeamcalendar.Visible = true;
            if (Convert.ToString(Session["EmployeeCodeId"]) == "18000000")
                liUserMycalendar.Visible = false;
        }
        //string strSetAlert = "";
        //dstMyCalendarTeam = objDash.GetMyCalendarDataTeam(Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["EmpAutoID"]));
        //string MyCalendarDataString = Convert.ToString(dstMyCalendarTeam.Tables[0].Rows[0]["MyCalendarOutput"]);
        //strSetAlert = "";
        //strSetAlert = strSetAlert + "<script language='javascript'>";
        //strSetAlert = strSetAlert + "clickTeamcalendar();MyCalendarDataTeam('" + MyCalendarDataString + "');clickUserMycalendar();";
        //strSetAlert = strSetAlert + "</script>";
        //Session["MyData"] = MyCalendarDataString;
        //Page.RegisterStartupScript("CallCalendar", strSetAlert);
        if (!IsPostBack)
        {
            string strdate = DateTime.Now.ToString("yyyy-MM-dd");
            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "ajaxGetmyCalendar('" + strdate + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("CallCalendarDataLoad", strSetAlert);
            //strSetAlert = "";
            //strSetAlert = strSetAlert + "<script language='javascript'>";
            //strSetAlert = strSetAlert + "clickIndividualUser();";
            //strSetAlert = strSetAlert + "</script>";
            //Page.RegisterStartupScript("IndividualUser", strSetAlert);
        }
    }
    #endregion
    #region UserDefinedFunctions
    private void LoadStrings(CultureInfo ci)
    {
        lblteamLeave.Text = lblLeave.Text = rm.GetString("MyCalendar_Leave", ci);
        lblteamAbsent.Text = lblAbsent.Text = rm.GetString("MyCalendar_Absent", ci);
        lblHoliday.Text = rm.GetString("MyCalendar_Holiday", ci);
        lblWeeklyOff.Text = rm.GetString("MyCalendar_WeekOff", ci);
        lblEHlegend.Text = rm.GetString("MyCalendar_EHlegend", ci);
        lblEHrs.Text = rm.GetString("MyCalendar_EHrs", ci);
        lblHw.Text = rm.GetString("MyCalendar_Hw", ci);
        lblteamPresent.Text = lblPresent.Text = "Present";
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(246, Convert.ToInt32(Session["userGroup_Id"]), "");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
            Response.Redirect("Landing.aspx");
    }
    #endregion
    protected void btnApply_Click(object sender, EventArgs e)
    {
        if (rbtLeaveApplication.Checked == true)
            Response.Redirect("Transactions/TA_UI_Transactions_LeaveApplicationAdd.aspx");
        else if (rbtPermissionApplication.Checked == true)
            Response.Redirect("Transactions/TA_UI_Transactions_LeavePermissionAdd.aspx");
        else if (rbtOnduty.Checked == true)
            Response.Redirect("Transactions/TA_UI_Transactions_OnDutyAdd.aspx");
    }
}