using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/****************************************************************************************************************************
* Project Name    : TimeCheck                    Started Date  : 18-July-2007
* Module          : Leave Application            Last Modified : 29-Aug-2007
* Programmer      : Prabakaran.P
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Transactions_AjaxEmployeeForLeaveApplication : Base.BasePage
{
    DataSet dsEmployees = new DataSet();
    LeaveApplicationEventData objLeaveApplicationEventData = new LeaveApplicationEventData();
    int DaysForSuccessive = 0;
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        base.Page_Load(sender, e);
        if (!IsPostBack)
        {
            int levelId;
            try
            {
                //if (Convert.ToInt32(Session["ParentLevelID"]) != 0)
                //{
                if (Session["ParentLevelID"] == null)
                {
                    levelId = Convert.ToInt32(Session["LeaveParentLevelID"]);
                    //Session["ParentLevelID"] = null;
                }
                else
                {
                    levelId = Convert.ToInt32(Session["ParentLevelID"]);
                    Session["LeaveParentLevelID"] = Convert.ToInt32(Session["ParentLevelID"]);
                    //Session["ParentLevelID"] = null;
                }
                if (levelId != 0)
                {
                    //Find all sub levels
                    Rpt_Common rptcommon = new Rpt_Common();
                    string Level = "";
                    if (levelId != 0)
                    {
                        Level = rptcommon.getNodes(levelId, Convert.ToString(Session["LevelRights"]));
                    }
                    dsEmployees = objLeaveApplicationEventData.GetEmployeeForLeaveApplication(Convert.ToInt32(Session["EmpAutoId"]), Level, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), levelId);
                    DaysForSuccessive = objLeaveApplicationEventData.GetSuccessiveDaysCount(levelId);
                    if (dsEmployees.Tables.Count > 0)
                    {
                        Session["DaysForSuccessive"] = DaysForSuccessive;
                        dsEmployees.Tables[0].TableName = "Details";
                        if (dsEmployees.Tables["Details"].Rows.Count > 0)
                        {
                            Response.Clear();
                            Response.ContentType = "text/xml";
                            Response.Write(dsEmployees.GetXml());
                            dsEmployees.Dispose();
                        }
                    }
                }
                else
                {
                    Response.Clear();
                    Response.ContentType = "text/xml";
                    Response.Write("Fail");
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            Response.End();
        }
    }
}
