using Oracle.ManagedDataAccess.Client;
using System;
using System.Data;

using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI.WebControls;
public partial class Reports_TA_UI_DetailedAttendanceSync : Base.BasePage
{
    #region Variable Declaration
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    GetReports rptEmp = new GetReports();
    Rpt_Common rptcommon = new Rpt_Common();
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    EmployeeEventData objEmployee = new EmployeeEventData();
    SMSNotification objSMS = new SMSNotification();
    string strFromdate, gstrDateFormat, strTodate;
    int payrollConfig = 0;
    int intIndividualUser = 0;
    string strSwipeCard = "";
    string dtFrom = "", dtTo = "";
    string Level = string.Empty;
    string employeeName = string.Empty;
    string empName = string.Empty;
    string empId = string.Empty;
    int shift;
    string strEmpAutoId = "0";
    string MinWorkHours = "";
    #endregion
    #region Page Load event
    /// <summary>
    /// On page loading
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected override void Page_Load(object sender, EventArgs e)
    {
        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"]);
        gvData.Styles.CssFilePath = Convert.ToString(Session["GridCSS"]);
        if (!Page.IsPostBack)
        {
            base.CheckPages(0);
            objCommon.menu("Attendance Reports", "311");

            LoadStrings(ci);
            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "SetAlertMessages('" + rm.GetString("Alert_EnterDate", ci) + "','" + rm.GetString("Alert_EnterToDate", ci) + "','" + rm.GetString("Alert_EntervalidMinimumWorkHours", 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 + "</script>";
            Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
            UserRights();
            BindingEmployeeCategoryandType();
            BindDesignation();
            if (Request.QueryString["Source"] != null)
                if (Session["parentLevelId"] != null || Convert.ToInt16(Session["parentLevelId"]) != 0)
                    Session["parentLevelId"] = null;
            ddlDesignation.PreRender += LB_PreRender;
            int ToYear = Convert.ToInt32(DateTime.Now.Year);
            int FromYear = Convert.ToInt32(DateTime.Now.Year) - 20;
            for (int i = ToYear; i >= FromYear; i--)
            {
                ListItem LI = new ListItem();
                LI.Value = Convert.ToString(i);
                LI.Text = Convert.ToString(i);
                ddlYear.Items.Add(LI);
            }
            ListItem liSelect = new ListItem();
            liSelect.Value = "Select";
            liSelect.Text = rm.GetString("Select", ci);
            ddlYear.Items.Insert(0, liSelect);
            ddlMonth.SelectedValue = Convert.ToString(DateTime.Today.Month);
            ddlYear.SelectedValue = Convert.ToString(DateTime.Today.Year);
        }
        if (ViewState["DetailedAttendanceData"] != null)
        {
            gvData.DataSource = (DataSet)ViewState["DetailedAttendanceData"];
        }
        if (ViewState["vsintIndividualUser"] != null)
        {
            intIndividualUser = Convert.ToInt16(ViewState["vsintIndividualUser"]);
        }
        else
        {
            intIndividualUser = objCheckUser.CheckIndividualUser(Convert.ToString(Session["UserGroupName"]));
            ViewState["vsintIndividualUser"] = intIndividualUser;
        }
        if (Page.MasterPageFile.ToString() == "TA_Popup_Report_MasterPage.master")
            conHeader.Visible = false;
    }
    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.QueryString["Source"] != null)
            this.Page.MasterPageFile = "TA_Popup_Report_MasterPage.master";
    }
    #endregion
    #region User Defined Functions
    private void BindTitle(DropDownList ddl)
    {
        foreach (ListItem item in ddl.Items)
        {
            item.Attributes.Add("title", item.Text);
        }
    }
    /// <summary>
    /// Fills the designation in the drop down
    /// </summary>
    private void BindDesignation()
    {
        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();
            //BindTitle(ddlDesignation);
        }
    }
    /// <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();
            //BindTitle(ddlEmpCatagory);
        }
        // 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();
            //BindTitle(ddlEmpType);
        }
    }
    /// <summary>
    /// Validate the ToDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    /// <summary>
    /// Compare ToDate with FromDate
    /// </summary>
    /// <param name="s"></param>
    /// <param name="e"></param>
    /// <summary>
    /// Getting Information from resource file and display it in label
    /// </summary>
    /// <param name="ci"></param>
    private void LoadStrings(CultureInfo ci)
    {
        lblFilter.Text = rm.GetString("lblFilter", ci);
        lblReport.Text = "Oracle Synchronization - Detailed Attendance";
        btn_View.Text = "&nbsp;&nbsp;" + rm.GetString("btn_View", 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);
        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);
        //btn_Export.Text = "&nbsp;&nbsp;" + rm.GetString("btn_ExporttoExcel", ci);
        ;
    }
    /// <summary>
    /// To check rights for the logged in user
    /// </summary>
    private void UserRights()
    {
        if (ViewState["vsUserRights"] != null)
            ds_Checkuser = (DataSet)ViewState["vsUserRights"];
        else
            ds_Checkuser = objCheckUser.checkRights(311, Convert.ToInt32(Session["userGroup_Id"]), "viewPrv");
        if (ds_Checkuser.Tables[0].Rows.Count > 0)
        {
            ViewState["vsUserRights"] = ds_Checkuser;
            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 Events
    private DataSet GetDataFromDatabase()
    {
        DataSet dsEmp = new DataSet();
        string strEmpAutoId = "";
        if (Session["ReportsBasedOn"] != null)
        {
            if (Convert.ToString(Session["ReportsBasedOn"]) == "False")
            {
                strEmpAutoId = "0";
            }
            else
            {
                strEmpAutoId = Convert.ToString(Session["EmpAutoID"]);
            }
        }
        string dtFrom = "", dtTo = "";
        string empName = "", empId = "";
        string employeeName = string.Empty;
        string Level = string.Empty;
        if (intIndividualUser >= 1)
        {
            empName = string.Empty;
            Level = string.Empty;
            empId = Convert.ToString(Session["EmployeeCodeId"]);
        }
        else
        {
            empName = Convert.ToString(txtEmployeeName.Text);
            empId = Convert.ToString(txtEmployeeId.Text).Trim();
            employeeName = this.txtEmployeeName.Text.Replace("'", "''");
            Level = rptcommon.getNodes(Convert.ToInt16(Session["parentLevelId"]), Convert.ToString(Session["LevelRights"]));
        }
        dsEmp = rptEmp.GetDetailedAttendance_OracleSync(empId, employeeName, Level,
            Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]),
            Convert.ToInt16(Session["parentLevelId"]), Convert.ToInt32(ddlDesignation.SelectedValue),
            ddlGender.SelectedValue, Convert.ToInt16(ddlEmpCatagory.SelectedValue),
            Convert.ToInt32(ddlEmpType.SelectedValue), Convert.ToInt32(Session["EmpAutoID"]), Convert.ToInt32(ddlMonth.SelectedValue), Convert.ToInt32(ddlYear.SelectedValue));
        return dsEmp;
    }
    protected void btn_View_Click(object sender, EventArgs e)
    {
        try
        {
            DataSet dsDetailedAttendanceData = new DataSet();
            if (Page.IsValid == true)
            {
                dsDetailedAttendanceData = GetDataFromDatabase();
                if (dsDetailedAttendanceData.Tables["Table"] == null || dsDetailedAttendanceData.Tables["Table"].Rows.Count == 0)
                {
                    Message(rm.GetString("Alert_Thereisnorecord", ci));
                    ViewState["DetailedAttendanceData"] = null;
                    btn_Export.Visible = false;
                    gvData.DataSource = null;
                    gvData.DataBind();
                    gvData.Visible = false;
                    return;
                }
                else
                {
                    ToRemoveUnknownColumns(dsDetailedAttendanceData);
                    btn_Export.Visible = true;
                    BindCaption(dsDetailedAttendanceData);
                    gvData.Visible = true;
                }
            }
        }
        catch (Exception ex)
        {
            Message(ex.ToString());
        };
    }
    private void BindCaption(DataSet dsEmp)
    {
        //dynamic report
        int iField = 1;
        int iInc = 0;
        DataTable dtHeaderLabel = new DataTable();
        dtHeaderLabel.TableName = "HeaderLabels";
        int iDiff = 0;
        if (dsEmp.Tables[0].Columns.Count < 33)
        {
            iDiff = (33 - dsEmp.Tables[0].Columns.Count);
            for (int iDum = 0; iDum < iDiff; iDum++)
            {
                dsEmp.Tables[0].Columns.Add(new DataColumn("iField" + iInc, System.Type.GetType("System.String")));
                iInc = iInc + 1;
            }
        }
        DataRow dsRow = dtHeaderLabel.NewRow();
        int iIcont = 1;
        for (int iRow = 0; iRow < dsEmp.Tables[0].Columns.Count; iRow++)
        {
            dtHeaderLabel.Columns.Add(new DataColumn("Header" + iIcont, System.Type.GetType("System.String")));
            if (dsEmp.Tables[0].Columns[iRow].ColumnName != "Others")
            {
                dsRow[iRow] = dsEmp.Tables[0].Columns[iRow].ColumnName;
            }
            else if (dsEmp.Tables[0].Columns[iRow].ColumnName == "Others")
            {
                dsRow[iRow] = rm.GetString("Employee_Others", ci);
            }
            iIcont = iIcont + 1;
        }
        dtHeaderLabel.Rows.InsertAt(dsRow, 0);
        for (int iCol = 23; iCol < dsEmp.Tables[0].Columns.Count; iCol++)
        {
            dsEmp.Tables[0].Columns[iCol].ColumnName = "Field" + iField;
            iField = iField + 1;
        }
        gvData.DataSource = dsEmp;
        gvData.DataBind();
        ViewState["DetailedAttendanceData"] = dsEmp;
        for (int iCol = 23; iCol < dtHeaderLabel.Columns.Count; iCol++)
        {
            gvData.Columns[iCol].Caption = dtHeaderLabel.Rows[0][iCol].ToString();
        }
        for (int i = (33 - iDiff); i < 33; i++)
        {
            gvData.Columns[i].Visible = false;
        }
    }

    private static void ToRemoveUnknownColumns(DataSet dsDetailedAttendanceData)
    {
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("SwipeCardNo"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("SwipeCardNo");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("Gender"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("Gender");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("WD Spec.OT1"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("WD Spec.OT1");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("WD Spec.OT2"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("WD Spec.OT2");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("WO Spec.OT1"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("WO Spec.OT1");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("WO Spec.OT2"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("WO Spec.OT2");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("H Spec.OT1"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("H Spec.OT1");
        }
        if (dsDetailedAttendanceData.Tables[0].Columns.Contains("H Spec.OT2"))
        {
            dsDetailedAttendanceData.Tables[0].Columns.Remove("H Spec.OT2");
        }
    }
    #endregion
    private string BindOracleDatabaseDetails()
    {
        DataSet dsOracleDB = new DataSet();
        string oradb = "";
        if (Convert.ToString(ViewState["OracleDBDetails"]) == "")
        {
            dsOracleDB = objSMS.GetOracleDbDetails();
            ViewState["OracleDBDetails"] = dsOracleDB;
        }
        else
        {
            dsOracleDB = (DataSet)ViewState["OracleDBDetails"];
        }
        if (dsOracleDB.Tables.Count > 0)
        {
            if (dsOracleDB.Tables[0].Rows.Count > 0)
            {
                oradb = "Data Source=(DESCRIPTION =" + "(ADDRESS = (PROTOCOL = TCP)(HOST = " + (Convert.ToString(dsOracleDB.Tables[0].Rows[0]["HostName"])) + ")(PORT = " + (Convert.ToString(dsOracleDB.Tables[0].Rows[0]["Port"])) + "))"
           + "(CONNECT_DATA =" + "(SERVER = DEDICATED)" + "(SERVICE_NAME = " + (Convert.ToString(dsOracleDB.Tables[0].Rows[0]["ServiceName"])) + ")));" + "User Id=" + (Convert.ToString(dsOracleDB.Tables[0].Rows[0]["UserName"])) + ";Password=" + (Convert.ToString(dsOracleDB.Tables[0].Rows[0]["Pwd"])) + ";";
            }
        }
        return oradb;
    }

    protected void btn_Export_Click(object sender, EventArgs e)
    {
        try
        {
            DataSet ds = new DataSet();
            if (ViewState["DetailedAttendanceData"] == null)
            {
                Message(rm.GetString("Alert_Thereisnorecord", ci));
                btn_Export.Visible = false;
                ViewState["DetailedAttendanceData"] = null;
                return;
            }
            else
            {
                ds = (DataSet)ViewState["DetailedAttendanceData"];
            }
            if (ds.Tables.Count > 0)
            {
                SaveUsingOracleBulkCopy(ds.Tables[0]);
                //foreach (DataRow dr in ds.Tables[0].Rows)
                //{
                //    string oradb = "";
                //    oradb = BindOracleDatabaseDetails();
                //    using (OracleConnection connection = new OracleConnection(oradb))
                //    {
                //        connection.Open();
                //        using (OracleCommand cmd = new OracleCommand("ProcAttendanceDetails", connection))
                //        {
                //            try
                //            {
                //                //cmd.CommandType = CommandType.StoredProcedure;
                //                //cmd.Parameters.Add("p_EmployeeId", OracleType.VarChar, 2000).Value = dr["Employee Id"];
                //                //cmd.Parameters.Add("p_EmployeeName", OracleType.VarChar, 2000).Value = dr["Employee Name"];
                //                //cmd.Parameters.Add("p_SwipeCardNo", OracleType.VarChar, 2000).Value = dr["Employee Id"];
                //                //cmd.Parameters.Add("p_GENDER", OracleType.VarChar, 2000).Value = "";
                //                //cmd.Parameters.Add("p_PRESENT", OracleType.VarChar, 2000).Value = dr["Present"];
                //                //cmd.Parameters.Add("p_ABSENT", OracleType.VarChar, 2000).Value = dr["Absent"];
                //                //cmd.Parameters.Add("p_WEEKLYOFF", OracleType.VarChar, 2000).Value = dr["WeeklyOff"];
                //                //cmd.Parameters.Add("p_HOLIDAY", OracleType.VarChar, 2000).Value = dr["Holiday"];
                //                //cmd.Parameters.Add("p_TotalLateDays", OracleType.VarChar, 2000).Value = dr["Total Late Days"];
                //                //cmd.Parameters.Add("p_TotalEarlyExitDays", OracleType.VarChar, 2000).Value = dr["Total Early Exit Days"];
                //                //cmd.Parameters.Add("p_TotalOTDays", OracleType.VarChar, 2000).Value = dr["Total OT Days"];
                //                //cmd.Parameters.Add("p_NormOTHrs", OracleType.VarChar, 2000).Value = dr["Norm OT Hrs"];
                //                //cmd.Parameters.Add("p_WeekOffOTHrs", OracleType.VarChar, 2000).Value = dr["WeekOff OT Hrs"];
                //                //cmd.Parameters.Add("p_HolidayOTHrs", OracleType.VarChar, 2000).Value = dr["Holiday OT Hrs"];
                //                //cmd.Parameters.Add("p_OTHERS", OracleType.VarChar, 2000).Value = dr["Others"];
                //                //cmd.Parameters.Add("p_Total_HoursWorkInMins", OracleType.VarChar, 2000).Value = dr["Total_HoursWorkInMins"];
                //                //cmd.Parameters.Add("p_PERMISSIONHOURS", OracleType.VarChar, 2000).Value = dr["PermissionHours"];
                //                //cmd.Parameters.Add("p_PERMISSIONDAYS", OracleType.VarChar, 2000).Value = dr["PermissionDays"];
                //                //cmd.Parameters.Add("p_LOPCount", OracleType.VarChar, 2000).Value = dr["LOPCount"];
                //                //cmd.Parameters.Add("p_TotalLateHours", OracleType.VarChar, 2000).Value = dr["Total Late Hours"];
                //                //cmd.Parameters.Add("p_TotalEarlyExitHours", OracleType.VarChar, 2000).Value = dr["Total Early Exit Hours"];
                //                //cmd.Parameters.Add("p_TotalOTHours", OracleType.VarChar, 2000).Value = dr["Total OT Hours"];
                //                //cmd.Parameters.Add("p_PayDays", OracleType.VarChar, 2000).Value = dr["PayDays"];
                //                //cmd.Parameters.Add("p_TotalDays", OracleType.VarChar, 2000).Value = dr["TotalDays"];
                //                //cmd.Parameters.Add("p_Month", OracleType.VarChar, 2000).Value = dr["Month"];
                //                //cmd.Parameters.Add("p_Leave1", OracleType.VarChar, 2000).Value = dr["Field1"];
                //                //cmd.Parameters.Add("p_Leave2", OracleType.VarChar, 2000).Value = dr["Field2"];
                //                //cmd.Parameters.Add("p_Leave3", OracleType.VarChar, 2000).Value = dr["Field3"];
                //                //cmd.Parameters.Add("p_Leave4", OracleType.VarChar, 2000).Value = dr["Field4"];
                //                //cmd.Parameters.Add("p_Leave5", OracleType.VarChar, 2000).Value = dr["Field5"];
                //                //cmd.Parameters.Add("p_Leave6", OracleType.VarChar, 2000).Value = dr["Field6"];
                //                //cmd.Parameters.Add("p_Leave7", OracleType.VarChar, 2000).Value = dr["Field7"];
                //                //cmd.Parameters.Add("p_Leave8", OracleType.VarChar, 2000).Value = dr["Field8"];
                //                //cmd.Parameters.Add("p_Leave9", OracleType.VarChar, 2000).Value = dr["Field9"];
                //                //cmd.Parameters.Add("p_Leave10", OracleType.VarChar, 2000).Value = dr["Field10"];
                //                //cmd.Parameters.Add("p_Year", OracleType.VarChar, 2000).Value = ddlYear.SelectedValue;
                //                //cmd.ExecuteNonQuery();
                //            }
                //            catch (Exception ex)
                //            {
                //                throw ex;
                //            }
                //        }
                //    }
                //}
                Message("Sync. to Oracle has been completed successfully");
                return;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    public void SaveUsingOracleBulkCopy(DataTable dt)
    {
        try
        {
            string oradb;
            oradb = BindOracleDatabaseDetails();
            using (OracleConnection connection = new OracleConnection(oradb))
            {
                connection.Open();
                //delete duplicate records if already existing in database;
                OracleCommand cmdDelete = connection.CreateCommand();
                cmdDelete.CommandType = CommandType.StoredProcedure;
                cmdDelete.CommandText = "DeleteDuplicateAttendances";

                OracleParameter pmonthDelete = new OracleParameter();
                pmonthDelete.OracleDbType = OracleDbType.Varchar2;
                pmonthDelete.Value = Convert.ToString(ddlMonth.SelectedItem.Text);

                OracleParameter pddlYearDelete = new OracleParameter();
                pddlYearDelete.OracleDbType = OracleDbType.Varchar2;
                pddlYearDelete.Value = Convert.ToString(ddlYear.SelectedValue);
                cmdDelete.Parameters.Add(pmonthDelete);
                cmdDelete.Parameters.Add(pddlYearDelete);
                cmdDelete.ExecuteNonQuery();

                //using (OracleCommand cmd = new OracleCommand())
                {
                    //using (var connection = new OracleConnection(connectionString))
                    {
                        //connection.Open();

                        string[] p_EmployeeId = new string[dt.Rows.Count];
                        /// cmd.Parameters.Add("p_EmployeeId", OracleType.VarChar, 2000).Value = dr["Employee Id"];
                        string[] p_EmployeeName = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_EmployeeName", OracleType.VarChar, 2000).Value = dr["Employee Name"];
                        string[] p_SwipeCardNo = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_SwipeCardNo", OracleType.VarChar, 2000).Value = dr["Employee Id"];
                        string[] p_GENDER = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_GENDER", OracleType.VarChar, 2000).Value = "";
                        string[] p_PRESENT = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_PRESENT", OracleType.VarChar, 2000).Value = dr["Present"];
                        string[] p_ABSENT = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_ABSENT", OracleType.VarChar, 2000).Value = dr["Absent"];
                        string[] p_WEEKLYOFF = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_WEEKLYOFF", OracleType.VarChar, 2000).Value = dr["WeeklyOff"];
                        string[] p_HOLIDAY = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_HOLIDAY", OracleType.VarChar, 2000).Value = dr["Holiday"];
                        string[] p_TotalLateDays = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalLateDays", OracleType.VarChar, 2000).Value = dr["Total Late Days"];
                        string[] p_TotalEarlyExitDays = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalEarlyExitDays", OracleType.VarChar, 2000).Value = dr["Total Early Exit Days"];
                        string[] p_TotalOTDays = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalOTDays", OracleType.VarChar, 2000).Value = dr["Total OT Days"];
                        string[] p_NormOTHrs = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_NormOTHrs", OracleType.VarChar, 2000).Value = dr["Norm OT Hrs"];
                        string[] p_WeekOffOTHrs = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_WeekOffOTHrs", OracleType.VarChar, 2000).Value = dr["WeekOff OT Hrs"];
                        string[] p_HolidayOTHrs = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_HolidayOTHrs", OracleType.VarChar, 2000).Value = dr["Holiday OT Hrs"];
                        string[] p_OTHERS = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_OTHERS", OracleType.VarChar, 2000).Value = dr["Others"];
                        string[] p_Total_HoursWorkInMins = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Total_HoursWorkInMins", OracleType.VarChar, 2000).Value = dr["Total_HoursWorkInMins"];
                        string[] p_PERMISSIONHOURS = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_PERMISSIONHOURS", OracleType.VarChar, 2000).Value = dr["PermissionHours"];
                        string[] p_PERMISSIONDAYS = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_PERMISSIONDAYS", OracleType.VarChar, 2000).Value = dr["PermissionDays"];
                        string[] p_LOPCount = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_LOPCount", OracleType.VarChar, 2000).Value = dr["LOPCount"];
                        string[] p_TotalLateHours = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalLateHours", OracleType.VarChar, 2000).Value = dr["Total Late Hours"];
                        string[] p_TotalEarlyExitHours = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalEarlyExitHours", OracleType.VarChar, 2000).Value = dr["Total Early Exit Hours"];
                        string[] p_TotalOTHours = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalOTHours", OracleType.VarChar, 2000).Value = dr["Total OT Hours"];
                        string[] p_PayDays = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_PayDays", OracleType.VarChar, 2000).Value = dr["PayDays"];
                        string[] p_TotalDays = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_TotalDays", OracleType.VarChar, 2000).Value = dr["TotalDays"];
                        string[] p_Month = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Month", OracleType.VarChar, 2000).Value = dr["Month"];
                        string[] p_Leave1 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave1", OracleType.VarChar, 2000).Value = dr["Field1"];
                        string[] p_Leave2 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave2", OracleType.VarChar, 2000).Value = dr["Field2"];
                        string[] p_Leave3 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave3", OracleType.VarChar, 2000).Value = dr["Field3"];
                        string[] p_Leave4 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave4", OracleType.VarChar, 2000).Value = dr["Field4"];
                        string[] p_Leave5 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave5", OracleType.VarChar, 2000).Value = dr["Field5"];
                        string[] p_Leave6 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave6", OracleType.VarChar, 2000).Value = dr["Field6"];
                        string[] p_Leave7 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave7", OracleType.VarChar, 2000).Value = dr["Field7"];
                        string[] p_Leave8 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave8", OracleType.VarChar, 2000).Value = dr["Field8"];
                        string[] p_Leave9 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave9", OracleType.VarChar, 2000).Value = dr["Field9"];
                        string[] p_Leave10 = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Leave10", OracleType.VarChar, 2000).Value = dr["Field10"];
                        string[] p_Year = new string[dt.Rows.Count];
                        //cmd.Parameters.Add("p_Year",

                        for (int j = 0; j < dt.Rows.Count; j++)
                        {
                            p_EmployeeId[j] = Convert.ToString(dt.Rows[j]["Employee Id"]);
                            //cmd.Parameters.Add("p_EmployeeId", OracleType.VarChar, 2000).Value = dr["Employee Id"];
                            p_EmployeeName[j] = Convert.ToString(dt.Rows[j]["Employee Name"]);
                            //cmd.Parameters.Add("p_EmployeeName", OracleType.VarChar, 2000).Value = dr["Employee Name"];
                            p_SwipeCardNo[j] = Convert.ToString(dt.Rows[j]["Employee Id"]);
                            //cmd.Parameters.Add("p_SwipeCardNo", OracleType.VarChar, 2000).Value = dr["Employee Id"];
                            p_GENDER[j] = "";
                            //cmd.Parameters.Add("p_GENDER", OracleType.VarChar, 2000).Value = "";
                            p_PRESENT[j] = Convert.ToString(dt.Rows[j]["Present"]);
                            //cmd.Parameters.Add("p_PRESENT", OracleType.VarChar, 2000).Value = dr["Present"];
                            p_ABSENT[j] = Convert.ToString(dt.Rows[j]["Absent"]);
                            //cmd.Parameters.Add("p_ABSENT", OracleType.VarChar, 2000).Value = dr["Absent"];
                            p_WEEKLYOFF[j] = Convert.ToString(dt.Rows[j]["WeeklyOff"]);
                            //cmd.Parameters.Add("p_WEEKLYOFF", OracleType.VarChar, 2000).Value = dr["WeeklyOff"];
                            p_HOLIDAY[j] = Convert.ToString(dt.Rows[j]["Holiday"]);
                            //cmd.Parameters.Add("p_HOLIDAY", OracleType.VarChar, 2000).Value = dr["Holiday"];
                            p_TotalLateDays[j] = Convert.ToString(dt.Rows[j]["Total Late Days"]);
                            //cmd.Parameters.Add("p_TotalLateDays", OracleType.VarChar, 2000).Value = dr["Total Late Days"];
                            p_TotalEarlyExitDays[j] = Convert.ToString(dt.Rows[j]["Total Early Exit Days"]);
                            //cmd.Parameters.Add("p_TotalEarlyExitDays", OracleType.VarChar, 2000).Value = dr["Total Early Exit Days"];
                            p_TotalOTDays[j] = Convert.ToString(dt.Rows[j]["Total OT Days"]);
                            //cmd.Parameters.Add("p_TotalOTDays", OracleType.VarChar, 2000).Value = dr["Total OT Days"];
                            p_NormOTHrs[j] = Convert.ToString(dt.Rows[j]["Norm OT Hrs"]);
                            //cmd.Parameters.Add("p_NormOTHrs", OracleType.VarChar, 2000).Value = dr["Norm OT Hrs"];
                            p_WeekOffOTHrs[j] = Convert.ToString(dt.Rows[j]["WeekOff OT Hrs"]);
                            //cmd.Parameters.Add("p_WeekOffOTHrs", OracleType.VarChar, 2000).Value = dr["WeekOff OT Hrs"];
                            p_HolidayOTHrs[j] = Convert.ToString(dt.Rows[j]["Holiday OT Hrs"]);
                            //cmd.Parameters.Add("p_HolidayOTHrs", OracleType.VarChar, 2000).Value = dr["Holiday OT Hrs"];
                            p_OTHERS[j] = Convert.ToString(dt.Rows[j]["Others"]);
                            //cmd.Parameters.Add("p_OTHERS", OracleType.VarChar, 2000).Value = dr["Others"];
                            p_Total_HoursWorkInMins[j] = Convert.ToString(dt.Rows[j]["Total_HoursWorkInMins"]);
                            //cmd.Parameters.Add("p_Total_HoursWorkInMins", OracleType.VarChar, 2000).Value = dr["Total_HoursWorkInMins"];
                            p_PERMISSIONHOURS[j] = Convert.ToString(dt.Rows[j]["PermissionHours"]);
                            //cmd.Parameters.Add("p_PERMISSIONHOURS", OracleType.VarChar, 2000).Value = dr["PermissionHours"];
                            p_PERMISSIONDAYS[j] = Convert.ToString(dt.Rows[j]["PermissionDays"]);
                            //cmd.Parameters.Add("p_PERMISSIONDAYS", OracleType.VarChar, 2000).Value = dr["PermissionDays"];
                            p_LOPCount[j] = Convert.ToString(dt.Rows[j]["LOPCount"]);
                            //cmd.Parameters.Add("p_LOPCount", OracleType.VarChar, 2000).Value = dr["LOPCount"];
                            p_TotalLateHours[j] = Convert.ToString(dt.Rows[j]["Total Late Hours"]);
                            //cmd.Parameters.Add("p_TotalLateHours", OracleType.VarChar, 2000).Value = dr["Total Late Hours"];
                            p_TotalEarlyExitHours[j] = Convert.ToString(dt.Rows[j]["Total Early Exit Hours"]);
                            //cmd.Parameters.Add("p_TotalEarlyExitHours", OracleType.VarChar, 2000).Value = dr["Total Early Exit Hours"];
                            p_TotalOTHours[j] = Convert.ToString(dt.Rows[j]["Total OT Hours"]);
                            //cmd.Parameters.Add("p_TotalOTHours", OracleType.VarChar, 2000).Value = dr["Total OT Hours"];
                            p_PayDays[j] = Convert.ToString(dt.Rows[j]["PayDays"]);
                            //cmd.Parameters.Add("p_PayDays", OracleType.VarChar, 2000).Value = dr["PayDays"];
                            p_TotalDays[j] = Convert.ToString(dt.Rows[j]["TotalDays"]);
                            //cmd.Parameters.Add("p_TotalDays", OracleType.VarChar, 2000).Value = dr["TotalDays"];
                            p_Month[j] = Convert.ToString(dt.Rows[j]["Month"]);
                            //cmd.Parameters.Add("p_Month", OracleType.VarChar, 2000).Value = dr["Month"];
                            p_Leave1[j] = Convert.ToString(dt.Rows[j]["Field1"]);
                            //cmd.Parameters.Add("p_Leave1", OracleType.VarChar, 2000).Value = dr["Field1"];
                            p_Leave2[j] = Convert.ToString(dt.Rows[j]["Field2"]);
                            //cmd.Parameters.Add("p_Leave2", OracleType.VarChar, 2000).Value = dr["Field2"];
                            p_Leave3[j] = Convert.ToString(dt.Rows[j]["Field3"]);
                            //cmd.Parameters.Add("p_Leave3", OracleType.VarChar, 2000).Value = dr["Field3"];
                            p_Leave4[j] = Convert.ToString(dt.Rows[j]["Field4"]);
                            //cmd.Parameters.Add("p_Leave4", OracleType.VarChar, 2000).Value = dr["Field4"];
                            p_Leave5[j] = Convert.ToString(dt.Rows[j]["Field5"]);
                            //cmd.Parameters.Add("p_Leave5", OracleType.VarChar, 2000).Value = dr["Field5"];
                            p_Leave6[j] = Convert.ToString(dt.Rows[j]["Field6"]);
                            //cmd.Parameters.Add("p_Leave6", OracleType.VarChar, 2000).Value = dr["Field6"];
                            p_Leave7[j] = Convert.ToString(dt.Rows[j]["Field7"]);
                            //cmd.Parameters.Add("p_Leave7", OracleType.VarChar, 2000).Value = dr["Field7"];
                            p_Leave8[j] = Convert.ToString(dt.Rows[j]["Field8"]);
                            //cmd.Parameters.Add("p_Leave8", OracleType.VarChar, 2000).Value = dr["Field8"];
                            p_Leave9[j] = Convert.ToString(dt.Rows[j]["Field9"]);
                            //cmd.Parameters.Add("p_Leave9", OracleType.VarChar, 2000).Value = dr["Field9"];
                            p_Leave10[j] = Convert.ToString(dt.Rows[j]["Field10"]);
                            //cmd.Parameters.Add("p_Leave10", OracleType.VarChar, 2000).Value = dr["Field10"];
                            p_Year[j] = ddlYear.SelectedValue;
                            //cmd.Parameters.Add("p_Year"
                        }


                        OracleParameter pEmployeeId = new OracleParameter();
                        pEmployeeId.OracleDbType = OracleDbType.Varchar2;
                        pEmployeeId.Value = p_EmployeeId;

                        OracleParameter pEmployeeName = new OracleParameter();
                        pEmployeeName.OracleDbType = OracleDbType.Varchar2;
                        pEmployeeName.Value = p_EmployeeName;

                        OracleParameter pSwipeCardNo = new OracleParameter();
                        pSwipeCardNo.OracleDbType = OracleDbType.Varchar2;
                        pSwipeCardNo.Value = p_EmployeeId;

                        OracleParameter pGENDER = new OracleParameter();
                        pGENDER.OracleDbType = OracleDbType.Varchar2;
                        pGENDER.Value = p_GENDER;

                        OracleParameter pPRESENT = new OracleParameter();
                        pPRESENT.OracleDbType = OracleDbType.Varchar2;
                        pPRESENT.Value = p_PRESENT;

                        OracleParameter pABSENT = new OracleParameter();
                        pABSENT.OracleDbType = OracleDbType.Varchar2;
                        pABSENT.Value = p_ABSENT;
                        OracleParameter pWEEKLYOFF = new OracleParameter();
                        pWEEKLYOFF.OracleDbType = OracleDbType.Varchar2;
                        pWEEKLYOFF.Value = p_WEEKLYOFF;
                        OracleParameter pHOLIDAY = new OracleParameter();
                        pHOLIDAY.OracleDbType = OracleDbType.Varchar2;
                        pHOLIDAY.Value = p_HOLIDAY;
                        OracleParameter pTotalLateDays = new OracleParameter();
                        pTotalLateDays.OracleDbType = OracleDbType.Varchar2;
                        pTotalLateDays.Value = p_TotalLateDays;

                        OracleParameter pTotalEarlyExitDays = new OracleParameter();
                        pTotalEarlyExitDays.OracleDbType = OracleDbType.Varchar2;
                        pTotalEarlyExitDays.Value = p_TotalEarlyExitDays;

                        OracleParameter pTotalOTDays = new OracleParameter();
                        pTotalOTDays.OracleDbType = OracleDbType.Varchar2;
                        pTotalOTDays.Value = p_TotalOTDays;

                        OracleParameter pNormOTHrs = new OracleParameter();
                        pNormOTHrs.OracleDbType = OracleDbType.Varchar2;
                        pNormOTHrs.Value = p_NormOTHrs;

                        OracleParameter pWeekOffOTHrs = new OracleParameter();
                        pWeekOffOTHrs.OracleDbType = OracleDbType.Varchar2;
                        pWeekOffOTHrs.Value = p_WeekOffOTHrs;

                        OracleParameter pHolidayOTHrs = new OracleParameter();
                        pHolidayOTHrs.OracleDbType = OracleDbType.Varchar2;
                        pHolidayOTHrs.Value = p_HolidayOTHrs;
                        OracleParameter pOTHERS = new OracleParameter();
                        pOTHERS.OracleDbType = OracleDbType.Varchar2;
                        pOTHERS.Value = p_OTHERS;

                        OracleParameter pTotal_HoursWorkInMins = new OracleParameter();
                        pTotal_HoursWorkInMins.OracleDbType = OracleDbType.Varchar2;
                        pTotal_HoursWorkInMins.Value = p_Total_HoursWorkInMins;
                        OracleParameter pPERMISSIONHOURS = new OracleParameter();
                        pPERMISSIONHOURS.OracleDbType = OracleDbType.Varchar2;
                        pPERMISSIONHOURS.Value = p_PERMISSIONHOURS;
                        OracleParameter pPERMISSIONDAYS = new OracleParameter();
                        pPERMISSIONDAYS.OracleDbType = OracleDbType.Varchar2;
                        pPERMISSIONDAYS.Value = p_PERMISSIONDAYS;

                        OracleParameter pLOPCount = new OracleParameter();
                        pLOPCount.OracleDbType = OracleDbType.Varchar2;
                        pLOPCount.Value = p_LOPCount;




                        OracleParameter pTotalLateHours = new OracleParameter();
                        pTotalLateHours.OracleDbType = OracleDbType.Varchar2;
                        pTotalLateHours.Value = p_TotalLateHours;
                        OracleParameter pTotalEarlyExitHours = new OracleParameter();
                        pTotalEarlyExitHours.OracleDbType = OracleDbType.Varchar2;
                        pTotalEarlyExitHours.Value = p_TotalEarlyExitHours;

                        OracleParameter pTotalOTHours = new OracleParameter();
                        pTotalOTHours.OracleDbType = OracleDbType.Varchar2;
                        pTotalOTHours.Value = p_TotalOTHours;

                        OracleParameter pPayDays = new OracleParameter();
                        pPayDays.OracleDbType = OracleDbType.Varchar2;
                        pPayDays.Value = p_PayDays;
                        OracleParameter pTotalDays = new OracleParameter();
                        pTotalDays.OracleDbType = OracleDbType.Varchar2;
                        pTotalDays.Value = p_TotalDays;
                        OracleParameter pMonth = new OracleParameter();
                        pMonth.OracleDbType = OracleDbType.Varchar2;
                        pMonth.Value = p_Month;
                        OracleParameter pLeave1 = new OracleParameter();
                        pLeave1.OracleDbType = OracleDbType.Varchar2;
                        pLeave1.Value = p_Leave1;
                        OracleParameter pLeave2 = new OracleParameter();
                        pLeave2.OracleDbType = OracleDbType.Varchar2;
                        pLeave2.Value = p_Leave2;
                        OracleParameter pLeave3 = new OracleParameter();
                        pLeave3.OracleDbType = OracleDbType.Varchar2;
                        pLeave3.Value = p_Leave3;
                        OracleParameter pLeave4 = new OracleParameter();
                        pLeave4.OracleDbType = OracleDbType.Varchar2;
                        pLeave4.Value = p_Leave4;
                        OracleParameter pLeave5 = new OracleParameter();
                        pLeave5.OracleDbType = OracleDbType.Varchar2;
                        pLeave5.Value = p_Leave5;
                        OracleParameter pLeave6 = new OracleParameter();
                        pLeave6.OracleDbType = OracleDbType.Varchar2;
                        pLeave6.Value = p_Leave6;
                        OracleParameter pLeave7 = new OracleParameter();
                        pLeave7.OracleDbType = OracleDbType.Varchar2;
                        pLeave7.Value = p_Leave7;
                        OracleParameter pLeave8 = new OracleParameter();
                        pLeave8.OracleDbType = OracleDbType.Varchar2;
                        pLeave8.Value = p_Leave8;
                        OracleParameter pLeave9 = new OracleParameter();
                        pLeave9.OracleDbType = OracleDbType.Varchar2;
                        pLeave9.Value = p_Leave9;
                        OracleParameter pLeave10 = new OracleParameter();
                        pLeave10.OracleDbType = OracleDbType.Varchar2;
                        pLeave10.Value = p_Leave10;
                        OracleParameter pYear = new OracleParameter();
                        pYear.OracleDbType = OracleDbType.Varchar2;
                        pYear.Value = p_Year;



                        //Insert records newly
                        OracleCommand cmd = connection.CreateCommand();
                        cmd.CommandText = "INSERT INTO ATTENDANCEDETAILS (EMPLOYEEID,EMPLOYEENAME,SWIPECARDNO,PRESENT,ABSENT,WEEKLYOFF,HOLIDAY,TOTALLATEDAYS,TOTALEARLYEXITDAYS,TOTALOTDAYS ,NORMOTHRS ,WEEKOFFOTHRS,HOLIDAYOTHRS,OTHERS ,TOTAL_HOURSWORKINMINS,PERMISSIONHOURS ,PERMISSIONDAYS ,LOPCOUNT ,TOTALLATEHOURS ,TOTALEARLYEXITHOURS ,TOTALOTHOURS ,PAYDAYS ,TOTALDAYS,MONTH ,LEAVE1 ,LEAVE2 ,LEAVE3 ,LEAVE4 ,LEAVE5 ,LEAVE6 ,LEAVE7,LEAVE8 ,LEAVE9 ,LEAVE10,YEAR) VALUES (:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23,:24,:25,:26,:27,:28,:29,:30,:31,:32,:33,:34,:35)";
                        cmd.ArrayBindCount = p_EmployeeId.Length;
                        cmd.Parameters.Add(pEmployeeId);
                        cmd.Parameters.Add(pEmployeeName);
                        cmd.Parameters.Add(pSwipeCardNo);
                        cmd.Parameters.Add(pPRESENT);
                        cmd.Parameters.Add(pABSENT);
                        cmd.Parameters.Add(pWEEKLYOFF);
                        cmd.Parameters.Add(pHOLIDAY);
                        cmd.Parameters.Add(pTotalLateDays);
                        cmd.Parameters.Add(pTotalEarlyExitDays);
                        cmd.Parameters.Add(pTotalOTDays);
                        cmd.Parameters.Add(pNormOTHrs);
                        cmd.Parameters.Add(pWeekOffOTHrs);
                        cmd.Parameters.Add(pHolidayOTHrs);
                        cmd.Parameters.Add(pOTHERS);
                        cmd.Parameters.Add(pTotal_HoursWorkInMins);
                        cmd.Parameters.Add(pPERMISSIONHOURS);
                        cmd.Parameters.Add(pPERMISSIONDAYS);
                        cmd.Parameters.Add(pLOPCount);
                        cmd.Parameters.Add(pTotalLateHours);
                        cmd.Parameters.Add(pTotalEarlyExitHours);
                        cmd.Parameters.Add(pTotalOTHours);
                        cmd.Parameters.Add(pPayDays);
                        cmd.Parameters.Add(pTotalDays);
                        cmd.Parameters.Add(pMonth);
                        cmd.Parameters.Add(pLeave1);
                        cmd.Parameters.Add(pLeave2);
                        cmd.Parameters.Add(pLeave3);
                        cmd.Parameters.Add(pLeave4);
                        cmd.Parameters.Add(pLeave5);
                        cmd.Parameters.Add(pLeave6);
                        cmd.Parameters.Add(pLeave7);
                        cmd.Parameters.Add(pLeave8);
                        cmd.Parameters.Add(pLeave9);
                        cmd.Parameters.Add(pLeave10);
                        cmd.Parameters.Add(pYear);
                        cmd.ExecuteNonQuery();

                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e)
    {
        ViewState["DetailedAttendanceData"] = null;
        btn_Export.Visible = false;
        gvData.DataSource = null;
        gvData.DataBind();
        gvData.Visible = false;
    }
}