ENDRPrint_12CRelease/.svn/pristine/93/93f516cdfef13625e3bc25be77c53ad69f82736d.svn-base

60 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

2024-08-14 10:58:03 +07:00
package th.co.muangthai.endrprint.controller.service;
import org.apache.log4j.Logger;
import th.co.muangthai.endrprint.controller.AbstractMasterController;
import th.co.muangthai.endrprint.model.bean.form.MsgErrorForm;
import th.co.muangthai.endrprint.model.bean.form.master.EndrCodeTabForm;
import th.co.muangthai.endrprint.model.bean.master.MstEndrcodeTabBean;
import java.util.List;
public class ENDR600Service extends AbstractMasterController {
static Logger log = Logger.getLogger(ENDR600Service.class);
public MsgErrorForm saveCodeTab(MstEndrcodeTabBean mstEndrcodeTabBean, String saveFlag) {
MsgErrorForm msgErrorForm = new MsgErrorForm();
try {
if (saveFlag.equals("I")) {//Insert
EndrCodeTabForm searchForm = new EndrCodeTabForm();
searchForm.setEndrCode(mstEndrcodeTabBean.getEndrCode());
List<EndrCodeTabForm> endrCodeTabFormList = commonService.searchMstCodeTabBeanByBean(searchForm);
//check Duplicate
if (endrCodeTabFormList != null && endrCodeTabFormList.size() > 0) {
msgErrorForm.setErrorFlag(getBigDecimal("1"));
msgErrorForm.setErrorDesc("Endr Code นี้มีในระแบบแล้ว");
return msgErrorForm;
}
//insert data
boolean insertSuccessful = commonService.insertEndrCodeTab(mstEndrcodeTabBean);
if (!insertSuccessful) {
msgErrorForm.setErrorFlag(getBigDecimal("1"));
msgErrorForm.setErrorDesc("Insert data error");
return msgErrorForm;
}
} else if (saveFlag.equals("E")) {//Edit
//save data
boolean insertSuccessful = commonService.insertEndrCodeTab(mstEndrcodeTabBean);
if (!insertSuccessful) {
msgErrorForm.setErrorFlag(getBigDecimal("1"));
msgErrorForm.setErrorDesc("save data error");
return msgErrorForm;
}
}
} catch (Exception e) {
msgErrorForm.setErrorFlag(getBigDecimal("1"));
msgErrorForm.setErrorDesc("Data not found ,Invalid team");
log.error(e.toString(), e);
}
return msgErrorForm;
}
}