⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goodsinfo.java

📁 用jsp,java写的在线购物系统
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   GoodsInfo.java

package mediastore.dao;

import java.io.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import mediastore.common.DBConnection;
import mediastore.rule.GoodsSearchRule;
import mediastore.util.StrUtility;
import mediastore.web.form.GoodsInfoObj;
import mediastore.web.form.GoodsSearchResultInfo;

// Referenced classes of package mediastore.dao:
//            GoodsTypeCode, GoodsClassCode, GoodsShelfIDCode, GoodsImportGoods

public class GoodsInfo
{

    public GoodsInfo()
    {
    }

    public String[] getGoodsNandUByGoodsId(String goodsId)
    {
        String strbuf[];
        String goodsName;
        float importUnitPrice;
        int nRet = 0;
        strbuf = new String[2];
        goodsName = "<font color=red>新进货</font>";
        importUnitPrice = 0.0F;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            stmt = conn.createStatement();
            strSQL = "SELECT GoodsName,ImportUnitPrice FROM TabGoodsInfo WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
            rs = stmt.executeQuery(strSQL);
            if(!rs.next())
            {
                nRet = -1;
                throw new Exception("获得货物名称失败");
            }
            goodsName = rs.getString(1);
            importUnitPrice = rs.getFloat(2);
            rs.close();
            rs = null;
        }
        catch(Exception exception) { }
        finally
        {
            try
            {
                if(rs != null)
                    rs.close();
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException e) { }
        }
        strbuf[0] = goodsName;
        strbuf[1] = String.valueOf(importUnitPrice);
        return strbuf;
    }

    public String[] getGoodsNandPUandSU(String goodsId)
    {
        String strbuf[];
        String goodsName;
        float PU;
        float SU;
        int nRet = 0;
        strbuf = new String[3];
        goodsName = "<font color=blue>未进货</font>";
        PU = 0.0F;
        SU = 0.0F;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            stmt = conn.createStatement();
            strSQL = "SELECT GoodsName,PurchaseUnitPrice,SpecialUnitPrice FROM TabGoodsInfo WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
            rs = stmt.executeQuery(strSQL);
            if(!rs.next())
            {
                nRet = -1;
                throw new Exception("获得货物名称失败");
            }
            goodsName = rs.getString(1);
            PU = rs.getFloat(2);
            SU = rs.getFloat(3);
            rs.close();
            rs = null;
        }
        catch(Exception exception) { }
        finally
        {
            try
            {
                if(rs != null)
                    rs.close();
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException e) { }
        }
        strbuf[0] = goodsName;
        strbuf[1] = String.valueOf(PU);
        strbuf[2] = String.valueOf(SU);
        return strbuf;
    }

    public int insertTempGoodsInfo(String goodsId, String goodsName, String createPerson)
    {
        int nRet;
        nRet = 0;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            conn.setAutoCommit(false);
            stmt = conn.createStatement();
            strSQL = "insert into TabGoodsInfo( GoodsID, GoodsName, RepertoryAmount, ImportUnitPrice, Creators, LastCreator, LastUpdateTime, ConfirmFlage) values ('" + StrUtility.replaceString(goodsId, "'", "''") + "', '" + StrUtility.replaceString(goodsName, "'", "''") + "', 0, 0, '" + StrUtility.replaceString(createPerson, "'", "''") + "', '" + StrUtility.replaceString(createPerson, "'", "''") + "', getdate(), '0')";
            nRet = stmt.executeUpdate(strSQL);
            if(nRet != 1)
            {
                nRet = -1;
                throw new Exception("插入新记录错误");
            }
            conn.commit();
        }
        catch(Exception e)
        {
            nRet = -1;
        }
        finally
        {
            try
            {
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException ex) { }
        }
        return nRet;
    }

    public void adjustAndDelTemp(String goodsId)
    {
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            stmt = conn.createStatement();
            strSQL = "SELECT ConfirmFlage FROM TabGoodsInfo WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
            rs = stmt.executeQuery(strSQL);
            if(!rs.next())
                throw new Exception("获得确认标志失败");
            String confirmFlage = rs.getString(1);
            rs.close();
            rs = null;
            if(confirmFlage.equals("0"))
            {
                int count = 0;
                strSQL = "SELECT count(*) FROM TabGoodsImportGoods WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "' and ConfirmFlage='0'";
                rs = stmt.executeQuery(strSQL);
                if(!rs.next())
                    throw new Exception("获得符合条件记录数失败");
                count = rs.getInt(1);
                if(count <= 0)
                    deleteAGoods(goodsId);
            }
        }
        catch(Exception exception) { }
        finally
        {
            try
            {
                if(rs != null)
                    rs.close();
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException e) { }
        }
        return;
    }

    public int deleteAGoods(String goodsId)
    {
        int nRet;
        nRet = 0;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            String strSQL = "DELETE FROM TabGoodsInfo WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "' ";
            stmt = conn.createStatement();
            nRet = stmt.executeUpdate(strSQL);
            if(nRet != 1)
                nRet = -1;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            nRet = -1;
        }
        finally
        {
            try
            {
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException e) { }
        }
        return nRet;
    }

    public void importAdjustAandU(String goodsId, int importAmount, float importUnitPrice, String submitPerson)
    {
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            stmt = conn.createStatement();
            strSQL = "SELECT ConfirmFlage FROM TabGoodsInfo WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
            rs = stmt.executeQuery(strSQL);
            if(!rs.next())
                throw new Exception("获得确认标志失败");
            String confirmFlage = rs.getString(1);
            rs.close();
            rs = null;
            if(confirmFlage.equals("0"))
            {
                strSQL = "UPDATE TabGoodsInfo SET RepertoryAmount=" + importAmount + ", ImportUnitPrice=" + importUnitPrice + ", Creators='" + StrUtility.replaceString(submitPerson, "'", "''") + "', LastCreator='" + StrUtility.replaceString(submitPerson, "'", "''") + "', LastUpdateTime=getdate(), ConfirmFlage='1'  WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
                stmt.executeUpdate(strSQL);
                strSQL = "insert into TabRepertoryGoodsPriceCurve( GoodsID, IndexNum, StartTime, EndTime, ImportUnitPrice) values ('" + StrUtility.replaceString(goodsId, "'", "''") + "', 1, getdate(), '2078-06-01 00:00:00', " + importUnitPrice + ")";
                stmt.executeUpdate(strSQL);
            } else
            {
                strSQL = "SELECT RepertoryAmount, ImportUnitPrice, Creators FROM TabGoodsInfo WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
                rs = stmt.executeQuery(strSQL);
                if(!rs.next())
                    throw new Exception("获得库存量、平均进价和创建人串失败");
                int repertoryAmount = rs.getInt(1);
                float oldImportUnitPrice = rs.getFloat(2);
                String oldCreators = rs.getString(3);
                if(oldCreators == null)
                    oldCreators = "";
                rs.close();
                rs = null;
                int newRepertoryAmount = repertoryAmount + importAmount;
                float newImportUnitPrice = (oldImportUnitPrice * (float)repertoryAmount + importUnitPrice * (float)importAmount) / (float)newRepertoryAmount;
                String newCreators = "";
                if(oldCreators.indexOf(submitPerson) == -1)
                    if(oldCreators.equals(""))
                        newCreators = submitPerson;
                    else
                        newCreators = oldCreators + "," + submitPerson;
                strSQL = "UPDATE TabGoodsInfo SET RepertoryAmount=" + newRepertoryAmount + ", ImportUnitPrice=" + newImportUnitPrice + ", Creators='" + StrUtility.replaceString(newCreators, "'", "''") + "', LastCreator='" + StrUtility.replaceString(submitPerson, "'", "''") + "', LastUpdateTime=getdate()  WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
                stmt.executeUpdate(strSQL);
                if(oldImportUnitPrice != newImportUnitPrice)
                {
                    int maxIndexNum = 2;
                    strSQL = "SELECT max(IndexNum) FROM TabRepertoryGoodsPriceCurve WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "'";
                    rs = stmt.executeQuery(strSQL);
                    if(!rs.next())
                        throw new Exception("获得最大序号数失败");
                    maxIndexNum = rs.getInt(1) + 1;
                    rs.close();
                    rs = null;
                    strSQL = "UPDATE TabRepertoryGoodsPriceCurve SET EndTime=getdate() WHERE GoodsID='" + StrUtility.replaceString(goodsId, "'", "''") + "' and IndexNum=" + (maxIndexNum - 1);
                    stmt.executeUpdate(strSQL);
                    strSQL = "insert into TabRepertoryGoodsPriceCurve( GoodsID, IndexNum, StartTime, EndTime, ImportUnitPrice) values ('" + StrUtility.replaceString(goodsId, "'", "''") + "', " + maxIndexNum + ", getdate(), '2078-06-01 00:00:00', " + newImportUnitPrice + ")";
                    stmt.executeUpdate(strSQL);
                }
            }
        }
        catch(Exception exception) { }
        finally
        {
            try
            {
                if(rs != null)
                    rs.close();
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException e) { }
        }
        return;
    }

    public int getRepertoryAmount(String goodsId)
    {
        int nRet;
        nRet = 0;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -