?? gbs_mifentryaction.java
字號:
public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
GBS_MifEntryForm thisForm = (GBS_MifEntryForm) form;
//get login user info from session
this.setUserInfoFromSession(request, thisForm);
GBS_MifEntryActionLogic logic = new GBS_MifEntryActionLogic(this.getDataSource(request));
GBS_MMif_stBean mif_st = new GBS_MMif_stBean();
ReturnValue returnValue = new ReturnValue();
MessageList errorMsg = new MessageList();
// getComboxValue
this.getComboxValueAndName(thisForm, request);
//GBS_MMif_stBean
mif_st.setCountryCode(thisForm.getCountryCode().trim());
mif_st.setCustomerId(thisForm.getCustomerId().trim());
mif_st.setProductCategory(thisForm.getProductCategory().trim());
mif_st.setSubsidiaryCode(thisForm.getSubsidiaryCode().trim());
returnValue = (ReturnValue) logic.delMifDetail(mif_st);
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
this.setMessage(errorMsg);
}
thisForm = returnFormData(thisForm, request);
return (mapping.findForward(nextview));
}
thisForm.reset(mapping, request);
thisForm.setMethod("close");
return (mapping.findForward(nextview));
}
/**
* InputCheck
* @param requestForm GBS_MifEntryForm
* @param request HttpServletRequest
* @throws Exception
* @return ErrorMessages
*/
private MessageList inputCheck(GBS_MifEntryForm requestform, HttpServletRequest request) throws Exception {
//create ErrorMessages to display error message
MessageList messages = new MessageList();
// FormFile attachmentFile = requestform.getAttachmentFile();
//ProductCategory check
if (BaseCommonCheck.isEmpty(requestform.getProductCategory()) || requestform.getProductCategory().equals("-1")) {
messages.setMessage(
"productCategory",
requestform.getProductCategory(),
"10000009",
Integer.MIN_VALUE,
new Object[] { "Category" });
}
//Country check
if (BaseCommonCheck.isEmpty(requestform.getCountryCode()) || requestform.getCountryCode().equals("-1")) {
messages.setMessage(
"countryCode",
requestform.getCountryCode(),
"10000009",
Integer.MIN_VALUE,
new Object[] { "Country" });
}
//Subsidiary check
if (BaseCommonCheck.isEmpty(requestform.getSubsidiaryCode()) || requestform.getSubsidiaryCode().equals("-1")) {
messages.setMessage(
"subsidiaryCode",
requestform.getSubsidiaryCode(),
"10000009",
Integer.MIN_VALUE,
new Object[] { "Subs" });
}
// //AttachmentFile check
// //if(requestform.getDeleteFile().equals("off")){
// if((attachmentFile != null && !attachmentFile.getFileName().equals("")) && attachmentFile.getFileSize()==0){
// messages.setMessage( "attachmentFile", null, "10000012", Integer.MIN_VALUE,
// new Object[]{ "AttachmentFile" }, "AttachmentFile");
// }
// //}
// //AttachmentFile's name check
// if(attachmentFile != null && attachmentFile.getFileName().length() > 100){
// messages.setMessage("","", "10000018", Integer.MIN_VALUE);
// }
String[] model = requestform.getModel();
String[] qty = requestform.getQty();
String[] hardPrice = requestform.getHardPrice();
String[] cpcPrice = requestform.getCpcPrice();
String[] mcv = requestform.getMcv();
String[] installDate = requestform.getInstallDate();
String[] rfpDate = requestform.getRfpDate();
for (int i = 0; model != null && i < model.length; i++) {
String strModel = model[i];
String strQty = remove(qty[i], ',');
String strHardPrice = remove(hardPrice[i], ',');
String strCpcPrice = remove(cpcPrice[i], ',');
String strMcv = remove(mcv[i], ',');
;
String strInstallDate = installDate[i];
String strRfpDate = rfpDate[i];
//model傪擖椡帪
if (!strModel.trim().equals("")) {
//update by Ym 20040824 start
//Qty check(Digit)
if (!BaseCommonCheck.isEmpty(strQty)) {
if (!BaseCommonCheck.isInteger(strQty)) {
//messages.setMessage("qty", qty[i], "90000008", i+1);
messages.setMessage("qty", qty[i], "90000008", i + 1, new Object[] { "Qty." }, "qty");
} else if (strQty.compareTo("999999") > 0) {
messages.setMessage("qty", strQty, "90000025", i + 1);
} else if (new Integer(strQty).intValue() < 0) {
messages.setMessage("qty", strQty, "90000015", i + 1);
}
}
//HardPrice check(Digit)
//BigDecimal bigHardPrice = new BigDecimal(strHardPrice);
if (!BaseCommonCheck.isEmpty(strHardPrice)) {
if (!BaseCommonCheck.isFloat(strHardPrice)) {
messages.setMessage("hardPrice", hardPrice[i], "90000008", i + 1);
//}else if (bigHardPrice.compareTo( new BigDecimal("9999999999.99")) > 0 ){
} else if (new Double(strHardPrice).doubleValue() > 9999999999.99) {
messages.setMessage("hardPrice", hardPrice[i], "90000025", i + 1);
} else if (new Double(strHardPrice).doubleValue() < 0) {
messages.setMessage("hardPrice", hardPrice[i], "90000015", i + 1);
}
}
//CpcPrice check(Digit)
if (!BaseCommonCheck.isEmpty(strCpcPrice)) {
if (!BaseCommonCheck.isFloat(strCpcPrice)) {
messages.setMessage("cpcPrice", cpcPrice[i], "90000008", i + 1);
} else if (new Double(strCpcPrice).doubleValue() > 999999.9999) {
//BigDecimal bigCpcPrice = new BigDecimal(strCpcPrice);
//if (bigCpcPrice.compareTo( new BigDecimal("999999.9999")) >0 ){
messages.setMessage("cpcPrice", cpcPrice[i], "90000025", i + 1);
} else if (new Double(strCpcPrice).doubleValue() < 0) {
messages.setMessage("cpcPrice", cpcPrice[i], "90000015", i + 1);
}
}
//Mcv check(Digit)
/*
if (!BaseCommonCheck.isEmpty(strMcv)){
if (!BaseCommonCheck.isFloat( strMcv )) {
messages.setMessage("mcv", mcv[i], "90000008", i+1);
}
}*/
if (!BaseCommonCheck.isEmpty(strMcv)) {
if (!BaseCommonCheck.isBigInteger(strMcv)) {
messages.setMessage("mcv", mcv[i], "90000008", i + 1, new Object[] { "MCV" }, "mcv");
} else if (strMcv.compareTo("9999999999") > 0) {
messages.setMessage("mcv", mcv[i], "90000025", i + 1);
} else if (new BigDecimal(strMcv).intValue() < 0) {
messages.setMessage("mcv", mcv[i], "90000015", i + 1);
}
}
//InstallDate check(Date)
if (!BaseCommonCheck.isEmpty(strInstallDate)) {
//strInstallDate = BaseCommonCheck.convertDateToYYYYMMDD( strInstallDate);
if ((!BaseCommonCheck.isDateType(strInstallDate))) {
messages.setMessage("installDate", installDate[i], "90000025", i + 1);
}
}
//RfpDate check(Date)
if (!BaseCommonCheck.isEmpty(strRfpDate)) {
//strRfpDate = BaseCommonCheck.convertDateToYYYYMMDD( strRfpDate );
if ((!BaseCommonCheck.isDateType(strRfpDate))) {
messages.setMessage("rfpDate", rfpDate[i], "90000025", i + 1);
}
}
}
}
return messages;
}
/**
* LogicCheck
* @param requestForm GBS_MifEntryForm
* @param request HttpServletRequest
* @throws Exception
* @return ErrorMessages
*/
private MessageList logicCheck(GBS_MifEntryForm requestForm, HttpServletRequest request) throws Exception {
//柧嵶椞堟?zhèn)虊鏂?model偑廳暋偟偰偄傞帪僄儔乕
MessageList messages = new MessageList();
boolean isError = false;
String model[] = requestForm.getModel();
for (int i = 0; model != null && i < model.length; i++) {
for (int j = i + 1; j < model.length - 1; j++) {
if (!model[i].trim().equals("")) {
if (model[i].trim().equals(model[j].trim())) {
messages.setMessage("model", model[i], "10000011", i + 1, "Model");
isError = true;
break;
}
}
}
if (isError) {
break;
}
}
return messages;
}
/**
* returnFormData
* @param requestForm GBS_MifEntryForm
* @param request HttpServletRequest
* @throws Exception
* @return ErrorMessages
*/
private GBS_MifEntryForm returnFormData(GBS_MifEntryForm thisForm, HttpServletRequest request) throws Exception {
GBS_MifEntryForm returnForm = (GBS_MifEntryForm) thisForm;
ArrayList lstDetail = new ArrayList();
String[] model = thisForm.getModel();
String[] modelOld = thisForm.getModelOld();
String[] qty = thisForm.getQty();
String[] currency = thisForm.getCurrency();
String[] hardPrice = thisForm.getHardPrice();
String[] cpcPrice = thisForm.getCpcPrice();
String[] mcv = thisForm.getMcv();
String[] installDate = thisForm.getInstallDate();
String[] rfpDate = thisForm.getRfpDate();
String[] person = thisForm.getPerson();
for (int i = 0; model != null && i < model.length; i++) {
GBS_MMifDetail_stBean mifdetail_st = new GBS_MMifDetail_stBean();
mifdetail_st.setModel(model[i]);
String strInstallDate = installDate[i];
mifdetail_st.setInstallDate(strInstallDate);
String strRfpDate = rfpDate[i];
mifdetail_st.setRfpDate(strRfpDate);
mifdetail_st.setQty(qty[i]);
mifdetail_st.setCurrency(currency[i]);
mifdetail_st.setHardPrice(hardPrice[i]);
mifdetail_st.setCpcPrice(cpcPrice[i]);
mifdetail_st.setMcv(mcv[i]);
mifdetail_st.setUserName(person[i]);
mifdetail_st.setPerson(person[i]);
mifdetail_st.setModelOld(modelOld[i]);
lstDetail.add(mifdetail_st);
}
returnForm.setMifDetail(lstDetail);
returnForm.setErrorFlag("error");
return returnForm;
}
/**
* remove
* @param String in,char re
* @return String
*/
private String remove(String in, char re) {
String out = "";
for (int i = 0; i < in.length(); i++) {
char charst = in.charAt(i);
if (charst != re) {
out += charst;
}
}
return out;
}
private void getComboxValueAndName(GBS_MifEntryForm thisForm, HttpServletRequest request) throws Exception {
//get combox value from database
GBS_MifEntryActionLogic logic = new GBS_MifEntryActionLogic(this.getDataSource(request));
ReturnValue returnValue = null;
ArrayList lstDetail = new ArrayList();
ArrayList lstModel = new ArrayList();
Map getCountry = new HashMap();
Map getSubsidiary = new HashMap();
Map getCurrency = new HashMap();
//Category
returnValue = logic.getProductCategory();
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
this.setMessage(returnValue.getMessageList());
}
// getErrorCode, getErrorMessage proc
} else {
Map getProductCategory = new HashMap();
getProductCategory = (Map) returnValue.getDataValue();
thisForm.setProductCategoryCodeValue((ArrayList) getProductCategory.get(PRODUCT_CATEGORY_CODE));
thisForm.setProductCategoryLabelValue((ArrayList) getProductCategory.get(PRODUCT_CATEGORY_LABEL));
}
//Country
returnValue = (ReturnValue) logic.getCountry();
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
this.setMessage(returnValue.getMessageList());
}
// getErrorCode, getErrorMessage proc
} else {
getCountry = (Map) returnValue.getDataValue();
thisForm.setCountryCodeValue((ArrayList) getCountry.get(COUNTRY_CODE));
thisForm.setCountryLabelValue((ArrayList) getCountry.get(COUNTRY_NAME));
}
//Subs
returnValue = (ReturnValue) logic.getSubsidiary();
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
this.setMessage(returnValue.getMessageList());
}
// getErrorCode, getErrorMessage proc
} else {
getSubsidiary = (Map) returnValue.getDataValue();
thisForm.setSubsidiaryCodeValue((ArrayList) getSubsidiary.get(SUBSIDIARY_CODE));
thisForm.setSubsidiaryLabelValue((ArrayList) getSubsidiary.get(SUBSIDIARY_NAME));
}
//Currency
returnValue = (ReturnValue) logic.getCurrency();
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
this.setMessage(returnValue.getMessageList());
}
// getErrorCode, getErrorMessage proc
} else {
getCurrency = (Map) returnValue.getDataValue();
thisForm.setCurrencyCodeValue((ArrayList) getCurrency.get(CURRENCY_CODE));
thisForm.setCurrencyLabelValue((ArrayList) getCurrency.get(CURRENCY_LABEL));
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -