using System;
using System.Data;
using System.Globalization;
using System.IO;
using System.Resources;
using System.Threading;
using System.Web.UI;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;

public partial class Transactions_EmpShiftSingle : Base.BasePage
{
    #region Variable Declaration
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    ShiftAllocationEvendata objShiftAllocation = new ShiftAllocationEvendata();
    string strSessionID, EmployeeCode = "";
    int intLeave, intpermission, intOnduty = 0;

    #endregion
    protected override void Page_Load(object sender, EventArgs e)
    {
        string source_Language;
        GC.Collect();
        base.Page_Load(sender, e);
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        if (Request.QueryString["EmployeeCodeID"] != null)
        {
            EmployeeCode = Convert.ToString(Request.QueryString["EmployeeCodeID"]);
        }
        loadEmployeeDetails();
        Response.Write(strSessionID);
        Response.End();
    }


    private void loadEmployeeDetails()
    {
        DataSet dsEmp = new DataSet();
        dsEmp = objShiftAllocation.GetEmployeeUsingCode(EmployeeCode, Convert.ToString(Session["UserGroupName"]), Convert.ToInt32(Session["EmpAutoID"]));
        if (dsEmp.Tables.Count > 0)
        {
            if (dsEmp.Tables[0].Rows.Count > 0)
            {
                int empID = 0;
                string empCode = "";
                string empName = "";
                int levelid = 0;
                empID = Convert.ToInt32(dsEmp.Tables[0].Rows[0]["Employee_ID"]);
                empCode = Convert.ToString(dsEmp.Tables[0].Rows[0]["Employee_Code_Id"]);
                empName = Convert.ToString(dsEmp.Tables[0].Rows[0]["EmployeeName"]);
                levelid = Convert.ToInt32(dsEmp.Tables[0].Rows[0]["parentLevelID"]);
                objShiftAllocation.DeleteEmpShiftDetails(Convert.ToInt32(Session["EmpAutoID"]));
                objShiftAllocation.InsertEmpDetails(empID, empCode, empName, Convert.ToInt32(Session["EmpAutoID"]));
                DataSet ds = new DataSet();
                ds = objShiftAllocation.SelectEmployeeDetails(Convert.ToInt32(Session["EmpAutoID"]));
                Session["EmpDetails"] = ds;
                Session["CheckRecordsAddInPopUP"] = "TEst";
                Session["ISSingleorMultiple"] = "IsSingle";
                Session["DataAddedby"] = "IsSingle";
                Session["currentSession"] = Convert.ToString(levelid);
                strSessionID = Convert.ToString(Session.SessionID);
            }
            else
            {
                objShiftAllocation.DeleteEmpShiftDetails(Convert.ToInt32(Session["EmpAutoID"]));
                strSessionID = "Invalid EmployeeCode";
                Session["CheckRecordsAddInPopUP"] = "TEst";
                Session["DataAddedby"] = "IsSingle";
                Session["ISSingleorMultiple"] = "IsSingle";
            }
        }
        else
        {
            objShiftAllocation.DeleteEmpShiftDetails(Convert.ToInt32(Session["EmpAutoID"]));
            strSessionID = "Invalid EmployeeCode";
            Session["CheckRecordsAddInPopUP"] = "TEst";
            Session["DataAddedby"] = "IsSingle";
            Session["ISSingleorMultiple"] = "IsSingle";
        }

    }
}