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;
public partial class Transactions_AjaxRemainingNoOfLOPDays : Base.BasePage
{
    LeaveApplicationEventData objLeaveApplicationEventData = new LeaveApplicationEventData();
    DataSet dsRemainingNoOfLOPDays = new DataSet();
    cls_Common objclsCommon = new cls_Common();
    int intYearSettingsId = 0;
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        base.Page_Load(sender, e);    
        if (Request.QueryString["EmpId"].ToString() == "" || Request.QueryString["leaveTypeId"].ToString() == "" || Request.QueryString["leaveTypeId"].ToString() == "-Select-")
        {
            Response.Write("Fail");
        }
        else
        {
            int EmpId = Convert.ToInt32(Request.QueryString["EmpId"]);
            int leaveTypeId = Convert.ToInt32(Request.QueryString["leaveTypeId"]);
            string LeaveFromDate = Request.QueryString["LeaveFromDate"].ToString();
            string LeaveToDate = Request.QueryString["LeaveToDate"].ToString();
            LeaveFromDate = objclsCommon.DateConvertion(Session["MDateFormat"].ToString(), LeaveFromDate);
            LeaveToDate = objclsCommon.DateConvertion(Session["MDateFormat"].ToString(), LeaveToDate);
            if (Request.QueryString["ApplicationYear"] != string.Empty && Request.QueryString["ApplicationYear"] != null)
            {
                intYearSettingsId = Convert.ToInt32(Request.QueryString["ApplicationYear"].ToString());
            }
            try
            {
               dsRemainingNoOfLOPDays = objLeaveApplicationEventData.GetRemainingNoOfLOP(EmpId, leaveTypeId, Convert.ToDateTime(LeaveFromDate).ToShortDateString().ToString(), Convert.ToDateTime(LeaveToDate).ToShortDateString().ToString(), intYearSettingsId);
                //dsRemainingNoOfLOPDays = objLeaveApplicationEventData.GetRemainingNoOfLOP(EmpId, leaveTypeId, Convert.ToDateTime(LeaveFromDate), Convert.ToDateTime(LeaveToDate).ToShortDateString().ToString(), intYearSettingsId);
                if (dsRemainingNoOfLOPDays.Tables.Count > 0)
                {
                    dsRemainingNoOfLOPDays.Tables[0].TableName = "Details";
                    if (dsRemainingNoOfLOPDays.Tables["Details"].Rows.Count > 0)
                    {
                        Response.Clear();
                        Response.ContentType = "text/xml";
                        Response.Write(dsRemainingNoOfLOPDays.GetXml());
                        dsRemainingNoOfLOPDays.Dispose();
                    }
                }
                else
                {
                    Response.Clear();
                    Response.ContentType = "text/xml";
                    Response.Write("Fail");
                }
            }
            catch 
            {
                Response.Clear();
                Response.ContentType = "text/xml";
                Response.Write("Fail");
            }
        }
        Response.End();
    }
}
