// Load Purchase Header private void loadSrchRslt() { try { logger.info( "Company ID : " + companyid + " | User Name : " + username + " > " + "Loading Search..."); tblMstScrSrchRslt.removeAllItems(); List<SmsPurEnqHdrDM> listPurEnq = new ArrayList<SmsPurEnqHdrDM>(); logger.info( "Company ID : " + companyid + " | User Name : " + username + " > " + "Search Parameters are " + companyid + ", " + cbBranch.getValue() + ", " + cbEnqStatus.getValue()); listPurEnq = serviceSmsPurEnqHdr.getSmsPurEnqHdrList( companyid, null, tfEnqNo.getValue(), (Long) cbBranch.getValue(), (String) cbEnqStatus.getValue(), username); recordCnt = listPurEnq.size(); beanPurEnqHdrDM = new BeanItemContainer<SmsPurEnqHdrDM>(SmsPurEnqHdrDM.class); beanPurEnqHdrDM.addAll(listPurEnq); logger.info( "Company ID : " + companyid + " | User Name : " + username + " > " + "Got the PurchaseEnquiry. result set"); tblMstScrSrchRslt.setContainerDataSource(beanPurEnqHdrDM); tblMstScrSrchRslt.setVisibleColumns( new Object[] { "enquiryId", "branchName", "enquiryNo", "enquiryStatus", "lastUpdateddt", "lastUpdatedby" }); tblMstScrSrchRslt.setColumnHeaders( new String[] { "Ref.Id", "Branch Name", "EnquiryNo.", "Status", "Last Updated Date", "Last Updated By" }); tblMstScrSrchRslt.setColumnAlignment("enquiryId", Align.RIGHT); tblMstScrSrchRslt.setColumnFooter("lastUpdatedby", "No.of Records : " + recordCnt); } catch (Exception e) { logger.info(e.getMessage()); } }
@Override protected void saveDetails() throws SaveException, FileNotFoundException, IOException { logger.info( "Company ID : " + companyid + " | User Name : " + username + " > " + "Saving Data... "); try { SmsPurEnqHdrDM purEnqobj = new SmsPurEnqHdrDM(); if (tblMstScrSrchRslt.getValue() != null) { purEnqobj = beanPurEnqHdrDM.getItem(tblMstScrSrchRslt.getValue()).getBean(); purEnqobj.setEnquiryNo(tfEnqNo.getValue()); } purEnqobj.setEnquiryNo(tfEnqNo.getValue()); purEnqobj.setCompanyId(companyid); purEnqobj.setEnqRemark(taEnqRem.getValue().toString()); purEnqobj.setBranchId((Long) cbBranch.getValue()); purEnqobj.setDueDate((Date) dfDueDate.getValue()); purEnqobj.setEnquiryDate((Date) dfEnqDate.getValue()); purEnqobj.setEnquiryStatus(((String) cbEnqStatus.getValue())); purEnqobj.setPreparedBy(employeeId); purEnqobj.setReviewedBy(null); purEnqobj.setActionedBy(null); purEnqobj.setLastUpdateddt(DateUtils.getcurrentdate()); purEnqobj.setLastUpdatedby(username); serviceSmsPurEnqHdr.saveorUpdateSmsPurEnqHdrDetails(purEnqobj); enquiryId = purEnqobj.getEnquiryId(); String[] split = lsVendorName.getValue().toString().replaceAll("\\[", "").replaceAll("\\]", "").split(","); for (String obj : split) { if (obj.trim().length() > 0) { EnquiryVendorDtlDM enqvendtl = new EnquiryVendorDtlDM(); enqvendtl.setEnqid(purEnqobj.getEnquiryId()); System.out.println("vendid" + Long.valueOf(obj.trim())); enqvendtl.setVendorid(Long.valueOf(obj.trim())); serviceEnquiryVendorDtl.save(enqvendtl); } } @SuppressWarnings("unchecked") Collection<SmsPurEnqDtlDM> itemIds = (Collection<SmsPurEnqDtlDM>) tblSmsEnqDtl.getVisibleItemIds(); for (SmsPurEnqDtlDM save : (Collection<SmsPurEnqDtlDM>) itemIds) { save.setEnquiryId(Long.valueOf(purEnqobj.getEnquiryId().toString())); serviceSmsPurEnqDtl.saveorUpdateSmsPurEnqDtlDetails(save); } comments.resetfields(); if (tblMstScrSrchRslt.getValue() == null) { try { SlnoGenDM slnoObj = serviceSlnogen.getSequenceNumber(companyid, branchId, moduleId, "SM_ENQRYNO").get(0); if (slnoObj.getAutoGenYN().equals("Y")) { serviceSlnogen.updateNextSequenceNumber(companyid, branchId, moduleId, "SM_ENQRYNO"); } } catch (Exception e) { } } tfEnqNo.setReadOnly(false); tfEnqNo.setValue(purEnqobj.getEnquiryNo()); tfEnqNo.setReadOnly(true); comments.saveEnquiry(purEnqobj.getEnquiryId(), purEnqobj.getEnquiryStatus()); loadSrchRslt(); enqDtlresetFields(); } catch (Exception e) { logger.info(e.getMessage()); } }
private void buildView() { logger.info( "Company ID : " + companyid + " | User Name : " + username + " > " + "Painting PurchaseEnquiry UI"); // Initialization for Purchase Enquire Details user input components tfEnqNo = new TextField("Enquiry No"); tfEnqNo.setMaxLength(40); tfEnqQty = new TextField(); tfEnqQty.setValue("0"); tfEnqQty.setWidth("90"); dfDueDate = new GERPPopupDateField("Due Date"); dfDueDate.setInputPrompt("Select Date"); dfEnqDate = new GERPPopupDateField("Enquiry Date"); dfEnqDate.setInputPrompt("Select Date"); taEnqDtlRem = new TextArea("Remarks"); taEnqDtlRem.setMaxLength(40); taEnqDtlRem.setWidth("150"); taEnqDtlRem.setHeight("50"); taEnqRem = new TextArea("Remarks"); taEnqRem.setHeight("50"); taEnqDtlRem.setMaxLength(100); cbBranch = new GERPComboBox("Branch Name"); cbBranch.setItemCaptionPropertyId("branchName"); loadBranchList(); try { ApprovalSchemaDM obj = serviceSmsPurEnqHdr.getReviewerId(companyid, appScreenId, branchId, roleId).get(0); if (obj.getApprLevel().equals("Approver")) { cbEnqStatus = new GERPComboBox("Status", BASEConstants.T_SMS_P_ENQUIRY_HDR, BASEConstants.RP_STATUS); } else { cbEnqStatus = new GERPComboBox( "Status", BASEConstants.T_SMS_P_ENQUIRY_HDR, BASEConstants.PE_STATUS_RV); } } catch (Exception e) { logger.info(e.getMessage()); } cbEnqStatus.setWidth("120"); cbEnqDtlStatus = new GERPComboBox("Status", BASEConstants.M_GENERIC_TABLE, BASEConstants.M_GENERIC_COLUMN); lsProduct = new ListSelect("Product Name"); lsProduct.setItemCaptionPropertyId("prodname"); lsProduct.setMultiSelect(true); loadProduct(); lsProduct.setImmediate(true); lsProduct.addValueChangeListener( new ValueChangeListener() { /** */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String[] split = lsProduct .getValue() .toString() .replaceAll("\\[", "") .replaceAll("\\]", "") .split(","); for (String obj : split) { if (obj.trim().length() > 0) { cbUom.setReadOnly(false); cbUom.setValue( serviceProduct .getProductList( companyid, Long.valueOf(obj.trim()), null, null, null, null, null, "F") .get(0) .getUom()); cbUom.setReadOnly(true); } } } }); cbUom = new TextField(); cbUom.setWidth("77"); cbUom.setHeight("23"); lsVendorName = new ListSelect("Vendor Name "); lsVendorName.setMultiSelect(true); lsVendorName.setItemCaptionPropertyId("vendorName"); loadVendorList(); lsVendorName.setWidth("150"); lsVendorName.setHeight("75"); hlSearchLayout = new GERPAddEditHLayout(); assembleSearchLayout(); hlSrchContainer.addComponent(GERPPanelGenerator.createPanel(hlSearchLayout)); resetFields(); loadSrchRslt(); loadPurDtl(); btnaddSpec.setStyleName("add"); btnaddSpec.addClickListener( new ClickListener() { // Click Listener for Add and Update private static final long serialVersionUID = 6551953728534136363L; @Override public void buttonClick(ClickEvent event) { if (dtlValidation()) { saveEnqDtl(); } } }); btndelete.setEnabled(false); // ClickListener for Enquire Detail Tale tblSmsEnqDtl.addItemClickListener( new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { if (tblSmsEnqDtl.isSelected(event.getItemId())) { tblSmsEnqDtl.setImmediate(true); btnaddSpec.setCaption("Add"); btnaddSpec.setStyleName("savebt"); btndelete.setEnabled(false); enqDtlresetFields(); } else { ((AbstractSelect) event.getSource()).select(event.getItemId()); btnaddSpec.setCaption("Update"); btnaddSpec.setStyleName("savebt"); btndelete.setEnabled(true); editSmsPurDetail(); } } }); btndelete.addClickListener( new ClickListener() { // Click Listener for Add and Update private static final long serialVersionUID = 6551953728534136363L; @Override public void buttonClick(ClickEvent event) { if (btndelete == event.getButton()) { deleteDetails(); } } }); }