Command003.java 1.18 KB
Newer Older
TongZuu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
package com.csc.library.command.common;

import com.csc.library.command.CommandNoResult;
import com.csc.library.command.util.CommonParameterUtil;
import com.csc.library.request.CommandState;
import com.csc.library.request.CommonModeParameter;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.MyLog;

/* Delete Record */
public class Command003 extends CommandNoResult<CommonModeParameter>{

	@Override
	public void execute(CommonModeParameter param) throws Exception {
		try{
			DbRecord rec = new InitialRecord(this.getUProfile()).getDbRecord(param.getTableName());
			
			CommonParameterUtil.setKeyRecord(rec, param);
			
			if(rec.search() == 1){
				int delStatus = rec.delete();
				if(delStatus == 4){
					this.sendMessage("Command003 : Delete Record Success" , CommandState.success);
				}else{
					this.sendMessage("Command003 : Delete Record Fail" , CommandState.fail);
				}
			}else{
				this.sendMessage("Command002 : Save Record Fail because Data Record not found data in database." , CommandState.fail);
			}
		}catch(Exception e){
			MyLog.error(this ,this.getUProfile() , e);
			this.sendMessage(e.getMessage());
		}
	}
}