package gf;

import org.opengion.fukurou.business.BizLogic_ENTRY;

public class GF0001 extends BizLogic_ENTRY {

	protected boolean check() {
		return must( "SYSTEM_ID,LANG,CLM" );
	}

	protected boolean logic() {
		String cnt = "select count(*) CNT from GF41 "
			+ "where system_id='{@SYSTEM_ID}' and lang='{@LANG}' and clm='{@CLM}'";
		sql( cnt );

		if( vari( "CNT" ) == 0 ) {
			String ins = "insert into GF41("
				+ "system_id, lang, clm, name_ja, label_name, kbsaku, fgj "
				+ ", dyset, usrset, pgset, pgpset, dyupd, usrupd, pgupd, pgpupd"
				+ ") values ("
				+ "'{@SYSTEM_ID}', '{@LANG}', '{@CLM}', '{@NAME_JA}', '{@LABEL_NAME}', '{@KBSAKU}', '1' "
				+ ", '{@CON.YMDH}', '{@CON.USERID}', '{@CON.PGID}', '{@CON.PGPID}', '{@CON.YMDH}', '{@CON.USERID}', '{@CON.PGID}', '{@CON.PGPID}'"
				+ ")";
			sql( ins );
		}
		else {
			String upd = "update GF41 set "
				+ "name_ja = '{@NAME_JA}' "
				+ ",label_name = '{@LABEL_NAME}' "
				+ ",kbsaku = '{@KBSAKU}' "
				+ ",system_id = '{@SYSTEM_ID}' "
				+ ",lang = '{@LANG}' "
				+ ",dyupd = '{@CON.YMDH}' "
				+ ",usrupd = '{@CON.USERID}' "
				+ ",pgupd = '{@CON.PGID}' "
				+ ",pgpupd = '{@CON.PGPID}' "
				+ "where system_id = '{@SYSTEM_ID}' "
				+ "and clm = '{@CLM}' "
				+ "and lang = '{@LANG}' ";
			sql( upd );
    	}

		return true;
	}
}
