package p2.application.tagents_cost;

import baseclass.PaoCust;
import p2.pao.PaoSet;
import p2.util.P2Exception;
import p2.application.tagents.tagents;

import java.util.Calendar;

public class tagents_cost extends PaoCust {
    public tagents_cost(PaoSet arg0) {
        super(arg0);
    }

    @Override
    public void add() throws P2Exception {
        super.add();
        if (getOwner() instanceof tagents) {
            setValue("tagentsid", getOwner().getLong("tagentsid"), 11L);
        }
    }

    @Override
    public void fieldAction(Object paoField, String fieldname) throws P2Exception {
        super.fieldAction(paoField, fieldname);
        if ("FDATE".equals(fieldname)) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(getDate("fdate"));
            setValue("fyear", calendar.get(Calendar.YEAR), 11L);
            setValue("fmonth", calendar.get(Calendar.MONTH), 11L);
        }
    }
}
