60 lines
2.3 KiB
Plaintext
60 lines
2.3 KiB
Plaintext
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;
|
|
}
|
|
}
|