using System;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.XtraCharts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;

public partial class DashBoardChart : Base.BasePage
{
    #region Variable Declaration
    ResourceManager rm;
    cls_Common objClas = new cls_Common();
    ShiftEvenData objShift = new ShiftEvenData();
    cls_Common objCommon = new cls_Common();
    EmployeeEventData ObjEmployeeEventData = new EmployeeEventData();
    userRightsEventData objUserRight = new userRightsEventData();
    Dashboard objDash = new Dashboard();
    DataSet dstAttendance = new DataSet();
    GetReports objReport = new GetReports();
    CultureInfo ci;
    GetReports rptEmp = new GetReports();
    Rpt_Common rptcommon = new Rpt_Common();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    string gstrUserGroupName = string.Empty;
    string SelectedShift = string.Empty;
    string From_Date = string.Empty;
    string LevelId = string.Empty;
    int intIndividualUser = 0;
    string marqText = string.Empty;
    string strEmpAutoId = "0";
    int payrollConfig = 0;
    #endregion
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        //get the culture info to set the language
        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;
        if (!Page.IsPostBack)
        {
            //base.CheckPages(50);
            //LoadNews();
            // checking license expiry date 
            //CheckDemoVersion();
            //News.Visible = false;
            ViewState["Board"] = "Bootstrap";
            Hidden2.Value = Convert.ToString(Session["IDateFormat"]);
            if (Session["SessionDashboardType"] == null)
            {
                Session.Add("SessionDashboardType", "");
            }
            Session["isDashBoard"] = "No";
            objCommon.menu("Dashboard", "179");
            LoadStrings(ci);
            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "MaxLengthh('" + rm.GetString("Alert_MaximumLengthis", ci) + "');";
            strSetAlert = strSetAlert + "SetAlertMessages('" + rm.GetString("Alert_EnterDate", ci) + "','" + rm.GetString("Alert_EnterToDate", ci) + "','" + rm.GetString("Alert_Selectshiftdate", ci) + "');";
            strSetAlert = strSetAlert + "SetAlertCheckDate('" + rm.GetString("Alert_Validmonthdatefourdigit", ci) + "','" + rm.GetString("Alert_Validdatemonthfourdigit", ci) + "','" + rm.GetString("Alert_Invalidyearentry", ci) + "','" + rm.GetString("Alert_Invalidmonthentry", ci) + "','" + rm.GetString("Alert_Invaliddateentry", ci) + "','" + rm.GetString("Alert_IncorrectdateformatDDMONYYYY", ci) + "','" + rm.GetString("Alert_Entertime", ci) + "','" + rm.GetString("Alert_Invalidvalueforhours", ci) + "','" + rm.GetString("Alert_Invalidvalueforminites", ci) + "','" + rm.GetString("Alert_Invalidtimeformat1", ci) + "','" + rm.GetString("Alert_PleaseentervalidDateandTime", ci) + "','" + rm.GetString("Alert_ValiddatemonthMMDDYYHHMM", ci) + "','" + rm.GetString("Alert_ValiddatemonthMMDDYYHHMMTT", ci) + "','" + rm.GetString("Alert_PleaseentervalidDateandTime", ci) + "','" + rm.GetString("Alert_Invalidvalueforhours", ci) + "','" + rm.GetString("Alert_Invalidvalueforminites", ci) + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        }
        payrollConfig = objCommon.CheckPageExistsInLicense(185);
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        if(!IsPostBack)
        {
            CompanyBinding();
        }
        
        LoadDash();
        exportData.Attributes.Add("src", "");
        if (Session["Session_ActiveLanguage"] == null)
        {
            Response.Redirect("Index.aspx");
        }
        if (Session["SanctionUrl"] != null)
        {
            Response.Redirect(Session["SanctionUrl"].ToString());
        }
        //  string source_Language = string.Empty;
        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;
            userRightsEventData objClass = new userRightsEventData();
            DataSet ds = new DataSet();
            ds = objClass.SelectLevelRights(Convert.ToInt32(Session["userGroup_Id"]));
            Session["LevelRights"] = "0";
            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["LevelId"] != DBNull.Value)
                        {
                            string strLevelID = Convert.ToString(ds.Tables[0].Rows[0]["LevelId"]);
                            Session["LevelRights"] = strLevelID;
                        }
                    }
                }
            }
            //GenerateMenu();
            CheckMandatoryPage();
        }
        Hidden1.Value = Convert.ToString(Session["IDateFormat"]);
        if (!IsPostBack)
        {
            cls_master_levels class1 = new cls_master_levels();
            DataSet ds = new DataSet();
            if (Session["UserGroupName"] != null)
            {
                ds = class1.getOrgLevelUpdated(0, Convert.ToString(Session["LevelRights"]), 0, Convert.ToString(Session["UserGroupName"]));
            }
            Session["OrgLevels"] = ds;
            if (txtFrom.Text == "")
            {
                txtFrom.Text = (Convert.ToDateTime(System.DateTime.Now.ToShortDateString())).ToString(Session["MDateFormat"].ToString());
                //txtTo.Text = (Convert.ToDateTime(System.DateTime.Now.ToShortDateString())).ToString(Session["MDateFormat"].ToString());
                //lbldisplayShiftDate.Text = txtFrom.Text;
            }
            //fillShift();
            if (Request.QueryString["Shift"] != null)
            {
                SelectedShift = Convert.ToString(Request.QueryString["Shift"]);
            }
            if (Request.QueryString["From_Date"] != null)
            {
                From_Date = Convert.ToString(Request.QueryString["From_Date"]);
            }
        }
        if (From_Date != string.Empty)
        {
            txtFrom.Text = (Convert.ToDateTime(From_Date)).ToString(Convert.ToString(Session["MDateFormat"]));
            //txtTo.Text = (Convert.ToDateTime(From_Date)).ToString(Convert.ToString(Session["MDateFormat"]));
        }
        if (Request.QueryString["LevelId"] != null)
            LevelId = Convert.ToString(Request.QueryString["LevelId"]);
        //if (ddlShift.SelectedIndex > 0)
        //    SelectedShift = ddlShift.SelectedItem.Value;
        //if (SelectedShift != string.Empty)
        //    ddlShift.SelectedItem.Value = SelectedShift;
        if (!IsPostBack)
        {
            if (Convert.ToString(Session["IsDashboardEnable"]) == "Yes")
            {
                //trFiller.Visible = true;
                //trFilterShowHide.Visible = true;
                trDashboard.Visible = true;
                trLanding.Visible = false;
            }
            else
            {
                lblDemo.Visible = true;
                trDashboard.Visible = false;
                //trFiller.Visible = false;
                //trFilterShowHide.Visible = false;
                trLanding.Visible = true;
            }
           // LoadDashBoardDetails();
        }
        //Check whether the employee is Individual User
        if (Convert.ToString(ViewState["Dash_IndividualUser"]) == "")
        {
            intIndividualUser = objCheckUser.CheckIndividualUser(Convert.ToString(Session["UserGroupName"]));
            ViewState["Dash_IndividualUser"] = intIndividualUser;
        }
        else
        {
            intIndividualUser = Convert.ToInt32(ViewState["Dash_IndividualUser"]);
        }
        //OrgFilter.Visible = (intIndividualUser >= 1) ? false : true;
        //lnkbtnshiftNotAllocation.Visible = (intIndividualUser >= 1) ? false : true;

        if (Convert.ToString(Session["LateEmailSave"]) == String.Empty)
        {

        }
        else
        {
            if (Convert.ToString(Session["LateEmailSaves"]) != String.Empty)
            {
                string strScript;
                strScript = "<script language='javascript'>";
                strScript = strScript + "alert('" + "Reason Save successfully" + "');";
                strScript = strScript + "</script>";
                Page.RegisterStartupScript("Alert", strScript);
            }
            string strScripts;
            strScripts = "<script language='javascript'>";
            strScripts = strScripts + "alert('" + "Reason Save successfully" + "');";
            strScripts = strScripts + "</script>";
            Page.RegisterStartupScript("Alert", strScripts);
        }


        string strScri;
        strScri = "<script language='javascript'>";
        strScri = strScri + "binddata();";
        strScri = strScri + "</script>";
        Page.RegisterStartupScript("Alert", strScri);



        
        if (!IsPostBack)
        {
            ChartValuesLoad();
            ChartValueforDepartment();
            ChartValueforAbsentDepartment();
            DllYearLoad();
        }
        //lblDataFor.Text = rm.GetString("AttendanceData_Dashboard", ci);
        grv_EmployeesLeaveDetail.DataSource = null;
        grv_EmployeesLeaveDetail.Visible = false;

    }

    private void ChartValueforDepartment()
    {
       
        DataSet datase = new DataSet();
        if (txtAttednaceFromDt.Text!="")
        {
            datase = objClas.SelectDepartmentwiseChart(0, 0, txtAttednaceFromDt.Text, txtAttednaceFromDt.Text);
        }
        else
        {
            string FromDate = DateTime.Now.ToString("dd/MM/yyyy");

            datase = objClas.SelectDepartmentwiseChart(0, 0,FromDate,FromDate);
        }

        //datase = objClas.SelectDepartmentwiseChart(0, 0, "01/July/2024", "04/July/2024");
        String DepartmentName = "";
        String DepartmentMonth = "";
        String DepartmentDaily = "";
        LblHdnLeave.Value = "";
        if (datase.Tables[0].Rows.Count != null)
        {
            int Co = 1;
            int Count = datase.Tables[0].Rows.Count;
            for (int i = 0; i < datase.Tables[1].Rows.Count; i++)
            {
                if(rbtn_Daily.Checked==true)
                {
                    
                    if (Count == i + 1)
                    {
                        DepartmentDaily = DepartmentDaily + datase.Tables[1].Rows[i]["Day" + Co + "_Present_Count"].ToString();
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString();
                    }
                    else
                    {
                        DepartmentDaily = DepartmentDaily + datase.Tables[1].Rows[i]["Day" + Co + "_Present_Count"].ToString() + ",";
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString() + ",";
                    }
                    Co = Co + 1;

                }
                else  if (rbtn_Monthly.Checked==true)
                {
                    if (Count == i + 1)
                    {
                        DepartmentMonth = DepartmentMonth + datase.Tables[1].Rows[i]["TotalPercenatge"].ToString();
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString();
                    }
                    else
                    {
                        DepartmentMonth = DepartmentMonth + datase.Tables[1].Rows[i]["TotalPercenatge"].ToString() + ",";
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString() + ",";
                    }
                   
                }
                
                
            }
            if(DepartmentDaily != "")
            {
                HdnDepartmentDaily.Value = Convert.ToString(DepartmentDaily);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "1";
            }
            else
            {
                HdnDeparmentMonth.Value = Convert.ToString(DepartmentMonth);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "0";
            }
            
        }

    }

    private void ChartValueforAbsentDepartment()
    {
        int companyId=Convert.ToInt32(ddlAbsentCompany.SelectedValue);
        DataSet datase = new DataSet();
        string isflag = string.Empty;
        if(rbtnDaily1.Checked)
        {
            isflag = "0";
        }
        else
        {
            isflag = "1";
        }
        if (txtAttednaceFromDt.Text != "")
        {
            datase = objClas.SelectAbsentDepartmentwiseChart(0, companyId, txtAttednaceFromDt.Text, txtAttednaceFromDt.Text, isflag);
        }
        else
        {
            string hdnFomat = Hidden2.Value;
            string FromDate = DateTime.Now.ToString("dd-MMM-yyyy");
            txtAbsentFromDt.Text = FromDate;
            datase = objClas.SelectAbsentDepartmentwiseChart(0, companyId, FromDate, FromDate,isflag);

        }

        //datase = objClas.SelectDepartmentwiseChart(0, 0, "01/July/2024", "04/July/2024");
        String DepartmentName = "";
        String DepartmentMonth = "";
        String DepartmentDaily = "";
        LblHdnLeave.Value = "";
        if (datase.Tables[0].Rows.Count != null)
        {
            int Co = 1;
            int Count = datase.Tables[1].Rows.Count;
            foreach (DataRow dr in datase.Tables[1].Rows)
            {
                DepartmentDaily = DepartmentDaily + dr["TotalPercenatge"].ToString() +",";
                DepartmentName = DepartmentName + dr["name"].ToString()+",";
            }
        
            if (DepartmentDaily != "")
            {
                HdnDepartmentDaily.Value = Convert.ToString(DepartmentDaily);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "1";
            }
            else
            {
                HdnDeparmentMonth.Value = Convert.ToString(DepartmentMonth);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "0";
            }

        }


    }

    private void DllYearLoad()
    {
        cls_Common objClas = new cls_Common();
        DataSet datase = new DataSet();
        datase = objClas.SelectDashBoardYear();

        DllYear.DataSource = datase;
        DllYear.DataTextField = "StartYear";
        DllYear.DataValueField = "YearSettings_Id";
        DllYear.DataBind();
        //DllYear.Items.Add("-Select-");
        //DllYear.SelectedValue = "-Select-";
        // DllYear.SelectedValue = "0";
        String YY = Convert.ToDateTime(txtFrom.Text).ToString("yyyy");
        DllYear.Items.Add(YY);
        DllYear.SelectedValue = YY;

        

    }

    private void ChartValuesLoad()
    {
        String DA = txtFrom.Text.ToString();
        

        if(Session["MDateFormat"].ToString() == "dd/MM/yyyy")
        {
            DateTime parsedDate = DateTime.ParseExact(DA, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            txtFrom.Text = parsedDate.ToString("MM-dd-yyyy");
        }
        else if (Session["MDateFormat"].ToString() == "dd-MMM-yyyy")
        {
            DateTime parsedDate = DateTime.ParseExact(DA, "dd-MMM-yyyy", CultureInfo.InvariantCulture);
            txtFrom.Text = parsedDate.ToString("MM-dd-yyyy");
        }
        
        DllSelectYear.Value = Convert.ToDateTime(txtFrom.Text).ToString("yyyy");

        String Year = txtFrom.Text;
        

        #region Leave
        cls_Common objClas = new cls_Common();
        DataSet datase = new DataSet();
        String Tag = "";
        int EmployeeId = Convert.ToInt32(Session["EmpAutoID"]);
        if(EmployeeId==1)
        {
            Tag = "Admin";
            
        }
        else
        {
            cls_Common objClasE = new cls_Common();
            DataSet dataseE = new DataSet();
            dataseE = objClasE.SelectNewDashBoardemployeeGet(EmployeeId);
            //Reporting_To,Leave_Sanc_Authority
            String ReportTo = dataseE.Tables[0].Rows[0]["Reporting_To"].ToString();
            String Authority = dataseE.Tables[0].Rows[0]["Leave_Sanc_Authority"].ToString();
            if(ReportTo == "0" || Authority=="0")
            {
                cls_Common objClasER = new cls_Common();
                DataSet dataseER = new DataSet();
                dataseER = objClasER.SelectNewDashBoardReportToEmployee(EmployeeId);
                if(dataseER.Tables[0].Rows.Count == 0)
                {
                    btnGo.Enabled = false;

                }
                else
                {
                   // btnGo.Enabled = true;
                }
                

            }




        }
        datase = objClas.SelectPredectionChart(Year, Tag, EmployeeId);
        String leaveCount = "";
        String TotaolLeave = "";
        LblHdnLeave.Value = "";
        if (datase.Tables[0].Rows.Count != null)
        {
            int Count = datase.Tables[0].Rows.Count;
            for (int i = 0; i < datase.Tables[0].Rows.Count; i++)
            {
                leaveCount = datase.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if(Count == i+1)
                {
                    TotaolLeave = TotaolLeave + leaveCount;
                }
                else
                {
                    TotaolLeave = TotaolLeave + leaveCount + ",";
                }

                
            }
            Session["HdnLeave"] = TotaolLeave.ToString();
            LblHdnLeave.Value = Convert.ToString(Session["HdnLeave"]);

            cls_Common objClasED = new cls_Common();
            DataSet dataseED = new DataSet();
            dataseED = objClasED.getEmployeeDetailForYearGrid(Year, Tag, EmployeeId);
            grv_AnalysisYear.DataSource = dataseED;
            grv_AnalysisYear.DataBind();

        }
        String YY = Convert.ToString(Convert.ToDateTime(txtFrom.Text).ToString("yyyy"));
        DllYear.SelectedItem.Value = YY;
        DllYear.DataBind();
        #endregion

        #region Latein
        cls_Common objClasLate = new cls_Common();
        DataSet dataseLAte = new DataSet();

        dataseLAte = objClasLate.SelectPredectionChartforLateIN(Year, Tag, EmployeeId);
        String leaveCountLate = "";
        String TotaolLeaveLate = "";

        HdnLate.Value = "";
        if (dataseLAte.Tables[0].Rows.Count != null)
        {
            int Count = dataseLAte.Tables[0].Rows.Count;
            for (int i = 0; i < dataseLAte.Tables[0].Rows.Count; i++)
            {
                leaveCountLate = dataseLAte.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeaveLate = TotaolLeaveLate + leaveCountLate;
                }
                else
                {
                    TotaolLeaveLate = TotaolLeaveLate + leaveCountLate + ",";
                }


            }

            HdnLate.Value = TotaolLeaveLate.ToString(); 


        }


        #endregion

        #region Absent
        cls_Common objClasAbsent = new cls_Common();
        DataSet dataseAbsent = new DataSet();
        HdnAbsent.Value = "";
        dataseAbsent = objClasAbsent.SelectPredectionChartforAbsnet(Year, Tag, EmployeeId);
        String leaveCountAbsent = "";
        String TotaolLeaveAbsent = "";


        if (dataseAbsent.Tables[0].Rows.Count != null)
        {
            int Count = dataseAbsent.Tables[0].Rows.Count;
            for (int i = 0; i < dataseAbsent.Tables[0].Rows.Count; i++)
            {
                leaveCountAbsent = dataseAbsent.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeaveAbsent = TotaolLeaveAbsent + leaveCountAbsent;
                }
                else
                {
                    TotaolLeaveAbsent = TotaolLeaveAbsent + leaveCountAbsent + ",";
                }


            }
            HdnAbsent.Value = TotaolLeaveAbsent.ToString(); 

        }
        #endregion


        #region Early Exit

        cls_Common objClasEE = new cls_Common();
        DataSet dataseEEt = new DataSet();

        dataseEEt = objClasEE.SelectPredectionChartforEarlyExit(Year, Tag, EmployeeId);
        String leaveCountEE = "";
        String TotaolLeaveEE = "";
        HdnEarlyExit.Value = "";

        if (dataseEEt.Tables[0].Rows.Count != null)
        {
            int Count = dataseEEt.Tables[0].Rows.Count;
            for (int i = 0; i < dataseEEt.Tables[0].Rows.Count; i++)
            {
                leaveCountAbsent = dataseEEt.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeaveEE = TotaolLeaveEE + leaveCountAbsent;
                }
                else
                {
                    TotaolLeaveEE = TotaolLeaveEE + leaveCountAbsent + ",";
                }


            }

            HdnEarlyExit.Value = TotaolLeaveEE.ToString();
        }

        #endregion



    }



    private void ChartValuesLoadClick()
    {
        int ParentID = Convert.ToInt32(Session["parentLevelId"]);
        String UserGroup = Convert.ToString(Session["UserGroupName"]);
        String GradeLevel = Convert.ToString(Session["GradeLevel"]);
        DllSelectYear.Value = DllYear.SelectedItem.ToString();
        //DllSelectYear.Value = txtFrom.Text;
        String Tag = "";
        int EmployeeId = Convert.ToInt32(Session["EmpAutoID"]);
        String Year = DllYear.SelectedItem.Text.ToString();
        cls_Common objClass = new cls_Common();
        DataSet datases = new DataSet();
        
        if(txtEmployeeId.Text == "")
        {

        }
        else
        {
            datases = objClass.getEmployeeAutoId(EmployeeId);
            if(datases.Tables[0].Rows.Count == 0)
            {
                
            }
            else
            {
                for (int i =0;i < datases.Tables[0].Rows.Count; i++)
                {
                   String EmpID= datases.Tables[0].Rows[i]["Employee_Code_Id"].ToString(); 
                    if (EmpID== txtEmployeeId.Text)
                    {
                        String EmpAutoID = datases.Tables[0].Rows[i]["Employee_Id"].ToString();
                        EmployeeId = Convert.ToInt32(EmpAutoID);

                    }
                    else
                    {
                         EmployeeId = Convert.ToInt32(Session["EmpAutoID"]);
                        string strScripts;
                        strScripts = "<script language='javascript'>";
                        strScripts = strScripts + "Not Eligible to Open This Employee";
                        strScripts = strScripts + "</script>";
                        Page.RegisterStartupScript("Alert", strScripts);


                    }
                }
                    
            }
        }


        #region Leave
        cls_Common objClas = new cls_Common();
        DataSet datase = new DataSet();
        
        if (EmployeeId == 1)
        {
            Tag = "Admin";

        }
        else
        {
            cls_Common objClasE = new cls_Common();
            DataSet dataseE = new DataSet();
            dataseE = objClasE.SelectNewDashBoardemployeeGet(EmployeeId);
            //Reporting_To,Leave_Sanc_Authority
            String ReportTo = dataseE.Tables[0].Rows[0]["Reporting_To"].ToString();
            String Authority = dataseE.Tables[0].Rows[0]["Leave_Sanc_Authority"].ToString();
            if (ReportTo == "0" || Authority == "0")
            {

                cls_Common objClasER = new cls_Common();
                DataSet dataseER = new DataSet();
                dataseER = objClasER.SelectNewDashBoardReportToEmployee(EmployeeId);
                if (dataseER.Tables[0].Rows.Count == 0)
                {
                    btnGo.Enabled = false;

                }
                else
                {
                    if(txtEmployeeId.Text == "")
                    {

                    }
                    else
                    {
                        cls_Common objClasEEE = new cls_Common();
                        DataSet dataseEE = new DataSet();
                        dataseEE = objClasEEE.getEmployeeFilterEmpCode(txtEmployeeId.Text);
                        String EmpFilterAutoIdGet = dataseEE.Tables[0].Rows[0]["Employee_Id"].ToString();

                        for (int i=0;i < dataseER.Tables[0].Rows.Count; i++)
                        {
                            String EmployeeCheck = dataseER.Tables[0].Rows[i]["Employee_Id"].ToString();
                            
                            
                            if (EmployeeCheck== EmpFilterAutoIdGet)
                            {
                                //cls_Common objClasEEE = new cls_Common();
                                //DataSet dataseEE = new DataSet();
                                //dataseEE = objClasEEE.getEmployeeFilterEmpCode(txtEmployeeId.Text);
                                //String EmpFilterAutoIdGet = dataseER.Tables[0].Rows[i]["Employee_Id"].ToString();
                                EmployeeId = Convert.ToInt32(EmpFilterAutoIdGet);
                            }
                        }
                        


                        
                    }
                    // btnGo.Enabled = true;
                }
            }

        }

        if(Tag=="Admin" && txtEmployeeId.Text != "")
        {
            cls_Common objClasEEE = new cls_Common();
            DataSet dataseEE = new DataSet();
            dataseEE = objClasEEE.getEmployeeFilterEmpCode(txtEmployeeId.Text);
            String EmpFilterAutoIdGet = dataseEE.Tables[0].Rows[0]["Employee_Id"].ToString();
            EmployeeId = Convert.ToInt32(EmpFilterAutoIdGet);
        }


        datase = objClas.SelectPredectionChart(Year, Tag, EmployeeId);
        String leaveCount = "";
        String TotaolLeave = "";
        if (datase.Tables[0].Rows.Count != null)
        {
            int Count = datase.Tables[0].Rows.Count;
            for (int i = 0; i < datase.Tables[0].Rows.Count; i++)
            {
                leaveCount = datase.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeave = TotaolLeave + leaveCount;
                }
                else
                {
                    TotaolLeave = TotaolLeave + leaveCount + ",";
                }


            }
            Session["HdnLeave"] = TotaolLeave.ToString();
            LblHdnLeave.Value = Convert.ToString(Session["HdnLeave"]);
        }
        cls_Common objClasEDs = new cls_Common();
        DataSet dataseEDs = new DataSet();
        dataseEDs = objClasEDs.getEmployeeDetailForYearGrid(Year, Tag, EmployeeId);
        grv_AnalysisYear.DataSource = dataseEDs;
        grv_AnalysisYear.DataBind();


        #endregion

        #region Latein
        cls_Common objClasLate = new cls_Common();
        DataSet dataseLAte = new DataSet();

        dataseLAte = objClasLate.SelectPredectionChartforLateIN(Year, Tag, EmployeeId);
        String leaveCountLate = "";
        String TotaolLeaveLate = "";


        if (dataseLAte.Tables[0].Rows.Count != null)
        {
            int Count = dataseLAte.Tables[0].Rows.Count;
            for (int i = 0; i < dataseLAte.Tables[0].Rows.Count; i++)
            {
                leaveCountLate = dataseLAte.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeaveLate = TotaolLeaveLate + leaveCountLate;
                }
                else
                {
                    TotaolLeaveLate = TotaolLeaveLate + leaveCountLate + ",";
                }


            }

            HdnLate.Value = TotaolLeaveLate.ToString();


        }


        #endregion

        #region Absent
        cls_Common objClasAbsent = new cls_Common();
        DataSet dataseAbsent = new DataSet();

        dataseAbsent = objClasAbsent.SelectPredectionChartforAbsnet(Year, Tag, EmployeeId);
        String leaveCountAbsent = "";
        String TotaolLeaveAbsent = "";


        if (dataseAbsent.Tables[0].Rows.Count != null)
        {
            int Count = dataseAbsent.Tables[0].Rows.Count;
            for (int i = 0; i < dataseAbsent.Tables[0].Rows.Count; i++)
            {
                leaveCountAbsent = dataseAbsent.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeaveAbsent = TotaolLeaveAbsent + leaveCountAbsent;
                }
                else
                {
                    TotaolLeaveAbsent = TotaolLeaveAbsent + leaveCountAbsent + ",";
                }


            }
            HdnAbsent.Value = TotaolLeaveAbsent.ToString();

        }
        #endregion


        #region Early Exit

        cls_Common objClasEE = new cls_Common();
        DataSet dataseEEt = new DataSet();

        dataseEEt = objClasEE.SelectPredectionChartforEarlyExit(Year, Tag, EmployeeId);
        String leaveCountEE = "";
        String TotaolLeaveEE = "";


        if (dataseEEt.Tables[0].Rows.Count != null)
        {
            int Count = dataseEEt.Tables[0].Rows.Count;
            for (int i = 0; i < dataseEEt.Tables[0].Rows.Count; i++)
            {
                leaveCountAbsent = dataseEEt.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
                if (Count == i + 1)
                {
                    TotaolLeaveEE = TotaolLeaveEE + leaveCountAbsent;
                }
                else
                {
                    TotaolLeaveEE = TotaolLeaveEE + leaveCountAbsent + ",";
                }


            }

            HdnEarlyExit.Value = TotaolLeaveEE.ToString();
        }

        #endregion



    }


   
    #region UserDefinedFunctions
    private void LoadStrings(CultureInfo ci)
    {
        
        lbl_DashHeader.Text = rm.GetString("Menu_Master_Dashboard", ci);
        //lbl_Filter.Text = rm.GetString("lblFilter", ci);
        lblShiftDate.Text = "Year";
        lbl_ToDate.Text ="To Date";
        btnGo.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Search", ci);
        lblCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        lblAbsentCompany.Text = rm.GetString("EntranceMaster_Company", ci);
        //App_Dash.Attributes.Add("title", rm.GetString("Menu_Master_Dashboard", ci));
        //App_Grid.Attributes.Add("title", rm.GetString("Dash_Grid", ci));
        //App_Chart.Attributes.Add("title", rm.GetString("Dash_Chart", ci));

        lblShiftDate.Text = "From Date";   
        HtmlGenericControl li = new HtmlGenericControl("li");
        
    }
    protected void CheckMandatoryPage()
    {
        cls_Common objClass = new cls_Common();
        DataSet ds = new DataSet();
        if (Convert.ToString(ViewState["MandatoryPageDetails"]) == "")
        {
            ds = objClass.GetCheckMandatory();
            ViewState["MandatoryPageDetails"] = ds;
        }
        else
        {
            ds = (DataSet)ViewState["MandatoryPageDetails"];
        }
        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {
            if (ds.Tables[0].Rows[0]["MandatoryChecking"] != DBNull.Value && Convert.ToInt16(ds.Tables[0].Rows[0]["MandatoryChecking"]) == 0)
                Session["CheckMandatoryPage"] = "Not Required";
            else
                Session["CheckMandatoryPage"] = "Required";
        }
        else
            Session["CheckMandatoryPage"] = "Required";
    }


    private bool UserRightsFromID(int pageID)
    {
        //Leave-->24
        //Onduty-->174
        //Permission-->25
        DataSet ds_Checkuser = new DataSet();
        ds_Checkuser = objCheckUser.checkRights(pageID, Convert.ToInt32(Session["userGroup_Id"]), "viewPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    private void GetSanctionPageRight(string leave, string onduty, string permission)
    {
        bool blLeave = false, blPermission, blOnduty;
        if (leave == "1")
        {
            if (Convert.ToString(ViewState["blLeave"]) == "")
            {
                blLeave = UserRightsFromID(248);
                ViewState["blLeave"] = blLeave;
            }
            else
            {
                blLeave = (bool)ViewState["blLeave"];
            }
            EnableDisableLeaveControls(blLeave);
        }
        if (permission == "1")
        {
            if (Convert.ToString(ViewState["blPermission"]) == "")
            {
                blPermission = UserRightsFromID(248);
                ViewState["blPermission"] = blPermission;
            }
            else
            {
                blPermission = (bool)ViewState["blPermission"];
            }
            EnableDisablePermissionControls(blPermission);
        }
        if (onduty == "1")
        {
            if (Convert.ToString(ViewState["blOnduty"]) == "")
            {
                blOnduty = UserRightsFromID(248);
                ViewState["blOnduty"] = blOnduty;
            }
            else
            {
                blOnduty = (bool)ViewState["blOnduty"];
            }
            EnableDisableOndutyControls(blOnduty);
        }
    }
    private void EnableDisableOndutyControls(bool isTrue)
    {
        //btnOndutyApproved.Enabled = isTrue;
        //btnOndutyForwarded.Enabled = isTrue;
        //btnLeavePending.Enabled = isTrue;
    }
    private void EnableDisablePermissionControls(bool isTrue)
    {
        //btnPermissionApproved.Enabled = isTrue;
        //btnPermissionForwarded.Enabled = isTrue;
        //btnPermissionPending.Enabled = isTrue;
    }
    private void EnableDisableLeaveControls(bool isTrue)
    {
        //btnLeaveApproved.Enabled = isTrue;
        //btnLeaveForwarded.Enabled = isTrue;
        //btnLeavePending.Enabled = isTrue;
    }
    #endregion
    #region PieChartEvents
    protected void WebChartControl1_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        try
        {
            PieDrawOptions options = (PieDrawOptions)e.SeriesDrawOptions;
            GradientFillOptionsBase gradientOptions = ((GradientFillOptionsBase)options.FillStyle.Options);
            options.FillStyle.FillMode = FillMode.Solid;
            switch (Convert.ToString(e.SeriesPoint.Argument))
            {
                case "Pending":
                    options.Color = Color.FromArgb(0, 166, 90);
                    e.LegendDrawOptions.Color = Color.FromArgb(0, 166, 90);
                    break;
                case "Forwarded":
                    options.Color = Color.FromArgb(210, 0, 0);
                    e.LegendDrawOptions.Color = Color.FromArgb(210, 0, 0);
                    break;
                case "Approved":
                    options.Color = Color.FromArgb(60, 141, 188);
                    e.LegendDrawOptions.Color = Color.FromArgb(60, 141, 188);
                    break;
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void devPieChartAdd_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        PieDrawOptions options = (PieDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode.Solid;
        ((PieSeriesLabel)e.Series.Label).Position = PieSeriesLabelPosition.Inside;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Present":
                options.Color = Color.FromArgb(131, 218, 246);
                e.LegendDrawOptions.Color = Color.FromArgb(131, 218, 246);
                break;
            case "Absent":
                options.Color = Color.FromArgb(255, 174, 174);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 174, 174);
                break;
            case "LeaveTaken":
                options.Color = Color.FromArgb(0, 204, 113);
                e.LegendDrawOptions.Color = Color.FromArgb(0, 204, 113);
                break;
            case "OnDuty":
                options.Color = Color.FromArgb(171, 220, 131);
                e.LegendDrawOptions.Color = Color.FromArgb(171, 220, 131);
                break;
            case "AttendanceSummary":
                options.Color = Color.FromArgb(203, 151, 225);
                e.LegendDrawOptions.Color = Color.FromArgb(203, 151, 225);
                break;
            case "Punctuality":
                options.Color = Color.FromArgb(255, 182, 108);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 182, 108);
                break;
        }
    }
    protected void devPieChartAssign_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        Pie3DDrawOptions options = (Pie3DDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode3D.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Present":
                options.Color = Color.FromArgb(131, 218, 246);
                e.LegendDrawOptions.Color = Color.FromArgb(131, 218, 246);
                break;
            case "Absent":
                options.Color = Color.FromArgb(255, 174, 174);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 174, 174);
                break;
            case "Approved Leave":
                options.Color = Color.FromArgb(0, 204, 113);
                e.LegendDrawOptions.Color = Color.FromArgb(0, 204, 113);
                break;
            case "Approved OnDuty":
                options.Color = Color.FromArgb(171, 220, 131);
                e.LegendDrawOptions.Color = Color.FromArgb(171, 220, 131);
                break;
            case "AttendanceSummary":
                options.Color = Color.FromArgb(203, 151, 225);
                e.LegendDrawOptions.Color = Color.FromArgb(203, 151, 225);
                break;
            case "Punctuality":
                options.Color = Color.FromArgb(255, 182, 108);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 182, 108);
                break;
        }
    }
    protected void devPieChartAssign_ObjectSelected(object sender, HotTrackEventArgs e)
    {
        Series series = e.Object as Series;
        if (series != null)
        {
            ExplodedSeriesPointCollection explodedPoints = ((PieSeriesViewBase)series.View).ExplodedPoints;
            SeriesPoint point = (SeriesPoint)e.AdditionalObject;
            explodedPoints.ToggleExplodedState(point);
        }
        e.Cancel = series == null;
    }
    protected void devchartException_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        PieDrawOptions options = (PieDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Late Entry":
                options.Color = Color.FromArgb(225, 81, 81);
                e.LegendDrawOptions.Color = Color.FromArgb(225, 81, 81);
                break;
            case "Early Exit":
                options.Color = Color.FromArgb(208, 69, 123);
                e.LegendDrawOptions.Color = Color.FromArgb(208, 69, 123);
                break;
            case "Shift Not Allocated":
                options.Color = Color.FromArgb(251, 177, 103);
                e.LegendDrawOptions.Color = Color.FromArgb(251, 177, 103);
                break;
            case "App Over Time":
                options.Color = Color.FromArgb(47, 182, 123);
                e.LegendDrawOptions.Color = Color.FromArgb(47, 182, 123);
                break;
            case "Discrepancy":
                options.Color = Color.FromArgb(131, 134, 255);
                e.LegendDrawOptions.Color = Color.FromArgb(131, 134, 255);
                break;
            case "Non Process":
                options.Color = Color.FromArgb(47, 148, 209);
                e.LegendDrawOptions.Color = Color.FromArgb(47, 148, 209);
                break;
        }
    }
    protected void devChartLeave_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        PieDrawOptions options = (PieDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Forwarded":
                options.Color = Color.FromArgb(255, 127, 0);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 127, 0);
                break;
            case "Approved":
                options.Color = Color.FromArgb(0, 204, 113);
                e.LegendDrawOptions.Color = Color.FromArgb(0, 204, 113);
                break;
            case "Pending":
                options.Color = Color.FromArgb(221, 75, 57);
                e.LegendDrawOptions.Color = Color.FromArgb(221, 75, 57);
                break;
        }
    }
    protected void devChartOnduty_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        PieDrawOptions options = (PieDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Forwarded":
                options.Color = Color.FromArgb(255, 127, 0);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 127, 0);
                break;
            case "Approved":
                options.Color = Color.FromArgb(91, 192, 222);
                e.LegendDrawOptions.Color = Color.FromArgb(91, 192, 222);
                break;
            case "Pending":
                options.Color = Color.FromArgb(221, 75, 57);
                e.LegendDrawOptions.Color = Color.FromArgb(221, 75, 57);
                break;
        }
    }
    protected void devChartPermission_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        PieDrawOptions options = (PieDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Forwarded":
                options.Color = Color.FromArgb(255, 127, 0);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 127, 0);
                break;
            case "Approved":
                options.Color = Color.FromArgb(87, 154, 208);
                e.LegendDrawOptions.Color = Color.FromArgb(87, 154, 208);
                break;
            case "Pending":
                options.Color = Color.FromArgb(221, 75, 57);
                e.LegendDrawOptions.Color = Color.FromArgb(221, 75, 57);
                break;
        }
    }
    protected void devWebChartLeave_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        GetLegendAndOptionColor(e, "Leave");
    }
    private static void GetLegendAndOptionColor(CustomDrawSeriesPointEventArgs e, string type)
    {
        Pie3DDrawOptions options = (Pie3DDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode3D.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Forwarded":
                options.Color = Color.FromArgb(255, 127, 0);
                e.LegendDrawOptions.Color = Color.FromArgb(255, 127, 0);
                break;
            case "Approved":
                if (type == "Leave")
                {
                    options.Color = Color.FromArgb(0, 204, 113);
                    e.LegendDrawOptions.Color = Color.FromArgb(0, 204, 113);
                }
                else if (type == "Onduty")
                {
                    options.Color = Color.FromArgb(91, 192, 222);
                    e.LegendDrawOptions.Color = Color.FromArgb(91, 192, 222);
                }
                else if (type == "Permission")
                {
                    options.Color = Color.FromArgb(87, 154, 208);
                    e.LegendDrawOptions.Color = Color.FromArgb(87, 154, 208);
                }
                break;
            case "Pending":
                options.Color = Color.FromArgb(221, 75, 57);
                e.LegendDrawOptions.Color = Color.FromArgb(221, 75, 57);
                break;
        }
    }
    protected void devWebChartOnduty_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        GetLegendAndOptionColor(e, "Onduty");
    }
    protected void devWebChartPermission_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        GetLegendAndOptionColor(e, "Permission");
    }
    protected void devxchartException_CustomDrawSeriesPoint(object sender, DevExpress.XtraCharts.CustomDrawSeriesPointEventArgs e)
    {
        Pie3DDrawOptions options = (Pie3DDrawOptions)e.SeriesDrawOptions;
        options.FillStyle.FillMode = FillMode3D.Solid;
        switch (Convert.ToString(e.SeriesPoint.Argument))
        {
            case "Late Entry":
                options.Color = Color.FromArgb(225, 81, 81);
                e.LegendDrawOptions.Color = Color.FromArgb(225, 81, 81);
                break;
            case "Early Exit":
                options.Color = Color.FromArgb(208, 69, 123);
                e.LegendDrawOptions.Color = Color.FromArgb(208, 69, 123);
                break;
            case "Shift Not Allocated":
                options.Color = Color.FromArgb(251, 177, 103);
                e.LegendDrawOptions.Color = Color.FromArgb(251, 177, 103);
                break;
            case "Approved Over Time":
                options.Color = Color.FromArgb(47, 182, 123);
                e.LegendDrawOptions.Color = Color.FromArgb(47, 182, 123);
                break;
            case "Discrepancy":
                options.Color = Color.FromArgb(131, 134, 255);
                e.LegendDrawOptions.Color = Color.FromArgb(131, 134, 255);
                break;
            case "Non Processed Record":
                options.Color = Color.FromArgb(47, 148, 209);
                e.LegendDrawOptions.Color = Color.FromArgb(47, 148, 209);
                break;
        }
    }
    #endregion
    #region Button Click Events
    protected void imgbtnSearch_Click(object sender, EventArgs e)
    {

        if(DllYear.Text != "-Select-")
        {
            ChartValuesLoadClick();
            string strScri;
            strScri = "<script language='javascript'>";
            strScri = strScri + "binddata();";
            strScri = strScri + "</script>";
            Page.RegisterStartupScript("Alert", strScri);
        }
        else
        {
            string strScripts;
            strScripts = "<script language='javascript'>";
            strScripts = strScripts + "alert('" + "Select the Year" + "');";
            strScripts = strScripts + "</script>";
            Page.RegisterStartupScript("Alert", strScripts);
        }
        

        //lbldisplayShiftDate.Text = txtFrom.Text;
        //trFiller.Style.Add("display", "");

        //cls_Common objClas = new cls_Common();
        //DataSet datase = new DataSet();
        //datase = objClas.SelectPredectionChart(txtFrom.Text, txtTo.Text);
        //String leaveCount = "";
        //String TotaolLeave = "";
        //if (datase.Tables[0].Rows.Count != null)
        //{
        //    int Count = datase.Tables[0].Rows.Count;
        //    for (int i = 0; i < datase.Tables[0].Rows.Count; i++)
        //    {
        //        leaveCount = datase.Tables[0].Rows[i]["LeaveDaysCount"].ToString();
        //        if (Count == i + 1)
        //        {
        //            TotaolLeave = TotaolLeave + leaveCount;
        //        }
        //        else
        //        {
        //            TotaolLeave = TotaolLeave + leaveCount + ",";
        //        }


        //    }
        //    Session["HdnLeave"] = TotaolLeave.ToString();
        //    LblHdnLeave.Value = Convert.ToString(Session["HdnLeave"]);
        //}


    }
    protected void btnCloseNews_Click(object sender, EventArgs e)
    {
        //News.Visible = false;
        Session["newsClose"] = "close";
    }
    protected void lbtn_logout_Click(object sender, EventArgs e)
    {
        if (Session["EmployeeId"] != null)
        {
            string userId = Convert.ToString(Session["EmployeeId"]);
            string sUser = Convert.ToString(Cache[Convert.ToString(Session["EmployeeId"]).ToUpper()]);
            if (sUser != null && sUser != String.Empty)
            {
                ObjEmployeeEventData.InsertUpdateLastLogout(userId);
                HttpContext.Current.Cache.Remove(Convert.ToString(Session["EmployeeId"]).ToUpper());
                Session.Clear();
            }
        }
        HttpContext.Current.Response.Redirect("~/Index.aspx");
    }
    
    protected void LoadLeave(string status, int Counts)
    {
        //if (Counts == 0)
        //{
        //    Message(rm.GetString("Alert_Norecordfound", ci));
        //}
        //else
        //{
        //    //btnLeaveApproved.OnClientClick = "document.forms[0].target = '_blank';";
        //    string strFromdate, gstrDateFormat;
        //    gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        //    strFromdate = txtFrom.Text;
        //    int LevelId = Convert.ToInt32(Session["parentLevelId"]);
        //    Session["isDashBoard"] = "Yes";
        //    switch (payrollConfig)
        //    {
        //        case 1:
        //            Response.Redirect("Transactions/TA_UI_Transactions_LeaveSanctionView_Angler.aspx?LevelId=" + LevelId + "&Status=" + status + "&From_Date=" + txtFrom.Text + "&To_Date=" + txtFrom.Text + "&strSwipeCardNo=&strEmployeeName=&strEmployeeCodeId=&Shift=" + SelectedShift, false);
        //            break;
        //        default:
        //            Response.Redirect("Transactions/TA_UI_Transactions_LeaveSanctionView.aspx?LevelId=" + LevelId + "&Status=" + status + "&From_Date=" + txtFrom.Text + "&To_Date=" + txtFrom.Text + "&strSwipeCardNo=&strEmployeeName=&strEmployeeCodeId=&Shift=" + SelectedShift, false);
        //            break;
        //    }
        //}
    }
    protected void LoadOnduty(string status, int Counts)
    {
        if (Counts == 0)
        {
            Message(rm.GetString("Alert_Norecordfound", ci));
        }
        else
        {
            string strFromdate, gstrDateFormat;
            gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
            strFromdate = txtFrom.Text;
            Session["isDashBoard"] = "Yes";
            switch (status)
            {
                case "Approved":
                    Response.Redirect("Transactions/TA_UI_Transactions_OnDutySanctionView.aspx?EmpId=&EmpName=&EmpCategory=0&EmpType=0&FromDate=" + txtFrom.Text + "&ToDate=" + txtFrom.Text + "&Status=" + status + "&SwipeCard=&Shift=" + SelectedShift, false);
                    break;
                default:
                    Response.Redirect("Transactions/TA_UI_Transactions_OnDutySanctionView.aspx?EmpId=&EmpName=&EmpCategory=0&EmpType=0&FromDate=" + txtFrom.Text + "&ToDate=" + txtFrom.Text + "&Status=" + status + "&SwipeCard=&Shift=" + SelectedShift, false);
                    break;
            }
        }
    }
    protected void LoadPermission(string status, int Counts)
    {
        if (Counts == 0)
        {
            Message(rm.GetString("Alert_Norecordfound", ci));
        }
        else
        {
            string strFromdate, gstrDateFormat;
            gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
            strFromdate = txtFrom.Text;
            int Level = Convert.ToInt32(Session["parentLevelId"]);
            Session["isDashBoard"] = "Yes";
            switch (status)
            {
                case "Approved":
                    if (payrollConfig == 1)
                    {
                        Response.Redirect("Transactions/TA_UI_Transactions_PermissionSanctionView_Angler.aspx?LevelId=" + Convert.ToString(Level) + "&Status=" + status + "&From_Date=" + txtFrom.Text + "&To_Date=" + txtFrom.Text + "&strSwipeCardNo=&strEmployeeName=&strEmployeeCodeId=&Shift=" + SelectedShift, false);
                    }
                    else
                    {
                        Response.Redirect("Transactions/TA_UI_Transactions_PermissionSanctionView.aspx?LevelId=" + Convert.ToString(Level) + "&Status=" + status + "&From_Date=" + txtFrom.Text + "&To_Date=" + txtFrom.Text + "&strSwipeCardNo=&strEmployeeName=&strEmployeeCodeId=&Shift=" + SelectedShift, false);
                    }
                    break;
                default:
                    if (payrollConfig == 1)
                    {
                        Response.Redirect("Transactions/TA_UI_Transactions_PermissionBulkSanction_Angler.aspx?LevelId=" + Convert.ToString(Level) + "&Status=" + status + "&From_Date=" + txtFrom.Text + "&To_Date=" + txtFrom.Text + "&strSwipeCardNo=&strEmployeeName=&strEmployeeCodeId=&Shift=" + SelectedShift, false);
                    }
                    else
                    {
                        Response.Redirect("Transactions/TA_UI_Transactions_PermissionBulkSanction.aspx?LevelId=" + Convert.ToString(Level) + "&Status=" + status + "&From_Date=" + txtFrom.Text + "&To_Date=" + txtFrom.Text + "&strSwipeCardNo=&strEmployeeName=&strEmployeeCodeId=&Shift=" + SelectedShift, false);
                    }
                    break;
            }
        }
    }
    protected void btnOndutyApproved_Click(object sender, EventArgs e)
    {
        try
        {
            LinkButton btnbutton = (LinkButton)sender;
            switch (Convert.ToString(btnbutton.CommandArgument))
            {
                case "Approved":
                    LoadOnduty("Approved", Convert.ToInt32(btnbutton.Text));
                    break;
                case "Forwarded":
                    LoadOnduty("Forwarded", Convert.ToInt32(btnbutton.Text));
                    break;
                case "Pending":
                    LoadOnduty("Pending", Convert.ToInt32(btnbutton.Text));
                    break;
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void btnLeaveApproved_Click(object sender, EventArgs e)
    {
        try
        {
            LinkButton btnbutton = (LinkButton)sender;
            switch (Convert.ToString(btnbutton.CommandArgument))
            {
                case "Approved":
                    LoadLeave("Approved", Convert.ToInt32(btnbutton.Text));
                    break;
                case "Forwarded":
                    LoadLeave("Forwarded", Convert.ToInt32(btnbutton.Text));
                    break;
                case "Pending":
                    LoadLeave("Pending", Convert.ToInt32(btnbutton.Text));
                    break;
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void btnBoardApproved_Click(object sender, EventArgs e)
    {
        try
        {
            LinkButton btnbutton = (LinkButton)sender;
            switch (Convert.ToString(btnbutton.CommandName))
            {
                case "Leave":
                    switch (Convert.ToString(btnbutton.CommandArgument))
                    {
                        case "Approved":
                            LoadLeave("Approved", Convert.ToInt32(btnbutton.Text));
                            break;
                        case "Forwarded":
                            LoadLeave("Forwarded", Convert.ToInt32(btnbutton.Text));
                            break;
                        case "Pending":
                            LoadLeave("Pending", Convert.ToInt32(btnbutton.Text));
                            break;
                    }
                    break;
                case "Onduty":
                    switch (Convert.ToString(btnbutton.CommandArgument))
                    {
                        case "Approved":
                            LoadOnduty("Approved", Convert.ToInt32(btnbutton.Text));
                            break;
                        case "Forwarded":
                            LoadOnduty("Forwarded", Convert.ToInt32(btnbutton.Text));
                            break;
                        case "Pending":
                            LoadOnduty("Pending", Convert.ToInt32(btnbutton.Text));
                            break;
                    }
                    break;
                case "Permission":
                    switch (Convert.ToString(btnbutton.CommandArgument))
                    {
                        case "Approved":
                            LoadPermission("Approved", Convert.ToInt32(btnbutton.Text));
                            break;
                        case "Forwarded":
                            LoadPermission("Forwarded", Convert.ToInt32(btnbutton.Text));
                            break;
                        case "Pending":
                            LoadPermission("Pending", Convert.ToInt32(btnbutton.Text));
                            break;
                    }
                    break;
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void btnPermissionApproved_Click(object sender, EventArgs e)
    {
        try
        {
            LinkButton btnbutton = (LinkButton)sender;
            switch (Convert.ToString(btnbutton.CommandArgument))
            {
                case "Approved":
                    LoadPermission("Approved", Convert.ToInt32(btnbutton.Text));
                    break;
                case "Forwarded":
                    LoadPermission("Forwarded", Convert.ToInt32(btnbutton.Text));
                    break;
                case "Pending":
                    LoadPermission("Pending", Convert.ToInt32(btnbutton.Text));
                    break;
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    
    protected void btnGridView_Click(object sender, EventArgs e)
    {
        try
        {
            //trBootstrap.Style.Add("display", "none");
            trDashboard.Style.Remove("display");
            //ModalPopupExtender1.TargetControlID = "btnAttChart";
            //ModalPopupExtender2.TargetControlID = "btnExpChart";
            ViewState["Board"] = "GridView";
            Session["SessionDashboardType"] = "GridView";
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void btnDashBoard_Click(object sender, EventArgs e)
    {
        try
        {
            trDashboard.Style.Add("display", "none");
            //trBootstrap.Style.Remove("display");
            //ModalPopupExtender1.TargetControlID = "btnChart1";
            //ModalPopupExtender2.TargetControlID = "btnChart2";
            ViewState["Board"] = "Bootstrap";
            Session["SessionDashboardType"] = "Bootstrap";
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void ExportXLPDF(string ReportName, int countvalue, string ExportType)
    {
        // problem found in OM_Books , so added
        if (Session["ReportsBasedOn"] != null)
        {
            if (Convert.ToString(Session["ReportsBasedOn"]) == "False")
            {
                strEmpAutoId = "0";
            }
            else
            {
                strEmpAutoId = Convert.ToString(Session["EmpAutoID"]);
            }
        }
        //end
        if (countvalue == 0)
        {
            Message(rm.GetString("Alert_Thereisnorecord", ci));
            return;
        }
        else
        {
            string employeeID;
            intIndividualUser = objCheckUser.CheckIndividualUser(Convert.ToString(Session["UserGroupName"]));
            if (intIndividualUser >= 1)
            {
                employeeID = Convert.ToString(Session["EmployeeCodeId"]);
            }
            else
            {
                employeeID = "";
            }
            DataSet dsEmp = new DataSet();
            string strFromdate, gstrDateFormat;
            gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
            strFromdate = txtFrom.Text;
            strFromdate = objCommon.DateConvertion(gstrDateFormat, strFromdate);
            int shift;
            //shift = Convert.ToInt32(ddlShift.SelectedValue);
            string Level = rptcommon.getNodes(Convert.ToInt32(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
            string strScript = "";
            if (ExportType == "PDF")
            {
                strScript = strScript + "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
                strScript = strScript + "<meta http-equiv='X-UA-Compatible' content='IE=edge' />";
                strScript = strScript + "<script language='javascript'>";
            }
            //switch (ReportName)
            //{
            //    case "Absentees":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=Absentees&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Normal=True&SwipeCard=" + "" + "&Designation=0&Gender=Both&absentType=3&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectAbsent(strFromdate, strFromdate, employeeID, shift, "", Level, 0,
            //               0, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]),
            //               Convert.ToString(""), Convert.ToInt32(Session["parentLevelId"]),
            //               0, Convert.ToString("Both"), 3,
            //               Convert.ToInt64(strEmpAutoId), 1, 0);
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "Leave_Angler":
            //    case "Leave":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=" + ReportName + "&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Normal=true&LeaveType=All&Status=Approved&SwipeCard=" + "" + "&Designation=0&Gender=Both&LeaveReportType=Details&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectLeave(strFromdate, strFromdate, employeeID, shift, "", Level,
            //           "All", "Approved", 0, 0,
            //           Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]),
            //           "", Convert.ToInt32(Session["parentLevelId"]), 0, "Both", Convert.ToInt32(Session["EmpAutoID"]));
            //            if (ReportName == "Leave_Angler") ReportName = "Leave";
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "MonthlyAttendance":
            //    case "AttendanceSummary":
            //        if (ExportType == "PDF")
            //        {
            //            switch (ReportName)
            //            {
            //                case "MonthlyAttendance":
            //                    strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?Dashboard=MonthlyAtt&isPresentReport=1&ReportName=MonthlyAttendance&MonthlydataLoadingVer=0&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&MinWorkHours=&SwipeCard=" + "" + "&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //                    break;
            //                case "AttendanceSummary":
            //                    strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?Dashboard=MonthlyAtt&isPresentReport=0&ReportName=MonthlyAttendance&MonthlydataLoadingVer=0&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&MinWorkHours=&SwipeCard=" + "" + "&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //                    break;
            //            }
            //        }
            //        else
            //        {
            //            switch (ReportName)
            //            {
            //                case "MonthlyAttendance":
            //                    if (Convert.ToString(Session["packageID"]) != "" && Convert.ToString(Session["packageID"]) == "161")
            //                    {
            //                        //Ardlysis
            //                        dsEmp = rptEmp.SelectMonthlyAttendance_Ardlysis("", strFromdate, strFromdate, "", Level, employeeID,
            //                            0, 0, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]),
            //                            "", Convert.ToInt16(Session["parentLevelId"]), 0, "Both", shift,
            //                            0, Convert.ToInt64(strEmpAutoId), 1);
            //                        ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //                    }
            //                    else
            //                    {
            //                        dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendance", "", strFromdate, strFromdate,
            //                   "", Level, employeeID, 0, 0, Convert.ToString(Session["UserGroupName"]),
            //                   Convert.ToString(Session["GradeLevel"]), "", Convert.ToInt32(Session["parentLevelId"]),
            //                   0, "Both", shift, 0, Convert.ToInt64(strEmpAutoId), 0);
            //                        if (dsEmp.Tables.Count > 0)
            //                        {
            //                            if (dsEmp.Tables[0].Rows.Count > 0)
            //                            {
            //                                dsEmp.Tables[0].DefaultView.RowFilter = "FIRSTSESSION='Present (On Duty)' or FIRSTSESSION='Present (On Duty)  #' or FIRSTSESSION='Present' or FIRSTSESSION='Present #' ";
            //                                dsEmp.AcceptChanges();
            //                                DataTable dt = dsEmp.Tables[0].DefaultView.ToTable();
            //                                DataSet ds = new DataSet();
            //                                ds.Tables.Add(dt);
            //                                if (ReportName == "MonthlyAttendance")
            //                                    ReportName = "Present";
            //                                ExportToExcel(ReportName, ds, txtFrom.Text);
            //                            }
            //                        }
            //                    }
            //                    break;
            //                default:
            //                    if (ReportName == "AttendanceSummary")
            //                        ReportName = "Attendance Summary";
            //                    dsEmp = rptEmp.SelectMonthlyAttendanceReport("Proc_TA_RptMonthlyAttendance", "", strFromdate, strFromdate,
            //                    "", Level, employeeID, 0, 0, Convert.ToString(Session["UserGroupName"]),
            //                    Convert.ToString(Session["GradeLevel"]), "", Convert.ToInt32(Session["parentLevelId"]),
            //                    0, "Both", shift, 0, Convert.ToInt64(strEmpAutoId), 0);
            //                    ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //                    break;
            //            }
            //        }
            //        break;
            //    case "LateEntry":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=LateEntry&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Normal=Normal" + "&SwipeCard=" + "" + "&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectLateInstanceReport(employeeID, Level, strFromdate, strFromdate, "",
            //                Convert.ToInt32(shift), 0,
            //                0, Convert.ToString(Session["UserGroupName"]),
            //               Convert.ToString(Session["GradeLevel"]), employeeID, Convert.ToInt32(Session["parentLevelId"]),
            //                0, "Both", Convert.ToInt64(strEmpAutoId), 1, "");
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "Punctuality":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=Punctuality&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Normal=True&SwipeCard=" + "" + "&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectPunctuality(strFromdate, strFromdate, employeeID, shift, "", Level,
            //           0, 0, Convert.ToString(Session["UserGroupName"]),
            //           Convert.ToString(Session["GradeLevel"]), "", Convert.ToInt32(Session["parentLevelId"]),
            //           0, "Both", Convert.ToInt64(strEmpAutoId), 1);
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "EarlyExit":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=EarlyExit&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Normal=Normal&SwipeCard=" + "" + "&Designation=0&Gender=Both&isPDFExcel=PDF','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectEarlyOutReportNew(strFromdate, strFromdate, employeeID,
            //                Convert.ToInt32(shift), "", Level,
            //                0, 0, Convert.ToString(Session["UserGroupName"]),
            //                Convert.ToString(Session["GradeLevel"]), employeeID,
            //                Convert.ToInt32(Session["parentLevelId"]),
            //                0, "Both", 1, "", Convert.ToInt32(Session["EmpAutoID"]));
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "OnDutyEntry":
            //    case "OnDuty":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=OnDutyEntry&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + "" + "&shft=" + shift + "&EmpName=" + "" + "&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Status=Approved&SwipeCard=" + "" + "&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectOnDutyEntryReport("", "", strFromdate, strFromdate, Level, 0, 0,
            //            Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]),
            //            "Approved", "", Convert.ToInt32(Session["parentLevelId"]),
            //            0, "Both", Convert.ToInt32(Session["EmpAutoID"]));
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "ShiftNotAllocated":
            //    case "Shift Not Allocated":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=ShiftNotAllocated&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]) + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&SwipeCard=&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectNotAllocationReport(
            //                strFromdate, strFromdate, "", Level, employeeID, 0, 0, Convert.ToString(Session["UserGroupName"]),
            //                Convert.ToString(Session["GradeLevel"]), "",
            //                Convert.ToInt32(Session["parentLevelId"]),
            //                0, "Both", 0);
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "OverTime":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=OverTime&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&SanctionType=OverTime&empid=" + employeeID + "&shft=" + shift + "&EmpName=&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&Status=Approved&SwipeCard=&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectOverTime(strFromdate, strFromdate, employeeID, shift, "", Level,
            //           0, 0, Convert.ToString(Session["UserGroupName"]),
            //           Convert.ToString(Session["GradeLevel"]), "Approved", "", Convert.ToInt32(Session["parentLevelId"]),
            //           0, "Both", "OverTime", Convert.ToInt32(strEmpAutoId));
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "Discrepancy":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=Discrepancy&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&shft=" + shift + "&EmpName=&Level=" + Level + "&EmpCategory=0&EmpType=0&ParentLevelId" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&SwipeCard=&Designation=0&Gender=Both&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.SelectDiscrepancy(strFromdate, strFromdate, employeeID, shift, "", Level,
            //           0, 0, Convert.ToString(Session["UserGroupName"]),
            //           Convert.ToString(Session["GradeLevel"]),
            //           "", Convert.ToInt32(Session["parentLevelId"]),
            //           0, "Both",
            //           Convert.ToInt32(strEmpAutoId), 1);
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //    case "RawData":
            //        if (ExportType == "PDF")
            //            strScript = strScript + "window.open('Reports/TA_UI_Report_ReportViewer.aspx?ReportName=RawData&dtFrom=" + strFromdate + "&dtTo=" + strFromdate + "&empid=" + employeeID + "&EmpName=&EmpCategory=0&EmpType=0&ParentLevelId=" + Convert.ToInt32(Session["parentLevelId"]).ToString() + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&Designation=0&Gender=Both&RawDataDashboard=" + 1 + "&ProcessType=2&isPDFExcel=" + ExportType + "','','left=150px, top=200px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
            //        else
            //        {
            //            dsEmp = rptEmp.RawData(strFromdate, strFromdate, employeeID, "",
            //            Convert.ToString(Session["UserGroupName"]), Convert.ToInt32(Session["parentLevelId"]),
            //            0, 0, 0, "Both", 2, Convert.ToInt32(Session["EmpAutoID"]), "");
            //            ExportToExcel(ReportName, dsEmp, txtFrom.Text);
            //        }
            //        break;
            //}
            if (ExportType == "PDF")
            {
                strScript = strScript + "</script>";
                Response.Write(strScript);
            }
        }
    }
    private void ExportToExcel(string ReportName, DataSet dsEmp, string strFromdate)
    {
        if (dsEmp.Tables["Table"] == null || dsEmp.Tables["Table"].Rows.Count == 0)
        {
            Message(rm.GetString("Alert_Thereisnorecord", ci));
        }
        else
        {
            Session["Export_ExcelData"] = dsEmp;
            Response.Redirect("Reports/Excel_Export.aspx?ReportName=" + ReportName + "&FrmDate=" + Convert.ToString(strFromdate) + "&toDate=" + Convert.ToString(strFromdate) + "");
            //exportData.Attributes.Add("src", "ExportReportData.aspx?ReportName=Absentees&FromDate=" + Convert.ToString(txtFrom.Text) + "&Todate=" + strFromdate);
        }
    }
    protected void ImgAbsentExcel_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            ImageButton Export = (ImageButton)(sender);
            Int32 countValue = 0;
            //countValue = GetDataCountValue(Export, countValue);
            ExportXLPDF(Export.CommandArgument.ToString(), Convert.ToInt32(countValue), "Excel");
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    protected void ImgAbsentPDF_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            ImageButton Export = (ImageButton)(sender);
            Int32 countValue = 0;
            //countValue = GetDataCountValue(Export, countValue);
            ExportXLPDF(Export.CommandArgument.ToString(), Convert.ToInt32(countValue), "PDF");
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        }
    }
    //private int GetDataCountValue(ImageButton Export, int countValue)
    //{
    //    switch (Export.CommandArgument.ToString())
    //    {
    //        case "MonthlyAttendance":
    //            countValue = Convert.ToInt32(lblCountPresent.Text);
    //            break;
    //        case "Absentees":
    //            countValue = Convert.ToInt32(lblCountAbsent.Text);
    //            break;
    //        case "Leave":
    //        case "Leave_Angler":
    //            countValue = Convert.ToInt32(lblCountLeaveTaken.Text);
    //            break;
    //        case "OnDutyEntry":
    //        case "OnDuty":
    //            countValue = Convert.ToInt32(lblCountOnduty.Text);
    //            break;
    //        case "AttendanceSummary":
    //            countValue = Convert.ToInt32(lblAttendanceSummary.Text);
    //            break;
    //        case "Punctuality":
    //            countValue = Convert.ToInt32(lblCountPunctuality.Text);
    //            break;
    //        case "LateEntry":
    //            countValue = Convert.ToInt32(lblCountLateEntry.Text);
    //            break;
    //        case "EarlyExit":
    //            countValue = Convert.ToInt32(lblCountEarlyExit.Text);
    //            break;
    //        case "ShiftNotAllocated":
    //        case "Shift Not Allocated":
    //            countValue = Convert.ToInt32(lblShiftNotAllocated.Text);
    //            break;
    //        case "OverTime":
    //            countValue = Convert.ToInt32(lblCountOverTime.Text);
    //            break;
    //        case "Discrepancy":
    //            countValue = Convert.ToInt32(lblCountDiscrepancy.Text);
    //            break;
    //        case "RawData":
    //            countValue = Convert.ToInt32(lblCountNoProcessRecord.Text);
    //            break;
    //    }
    //    return countValue;
    //}
    #endregion
    protected void dgrdException_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        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;
        if (e.Row.RowType == DataControlRowType.Header)
        {
            Label lblHeader = (Label)e.Row.Cells[0].FindControl("lblHeaderName");
            Label lblCount = (Label)e.Row.Cells[0].FindControl("lblHeadCount");
            lblHeader.Text = Convert.ToString(Session["TotalEmployee"]);
            lblCount.Text = rm.GetString("Dash_Count", ci);
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lbl = (Label)e.Row.Cells[0].FindControl("lbltopic");
            ImageButton imgtopic = (ImageButton)e.Row.Cells[0].FindControl("imgtips");
            switch (lbl.Text)
            {
                case "Present":
                    lbl.Text = rm.GetString("AttendanceCode_Present", ci);
                    imgtopic.ImageUrl = "dist/img/icon1.jpg";
                    break;
                case "Absent":
                    lbl.Text = rm.GetString("Dash_Absent", ci);
                    imgtopic.ImageUrl = "dist/img/icon2.jpg";
                    break;
                case "Approved Leave":
                    lbl.Text = rm.GetString("Dash_ApprovedLeave", ci);
                    imgtopic.ImageUrl = "dist/img/icon3.jpg";
                    break;
                case "Approved OnDuty":
                    lbl.Text = rm.GetString("Dash_ApprovedOnDuty", ci);
                    imgtopic.ImageUrl = "dist/img/icon4.jpg";
                    break;
                case "Punctuality":
                    lbl.Text = rm.GetString("Dash_Punctuality", ci);
                    imgtopic.ImageUrl = "dist/img/icon5.jpg";
                    break;
                case "Attendance Summary":
                    lbl.Text = rm.GetString("Dash_AttendanceSummary", ci);
                    imgtopic.ImageUrl = "dist/img/icon6.jpg";
                    break;
            }
        }
    }
    protected void OnDataBound(object sender, EventArgs e)
    {
        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;
        GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
        TableHeaderCell cell = new TableHeaderCell();
        cell.Text = "";
        cell.ColumnSpan = 1;
        cell.CssClass = "head2";
        row.Controls.Add(cell);
        ImageButton imbut1 = new ImageButton();
        Label lbl1 = new Label();
        imbut1.ImageUrl = "dist/img/pending-icon.jpg";
        imbut1.Style.Add("vertical-align", "middle");
        imbut1.Style.Add("padding-right", "2px");
        imbut1.Enabled = false;
        cell = new TableHeaderCell();
        cell.ColumnSpan = 2;
        cell.CssClass = "head2 pen-text";
        lbl1.Text = rm.GetString("btn_Pending", ci);
        cell.Controls.Add(imbut1);
        cell.Controls.Add(lbl1);
        row.Controls.Add(cell);
        cell = new TableHeaderCell();
        ImageButton imbut2 = new ImageButton();
        Label lbl2 = new Label();
        cell.ColumnSpan = 2;
        cell.CssClass = "head2 for-text";
        imbut2.ImageUrl = "dist/img/forwarded-icon.jpg";
        imbut2.Style.Add("vertical-align", "middle");
        imbut2.Style.Add("padding-right", "2px");
        imbut2.Enabled = false;
        lbl2.Text = rm.GetString("btn_Forwarded", ci);
        cell.Controls.Add(imbut2);
        cell.Controls.Add(lbl2);
        row.Controls.Add(cell);
        cell = new TableHeaderCell();
        ImageButton imbut3 = new ImageButton();
        Label lbl3 = new Label();
        cell.ColumnSpan = 2;
        cell.CssClass = "head2 app-text";
        imbut3.ImageUrl = "dist/img/approved-icon.jpg";
        imbut3.Style.Add("vertical-align", "middle");
        imbut3.Style.Add("padding-right", "2px");
        imbut3.Enabled = false;
        lbl3.Text = rm.GetString("btn_Approved", ci);
        cell.Controls.Add(imbut3);
        cell.Controls.Add(lbl3);
        row.VerticalAlign = VerticalAlign.Top;
        row.Controls.Add(cell);
        //row.BackColor = ColorTranslator.FromHtml("#3AC0F2");
        //gvBoardDetails.HeaderRow.Parent.Controls.AddAt(0, row);
    }
    protected void gvBoardDetails_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        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;
        if (e.Row.RowType == DataControlRowType.Header)
        {
            Label lblHeader = (Label)e.Row.Cells[0].FindControl("lblHeaderNameBoard");
            lblHeader.Text = Convert.ToString(Session["TotalEmployee"]);
            Label lblBoardCount3 = (Label)e.Row.Cells[0].FindControl("lblBoardCount3");
            lblBoardCount3.Text = rm.GetString("Dash_Count", ci);
            Label lblBoardCount2 = (Label)e.Row.Cells[0].FindControl("lblBoardCount2");
            lblBoardCount2.Text = rm.GetString("Dash_Count", ci);
            Label lblBoardCount1 = (Label)e.Row.Cells[0].FindControl("lblBoardCount1");
            lblBoardCount1.Text = rm.GetString("Dash_Count", ci);
            //lblHeader.Text = Convert.ToString(Session["TotalEmployeePer"]);
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lbl = (Label)e.Row.Cells[0].FindControl("lblHeading");
            ImageButton imgtopic = (ImageButton)e.Row.Cells[0].FindControl("imgbtn");
            switch (lbl.Text)
            {
                case "Leave":
                    lbl.Text = rm.GetString("LeaveApplication_Leave", ci);
                    imgtopic.ImageUrl = "dist/img/lea-icon.jpg";
                    break;
                case "Onduty":
                    lbl.Text = rm.GetString("Dash_OnDuty", ci);
                    imgtopic.ImageUrl = "dist/img/ond-icon.jpg";
                    break;
                case "Permission":
                    lbl.Text = rm.GetString("Dash_Permission", ci);
                    imgtopic.ImageUrl = "dist/img/per-icon.jpg";
                    break;
            }
        }
    }
    protected void dgdLeaveDetails_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        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;
        if (e.Row.RowType == DataControlRowType.Header)
        {
            Label lblHeader = (Label)e.Row.Cells[0].FindControl("lblHeaderNameBoard");
            lblHeader.Text = Convert.ToString(Session["TotalEmployeePer"]);
            Label lblHeadCount = (Label)e.Row.Cells[0].FindControl("lblHeadCount");
            lblHeadCount.Text = rm.GetString("Dash_Count", ci);
            //lblHeader.Text = Convert.ToString(Session["TotalEmployee"]);
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label lbl = (Label)e.Row.Cells[0].FindControl("lbltopic");
            ImageButton imgtopic = (ImageButton)e.Row.Cells[0].FindControl("imgbtn");
            ImageButton btnExcel = (ImageButton)e.Row.Cells[3].FindControl("btnImagExcel");
            ImageButton btnPDF = (ImageButton)e.Row.Cells[4].FindControl("btnimgPDF");
            switch (lbl.Text)
            {
                case "Late Entry":
                    lbl.Text = rm.GetString("Dashboard_Late", ci);
                    imgtopic.ImageUrl = "dist/img/icon7.jpg";
                    break;
                case "Early Exit":
                    lbl.Text = rm.GetString("Dash_EarlyExit", ci);
                    imgtopic.ImageUrl = "dist/img/icon8.jpg";
                    break;
                case "Shift Not Allocated":
                    lbl.Text = rm.GetString("Alert_Shiftnotallocated", ci);
                    imgtopic.ImageUrl = "dist/img/icon9.jpg";
                    break;
                case "Approved Over Time":
                    lbl.Text = rm.GetString("Dash_ApprovedOverTime", ci);
                    imgtopic.ImageUrl = "dist/img/icon10.jpg";
                    break;
                case "Discrepancy":
                    lbl.Text = rm.GetString("Dash_Discrepancy", ci);
                    imgtopic.ImageUrl = "dist/img/icon11.jpg";
                    break;
                case "Non Processed Record":
                    lbl.Text = rm.GetString("Dash_NonProcessedRecord", ci);
                    imgtopic.ImageUrl = "dist/img/icon12.jpg";
                    btnExcel.Enabled = false;
                    btnPDF.Enabled = false;
                    break;
            }
        }
    }
    private void LoadNews()
    {
        //DataSet ds = new DataSet();
        //ds = objCommon.getNewsBanner("LeftNewsEvent");
        //if (ds.Tables[0].Rows.Count > 0)
        //{
        //    News.Visible = true;
        //}
        //else
        //{
        //    News.Visible = false;
        //}
        ////this.litLeftNews.Text = "";
        //marqText = "<marquee direction='up' onmouseover='this.stop();' onmouseout='this.start();' scrollamount='2' height='100' style='text-align:center;'>";
        //for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
        //{
        //    if (ds.Tables[0].Rows[i]["NewsEventTitle"] != DBNull.Value && ds.Tables[0].Rows[i]["NewsEventDescription"] != DBNull.Value)
        //        marqText = marqText + "<div class='config-hdr' style='margin:0;padding:0'> <b style='color:red'>" + ds.Tables[0].Rows[i]["NewsEventTitle"] + "</b></div>" + ds.Tables[0].Rows[i]["NewsEventDescription"] + "<br>";
        //}
        //marqText = marqText + " </marquee>";
        //this.litLeftNews.Text = marqText;
    }
    private void LoadDash()
    {
        string str1, str2, str3;
        str1 = Convert.ToString(hdAttendance.Value);
        str2 = Convert.ToString(hdApproval.Value);
        str3 = Convert.ToString(hdException.Value);
        if (str1 != "")
            Session["AttData"] = str1;
        if (str2 != "")
            Session["AppData"] = str2;
        if (str3 != "")
            Session["ExcData"] = str3;
        //Board 1
        string strSetAlert1 = "";
        strSetAlert1 = strSetAlert1 + "<script language='javascript'>";
        if (Request.QueryString["From_Date"] != null)
        {
            //Board 1
            switch (Convert.ToString(Session["AttData"]))
            {
                case "1":
                    strSetAlert1 = strSetAlert1 + "$('#tablist1 a[href=\"#tab1\"]').tab('show');";
                    break;
                case "2":
                    strSetAlert1 = strSetAlert1 + "$('#tablist1 a[href=\"#tab2\"]').tab('show');";
                    break;
                case "3":
                    strSetAlert1 = strSetAlert1 + "$('#tablist1 a[href=\"#tab3\"]').tab('show');";
                    break;
            }
            switch (Convert.ToString(Session["AppData"]))
            {
                case "1":
                    strSetAlert1 = strSetAlert1 + "$('#tablist2 a[href=\"#tab4\"]').tab('show');";
                    break;
                case "2":
                    strSetAlert1 = strSetAlert1 + "$('#tablist2 a[href=\"#tab5\"]').tab('show');";
                    break;
                case "3":
                    strSetAlert1 = strSetAlert1 + "$('#tablist2 a[href=\"#tab6\"]').tab('show');";
                    break;
            }
            switch (Convert.ToString(Session["ExcData"]))
            {
                case "1":
                    strSetAlert1 = strSetAlert1 + "$('#tablist3 a[href=\"#tab7\"]').tab('show');";
                    break;
                case "2":
                    strSetAlert1 = strSetAlert1 + "$('#tablist3 a[href=\"#tab8\"]').tab('show');";
                    break;
                case "3":
                    strSetAlert1 = strSetAlert1 + "$('#tablist3 a[href=\"#tab9\"]').tab('show');";
                    break;
            }
        }
        else
        {
            //Board 1
            switch (str1)
            {
                case "1":
                    strSetAlert1 = strSetAlert1 + "$('#tablist1 a[href=\"#tab1\"]').tab('show');";
                    break;
                case "2":
                    strSetAlert1 = strSetAlert1 + "$('#tablist1 a[href=\"#tab2\"]').tab('show');";
                    break;
                case "3":
                    strSetAlert1 = strSetAlert1 + "$('#tablist1 a[href=\"#tab3\"]').tab('show');";
                    break;
            }
            switch (str2)
            {
                case "1":
                    strSetAlert1 = strSetAlert1 + "$('#tablist2 a[href=\"#tab4\"]').tab('show');";
                    break;
                case "2":
                    strSetAlert1 = strSetAlert1 + "$('#tablist2 a[href=\"#tab5\"]').tab('show');";
                    break;
                case "3":
                    strSetAlert1 = strSetAlert1 + "$('#tablist2 a[href=\"#tab6\"]').tab('show');";
                    break;
            }
            switch (str3)
            {
                case "1":
                    strSetAlert1 = strSetAlert1 + "$('#tablist3 a[href=\"#tab7\"]').tab('show');";
                    break;
                case "2":
                    strSetAlert1 = strSetAlert1 + "$('#tablist3 a[href=\"#tab8\"]').tab('show');";
                    break;
                case "3":
                    strSetAlert1 = strSetAlert1 + "$('#tablist3 a[href=\"#tab9\"]').tab('show');";
                    break;
            }
        }
        strSetAlert1 = strSetAlert1 + "</script>";
        Page.RegisterStartupScript("SetAlertMessages", strSetAlert1);
        //grvRecentPunches.DataSource = null;
        //grvRecentPunches.DataBind();
    }
    protected void lnkbtnshiftNotAllocation_Click(object sender, EventArgs e)
    {
        Response.Redirect("Transactions/TA_UI_Transaction_ShiftAllocationAdd.aspx");
    }

    protected void Timer1_Tick(object sender, EventArgs e)
    {
        //LoadDashBoardDetails();
        //TimeOfPrice.Text = DateTime.Now.ToLongTimeString();
    }
    protected void Page_Unload(object sender, EventArgs e)
    {

    }

    protected void Label1_Click(object sender, EventArgs e)
    {

    }

    protected void DllYear_SelectedIndexChanged(object sender, EventArgs e)
    {
        var MonthName = ((DllYear).SelectedItem.Text);
    }

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

    protected void grv_AnalysisYear_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // Hide the first and second columns (Column 1 and Column 2)
            e.Row.Cells[1].Visible = false; // Column 1
            e.Row.Cells[2].Visible = false; // Column 2
        }
        if (e.Row.RowType == DataControlRowType.Header)
        {
            // Hide the first header cell
            e.Row.Cells[1].Visible = false;
            e.Row.Cells[2].Visible = false;
            int GCount = Convert.ToInt32( grv_AnalysisYear.Columns.Count.ToString());
           // string desiredWidth = "100px";
           // grv_AnalysisYear.HeaderRow.Cells[GCount].Width = Unit.Pixel(Convert.ToInt32(desiredWidth.Replace("200px", ""))); ; // Replace YourColumnIndex and YourDesiredWidth

        }

        


    }

    protected void grv_EmployeesLeaveDetail_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

    }


    protected void grv_AnalysisYear_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow row = grv_AnalysisYear.SelectedRow;
        string Month = "";
        int EmployeeId = Convert.ToInt32(Session["EmpAutoID"]);
        cls_Common objClasEF = new cls_Common();
        DataSet dataseEF = new DataSet();
        if (row != null)
        {
            //string column1Value = row.Cells[1].Text;
             Month = row.Cells[2].Text;

        }
        if(txtEmployeeId.Text=="")
        {
            grv_EmployeesLeaveDetail.DataSource = null;
            grv_EmployeesLeaveDetail.Visible = true;
            dataseEF = objClasEF.getEmployeeDetailForMonthGrid(Month, EmployeeId);
            grv_EmployeesLeaveDetail.DataSource = dataseEF;
            grv_EmployeesLeaveDetail.DataBind();
            

        }
        else
        {
            grv_EmployeesLeaveDetail.DataSource = null;
            grv_EmployeesLeaveDetail.Visible = true;
            cls_Common objClasEEE = new cls_Common();
            DataSet dataseEE = new DataSet();
            dataseEE = objClasEEE.getEmployeeFilterEmpCode(txtEmployeeId.Text);
            String EmpFilterAutoIdGet = dataseEE.Tables[0].Rows[0]["Employee_Id"].ToString();
            dataseEF = objClasEF.getEmployeeDetailForMonthGrid(Month,Convert.ToInt32( EmpFilterAutoIdGet));
            grv_EmployeesLeaveDetail.DataSource = dataseEF;
            grv_EmployeesLeaveDetail.DataBind();
           

        }

        //ScriptManager.RegisterStartupScript(this, this.GetType(), "FocusScript", "setFocusToGridView();", true);
    }
    private void CompanyBinding()
    {
        DataSet dsCompany = new DataSet();
        dsCompany = objShift.SelectCompany(gstrUserGroupName, Convert.ToString(Session["LevelRights"]), 0);
        if (dsCompany != null)
        {
            if (dsCompany.Tables[0].Rows.Count > 0)
            {
                BindDropDown(dsCompany, ddlCompany);
                BindDropDownAbsentCompany(dsCompany, ddlAbsentCompany);

            }
        }
    }
    private void BindDropDown(DataSet dsCompany, DropDownList ddl)
    {
        ddl.DataSource = dsCompany;
        ddl.DataTextField = "CompanyName";
        ddl.DataValueField = "CompanyId";
        ddl.DataBind();
        //FillTitle(ddl);
        ddlAbsentCompany.SelectedIndex = 1;
    }

    private void BindDropDownAbsentCompany(DataSet dsCompany, DropDownList ddl)
    {
        //string ddl_value = ddlAbsentCompany.SelectedValue;
        ddlAbsentCompany.DataSource = dsCompany.Tables[0];
        ddl.DataTextField = "CompanyName";
        ddl.DataValueField = "CompanyId";
        ddl.DataBind();
        //FillTitle(ddl);
        
    }
    //private void FillTitle(DropDownList ddl)
    //{
    //    foreach (ListItem item in ddl.Items)
    //    {
    //        item.Attributes.Add("title", item.Text);
    //    }
    //}
    // Maria Prasanth Developed 
    protected void btnAttendanceSearch_Click(object sender, EventArgs e)
    {
        DataSet datase = new DataSet();
        int companyId = ddlCompany.SelectedIndex;
        if (txtAttednaceFromDt.Text != "")
        {
            datase = objClas.SelectDepartmentwiseChart(0, 0, txtAttednaceFromDt.Text, txtAttednaceFromDt.Text);
        }
        else
        {
            string FromDate = DateTime.Now.ToString("dd/MM/yyyy");

            datase = objClas.SelectDepartmentwiseChart(0, 0, FromDate, FromDate);
        }
        //datase = objClas.SelectDepartmentwiseChart(0, 0, "01/July/2024", "04/July/2024");
        String DepartmentName = "";
        String DepartmentMonth = "";
        String DepartmentDaily = "";
        LblHdnLeave.Value = "";
        if (datase.Tables[0].Rows.Count != null)
        {
            int Co = 1;
            int Count = datase.Tables[0].Rows.Count;
            for (int i = 0; i < datase.Tables[1].Rows.Count; i++)
            {
                if (rbtn_Daily.Checked == true)
                {

                    if (Count == i + 1)
                    {
                        DepartmentDaily = DepartmentDaily + datase.Tables[1].Rows[i]["Day" + Co + "_Present_Count"].ToString();
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString();
                    }
                    else
                    {
                        DepartmentDaily = DepartmentDaily + datase.Tables[1].Rows[i]["Day" + Co + "_Present_Count"].ToString() + ",";
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString() + ",";
                    }
                    Co = Co + 1;

                }
                else if (rbtn_Monthly.Checked == true)
                {
                    if (Count == i + 1)
                    {
                        DepartmentMonth = DepartmentMonth + datase.Tables[1].Rows[i]["TotalPercenatge"].ToString();
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString();
                    }
                    else
                    {
                        DepartmentMonth = DepartmentMonth + datase.Tables[1].Rows[i]["TotalPercenatge"].ToString() + ",";
                        DepartmentName = DepartmentName + datase.Tables[1].Rows[i]["name"].ToString() + ",";
                    }

                }


            }
            if (DepartmentDaily != "")
            {
                HdnDepartmentDaily.Value = Convert.ToString(DepartmentDaily);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "1";
            }
            else
            {
                HdnDeparmentMonth.Value = Convert.ToString(DepartmentMonth);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "0";
            }
        }
    }

    protected void btnAbsentSearch_Click(object sender, EventArgs e)
    {
        DataSet datase = new DataSet();
        int companyId =Convert.ToInt32(ddlAbsentCompany.SelectedValue);
        string isflag = string.Empty;
        if(rbtnDaily1.Checked)
        {
            isflag = "0";
        }
        else
        {
            isflag = "1";
        }

        if (txtAbsentFromDt.Text != "")
        {
            datase = objClas.SelectAbsentDepartmentwiseChart(0, companyId, txtAbsentFromDt.Text, txtAbsentFromDt.Text, isflag);
        }
        else
        {
            string FromDate = DateTime.Now.ToString("dd/MM/yyyy");

            datase = objClas.SelectAbsentDepartmentwiseChart(0, companyId, FromDate, FromDate, isflag);
        }

        //datase = objClas.SelectDepartmentwiseChart(0, 0, "01/July/2024", "04/July/2024");
        String DepartmentName = "";
        String DepartmentMonth = "";
        String DepartmentDaily = "";
        LblHdnLeave.Value = "";
        if (datase.Tables[0].Rows.Count != null)
        {
            foreach (DataRow dr in datase.Tables[1].Rows)
            {
                DepartmentDaily = DepartmentDaily + dr["TotalPercenatge"].ToString() + ",";
                DepartmentName = DepartmentName + dr["name"].ToString() + ",";
            }

            if (DepartmentDaily != "")
            {
                HdnDepartmentDaily.Value = Convert.ToString(DepartmentDaily);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "1";
            }
            else
            {
                HdnDeparmentMonth.Value = Convert.ToString(DepartmentMonth);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "0";
            }


            if (DepartmentDaily != "")
            {
                HdnDepartmentDaily.Value = Convert.ToString(DepartmentDaily);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "1";
            }
            else
            {
                HdnDeparmentMonth.Value = Convert.ToString(DepartmentMonth);
                HdnDepartmentName.Value = Convert.ToString(DepartmentName);
                HdnDailyMonthly.Value = "0";
            }

        }

        string script = @"$(document).ready(function() {
        $('#tablist a[href=""#AbsentChart""]').tab('show');
        AbsentbydeparmentChart('" + HdnDepartmentDaily.Value + "', '" + HdnDepartmentName.Value + "');document.getElementById('ctl00_BodyContentPH_AbsentCharts').style.display = 'block';});";

        ScriptManager.RegisterStartupScript(this, this.GetType(), "initializeDateTimePicker", script, true);
        
    }

    protected void rbtn_Daily_CheckedChanged(object sender, EventArgs e)
    {
        if(rbtn_Monthly.Checked)
        {
            string script = "$('#ctl00_BodyContentPH_txtAttednaceFromDt').datetimepicker({ format: 'MMM-YYYY' });";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "initializeDateTimePicker", script, true);
        }
        else
        {
            string script = "$('#ctl00_BodyContentPH_txtAttednaceFromDt').datetimepicker({ format: document.getElementById('ctl00_BodyContentPH_Hidden2').value });";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "initializeDateTimePicker", script, true);
        }
    }
}




