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

📄 goodstypecode.java

📁 用jsp,java写的在线购物系统
💻 JAVA
字号:
// 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:   GoodsTypeCode.java

package mediastore.dao;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import mediastore.common.DBConnection;
import mediastore.util.StrUtility;

// Referenced classes of package mediastore.dao:
//            GoodsInfo

public class GoodsTypeCode
{

    public GoodsTypeCode()
    {
    }

    public String getGoodsTypeName(String goodsType)
    {
        String tmpStr;
        tmpStr = "";
        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 GoodsTypeName FROM TabGoodsTypeCode WHERE GoodsType='" + StrUtility.replaceString(goodsType, "'", "''") + "'";
            rs = stmt.executeQuery(strSQL);
            if(rs.next())
                tmpStr = rs.getString(1);
            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) { }
        }
        return tmpStr;
    }

    public List getGoodsTypeList()
    {
        List goodsTypeList;
        goodsTypeList = new ArrayList();
        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 GoodsType, GoodsTypeName FROM TabGoodsTypeCode ";
            String tmp[];
            for(rs = stmt.executeQuery(strSQL); rs.next(); goodsTypeList.add(tmp))
            {
                tmp = new String[3];
                tmp[0] = rs.getString(1);
                tmp[1] = rs.getString(2);
                GoodsInfo gi = new GoodsInfo();
                if(gi.getGoodsTypeCount(rs.getString(1)) > 0)
                    tmp[2] = "0";
                else
                    tmp[2] = "1";
            }

            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) { }
        }
        return goodsTypeList;
    }

    public int insertNewGoodsType(int max, String goodsTypeName)
    {
        int nRet;
        nRet = 0;
        String goodsType = "";
        goodsType = String.valueOf(max);
        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 TabGoodsTypeCode( GoodsType, GoodsTypeName) values ('" + StrUtility.replaceString(goodsType, "'", "''") + "', '" + StrUtility.replaceString(goodsTypeName, "'", "''") + "')";
            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 int updateGoodsType(String goodsType, String newGoodsTypeName)
    {
        int nRet;
        nRet = 0;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        String strSQL = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            stmt = conn.createStatement();
            strSQL = "UPDATE TabGoodsTypeCode SET GoodsTypeName = '" + StrUtility.replaceString(newGoodsTypeName, "'", "''") + "' WHERE GoodsType = '" + StrUtility.replaceString(goodsType, "'", "''") + "'";
            stmt.executeUpdate(strSQL);
        }
        catch(Exception e)
        {
            nRet = -1;
        }
        finally
        {
            try
            {
                if(stmt != null)
                    stmt.close();
                if(conn != null)
                    dbc.closeDBConnection(conn);
            }
            catch(SQLException e) { }
        }
        return nRet;
    }

    public int deleteGoodsType(String goodsType)
    {
        int nRet;
        nRet = 0;
        DBConnection dbc = null;
        Connection conn = null;
        Statement stmt = null;
        try
        {
            dbc = new DBConnection();
            conn = dbc.getDBConnection();
            String strSQL = "DELETE FROM TabGoodsTypeCode WHERE GoodsType='" + StrUtility.replaceString(goodsType, "'", "''") + "' ";
            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;
    }
}

⌨️ 快捷键说明

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