Search in sources :

Example 41 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class InfoOrderPanel method zoom.

// Elaine 2008/12/16
/**
	 *	Zoom
	 */
public void zoom() {
    log.info("");
    Integer C_Order_ID = getSelectedRowKey();
    if (C_Order_ID == null)
        return;
    MQuery query = new MQuery("C_Order");
    query.addRestriction("C_Order_ID", MQuery.EQUAL, C_Order_ID);
    query.setRecordCount(1);
    int AD_WindowNo = getAD_Window_ID("C_Order", fIsSOTrx.isSelected());
    AEnv.zoom(AD_WindowNo, query);
}
Also used : MQuery(org.compiere.model.MQuery)

Example 42 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class GraphColumn method getMQuery.

//	setHeight
public MQuery getMQuery(MGoal mGoal) {
    MQuery query = null;
    if (//	Single Achievement
    getAchievement() != null) {
        MAchievement a = getAchievement();
        query = MQuery.getEqualQuery("PA_Measure_ID", a.getPA_Measure_ID());
    } else if (//	Multiple Achievements
    getGoal() != null) {
        MGoal goal = getGoal();
        query = MQuery.getEqualQuery("PA_Measure_ID", goal.getPA_Measure_ID());
    } else if (//	Document
    getMeasureCalc() != null) {
        MMeasureCalc mc = getMeasureCalc();
        query = mc.getQuery(mGoal.getRestrictions(false), getMeasureDisplay(), getDate(), //	logged in role
        MRole.getDefault());
    } else if (//	Document
    getProjectType() != null) {
        MProjectType pt = getProjectType();
        query = pt.getQuery(mGoal.getRestrictions(false), getMeasureDisplay(), getDate(), getID(), //	logged in role
        MRole.getDefault());
    } else if (//	Document
    getRequestType() != null) {
        MRequestType rt = getRequestType();
        query = rt.getQuery(mGoal.getRestrictions(false), getMeasureDisplay(), getDate(), getID(), //	logged in role
        MRole.getDefault());
    }
    return query;
}
Also used : MAchievement(org.compiere.model.MAchievement) MProjectType(org.compiere.model.MProjectType) MRequestType(org.compiere.model.MRequestType) MQuery(org.compiere.model.MQuery) MMeasureCalc(org.compiere.model.MMeasureCalc) MGoal(org.compiere.model.MGoal)

Example 43 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class InfoBPartner method zoom.

//	hasHistory
/**
	 *	Zoom
	 */
protected void zoom(int record_ID) {
    log.info("InfoBPartner.zoom");
    Integer C_BPartner_ID = record_ID;
    if (C_BPartner_ID == null)
        return;
    //	AEnv.zoom(MBPartner.Table_ID, C_BPartner_ID.intValue(), true);	//	SO
    MQuery query = new MQuery("C_BPartner");
    query.addRestriction("C_BPartner_ID", MQuery.EQUAL, C_BPartner_ID);
    query.setRecordCount(1);
    //	SO
    int AD_WindowNo = getAD_Window_ID("C_BPartner", true);
    zoom(AD_WindowNo, query);
}
Also used : MQuery(org.compiere.model.MQuery) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 44 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class InfoInOut method zoom.

//  setParameters
/**
	 *	Zoom
	 */
protected void zoom(int record_ID) {
    log.info("InfoInOut.zoom");
    Integer M_InOut_ID = record_ID;
    if (M_InOut_ID == null)
        return;
    MQuery query = new MQuery("M_InOut");
    query.addRestriction("M_InOut_ID", MQuery.EQUAL, M_InOut_ID);
    query.setRecordCount(1);
    int AD_WindowNo = getAD_Window_ID("M_InOut", fIsSOTrx.isSelected());
    zoom(AD_WindowNo, query);
}
Also used : MQuery(org.compiere.model.MQuery) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 45 with MQuery

use of org.compiere.model.MQuery in project adempiere by adempiere.

the class WWindow method doGet.

/**
	 *  Process the HTTP Get request - Initial Call.
	 *  <br>
	 *  http://localhost/adempiere/WWindow?AD_Window_ID=123
	 *  <br>
	 *  Create Window with request parameters
	 *  AD_Window_ID
	 *  AD_Menu_ID
	 *
	 *  Clean up old/existing window
	 *
	 *  @param request
	 *  @param response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //  Get Session attributes
    MobileDoc doc = null;
    sess = request.getSession();
    MobileSessionCtx wsc = MobileSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    if (wsc == null) {
        MobileUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    String line = request.getParameter("record");
    int lineNo = -1;
    if (!Util.isEmpty(line))
        lineNo = Integer.parseInt(line);
    if (lineNo != -1) {
        ws.curTab.navigate(lineNo);
        ws.curTab.setSingleRow(true);
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
        //
        log.fine("Fini");
        //	log.trace(log.l6_Database, doc.toString());
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    }
    String action = MobileUtil.getParameter(request, "action");
    String strSQL = MobileUtil.getParameter(request, "txtSQL");
    if ("edit".equals(action)) {
        ws.setRO(false);
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
        //
        log.fine("Fini");
        //	log.trace(log.l6_Database, doc.toString());
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    } else if ("insert".equals(action)) {
        if (!ws.curTab.dataNew(false))
            ws.curTab.dataIgnore();
        ws.setRO(false);
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
        //
        log.fine("Fini");
        //	log.trace(log.l6_Database, doc.toString());
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    } else if ("list".equals(action)) {
        ws.setRO(true);
        ws.curTab.setSingleRow(false);
        ws.curTab.query(false);
        ws.curTab.navigate(0);
        doc = getMR_Form(request.getRequestURI(), wsc, ws, ws.curTab.getTabLevel() == 0);
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    } else if (!Util.isEmpty(strSQL)) {
        MQuery query = new MQuery();
        if ("FIND".equals(strSQL)) {
            String value = MobileUtil.getParameter(request, "txtValue");
            String docno = MobileUtil.getParameter(request, "txtDocumentNo");
            String name = MobileUtil.getParameter(request, "txtName");
            String desc = MobileUtil.getParameter(request, "txtDescription");
            if (value != null && value.length() != 0)
                query.addRestriction("UPPER(Value)", MQuery.LIKE, "%" + value.toUpperCase() + "%");
            if (docno != null && docno.length() != 0)
                query.addRestriction("UPPER(DocumentNo)", MQuery.LIKE, "%" + docno.toUpperCase() + "%");
            if (name != null && name.length() != 0)
                query.addRestriction("UPPER(Name)", MQuery.LIKE, "%" + name.toUpperCase() + "%");
            if (desc != null && desc.length() != 0)
                query.addRestriction("(UPPER(Description", MQuery.LIKE, "%" + desc.toUpperCase() + "%");
        } else {
            query.addRestriction(strSQL);
        }
        ws.setRO(true);
        ws.curTab.setSingleRow(false);
        ws.curTab.setQuery(query);
        ws.curTab.query(false);
        ws.curTab.navigate(0);
        doc = getMR_Form(request.getRequestURI(), wsc, ws, ws.curTab.getTabLevel() == 0);
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    } else if ("previous".equals(action)) {
        int curTabLevel = ws.curTab.getTabLevel();
        ws.setRO(true);
        ws.curTab.setSingleRow(true);
        while (curTabLevel <= ws.curTab.getTabLevel()) {
            ws.curTab = ws.mWindow.getTab(ws.curTab.getTabNo() - 1);
        }
        ws.curTab.dataRefresh();
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    }
    String tab = request.getParameter("tab");
    int tabNo = -1;
    if (!Util.isEmpty(tab))
        tabNo = Integer.parseInt(tab);
    if (tabNo != -1) {
        ws.mWindow.initTab(tabNo);
        ws.curTab = ws.mWindow.getTab(tabNo);
        ws.curTab.query(false);
        ws.curTab.navigate(0);
        ws.curTab.setSingleRow(false);
        ws.setRO(true);
        doc = getMR_Form(request.getRequestURI(), wsc, ws, false);
        MobileUtil.createResponse(request, response, this, null, doc, false);
        return;
    }
    //  Parameter: AD_Window_ID
    int AD_Window_ID = MobileUtil.getParameterAsInt(request, "AD_Window_ID");
    //  Get Parameter: Menu_ID
    int AD_Menu_ID = MobileUtil.getParameterAsInt(request, "AD_Menu_ID");
    log.info("AD_Window_ID=" + AD_Window_ID + "; AD_Menu_ID=" + AD_Menu_ID);
    String TableName = null;
    //Check to see if Zoom
    int AD_Record_ID = MobileUtil.getParameterAsInt(request, "AD_Record_ID");
    int AD_Table_ID = MobileUtil.getParameterAsInt(request, "AD_Table_ID");
    if (AD_Record_ID != 0 || AD_Table_ID != 0) {
        AD_Window_ID = 0;
        int PO_Window_ID = 0;
        String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
        try {
            PreparedStatement pstmt = DB.prepareStatement(sql, null);
            pstmt.setInt(1, AD_Table_ID);
            ResultSet rs = pstmt.executeQuery();
            if (rs.next()) {
                TableName = rs.getString(1);
                AD_Window_ID = rs.getInt(2);
                PO_Window_ID = rs.getInt(3);
            }
            rs.close();
            pstmt.close();
        } catch (SQLException e) {
            log.log(Level.SEVERE, sql, e);
        }
        if (TableName == null || AD_Window_ID == 0) {
            doc = MobileDoc.createPopup("No Context");
        }
        //	PO Zoom ?
        boolean isSOTrx = true;
        if (PO_Window_ID != 0) {
            String whereClause = TableName + "_ID=" + AD_Record_ID;
            isSOTrx = DB.isSOTrx(TableName, whereClause);
            if (!isSOTrx)
                AD_Window_ID = PO_Window_ID;
        }
    }
    if (ws != null) {
        int WindowNo = ws.mWindow.getWindowNo();
        log.fine("Disposing - WindowNo=" + WindowNo + ", ID=" + ws.mWindow.getAD_Window_ID());
        ws.mWindow.dispose();
        Env.clearWinContext(wsc.ctx, WindowNo);
    }
    /**
		 *  New Window data
		 */
    GridWindowVO mWindowVO = GridWindowVO.create(wsc.ctx, s_WindowNo++, AD_Window_ID, AD_Menu_ID);
    if (mWindowVO == null) {
        String msg = Msg.translate(wsc.ctx, "AD_Window_ID") + " " + Msg.getMsg(wsc.ctx, "NotFound") + ", ID=" + AD_Window_ID + "/" + AD_Menu_ID;
        MobileUtil.createErrorPage(request, response, this, msg);
        sess.setAttribute(WWindowStatus.NAME, null);
        return;
    }
    //  Create New Window
    ws = new WWindowStatus(mWindowVO);
    sess.setAttribute(WWindowStatus.NAME, ws);
    //  Query
    if (AD_Record_ID != 0 || AD_Table_ID != 0) {
        //If Zoom
        ws.mWindow.initTab(ws.curTab.getTabNo());
        ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
        ws.curTab.query(false);
    } else {
        ws.mWindow.initTab(ws.curTab.getTabNo());
        ws.curTab.query(ws.mWindow.isTransaction());
        ws.curTab.navigate(0);
        ws.curTab.setSingleRow(false);
    }
    //  Create Single/Multi Row
    if (ws.curTab.isSingleRow())
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
    else
        doc = getMR_Form(request.getRequestURI(), wsc, ws, true);
    ws.setRO(true);
    MobileUtil.createResponse(request, response, this, null, doc, false);
    log.fine("Closed");
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) GridWindowVO(org.compiere.model.GridWindowVO) MQuery(org.compiere.model.MQuery) PreparedStatement(java.sql.PreparedStatement)

Aggregations

MQuery (org.compiere.model.MQuery)109 PrintInfo (org.compiere.model.PrintInfo)19 GridField (org.compiere.model.GridField)15 MPrintFormat (org.compiere.print.MPrintFormat)14 ReportEngine (org.compiere.print.ReportEngine)12 Point (java.awt.Point)11 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)9 GridWindowVO (org.compiere.model.GridWindowVO)9 SQLException (java.sql.SQLException)8 GridTab (org.compiere.model.GridTab)8 GridWindow (org.compiere.model.GridWindow)7 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 AWindow (org.compiere.apps.AWindow)6 File (java.io.File)5 IOException (java.io.IOException)5 Language (org.compiere.util.Language)4 AdempiereException (org.adempiere.exceptions.AdempiereException)3 MClient (org.compiere.model.MClient)3 MLookup (org.compiere.model.MLookup)3