using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Reports_TA_UI_Report_Employee : Base.BasePage
{
    #region Variable Declaration
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    HeaderInformation hdrTable = new HeaderInformation();
    GetReports rptEmp = new GetReports();
    Rpt_Common rptcommon = new Rpt_Common();
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    EmployeeEventData objEmployee = new EmployeeEventData();
    LeaveEventData objLeave = new LeaveEventData();
    string strFromdate, gstrDateFormat, strTodate;
    int gempCategory = 0, gempType = 0;
    //Get the Report source from the Server and load this into the report table
    DataSet gdsEmp = new DataSet();
    //this is new report
    int gshft = 0;
    string gLevel = string.Empty;
    string gemployeeName = string.Empty;
    string gempName = string.Empty;
    string gempId = string.Empty;
    string gdtFrom = "", gdtTo = "";
    int gintIndividualUser = 0;
    string gstrSwipOpt = "", gEmpStatus = "", gstrSwipeCard = "";
    #endregion
    #region PageLoad
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, 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;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        if (!Page.IsPostBack)
        {
            base.CheckPages(0);
            objCommon.menu("EmployeeReports", "42");
            UserRights();
            LoadStrings(ci);
            //Set UserRights
            Hidden1.Value = Convert.ToString(Session["IDateFormat"]);
            // Bindings the employee category and type.
            BindingEmployeeCategoryandType();
            FillDesignation();
            BindUsergroup();
            BindLeavepolicy();
            BindReportingManagers();
            ddlDesignation.PreRender += LB_PreRender;
            //txtFromDate.Text = (Convert.ToDateTime(objCommon.CurrentMonthStartDate())).ToString(Convert.ToString(Session["MDateFormat"]));
            txtToDate.Text = (Convert.ToDateTime(System.DateTime.Now.ToShortDateString())).ToString(Convert.ToString(Session["MDateFormat"]));
            if (Session["parentLevelId"] != null || Convert.ToInt16(Session["parentLevelId"]) != 0)
            {
                Session["parentLevelId"] = null;
            }
        }
        string strSetAlert = "";
        strSetAlert = strSetAlert + "<script language='javascript'>";
        strSetAlert = strSetAlert + "SetAlertMessages('" + rm.GetString("Alert_EnterToDate", ci) + "');";
        strSetAlert = strSetAlert + "MaxLengthh('" + rm.GetString("Alert_MaximumLengthis", 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 + "DisplayReminderDaysField(" + chkboxRemind_PassVisa.ClientID + ")</script>";
        Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        //Check whether the employee is Individual User
        gintIndividualUser = objCheckUser.CheckIndividualUser(Convert.ToString(Session["UserGroupName"]));
        if (gintIndividualUser >= 1)
        {
            PlaceHolderEmployees.Controls.Clear();
            divEmployeeDetails.Visible = false;
            lblEmpSwipeCard.Visible = false;
            txtSwipeCard.Visible = false;
        }
        //Convert date time to MM/dd/YYYY format
        gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
        strFromdate = txtFromDate.Text;
        strFromdate = objCommon.DateConvertion(gstrDateFormat, strFromdate);
        strTodate = txtToDate.Text;
        strTodate = objCommon.DateConvertion(gstrDateFormat, strTodate);
    }
    #endregion
    #region User Defined function
    /// <summary>
    /// Fills the designation in the drop down
    /// </summary>
    private void FillDesignation()
    {
        DataSet ds_designation = new DataSet();
        ds_designation = objEmployee.select_CommonDesignation();
        if (ds_designation != null)
        {
            if (ds_designation.Tables[0].Rows.Count > 0)
            {
                ddlDesignation.DataSource = ds_designation;
                ddlDesignation.DataTextField = "TitleName";
                ddlDesignation.DataValueField = "TitleId";
                ddlDesignation.DataBind();
            }
            ds_designation.Dispose();
            foreach (ListItem item in ddlDesignation.Items)
            {
                item.Attributes.Add("title", item.Text);
            }
        }
    }
    /// <summary>
    /// Bindings the employee category and type.
    /// </summary>
    private void BindingEmployeeCategoryandType()
    {
        // employee category binding
        DataSet dsCategory = new DataSet();
        dsCategory = objEmployee.SelectCategoryDetailsEmployee("");
        if (dsCategory != null)
        {
            if (dsCategory.Tables[0].Rows.Count > 0)
            {
                ddlEmpCatagory.DataSource = dsCategory;
                ddlEmpCatagory.DataTextField = "CategoryName";
                ddlEmpCatagory.DataValueField = "CategoryId";
                ddlEmpCatagory.DataBind();
            }
            dsCategory.Dispose();
            foreach (ListItem item in ddlEmpCatagory.Items)
            {
                item.Attributes.Add("title", item.Text);
            }
        }
        // employee type binding
        DataSet dsType = new DataSet();
        dsType = objEmployee.SelectTypeDetailsEmployee("");
        if (dsType != null)
        {
            if (dsType.Tables[0].Rows.Count > 0)
            {
                ddlEmpType.DataSource = dsType;
                ddlEmpType.DataTextField = "TypeName";
                ddlEmpType.DataValueField = "TypeId";
                ddlEmpType.DataBind();
            }
            dsType.Dispose();
            foreach (ListItem item in ddlEmpType.Items)
            {
                item.Attributes.Add("title", item.Text);
            }
        }
    }
    /// <summary>
    /// Validate the FromDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public void ValidateFromDate(object s, ServerValidateEventArgs e)
    {
        try
        {
            strFromdate = txtFromDate.Text;
            gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
            //strCurrentDate = objCommon.DateConvertion(gstrDateFormat,DateTime.Today.Date.ToString());
            strFromdate = objCommon.DateConvertion(gstrDateFormat, strFromdate);
            //strTodate = objCommon.DateConvertion(gstrDateFormat, strTodate);
            //DateTime dtCurrentDate = Convert.ToDateTime(DateTime.Today.Date.ToString("MM/dd/yyyy")); ;
            DateTime dtCurrentDate = Convert.ToDateTime(DateTime.Today.Date);
            DateTime dtFromDate = DateTime.Parse(strFromdate);
            TimeSpan diff = dtFromDate.Subtract(dtCurrentDate);
            int day = diff.Days;
            if (day <= 0)
                e.IsValid = true;
            else
            {
                // base.Message("Select valid From Date");  
                base.Message(rm.GetString("Alert_SelectvalidFromDate", ci));
                e.IsValid = false;
            }
        }
        catch
        {
            //
        }
    }
    /// <summary>
    /// Validate the ToDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public void ValidateToDate(object s, ServerValidateEventArgs e)
    {
        try
        {
            gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
            //strCurrentDate = objCommon.DateConvertion(gstrDateFormat, DateTime.Today.Date.ToString());
            strTodate = txtToDate.Text;
            strTodate = objCommon.DateConvertion(gstrDateFormat, strTodate);
            //DateTime dtCurrentDate = Convert.ToDateTime(DateTime.Today.Date.ToString("MM/dd/yyyy"));
            DateTime dtCurrentDate = Convert.ToDateTime(DateTime.Today.Date);
            DateTime dtFromDate = DateTime.Parse(strTodate);
            TimeSpan diff = dtFromDate.Subtract(dtCurrentDate);
            int day = diff.Days;
            if (day <= 0)
                e.IsValid = true;
            else
            {
                // base.Message("Select valid To Date");  
                base.Message(rm.GetString("Alert_SelectvalidToDate", ci));
                e.IsValid = false;
            }
        }
        catch
        {
            //
        }
    }
    /// <summary>
    /// Compare ToDate with FromDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    public void CompareDate(object s, ServerValidateEventArgs e)
    {
        try
        {
            strFromdate = txtFromDate.Text;
            strTodate = txtToDate.Text;
            gstrDateFormat = Convert.ToString(Session["MDateFormat"]);
            strTodate = objCommon.DateConvertion(gstrDateFormat, strTodate);
            strFromdate = objCommon.DateConvertion(gstrDateFormat, strFromdate);
            DateTime dtToDate = DateTime.Parse(strTodate);
            DateTime dtFromDate = DateTime.Parse(strFromdate);
            TimeSpan diff = dtToDate.Subtract(dtFromDate);
            int day = diff.Days;
            if (day >= 0)
                e.IsValid = true;
            else
            {
                base.Message(rm.GetString("Msg_SelectvaliddatecomparewithFromdate", ci));
                e.IsValid = false;
            }
        }
        catch
        {
            //
        }
    }
    /// <summary>
    /// Getting Information from resource file and display it in label
    /// </summary>
    /// <param name="ci"></param>
    private void LoadStrings(CultureInfo ci)
    {
        lblUserGroup.Text = rm.GetString("EmployeeMaster_UserGroup", ci);
        lblLeavepolicy.Text = rm.GetString("Employee_LeavePolicy", ci);
        lbl_ReportingTo.Text = rm.GetString("EmployeeMaster_ReportingTo", ci);
        lbl_LeaveSanctioninguthority.Text = rm.GetString("EmployeeMaster_LeaveSanctioningAuthority", ci);
        lblFilter.Text = rm.GetString("lblFilter", ci);
        btn_View.Text = "&nbsp;&nbsp;" + rm.GetString("btn_View", ci);
        lblEmployeeDetailsReport.Text = rm.GetString("Report_Employee_Details", ci);
        lblStatus.Text = rm.GetString("EmployeeMaster_EmployeeStatus", ci);
        lblEmployeeName.Text = rm.GetString("email_EmployeeName", ci);
        lblEmployeeId.Text = rm.GetString("email_EmployeeId", ci);
        lblEmpCategory.Text = rm.GetString("Master_Category", ci);
        lblEmpType.Text = rm.GetString("Master_Type", ci);
        lblTimePeriod.Text = rm.GetString("Reports_TimePeriod", ci);
        lblFrom.Text = rm.GetString("email_FromDate", ci);
        lblTo.Text = rm.GetString("email_ToDate", ci);
        lblEmpSwipe.Text = rm.GetString("TerminalDataType_Card_No", ci);
        lblEmpSwipeCard.Text = rm.GetString("TerminalDataType_Card_No", ci);
        ddlStatus.Items[0].Text = rm.GetString("ExportData_All", ci);
        ddlStatus.Items[1].Text = rm.GetString("rbtn_EmployeeMaster_Active", ci);
        ddlStatus.Items[2].Text = rm.GetString("rbtn_EmployeeMaster_InActive", ci);
        ddlSwipeOpt.Items[0].Text = rm.GetString("Select", ci);
        ddlSwipeOpt.Items[1].Text = rm.GetString("ExportData_All", ci);
        ddlSwipeOpt.Items[2].Text = rm.GetString("Report_Exists", ci);
        ddlSwipeOpt.Items[3].Text = rm.GetString("Report_NotExists", ci);
        ddlEmpCatagory.Items[0].Text = rm.GetString("Select", ci);
        ddlEmpType.Items[0].Text = rm.GetString("Select", ci);
        lblDesignation.Text = rm.GetString("EmployeeMaster_Designation", ci);
        lblGender.Text = rm.GetString("EmployeeMaster_Gender", ci);
        ddlGender.Items[0].Text = rm.GetString("Caption_Both", ci);
        ddlGender.Items[1].Text = rm.GetString("rbtn_EmployeeMaster_Male", ci);
        ddlGender.Items[2].Text = rm.GetString("rbtn_EmployeeMaster_Female", ci);
        ddlDesignation.Items[0].Text = rm.GetString("ExportData_All", ci);
        lblDateFilter.Text = rm.GetString("lbl_DateFilter", ci);
        rbCustom.Text = rm.GetString("rb_Custom", ci);
        rbpreviousMonth.Text = rm.GetString("rb_PreviousMonth", ci);
        rbpreviousweek.Text = rm.GetString("rb_PreviousWeek", ci);
        rbThisMonth.Text = rm.GetString("rb_ThisMonth", ci);
        rbThisweek.Text = rm.GetString("rb_ThisWeek", ci);
        btn_Export.Text = "&nbsp;&nbsp;" + rm.GetString("btn_ExporttoExcel", ci);
        lblAdvanced.Text = rm.GetString("Eligibility", ci);
    }
    #region "Fills UserGroup dropdown"
    private void BindTooltip(DropDownList ddl)
    {
        foreach (ListItem item in ddl.Items)
        {
            item.Attributes.Add("title", item.Text);
        }
    }
    private void BindUsergroup()
    {
        DataSet ds_Usergroup = new DataSet();
        ds_Usergroup = objEmployee.select_Usergroupdetails();
        if (ds_Usergroup != null)
        {
            if (ds_Usergroup.Tables[0].Rows.Count > 0)
            {
                ddl_UserGroup.DataSource = ds_Usergroup;
                ddl_UserGroup.DataTextField = "groupName";
                ddl_UserGroup.DataValueField = "groupId";
                ddl_UserGroup.DataBind();
            }
            ds_Usergroup.Dispose();
        }
        BindTooltip(ddl_UserGroup);
    }
    #endregion
    #region "function fills Leave policy ddl"
    private void BindLeavepolicy()
    {
        DataSet ds_leavepolicy = new DataSet();
        ds_leavepolicy = objLeave.SelectAllLeavePolicy(string.Empty);
        if (ds_leavepolicy != null)
        {
            if (ds_leavepolicy.Tables[0].Rows.Count > 0)
            {
                ddl_LeavePolicy.DataSource = ds_leavepolicy;
                ddl_LeavePolicy.DataTextField = "PolicyName";
                ddl_LeavePolicy.DataValueField = "Policy_Id";
                ddl_LeavePolicy.DataBind();
            }
            ds_leavepolicy.Dispose();
        }
        BindTooltip(ddl_LeavePolicy);
    }
    #endregion
    #region fillReportingddl
    private void BindReportingManagers()
    {
        DataSet ds_Reporting = new DataSet();
        ds_Reporting = objEmployee.SelectReportingPersonReport();
        if (ds_Reporting != null)
        {
            if (ds_Reporting.Tables[0].Rows.Count > 0)
            {
                ddl_ReportingTo.DataSource = ds_Reporting;
                ddl_ReportingTo.DataTextField = "Employee_FirstName";
                ddl_ReportingTo.DataValueField = "Employee_Id";
                ddl_ReportingTo.DataBind();
                ddl_LeaveSancAuthority.DataSource = ds_Reporting;
                ddl_LeaveSancAuthority.DataTextField = "Employee_FirstName";
                ddl_LeaveSancAuthority.DataValueField = "Employee_Id";
                ddl_LeaveSancAuthority.DataBind();
            }
        }
        BindTooltip(ddl_LeaveSancAuthority);
        BindTooltip(ddl_ReportingTo);
    }
    #endregion
    /// <summary>
    /// To check rights for the logged in user
    /// </summary>
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(42, Convert.ToInt32(Session["userGroup_Id"]), "viewPrv");
        if (ds_Checkuser.Tables[0].Rows.Count > 0)
        {
            if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] == DBNull.Value || Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) == 1)
            {
                btn_View.Visible = true;
            }
            else
            {
                btn_View.Visible = false;
            }
        }
        else
        {
            Response.Redirect("ReportsLandingPage.aspx");
        }
    }
    /// <summary>
    /// To apply tooltip for the designation in the drop down
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void LB_PreRender(object sender, System.EventArgs e)
    {
        foreach (ListItem item in ddlDesignation.Items)
        {
            item.Attributes.Add("title", item.Text);
        }
    }
    #endregion
    #region Button Event
    private void CommonFieldValues()
    {
        if (txtFromDate.Text != "")
            gdtFrom = strFromdate;
        if (txtToDate.Text != "")
            gdtTo = strTodate;
        // set employee category and type
        if (Convert.ToInt32(ddlEmpCatagory.SelectedValue) != 0)
        {
            gempCategory = Convert.ToInt32(ddlEmpCatagory.SelectedValue);
        }
        if (Convert.ToInt32(ddlEmpType.SelectedValue) != 0)
        {
            gempType = Convert.ToInt32(ddlEmpType.SelectedValue);
        }
        ;
        if (gintIndividualUser >= 1)
        {
            gempName = string.Empty;
            gshft = 0;
            //Level = string.Empty;
            gempId = Convert.ToString(Session["EmployeeCodeId"]);
        }
        else
        {
            gempName = Convert.ToString(txtEmployeeName.Text);
            gempId = Convert.ToString(txtEmployeeId.Text.Trim());
            gemployeeName = this.txtEmployeeName.Text.Replace("'", "''");
            gemployeeName = gemployeeName.Replace(' ', '%');
            //Level = rptcommon.getNodes(Convert.ToInt16(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
        }
        gEmpStatus = Convert.ToString(ddlStatus.SelectedValue);
        if (ddlSwipeOpt.SelectedIndex != 0)
        {
            gstrSwipOpt = ddlSwipeOpt.SelectedValue;
        }
        gstrSwipeCard = Convert.ToString(txtSwipeCard.Text).Trim().Replace("'", "''");
    }
    /// <summary>
    /// Load the Employee report
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_View_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid == true)
            {
                LinkButton btn = (LinkButton)sender;
                if (btn != null)
                {
                    gdsEmp = getEmployeeDetails();
                    //Redirect the page to the report viewer
                    if (gdsEmp.Tables["Table"] == null || gdsEmp.Tables["Table"].Rows.Count == 0)
                    {
                        Message(rm.GetString("Alert_Thereisnorecord", ci));
                        return;
                    }
                    else
                    {
                        Session["Export_ExcelData"] = gdsEmp;
                        if (btn.CommandName == "View")
                        {
                            string strScript = "";
                            int expiryDays = 0;
                            if (chkboxRemind_PassVisa.Checked) expiryDays = Convert.ToInt32(txtPassVisaRemindDays.Text);
                            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'>";
                            strScript = strScript + "window.open('TA_UI_Report_ReportViewer.aspx?ReportName=EmployeeDetails&dtFrom=" + gdtFrom + "&dtTo=" + gdtTo + "&empid=" + gempId + "&shft=" + gshft + "&EmpName=" + gemployeeName + "&Level=" + gLevel + "&EmpCategory=" + gempCategory + "&EmpType=" + gempType + "&ParentLevelId=" + Convert.ToInt16(Session["parentLevelId"]) + "&UserGroupName=" + Convert.ToString(Session["UserGroupName"]) + "&GradeLevel=" + Convert.ToString(Session["GradeLevel"]) + "&EmpStatus=" + gEmpStatus + "&SwipOpt=" + gstrSwipOpt + "&SwipeCard=" + gstrSwipeCard + "&Designation=" + Convert.ToInt32(ddlDesignation.SelectedValue) + "&Gender=" + ddlGender.SelectedValue + "&expiryDays=" + expiryDays + "','','left=10px, top=60px, width=1000px, height=600px, scrollbars=yes, status=no, resizable=yes');";
                            strScript = strScript + "</script>";
                            Response.Write(strScript);
                        }
                        else if (btn.CommandName == "Excel")
                        {
                            ToRemoveAndChange_UnwantedFields(gdsEmp);
                            Response.Redirect("Excel_Export.aspx?ReportName=Employee Detail&FrmDate=" + Convert.ToString(txtFromDate.Text) + "&toDate=" + Convert.ToString(txtToDate.Text) + "");
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());

            return;
        }
    }
    private DataSet getEmployeeDetails()
    {
        CommonFieldValues();
        int expiryDays = 0;
        if (chkboxRemind_PassVisa.Checked) expiryDays = Convert.ToInt32(txtPassVisaRemindDays.Text);
        gdsEmp = rptEmp.SelectEmployee
           (
               gdtFrom,
               gdtTo,
               gempId,
               gshft,
               gemployeeName,
               gLevel,
               gempCategory,
               gempType,
               gEmpStatus,
               Convert.ToString(Session["UserGroupName"]),
               Convert.ToString(Session["GradeLevel"]),
               gstrSwipOpt,
               gstrSwipeCard,
               Convert.ToInt16(Session["parentLevelId"]),
               Convert.ToInt32(ddlDesignation.SelectedValue),
               ddlGender.SelectedValue,
               Convert.ToInt32(Session["EmpAutoID"]),
               expiryDays
            );
        return gdsEmp;
    }
    private void ToRemoveAndChange_UnwantedFields(DataSet gdsEmp)
    {
        if (gdsEmp.Tables[0].Columns.Contains("empname"))
            gdsEmp.Tables[0].Columns["empname"].ColumnName = "Employee Name";
        if (gdsEmp.Tables[0].Columns.Contains("employee_id"))
            gdsEmp.Tables[0].Columns["employee_id"].ColumnName = "Employee ID";
        if (gdsEmp.Tables[0].Columns.Contains("TitleName"))
            gdsEmp.Tables[0].Columns["TitleName"].ColumnName = "Designation";
        if (gdsEmp.Tables[0].Columns.Contains("name"))
            gdsEmp.Tables[0].Columns["name"].ColumnName = "Organization Levels";
        if (gdsEmp.Tables[0].Columns.Contains("dateJoin"))
            gdsEmp.Tables[0].Columns["dateJoin"].ColumnName = "Date of Joining";
        if (gdsEmp.Tables[0].Columns.Contains("dateOfBirth"))
            gdsEmp.Tables[0].Columns["dateOfBirth"].ColumnName = "Date of Birth";
        if (gdsEmp.Tables[0].Columns.Contains("Visa_No"))
            gdsEmp.Tables[0].Columns["Visa_No"].ColumnName = "Visa No.";
        if (gdsEmp.Tables[0].Columns.Contains("Visa_expirydate"))
            gdsEmp.Tables[0].Columns["Visa_expirydate"].ColumnName = "Visa Expiry Date";
        if (gdsEmp.Tables[0].Columns.Contains("Passport_No"))
            gdsEmp.Tables[0].Columns["Passport_No"].ColumnName = "Passport No.";
        if (gdsEmp.Tables[0].Columns.Contains("Passport_expirydate"))
            gdsEmp.Tables[0].Columns["Passport_expirydate"].ColumnName = "Passport Expiry Date";
        if (gdsEmp.Tables[0].Columns.Contains("CustomField1"))
            gdsEmp.Tables[0].Columns.Remove("CustomField1");
        if (gdsEmp.Tables[0].Columns.Contains("CustomField2"))
            gdsEmp.Tables[0].Columns.Remove("CustomField2");
        if (gdsEmp.Tables[0].Columns.Contains("empAutoId"))
            gdsEmp.Tables[0].Columns.Remove("empAutoId");
        if (gdsEmp.Tables[0].Columns.Contains("department"))
            gdsEmp.Tables[0].Columns.Remove("department");
        if (gdsEmp.Tables[0].Columns.Contains("Report_Exclude"))
            gdsEmp.Tables[0].Columns.Remove("Report_Exclude");
    }
    #endregion
}
