//public void loadState()
    //{
    //    info = new ListInfo();
    //    int page = 0;
    //    if (!CurPage.Value.Equals(""))
    //        page = Int32.Parse(CurPage.Value);
    //    info.loadState(Request, page);
    //    info.order = Order.Value.Equals("True");
    //    info.orderby = OrderBy.Value;
    //    if (info.orderby == "")
    //        info.orderby = null;
    //    info.recordPerPage = -1;
    //}
    public DataView loadData(ListInfo info, DBManager db, DataList repeater)
    {
        DBFilter filter = binding.createFilter();

        DateTime dtPeriodFr, dtPeriodTo;

        if (DateTime.TryParse(RequestFromDate.Value, out dtPeriodFr))
        {
            filter.add(new Match("RequestLeaveAppCancelCreateDateTime", ">=", dtPeriodFr));
        }
        if (DateTime.TryParse(RequestToDate.Value, out dtPeriodTo))
        {
            filter.add(new Match("RequestLeaveAppCancelCreateDateTime", "<", dtPeriodTo.AddDays(1)));
        }

        //if (info != null && info.orderby != null && !info.orderby.Equals(""))
        //    filter.add(info.orderby, info.order);

        filter.add(new Match("c.EmpID", this.CurID));

        if (!EmpRequestStatus.SelectedValue.Equals(string.Empty))
        {
            if (EmpRequestStatus.SelectedValue.Equals("REQUEESTSTATUS_PROCESSING"))
            {
                //AND andTerms = new AND();
                //andTerms.add(new Match("EmpRequestStatus", "<>", EEmpRequest.STATUS_APPROVED));
                //andTerms.add(new Match("EmpRequestStatus", "<>", EEmpRequest.STATUS_CANCELLED));
                //andTerms.add(new Match("EmpRequestStatus", "<>", EEmpRequest.STATUS_REJECTED));
                filter.add(EEmpRequest.EndStatusDBTerms("EmpRequestStatus", true));
            }
            else if (EmpRequestStatus.SelectedValue.Equals("REQUEESTSTATUS_END_PROCESS"))
            {
                //OR orTerms = new OR();
                //orTerms.add(new Match("EmpRequestStatus", EEmpRequest.STATUS_APPROVED));
                //orTerms.add(new Match("EmpRequestStatus", EEmpRequest.STATUS_CANCELLED));
                //orTerms.add(new Match("EmpRequestStatus", EEmpRequest.STATUS_REJECTED));
                filter.add(EEmpRequest.EndStatusDBTerms("EmpRequestStatus", false));
            }
        }

        string select = "c.RequestLeaveAppCancelID, c.RequestLeaveAppCancelCreateDateTime, l.LeaveCode, l.LeaveCodeDesc, r.EmpRequestStatus, r.EmpRequestID, r.EmpRequestLastAuthorizationWorkFlowIndex, la.* ";
        string from   = "from " + db.dbclass.tableName + " c " +
                        " LEFT JOIN " + ELeaveApplication.db.dbclass.tableName + " la ON c.LeaveAppID = la.LeaveAppID " +
                        "  LEFT JOIN " + ELeaveCode.db.dbclass.tableName + " l ON la.LeaveCodeID=l.LeaveCodeID " +
                        " LEFT JOIN " + EEmpRequest.db.dbclass.tableName + " r On r.EmpRequestRecordID = c.RequestLeaveAppCancelID and r.EmpRequestType = '" + EEmpRequest.TYPE_EELEAVECANCEL + "'";


        DataTable table = filter.loadData(dbConn, info, select, from);

        view = new DataView(table);

        ListFooter.Refresh();

        if (repeater != null)
        {
            repeater.DataSource = view;
            repeater.DataBind();
        }
        return(view);
    }
    public DataView loadData(ListInfo info, DBManager db, DataList repeater)
    {
        DBFilter filter = binding.createFilter();

        DateTime dtPeriodFr, dtPeriodTo;

        if (DateTime.TryParse(RequestFromDate.Value, out dtPeriodFr))
        {
            filter.add(new Match("RequestOTClaimCancelCreateDateTime", ">=", dtPeriodFr));
        }
        if (DateTime.TryParse(RequestToDate.Value, out dtPeriodTo))
        {
            filter.add(new Match("RequestOTClaimCancelCreateDateTime", "<", dtPeriodTo.AddDays(1)));
        }

        filter.add(new Match("c.EmpID", this.CurID));

        if (!EmpRequestStatus.SelectedValue.Equals(string.Empty))
        {
            if (EmpRequestStatus.SelectedValue.Equals("REQUEESTSTATUS_PROCESSING"))
            {
                filter.add(EEmpRequest.EndStatusDBTerms("EmpRequestStatus", true));
            }
            else if (EmpRequestStatus.SelectedValue.Equals("REQUEESTSTATUS_END_PROCESS"))
            {
                filter.add(EEmpRequest.EndStatusDBTerms("EmpRequestStatus", false));
            }
        }

        string select = "c.RequestOTClaimCancelID, c.RequestOTClaimCancelCreateDateTime, r.EmpRequestStatus, r.EmpRequestID, r.EmpRequestLastAuthorizationWorkFlowIndex, la.* ";
        string from   = "from " + db.dbclass.tableName + " c " +
                        " LEFT JOIN " + EOTClaim.db.dbclass.tableName + " la ON c.OTClaimID = la.OTClaimID " +
                        " LEFT JOIN " + EEmpRequest.db.dbclass.tableName + " r On r.EmpRequestRecordID = c.RequestOTClaimCancelID and r.EmpRequestType = '" + EEmpRequest.TYPE_EEOTCLAIM + "'";


        DataTable table = filter.loadData(dbConn, info, select, from);

        view = new DataView(table);

        ListFooter.Refresh();

        if (repeater != null)
        {
            repeater.DataSource = view;
            repeater.DataBind();
        }
        return(view);
    }
    protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataRowView       row = (DataRowView)e.Item.DataItem;
        ELeaveApplication obj = new ELeaveApplication();

        ELeaveApplication.db.toObject(row.Row, obj);

        Button cancelButton = (Button)e.Item.FindControl("Cancel");

        DBFilter requestLeaveAppCancelFilter = new DBFilter();

        requestLeaveAppCancelFilter.add(new Match("EmpID", CurID));
        requestLeaveAppCancelFilter.add(new Match("LeaveAppID", obj.LeaveAppID));

        DBFilter empRequestFilter = new DBFilter();

        empRequestFilter.add(new Match("EmpID", CurID));
        empRequestFilter.add(new Match("EmpRequestType", EEmpRequest.TYPE_EELEAVECANCEL));
        empRequestFilter.add(new IN("EmpRequestRecordID", "SELECT RequestLeaveAppCancelID FROM " + ERequestLeaveApplicationCancel.db.dbclass.tableName, requestLeaveAppCancelFilter));
        empRequestFilter.add(EEmpRequest.EndStatusDBTerms("EmpRequestStatus", true));

        if (obj.LeaveAppCancelID > 0 || EEmpRequest.db.count(dbConn, empRequestFilter) > 0)
        {
            cancelButton.Visible = false;
        }
        else
        {
            ELeaveCode leaveCode = new ELeaveCode();
            leaveCode.LeaveCodeID = obj.LeaveCodeID;
            if (ELeaveCode.db.select(dbConn, leaveCode))
            {
                if (leaveCode.LeaveCodeHideInESS)
                {
                    cancelButton.Visible = false;
                }
                else
                {
                    //  Temporary set to invisible to add more constraint before launch
                    cancelButton.Visible = isAllowLeaveCancel;
                    cancelButton.Attributes["LeaveAppID"] = obj.LeaveAppID.ToString();
                }
            }
            else
            {
                cancelButton.Visible = false;
            }
        }

        // Start 0000094, Ricky So, 2014-09-09
        Label RequestQty = (Label)e.Item.FindControl("LeaveAppDays");

        string m_unit = ((DataRowView)e.Item.DataItem)["LeaveAppUnit"].ToString();
        double m_appHours;
        double m_appDays;

        Double.TryParse(((DataRowView)e.Item.DataItem)["LeaveAppHours"].ToString(), out m_appHours);
        Double.TryParse(((DataRowView)e.Item.DataItem)["LeaveAppDays"].ToString(), out m_appDays);

        switch (m_unit)
        {
        case "H": RequestQty.Text = m_appHours.ToString("0.000");
            break;

        default: RequestQty.Text = m_appDays.ToString("0.000");
            break;
        }
        // End 0000094, Ricky So, 2014-09-09

        HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);
    }