managerpurchase.java

来自「对学习 VC有所帮助的几个例子」· Java 代码 · 共 790 行 · 第 1/3 页

JAVA
790
字号
            String s2 = String.valueOf(String.valueOf(hashtable1.get("name")));
            float f2 = Float.parseFloat(String.valueOf(String.valueOf(hashtable1.get("price"))));
            float f3 = f2 * f;
            f4 += f3;
            s3 = s3 + "<tr align=center valign=middle> ";
            s3 = s3 + "\t<td>" + s2 + "</td>";
            s3 = s3 + "\t<td>" + f2 + "</td>";
            s3 = s3 + "\t<td>";
            s3 = s3 + "\t<input name=Para" + i + " type=text value=" + (int)f + " size=3></td>";
            s3 = s3 + "\t<td>" + f3 + "</td>";
            s3 = s3 + "\t<td><a href=DealWithCenter.jsp?action=favorite&Pid=" + i + "><font color=blue>收藏</font></a> <a href=DealWithCenter.jsp?action=delcarpro&Pid=" + i + " ><font color=#FF0000>删除</font></a></td>";
            s3 = s3 + "</tr>";
        }

        hashtable2.put("html", s3);
        hashtable2.put("all_total_price", new Float(f4));
        return hashtable2;
    }

    public void KillCar(HttpSession httpsession, String s)
    {
        httpsession.removeValue(s);
    }

    public void Logout(HttpSession httpsession)
    {
        httpsession.invalidate();
    }

    public Hashtable ProductPN(String s, int i)
        throws Exception
    {
        Hashtable hashtable = new Hashtable();
        try
        {
            String s1 = "SELECT * FROM " + s + " WHERE id=" + i;
            ResultSet resultset = dbconn.ExeQuery(s1);
            resultset.next();
            hashtable.put("name", resultset.getString("name"));
            hashtable.put("price", new Float(resultset.getFloat("price")));
            dbconn.CloseConn();
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        return hashtable;
    }

    public void PutProduct(HttpServletRequest httpservletrequest, HttpSession httpsession)
    {
        boolean flag = false;
        Car car = getCar(httpservletrequest);
        Vector vector;
        if(httpsession.getValue("Car") == null)
        {
            vector = new Vector();
        } else
        {
            vector = (Vector)httpsession.getValue("Car");
            for(int i = 0; i < vector.size(); i++)
            {
                Car car1 = (Car)vector.elementAt(i);
                if(car1.getPid() == car.getPid())
                {
                    if(car.getQuantity() == 1)
                        car1.setQuantity(car1.getQuantity() + 1);
                    else
                        car1.setQuantity(car.getQuantity());
                    vector.setElementAt(car1, i);
                    flag = true;
                }
            }

        }
        if(!flag)
            vector.addElement(car);
        httpsession.putValue("Car", vector);
    }

    public Hashtable ReadDataAdmin(String s, int i, String s1, String s2, String s3, String s4, String s5)
        throws Exception
    {
        String s7 = "";
        String s8 = "";
        int j = 0;
        float f = 0.0F;
        boolean flag = false;
        Hashtable hashtable = new Hashtable();
        Hashtable hashtable1 = new Hashtable();
        Vector vector = new Vector();
        try
        {
            s2 = handle.GBK2ISO(s2);
            String s6;
            if(s3.equals("orderid"))
            {
                String s10 = s2;
                s10 = s10.substring(0, s10.length() - 14);
                s6 = "SELECT * FROM " + s4 + " AS a," + s5 + " AS b WHERE a.r_info_id = b.id AND b.id=" + Integer.parseInt(s10) + " GROUP BY a.r_info_id ORDER BY b.id DESC";
            } else
            if(s3.equals("name"))
                s6 = "SELECT *,a.id AS mid,b.id AS rid FROM " + s4 + " AS a," + s5 + " AS b WHERE a.r_info_id = b.id AND a.name LIKE '%" + s2 + "%' GROUP BY a.r_info_id ORDER BY b.id DESC";
            else
            if(s3.equals("r_name"))
                s6 = "SELECT *,a.id AS mid,b.id AS rid FROM " + s4 + " AS a," + s5 + " AS b WHERE a.r_info_id = b.id AND b.r_name LIKE '%" + s2 + "%' GROUP BY a.r_info_id ORDER BY b.id DESC";
            else
                s6 = "SELECT *,a.id AS mid,b.id AS rid FROM " + s4 + " AS a," + s5 + " AS b WHERE a.r_info_id = b.id GROUP BY a.r_info_id ORDER BY b.id DESC";
            ResultSet resultset = dbconn.ExeQuery(s6);
            resultset.last();
            j = resultset.getRow();
            hashtable = turn_page(s, i, j);
            int l = Integer.parseInt(String.valueOf(hashtable.get("pt_st"))) + 1;
            int i1 = Integer.parseInt(String.valueOf(hashtable.get("pt_en"))) + 1;
            resultset.absolute(l);
            for(int k = l; k < i1; k++)
            {
                f++;
                int j1 = resultset.getInt("rid");
                String s9 = handle.Replace(" ", "", resultset.getString("date_time"));
                s9 = handle.Replace(":", "", s9);
                s9 = handle.Replace("-", "", s9);
                s9 = String.valueOf(j1) + s9;
                orderBean orderbean = new orderBean();
                orderbean.setRid(resultset.getInt("rid"));
                orderbean.setStatus(resultset.getInt("status"));
                orderbean.setOrderid(s9);
                orderbean.setName(resultset.getString("name"));
                orderbean.setRName(resultset.getString("r_name"));
                orderbean.setRAddress(resultset.getString("r_address"));
                orderbean.setRTel(resultset.getString("r_tel"));
                orderbean.setDateTime(resultset.getString("date_time"));
                vector.addElement(orderbean);
                if(!resultset.next())
                    break;
            }

            dbconn.CloseConn();
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        String s11 = search_turn(hashtable, s1, s2, s3);
        hashtable1.put("RecordCount", String.valueOf(j));
        hashtable1.put("orderBeanVector", vector);
        hashtable1.put("TurpageStr", s11);
        return hashtable1;
    }

    public void SendOrder(HttpServletRequest httpservletrequest, HttpSession httpsession, String s, String s1, String s2, String s3)
        throws Exception
    {
        String s7 = handle.GBK2ISO(httpservletrequest.getParameter("r_name"));
        String s8 = handle.GBK2ISO(httpservletrequest.getParameter("r_address"));
        String s9 = handle.GBK2ISO(httpservletrequest.getParameter("r_tel"));
        String s10 = handle.GBK2ISO(handle.getString(httpservletrequest, "note"));
        int i = 0;
        Hashtable hashtable = new Hashtable();
        String s4 = "INSERT INTO " + s1 + "(r_name,r_address,r_tel,note,date_time) VALUES('" + s7 + "','" + s8 + "','" + s9 + "','" + s10 + "',sysdate())";
        dbconn.ExeUpdate(s4);
        try
        {
            String s5 = "SELECT * FROM " + s1 + " WHERE r_name = '" + s7 + "' ORDER BY id DESC";
            ResultSet resultset = dbconn.ExeQuery(s5);
            resultset.next();
            i = resultset.getInt("id");
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        Vector vector = (Vector)httpsession.getValue("Car");
        String s11 = (String)httpsession.getValue("LoginUser");
        for(int l = 0; l < vector.size(); l++)
        {
            Car car = (Car)vector.elementAt(l);
            int j = car.getPid();
            int k = car.getQuantity();
            Hashtable hashtable1 = ManagerProduct.DetailProInfo(s2, s3, j);
            float f = Float.parseFloat(String.valueOf(String.valueOf(hashtable1.get("price"))));
            String s6 = "INSERT INTO " + s + "(name,product_id,r_info_id,price,quantity) VALUES('" + s11 + "'," + j + "," + i + "," + f + "," + k + ")";
            dbconn.ExeUpdate(s6);
            s6 = "UPDATE " + s3 + " SET purchase_num = purchase_num + 1 WHERE id = " + j;
            dbconn.ExeUpdate(s6);
        }

        KillCar(httpsession, "Car");
        dbconn.CloseConn();
    }

    public String ShowFavorite(String s, String s1, HttpSession httpsession)
        throws Exception
    {
        Object obj = null;
        String s5 = "";
        int j = 0;
        String s6 = handle.GBK2ISO((String)httpsession.getValue("LoginUser"));
        try
        {
            String s2 = "SELECT * FROM " + s + " WHERE MName='" + s6 + "' ORDER BY id DESC";
            for(ResultSet resultset = dbconn.ExeQuery(s2); resultset.next();)
            {
                j++;
                int k = resultset.getInt("id");
                int i = resultset.getInt("Pid");
                String s3 = "SELECT * FROM " + s1 + " WHERE id=" + i;
                ResultSet resultset1 = dbconn.ExeQuery(s3);
                resultset1.next();
                String s4 = resultset1.getString("name");
                int l = resultset1.getInt("absence");
                String s7;
                if(l == 0)
                    s7 = "<font color=blue>有货</font>";
                else
                    s7 = "<font color=red>缺货</font>";
                s5 = s5 + "<tr align=center valign=middle> ";
                s5 = s5 + "\t<td>" + j + "</td>";
                s5 = s5 + "\t<td>" + s4 + "</td>";
                s5 = s5 + "\t<td>" + resultset.getString("date_time") + "</td>";
                s5 = s5 + "\t<td><font color=#0000FF>" + s7 + "</font></td>";
                s5 = s5 + "\t<td><a href=DealWithCenter.jsp?action=buy&Pid=" + i + ">购买</a> <a href=DealWithCenter.jsp?action=delfavoritepro&Fid=" + k + " onclick=\"return (AlertDel('" + s4 + "'));\"><font color=#FF0000>删除</font></a></td>";
                s5 = s5 + "</tr>";
            }

            dbconn.CloseConn();
        }
        catch(SQLException sqlexception)
        {
            System.err.println("aq.executeQuery:" + sqlexception.getMessage());
        }
        return s5;
    }

    public void UpdateQuantity(HttpServletRequest httpservletrequest, HttpSession httpsession)
    {
        for(Enumeration enumeration = httpservletrequest.getParameterNames(); enumeration.hasMoreElements();)
        {
            String s = (String)enumeration.nextElement();
            if(s.substring(0, 4).equals("Para"))
            {
                int i = Integer.parseInt(httpservletrequest.getParameter(s));
                Vector vector = (Vector)httpsession.getValue("Car");
                for(int j = 0; j < vector.size(); j++)
                {
                    Car car = (Car)vector.elementAt(j);
                    if(s.equals("Para" + String.valueOf(car.getPid())))
                    {
                        car.setQuantity(i);
                        vector.setElementAt(car, j);
                    }
                }

            }
        }

    }

    public boolean changePwd(HttpServletRequest httpservletrequest, String s)
        throws Exception
    {
        boolean flag = false;
        String s1 = "";
        String s4 = handle.getString(httpservletrequest, "old_pwd");

⌨️ 快捷键说明

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