📄 info.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.wstore;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import org.apache.log4j.Logger;
import org.compiere.model.*;
import org.compiere.util.*;
/**
* Information Storage.
* Container for JSP Information
*
* @author Jorg Janke
* @version $Id: Info.java,v 1.5 2003/05/04 06:47:27 jjanke Exp $
*/
public class Info
{
/**
* Constructor
* @param ctx context
* @param C_BPartner_ID BPartner
*/
public Info (Properties ctx, int C_BPartner_ID)
{
m_ctx = ctx;
m_C_BPartner_ID = C_BPartner_ID;
log.debug("C_BPartner_ID=" + C_BPartner_ID);
} // Info
/** JSP Name */
static public final String NAME = "info";
/** Logging */
private Logger log = Logger.getLogger(getClass());
/** Context */
private Properties m_ctx = null;
/** Business Partner */
private int m_C_BPartner_ID = 0;
/** Info Message */
private String m_infoMessage = null;
/** Info ID */
private int m_id = 0;
/**
* String Representation
* @return info
*/
public String toString()
{
StringBuffer sb = new StringBuffer("Info[");
sb.append(m_C_BPartner_ID);
sb.append("]");
return sb.toString();
} // toString
/**
* Get Info Message & reset
* @return info message
*/
public String getMessage()
{
String retValue = m_infoMessage;
m_infoMessage = null;
return retValue;
} // getMessage
/**
* Get Info Message - do not reset
* @return info message
*/
public String getInfo()
{
return m_infoMessage;
} // getInfo
/**
* Set Info Message
* @param msg info message
*/
public void setMessage (String msg)
{
m_infoMessage = msg;
} // setMessage
/**
* Get Info Message
* @return info id
*/
public int getId()
{
return m_id;
} // getId
/**
* Set Info Message
* @param id info id
*/
public void setId (String id)
{
try
{
setId (Integer.parseInt (id));
}
catch (NumberFormatException ex)
{
log.error("setId - " + id + " - " + ex.toString());
}
} // setId
/**
* Set Info Message
* @param id info id
*/
public void setId (int id)
{
log.info("setID = " + id);
m_id = id;
} // setId
/*************************************************************************/
/**
* Get Orders
* @return invoices of BP
*/
public ArrayList getOrders()
{
m_infoMessage = null;
ArrayList list = new ArrayList();
String sql = "SELECT * FROM C_Order WHERE C_BPartner_ID=? ORDER BY DocumentNo DESC";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MOrder (m_ctx, rs));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getOrders", e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
log.debug ("getOrders #" + list.size());
return list;
} // getOrders
/**
* Get Shipments
* @return shipments of BP
*/
public ArrayList getShipments()
{
m_infoMessage = null;
ArrayList list = new ArrayList();
String sql = "SELECT * FROM M_InOut WHERE C_BPartner_ID=? ORDER BY DocumentNo DESC";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MInOut (m_ctx, rs));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getShipments", e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
log.debug ("getShipments #" + list.size());
return list;
} // getShipments
/**
* Get Invoices
* @return invoices of BP
*/
public ArrayList getInvoices()
{
ArrayList list = new ArrayList();
String sql = "SELECT * FROM C_Invoice WHERE C_BPartner_ID=? ORDER BY DocumentNo DESC";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MInvoice (m_ctx, rs));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getInvoices", e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
log.debug ("getInvoices #" + list.size());
return list;
} // getInvoices
/**
* Get Invoice.
* Needs to have ID set first
* @return invoices of BP
*/
public MInvoice getInvoice()
{
MInvoice retValue = null;
String sql = "SELECT * FROM C_Invoice WHERE C_BPartner_ID=? AND C_Invoice_ID=?";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, m_C_BPartner_ID);
pstmt.setInt(2, m_id);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = new MInvoice (m_ctx, rs);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getInvoice ID=" + m_id, e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
log.debug ("getInvoice ID=" + m_id + " - " + retValue);
return retValue;
} // getInvoice
/**
* Get Payments
* @return payments of BP
*/
public ArrayList getPayments()
{
ArrayList list = new ArrayList();
String sql = "SELECT * FROM C_Payment WHERE C_BPartner_ID=? ORDER BY DocumentNo DESC";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MPayment (m_ctx, rs));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getPayments", e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
log.debug ("getPayments #" + list.size());
return list;
} // getPayments
/**
* Get Assets
* @return payments of BP
*/
public ArrayList getAssets()
{
ArrayList list = new ArrayList();
String sql = "SELECT * FROM A_Asset WHERE C_BPartner_ID=? ORDER BY Name";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, m_C_BPartner_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MAsset (m_ctx, rs));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getAssets", e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
log.debug ("getAssets #" + list.size());
return list;
} // getAssets
} // Info
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -