public bool Delete()
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        EEmpPersonalInfo c = new EEmpPersonalInfo();

        c.EmpID = EmpID;
        if (EEmpPersonalInfo.db.select(dbConn, c))
        {
            DBFilter empPayrollFilter = new DBFilter();
            empPayrollFilter.add(new Match("EmpID", c.EmpID));
            DBFilter paymentRecordFilter = new DBFilter();
            paymentRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from [" + EEmpPayroll.db.dbclass.tableName + "]", empPayrollFilter));

            if (EPaymentRecord.db.count(dbConn, paymentRecordFilter) <= 0)
            {
                WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
                EmpUtils.DeleteEmp(dbConn, c.EmpID);
                db.delete(dbConn, c);
                WebUtils.EndFunction(dbConn);
                return(true);
            }
            else
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_DELETE_EMP_PAYMENT_EXISTS, new string[] { c.EmpNo }));
                return(false);
            }
        }
        return(true);
    }
Beispiel #2
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        ArrayList list = WebUtils.SelectedRepeaterItemToBaseObjectList(db, Repeater, "ItemSelect");

        foreach (EEmpPersonalInfo o in list)
        {
            if (EEmpPersonalInfo.db.select(dbConn, o))
            {
                DBFilter empPayrollFilter = new DBFilter();
                empPayrollFilter.add(new Match("EmpID", o.EmpID));
                DBFilter paymentRecordFilter = new DBFilter();
                paymentRecordFilter.add(new IN("EmpPayrollID", "Select EmpPayrollID from [" + EEmpPayroll.db.dbclass.tableName + "]", empPayrollFilter));

                if (EPaymentRecord.db.count(dbConn, paymentRecordFilter) <= 0)
                {
                    WebUtils.StartFunction(Session, FUNCTION_CODE, o.EmpID);
                    EmpUtils.DeleteEmp(dbConn, o.EmpID);
                    db.delete(dbConn, o);
                    WebUtils.EndFunction(dbConn);
                }
                else
                {
                    errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_DELETE_EMP_PAYMENT_EXISTS, new string[] { o.EmpNo }));
                }
            }
        }
        //loadState();
        loadData(info, db, Repeater);
    }