protected void Delete_Click(object sender, EventArgs e)
    {
        ArrayList list = new ArrayList();

        foreach (DataListItem item in Repeater.Items)
        {
            CheckBox        c = (CheckBox)item.FindControl("DeleteItem");
            HtmlInputHidden h = (HtmlInputHidden)item.FindControl("LeavePlanEntitleID");
            if (c.Checked)
            {
                ELeavePlanEntitle obj = new ELeavePlanEntitle();
                obj.LeavePlanEntitleID = Int32.Parse(h.Value);
                list.Add(obj);
            }
        }

        if (list.Count > 0)
        {
            WebUtils.StartFunction(Session, FUNCTION_CODE);
            foreach (BaseObject o in list)
            {
                if (sdb.select(dbConn, o))
                {
                    sdb.delete(dbConn, o);
                }
            }
            WebUtils.EndFunction(dbConn);
        }
        loadData(info, sdb, Repeater);
    }
    protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        e.Item.FindControl("DeleteItem").Visible = Delete.Visible;
        if (e.Item.ItemIndex == Repeater.EditItemIndex)
        {
            Binding ebinding = new Binding(dbConn, sdb);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("LeavePlanEntitleID"));
            ebinding.add((TextBox)e.Item.FindControl("LeavePlanEntitleYearOfService"));
            ebinding.add((TextBox)e.Item.FindControl("LeavePlanEntitleDays"));

            ebinding.init(Request, Session);


            ELeavePlanEntitle obj = new ELeavePlanEntitle();
            sdb.toObject(((DataRowView)e.Item.DataItem).Row, obj);
            Hashtable values = new Hashtable();
            sdb.populate(obj, values);
            ebinding.toControl(values);
        }
        else
        {
            e.Item.FindControl("Edit").Visible = Delete.Visible;
            HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("LeavePlanEntitleID");
            h.Value = ((DataRowView)e.Item.DataItem)["LeavePlanEntitleID"].ToString();
        }
        HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);


        //DataRowView row = (DataRowView)e.Item.DataItem;
        //CheckBox cb = (CheckBox)e.Item.FindControl("DeleteItem");
        //WebFormUtils.LoadKeys(sdb, row, cb);
        //e.Item.FindControl("DeleteItem").Visible = Delete.Visible;//toolBar.DeleteButton_Visible;
    }
    //protected void FirstPage_Click(object sender, EventArgs e)
    //{
    //    loadState();
    //    info.page = 0;
    //    view = loadData(info, sdb, Repeater);

    //}
    //protected void PrevPage_Click(object sender, EventArgs e)
    //{
    //    loadState();
    //    info.page--;
    //    view = loadData(info, sdb, Repeater);

    //}
    //protected void NextPage_Click(object sender, EventArgs e)
    //{
    //    loadState();
    //    info.page++;
    //    view = loadData(info, sdb, Repeater);

    //}
    //protected void LastPage_Click(object sender, EventArgs e)
    //{
    //    loadState();

    //    info.page = Int32.Parse(NumPage.Value);
    //    view = loadData(info, sdb, Repeater);

    //}

    protected void Add_Click(object sender, EventArgs e)
    {
        Repeater.EditItemIndex = -1;
        ELeavePlanEntitle c = new ELeavePlanEntitle();

        Hashtable values = new Hashtable();

        binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(sdb, Page.Master);

        errors.clear();


        sdb.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }


        sdb.parse(values, c);

        DBFilter filter = new DBFilter();

        filter.add(new Match("LeavePlanID", c.LeavePlanID));
        filter.add(new Match("LeaveTypeID", c.LeaveTypeID));
        filter.add(new Match("LeavePlanEntitleID", "<>", c.LeavePlanEntitleID));
        filter.add(new Match("LeavePlanEntitleYearOfService", c.LeavePlanEntitleYearOfService));
        if (sdb.count(dbConn, filter) > 0)
        {
            errors.addError("LeavePlanEntitleYearOfService", HROne.Translation.PageErrorMessage.ERROR_DUPLICATE_YEAR_SERVICE);
        }
        if (!errors.isEmpty())
        {
            return;
        }

        WebUtils.StartFunction(Session, FUNCTION_CODE);
        sdb.insert(dbConn, c);
        WebUtils.EndFunction(dbConn);

        LeavePlanEntitleYearOfService.Text = string.Empty;
        LeavePlanEntitleDays.Text          = string.Empty;
        view = loadData(info, sdb, Repeater);
    }
    protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Button b = (Button)e.CommandSource;



        if (b.ID.Equals("Edit"))
        {
            Repeater.EditItemIndex = e.Item.ItemIndex;
            view = loadData(info, sdb, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, false);
        }
        else if (b.ID.Equals("Cancel"))
        {
            Repeater.EditItemIndex = -1;
            view = loadData(info, sdb, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
        else if (b.ID.Equals("Save"))
        {
            Binding ebinding = new Binding(dbConn, sdb);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("LeavePlanEntitleID"));
            ebinding.add((TextBox)e.Item.FindControl("LeavePlanEntitleYearOfService"));
            ebinding.add((TextBox)e.Item.FindControl("LeavePlanEntitleDays"));
            ebinding.add(LeavePlanID);
            ebinding.add(LeaveTypeID);

            ebinding.init(Request, Session);


            ELeavePlanEntitle obj    = new ELeavePlanEntitle();
            Hashtable         values = new Hashtable();

            PageErrors errors = PageErrors.getErrors(sdb, Page.Master);
            errors.clear();


            ebinding.toValues(values);
            sdb.validate(errors, values);

            if (!errors.isEmpty())
            {
                return;
            }

            sdb.parse(values, obj);

            DBFilter filter = new DBFilter();
            filter.add(new Match("LeavePlanID", obj.LeavePlanID));
            filter.add(new Match("LeaveTypeID", obj.LeaveTypeID));
            filter.add(new Match("LeavePlanEntitleID", "<>", obj.LeavePlanEntitleID));
            filter.add(new Match("LeavePlanEntitleYearOfService", obj.LeavePlanEntitleYearOfService));
            if (sdb.count(dbConn, filter) > 0)
            {
                errors.addError("LeavePlanEntitleYearOfService", HROne.Translation.PageErrorMessage.ERROR_DUPLICATE_YEAR_SERVICE);
            }
            if (!errors.isEmpty())
            {
                return;
            }

            WebUtils.StartFunction(Session, FUNCTION_CODE);
            sdb.update(dbConn, obj);
            WebUtils.EndFunction(dbConn);

            Repeater.EditItemIndex = -1;

            view = loadData(info, sdb, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
    }