手机仓储管理系统

1 设计的内容要求

本设计是基于Java实现的手机仓储管理系统,并对手机仓储管理系统进行框架设计和内容的描述。

1.1 设计目的

手机仓储管理系统,本系统作为本学期课程设计必选题目,后台连接数据库,前端有操作友好的界面设计有菜单操作。

1.2  设计要求

实现:

  1. 系统各种信息的输入,包括手机信息、客户订单、厂商信息的输入等。
  2. 手机仓储管理系统的各种信息的查询、修改和维护。
  3. 仓储管理系统要实现如下基本功能:入库业务、出库业务、仓库调拨、库存调拨。
  4. 要有用户的注册与用户管理。

系统功能,同学们在满足上述基础上,可以自行扩展,但要结合实际应用背景与需求分析,设计合理系统功能与友好的操作

2  整体设计

该部分将从系统的需求分析、系统功能设计、系统数据库设计以及整体设计图来描述该系统。

2.1 系统需求分析

目标:客户可以通过系统方便的实现订单录入,出入库管理等业务功能。

面向用户:本系统内部工作人员进行操作。

功能设计

记录客户订单信息,形成订单号,对应订单信息,查询仓库状态;

记录手机信息(品牌、型号、批次、进价、售价)对应订单信息;

记录厂商信息(公司、联系电话、地址、负责人、备注);

入库(完成名称、数量、仓库、品牌、编号信息的入库);

出库(完成名称、数量、仓库、品牌、编号信息的出库)也可以按订单出库;

仓库调拨(用户从一个仓库中可以选择多种手机型号和数量,将其调入到另一个仓库中)

2.2 系统功能设计

(1)有完整的用户登陆和用户注册功能;

(2)有完整的手机信息增删改查功能。用户输入手机型号、品牌、内存、进价、售价、生产时间等信息, 生成相应的手机信息;

(3)有完整的订单信息增删改查功能。用户选择需要的手机型号和数量,并输入客户名、手机号、地址、 时间等信息,生成相应的订单;

(4)有完整的入库功能。用户从已经登记的手机信息中选取需要入库的手机型号和数量,将其放入选定的 仓库中;

(5)有完整的出库功能。用户从未完成的订单信息中选择一条信息,之后选择相应的仓库,如果该仓库中

足订单的要求,即可以完成出库操作,订单从未完成状态变成完成状态,库存中相应的手机型号的数量也 会减少。

(6)有完整的库存调拨功能。用户从一个仓库中可以选择多种手机型号和数量,将其调入到另一个仓库中, 该手机型号的状态在发生调拨的两个仓库中发生变化。

3 设计

手机仓储管理系统

代码的整体结构

手机仓储管理系统

数据库操作类 database 的实现

手机仓储管理系统

 

 

 

户注册与登陆功能实现的流程图

手机仓储管理系统

 

手机信息增删改查功能实现的流程图

手机仓储管理系统

 

 

订单信息增删改查功能实现的流程图

手机仓储管理系统

 

厂商信息增删改查功能实现的流程图

手机仓储管理系统

 

 

入库功能实现的流程图

手机仓储管理系统

 

 

出库功能实现的流程图

手机仓储管理系统

 

 

系统的功能说明

用户注册和登录功能

 手机仓储管理系统

 

 手机仓储管理系统

 

手机仓储管理系统

 

 

 

系统菜单

手机仓储管理系统

 

 

手机信息功能的演示 

(1)选择手机信息,如图

 手机仓储管理系统

 

点击表格,数据会自动填写在下方输入框内

 手机仓储管理系统

 

 

4 实现程序

   1 import java.awt.*;
   2 import javax.swing.*;
   3 import java.sql.Connection;
   4 import java.sql.DriverManager;
   5 import java.sql.ResultSet;
   6 import java.sql.SQLException;
   7 import java.sql.Statement;
   8 
   9 import java.awt.event.MouseAdapter;
  10 import java.awt.event.MouseEvent;
  11 
  12 import javax.swing.ImageIcon;
  13 import javax.swing.JButton;
  14 import javax.swing.table.DefaultTableModel;
  15 import java.awt.BorderLayout;
  16 import java.awt.event.ActionEvent;
  17 import java.awt.event.ActionListener;
  18 import java.util.ArrayList;
  19 import java.util.List;
  20 import javax.swing.JFrame;
  21 import javax.swing.JLabel;
  22 import javax.swing.JPanel;
  23 import javax.swing.JScrollPane;
  24 import javax.swing.JTable;
  25 import javax.swing.JTextField;
  26 import javax.swing.ListSelectionModel;
  27 
  28 public class systems extends JFrame implements ActionListener {
  29     static systems ss;
  30     private List<ImageIcon> list= new ArrayList<ImageIcon>();
  31     JPanel panel = new JPanel();
  32     JLabel label1 = new JLabel("用户名");
  33     JTextField name = new JTextField();
  34     JLabel label2 = new JLabel("密码");
  35     JPasswordField pwd = new JPasswordField();
  36     JButton Enter = new JButton("登录");
  37     JButton Clear = new JButton("注册");
  38     ButtonGroup bgp = new ButtonGroup();
  39     JLabel bg;
  40     public static String[] DEFAULT_FONT  = new String[]{
  41             "Table.font"
  42             ,"TableHeader.font"
  43             ,"CheckBox.font"
  44             ,"Tree.font"
  45             ,"Viewport.font"
  46             ,"ProgressBar.font"
  47             ,"RadioButtonMenuItem.font"
  48             ,"ToolBar.font"
  49             ,"ColorChooser.font"
  50             ,"ToggleButton.font"
  51             ,"Panel.font"
  52             ,"TextArea.font"
  53             ,"Menu.font"
  54             ,"TableHeader.font"
  55              ,"TextField.font"
  56             ,"OptionPane.font"
  57             ,"MenuBar.font"
  58             ,"Button.font"
  59             ,"Label.font"
  60             ,"PasswordField.font"
  61             ,"ScrollPane.font"
  62             ,"MenuItem.font"
  63             ,"ToolTip.font"
  64             ,"List.font"
  65             ,"EditorPane.font"
  66             ,"Table.font"
  67             ,"TabbedPane.font"
  68             ,"RadioButton.font"
  69             ,"CheckBoxMenuItem.font"
  70             ,"TextPane.font"
  71             ,"PopupMenu.font"
  72             ,"TitledBorder.font"
  73             ,"ComboBox.font",
  74             "Title.font"
  75     };
  76     public systems() {
  77         super("登录系统");
  78         this.setResizable(true);
  79         JLayeredPane layeredPane = new JLayeredPane();
  80         bg = new JLabel();
  81 
  82         bg.setIcon(new ImageIcon("image/555.jpg"));
  83 
  84         bg.setBounds(0, 0, 480, 300);
  85         layeredPane.add(bg, new Integer(5));
  86 
  87         Enter.setBounds(80, 250, 100, 20);
  88         Clear.setBounds(250, 250, 100, 20);
  89         layeredPane.add(Clear, new Integer(6));
  90         Enter.addActionListener(this);
  91         Clear.addActionListener(this);
  92         layeredPane.add(Enter, new Integer(6));
  93         label1.setBounds(65, 65, 150, 25);
  94         label1.setForeground(Color.WHITE);
  95         layeredPane.add(label1, new Integer(6));
  96         name.setBounds(230, 65, 150, 25);
  97         layeredPane.add(name, new Integer(6));
  98         label2.setBounds(65, 125, 100, 25);
  99         label2.setForeground(Color.WHITE);
 100         layeredPane.add(label2, new Integer(6));
 101         pwd.setBounds(230, 125, 150, 25);
 102         layeredPane.add(pwd, new Integer(6));
 103 /*
 104         Enter.setBounds(65, 185, 80, 20);
 105         Clear.setBounds(185, 185, 80, 20);
 106         Enter.addActionListener(this);
 107         Clear.addActionListener(this);
 108         panel.add(Enter);
 109         panel.add(Clear);
 110         panel.setLayout(null);
 111 
 112 
 113         label1.setBounds(65, 65, 100, 25);
 114 
 115         name.setBounds(165, 65, 100, 25);
 116 
 117         label2.setBounds(65, 125, 100, 25);
 118 
 119         pwd.setBounds(165, 125, 100, 25);
 120 
 121         this.add(panel);
 122         panel.add(label1);panel.add(name);panel.add(label2);  panel.add(pwd);this.add(bg);
 123 */
 124         this.add(layeredPane);
 125         this.setBounds(600, 400, 530, 370);
 126         this.setVisible(true);
 127         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 128         //new LoginUI();
 129 
 130     }
 131 
 132     public void actionPerformed(ActionEvent e) {
 133         if (e.getSource() == Enter) {
 134             String username, password;
 135             username = name.getText();
 136             password = pwd.getText();
 137             System.out.println(username);
 138             System.out.println(password);
 139             database db =new database();
 140             boolean a = db.user_verify(username,password);
 141             if (a)
 142             {
 143                 this.dispose();
 144                 new frame4();
 145             }
 146             else {
 147                 JOptionPane.showMessageDialog(ss, "登录失败!");
 148             }
 149 
 150         }else if(e.getSource() == Clear)
 151         {
 152             new frame3();
 153         }
 154         else {
 155         System.exit(0);
 156         }
 157     }
 158 
 159     public static void main(String[] args) {
 160         try
 161         {
 162             org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
 163             UIManager.put("RootPane.setupButtonVisible", false);
 164             for (int i = 0; i < DEFAULT_FONT.length; i++)
 165                 UIManager.put(DEFAULT_FONT[i],new Font("微软雅黑", Font.PLAIN,16));
 166         }
 167         catch(Exception e)
 168         {
 169             //TODO exception
 170         }
 171 
 172         systems sys = new systems();
 173     }
 174 }
 175 //4、菜单
 176 class frame4 extends JFrame implements ActionListener{
 177 
 178     JPanel panel = new JPanel();
 179     JLabel label1 = new JLabel("注册用户名");
 180     JMenuBar toolBar,toolBar1;
 181     JLabel label2 = new JLabel("注册密码");
 182     JButton phone,order,manufacturer,in,out,ins,outs,user,sea;
 183     int BUTTONWIDTH=30;
 184     int BUTTONHEIGHT=30;
 185 //菜单
 186     frame4(){
 187         super("菜单");
 188        // this.setResizable(true);
 189         toolBar=new JMenuBar();
 190         toolBar1=new JMenuBar();
 191 
 192         phone=new JButton("手机信息",new ImageIcon("image/手机.png"));
 193         order=new JButton("订单管理",new ImageIcon("image/订单管理.png"));
 194         manufacturer=new JButton("厂商信息",new ImageIcon("image/厂商信息.png"));
 195         in =new JButton("入库业务",new ImageIcon("image/入库业务.png"));
 196         out=new JButton("出库业务",new ImageIcon("image/出库业务.png"));
 197         ins=new JButton("库存调拨",new ImageIcon("image/库存调拨.png"));
 198         outs=new JButton("仓库调拨",new ImageIcon("image/仓库调拨.png"));
 199         user=new JButton("用户管理",new ImageIcon("image/用户管理.png"));
 200         sea=new JButton("虚位以待",new ImageIcon("image/查询信息.png"));
 201         phone.addActionListener(this);
 202         order.addActionListener(this);
 203         manufacturer.addActionListener(this);
 204         in.addActionListener(this);
 205         out.addActionListener(this);
 206         ins.addActionListener(this);
 207         outs.addActionListener(this);
 208         user.addActionListener(this);
 209         sea.addActionListener(this);
 210 
 211         panel.setLayout(null);
 212         toolBar.add(phone);
 213         toolBar.add(order);
 214         toolBar.add(manufacturer);
 215         toolBar.add(in);
 216         toolBar.add(out);
 217         toolBar.add(ins);
 218         toolBar.add(outs);
 219         toolBar.add(user);
 220         toolBar.add(sea);
 221         toolBar.setLayout(new FlowLayout());
 222 
 223         this.add(toolBar);
 224         this.setBounds(400, 200, 750, 520);
 225         this.setVisible(true);
 226         this.setResizable(false);
 227         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 228     }
 229     public void actionPerformed(ActionEvent e) {
 230         if (e.getSource() == phone) {
 231             frame2  fm=new frame2();
 232             fm.setVisible(true);
 233         }else if(e.getSource() == in)
 234         {
 235             frame5  fm5=new frame5();
 236             fm5.setVisible(true);
 237         }else if(e.getSource() == out)
 238         {
 239             frame6  fm6=new frame6();
 240             fm6.setVisible(true);
 241         }else if(e.getSource() == order)
 242         {
 243             frame7  fm7=new frame7();
 244             fm7.setVisible(true);
 245         } else if(e.getSource() == manufacturer)
 246         {
 247             frame8  fm8=new frame8();
 248             fm8.setVisible(true);
 249         }else if(e.getSource() == user)
 250         {
 251             frame9  fm9=new frame9();
 252             fm9.setVisible(true);
 253         }else if(e.getSource() == ins)
 254         {
 255             frame11  fm11=new frame11();
 256             fm11.setVisible(true);
 257         }
 258         else if(e.getSource() == outs)
 259         {
 260             frame11  fm12=new frame11();
 261             fm12.setVisible(true);
 262         }
 263         else if(e.getSource() ==sea )
 264         {
 265             frame12  fm13=new frame12();
 266             fm13.setVisible(true);
 267         }
 268 
 269     }
 270 }
 271 //3、注册
 272 class frame3 extends JFrame implements ActionListener{
 273 
 274     JPanel panel = new JPanel();
 275     JLabel label1 = new JLabel("注册用户名");
 276     JTextField name = new JTextField();
 277     JLabel label2 = new JLabel("注册密码");
 278     JPasswordField pwd = new JPasswordField();
 279     JButton Enter = new JButton("确定");
 280     JButton Clear = new JButton("取消");
 281     frame3(){
 282         super("注册用户");
 283         this.setResizable(true);
 284 
 285         JLayeredPane layeredPane = new JLayeredPane();
 286         JLabel bg = new JLabel();
 287 
 288         bg.setIcon(new ImageIcon("image/555.jpg"));
 289 
 290         bg.setBounds(0, 0, 480, 300);
 291         layeredPane.add(bg, new Integer(4));
 292 
 293         Enter.setBounds(80, 250, 100, 20);
 294         Clear.setBounds(250, 250, 100, 20);
 295         Enter.addActionListener(this);
 296         Clear.addActionListener(this);
 297         layeredPane.add(Enter,new Integer(5));
 298         layeredPane.add(Clear,new Integer(5));
 299        // panel.setLayout(null);
 300         this.add(layeredPane);
 301         label1.setBounds(65, 65, 150, 25);
 302         label1.setForeground(Color.WHITE);
 303         layeredPane.add(label1,new Integer(5));
 304         name.setBounds(230, 65, 150, 25);
 305         layeredPane.add(name,new Integer(5));
 306         label2.setBounds(65, 125, 100, 25);
 307         label2.setForeground(Color.WHITE);
 308         layeredPane.add(label2,new Integer(5));
 309         pwd.setBounds(230, 125, 150, 25);
 310         layeredPane.add(pwd,new Integer(5));
 311 
 312 
 313         this.setBounds(600, 400, 530, 370);
 314         this.setVisible(true);
 315         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 316 
 317     }
 318 
 319     public void actionPerformed(ActionEvent e) {
 320         if (e.getSource() == Enter) {
 321             String username, password;
 322             username = name.getText();
 323             password = pwd.getText();
 324             System.out.println(username);
 325             System.out.println(password);
 326             database db =new database();
 327             if(username.equals("")||password.equals("")){
 328                 this.dispose();
 329             }
 330             else {
 331                 db.user_register(username, password);
 332             }
 333 
 334         }else if(e.getSource() == Clear)
 335         {
 336             this.dispose();
 337         }
 338 
 339     }
 340 }
 341 //phone
 342 class frame2 extends JFrame  {
 343     private DefaultTableModel tableModel;   //表格模型对象
 344     private JTable table;
 345     private JTextField aTextField;
 346     private JTextField bTextField;
 347     private JTextField cTextField;
 348     private JTextField dTextField;
 349     private JTextField eTextField;
 350     private JTextField fTextField;
 351     private JTextField gTextField;
 352     database DB;
 353     String tableVales[][];
 354     public frame2()
 355     {    super();
 356         setTitle("手机信息管理");
 357         setBounds(100,100,500,400);
 358         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 359         String[] columnNames = {"id","品牌","型号","厂商","批次","进价","售价"};   //列名
 360         DB=new database();
 361         String [][]tableVales=new String[200][7]; //数据
 362         String [][]tableVale=null;
 363         tableModel = new DefaultTableModel(tableVale,columnNames);
 364         table = new JTable(tableModel);
 365         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
 366         getContentPane().add(scrollPane,BorderLayout.CENTER);
 367         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
 368         table.addMouseListener(new MouseAdapter(){    //鼠标事件
 369             public void mouseClicked(MouseEvent e){
 370                 int selectedRow = table.getSelectedRow(); //获得选中行索引
 371                 Object oa = tableModel.getValueAt(selectedRow, 0);
 372                 Object ob = tableModel.getValueAt(selectedRow, 1);
 373                 Object oc = tableModel.getValueAt(selectedRow, 2);
 374                 Object od = tableModel.getValueAt(selectedRow, 3);
 375                 Object oe = tableModel.getValueAt(selectedRow, 4);
 376                 Object of = tableModel.getValueAt(selectedRow, 5);
 377                 Object og = tableModel.getValueAt(selectedRow, 6);
 378 
 379                 aTextField.setText(oa.toString());  //给文本框赋值
 380                 bTextField.setText(ob.toString());
 381                 cTextField.setText(oc.toString());  //给文本框赋值
 382                 dTextField.setText(od.toString());
 383                 eTextField.setText(oe.toString());  //给文本框赋值
 384                 fTextField.setText(of.toString());
 385                 gTextField.setText(og.toString());  //给文本框赋值
 386 
 387             }
 388         });
 389         scrollPane.setViewportView(table);
 390         final JPanel panel = new JPanel();
 391         getContentPane().add(panel,BorderLayout.SOUTH);
 392 
 393         panel.add(new JLabel("id: "));
 394         aTextField = new JTextField("",10);
 395         panel.add(aTextField);
 396         panel.add(new JLabel("品牌: "));
 397         bTextField = new JTextField("",10);
 398         panel.add(bTextField);
 399 
 400         panel.add(new JLabel("型号: "));
 401         cTextField = new JTextField("",10);
 402         panel.add(cTextField);
 403         panel.add(new JLabel("厂商: "));
 404         dTextField = new JTextField("",10);
 405         panel.add(dTextField);
 406 
 407         panel.add(new JLabel("批次: "));
 408         eTextField = new JTextField("",10);
 409         panel.add(eTextField);
 410         panel.add(new JLabel("进价: "));
 411         fTextField = new JTextField("",10);
 412         panel.add(fTextField);
 413 
 414         panel.add(new JLabel("售价: "));
 415         gTextField = new JTextField("",10);
 416         panel.add(gTextField);
 417 
 418 
 419         final JButton addButton = new JButton("添加");   //添加按钮
 420         addButton.addActionListener(new ActionListener(){//添加事件
 421             public void actionPerformed(ActionEvent e){
 422                 String []rowValues = {aTextField.getText(),bTextField.getText(),
 423                         cTextField.getText(),dTextField.getText(),
 424                         eTextField.getText(),fTextField.getText(),
 425                         gTextField.getText()};
 426                 tableModel.addRow(rowValues);  //添加一行
 427                 int rowCount = table.getRowCount() +1;   //行数加上1
 428                 //同步数据库
 429                 DB=new database();
 430                 DB.phone_add(aTextField.getText(),
 431                         bTextField.getText(),
 432                         cTextField.getText(),
 433                         dTextField.getText(),
 434                         eTextField.getText(),
 435                         fTextField.getText(),
 436                         gTextField.getText());
 437                 System.out.println("phone.add");
 438 
 439             }
 440         });
 441         panel.add(addButton);
 442 
 443         final JButton updateButton = new JButton("修改");   //修改按钮
 444         updateButton.addActionListener(new ActionListener(){//添加事件
 445             public void actionPerformed(ActionEvent e){
 446                 int selectedRow = table.getSelectedRow();//获得选中行的索引
 447                 if(selectedRow!= -1)   //是否存在选中行
 448                 {
 449                     //修改指定的值:
 450                     tableModel.setValueAt(aTextField.getText(), selectedRow, 0);
 451                     tableModel.setValueAt(bTextField.getText(), selectedRow, 1);
 452                     tableModel.setValueAt(cTextField.getText(), selectedRow, 2);
 453                     tableModel.setValueAt(dTextField.getText(), selectedRow, 3);
 454                     tableModel.setValueAt(eTextField.getText(), selectedRow, 4);
 455                     tableModel.setValueAt(fTextField.getText(), selectedRow, 5);
 456                     tableModel.setValueAt(gTextField.getText(), selectedRow, 6);
 457 
 458                     DB=new database();
 459                     DB.phone_update(aTextField.getText(),
 460                             bTextField.getText(),
 461                             cTextField.getText(),
 462                             dTextField.getText(),
 463                             eTextField.getText(),
 464                             fTextField.getText(),
 465                             gTextField.getText());
 466                     System.out.println("phone.upgrate");
 467                 }
 468             }
 469         });
 470         panel.add(updateButton);
 471 
 472         final JButton delButton = new JButton("删除");
 473         delButton.addActionListener(new ActionListener(){//添加事件
 474             public void actionPerformed(ActionEvent e){
 475                 int selectedRow = table.getSelectedRow();//获得选中行的索引
 476                 if(selectedRow!=-1)  //存在选中行
 477                 {
 478                     tableModel.removeRow(selectedRow);  //删除行
 479                     DB=new database();
 480                     DB.phone_del(aTextField.getText());
 481                 }
 482             }
 483         });
 484         panel.add(delButton);
 485 
 486         final JButton seaButton = new JButton("刷新列表");
 487         seaButton.addActionListener(new ActionListener(){
 488             private String[][] tableVales;//添加事件
 489             private int i=0,j=0;
 490             public void actionPerformed(ActionEvent e){
 491                 i=0;j=0;
 492                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
 493                 System.out.println(selectedRow);
 494                 DB =new database();
 495                 tableVales=DB.search_phone_message();
 496                 while (selectedRow>-1){
 497                 tableModel.removeRow(selectedRow);
 498                     System.out.println(selectedRow);
 499                     selectedRow--;
 500                 }
 501                 while(tableVales[i][j]!=null)
 502                 {      tableModel.addRow(tableVales[i]);
 503                        i=i+1;
 504                 }
 505             }
 506         });
 507         panel.add(seaButton);
 508 
 509         final JButton sButton = new JButton("查询");
 510         sButton.addActionListener(new ActionListener(){
 511             private String[][] tableVales;//添加事件
 512             private int i=0,j=0;
 513             public void actionPerformed(ActionEvent e){
 514                 i=0;j=0;
 515                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
 516                 System.out.println(selectedRow);
 517                 DB =new database();
 518                 tableVales=DB.s_phone_message(bTextField.getText());
 519 
 520                 while (selectedRow!=0){
 521                     tableModel.removeRow(selectedRow);
 522                     selectedRow--;
 523                 }
 524                 tableModel.removeRow(0);
 525                 while(tableVales[i][j]!=null)
 526                 {      tableModel.addRow(tableVales[i]);
 527                     i=i+1;
 528                 }
 529             }
 530         });
 531         panel.add(sButton);
 532 
 533         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 534         this.fresh();
 535         this.setBounds(30,30,1900,1000);
 536     }
 537 
 538 
 539     public void fresh(){
 540         int i=0,j=0;
 541         int selectedRow = table.getRowCount();//获得行数
 542         DB =new database();
 543         tableVales=DB.search_phone_message();
 544         while (selectedRow!=0){
 545             tableModel.removeRow(selectedRow);
 546             selectedRow--;
 547         }
 548         while(tableVales[i][j]!=null)
 549         {      tableModel.addRow(tableVales[i]);
 550             i=i+1;
 551         }
 552     }
 553 
 554 
 555 }
 556 //order
 557 class frame7 extends JFrame  {
 558     private DefaultTableModel tableModel;   //表格模型对象
 559     private JTable table;
 560     private JTextField aTextField;
 561     private JTextField bTextField;
 562     private JTextField cTextField;
 563     private JTextField dTextField;
 564     private JTextField eTextField;
 565     private JTextField fTextField;
 566     private JTextField gTextField;
 567     private JTextField hTextField;
 568     database DB;
 569     String tableVales[][];
 570     public frame7()
 571     {    super();
 572         setTitle("订单信息管理");
 573         setBounds(100,100,500,400);
 574         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 575         String[] columnNames = {"id","编号","用户姓名","手机号","交易金额","订单状态","购买商品","商品数量"};   //列名
 576         DB=new database();
 577         String [][]tableVales=new String[200][8]; //数据
 578         String [][]tableVale=null;
 579         tableModel = new DefaultTableModel(tableVale,columnNames);
 580         table = new JTable(tableModel);
 581         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
 582         getContentPane().add(scrollPane,BorderLayout.CENTER);
 583         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
 584         table.addMouseListener(new MouseAdapter(){    //鼠标事件
 585             public void mouseClicked(MouseEvent e){
 586                 int selectedRow = table.getSelectedRow(); //获得选中行索引
 587                 Object oa = tableModel.getValueAt(selectedRow, 0);
 588                 Object ob = tableModel.getValueAt(selectedRow, 1);
 589                 Object oc = tableModel.getValueAt(selectedRow, 2);
 590                 Object od = tableModel.getValueAt(selectedRow, 3);
 591                 Object oe = tableModel.getValueAt(selectedRow, 4);
 592                 Object of = tableModel.getValueAt(selectedRow, 5);
 593                 Object og = tableModel.getValueAt(selectedRow, 6);
 594                 Object oh = tableModel.getValueAt(selectedRow, 7);
 595 
 596                 aTextField.setText(oa.toString());  //给文本框赋值
 597                 bTextField.setText(ob.toString());
 598                 cTextField.setText(oc.toString());  //给文本框赋值
 599                 dTextField.setText(od.toString());
 600                 eTextField.setText(oe.toString());  //给文本框赋值
 601                 fTextField.setText(of.toString());
 602                 gTextField.setText(og.toString());
 603                 hTextField.setText(oh.toString());//给文本框赋值
 604 
 605             }
 606         });
 607         scrollPane.setViewportView(table);
 608         final JPanel panel = new JPanel();
 609         getContentPane().add(panel,BorderLayout.SOUTH);
 610 
 611         panel.add(new JLabel("id: "));
 612         aTextField = new JTextField("",7);
 613         panel.add(aTextField);
 614         panel.add(new JLabel("编号: "));
 615         bTextField = new JTextField("",7);
 616         panel.add(bTextField);
 617 
 618         panel.add(new JLabel("用户姓名: "));
 619         cTextField = new JTextField("",7);
 620         panel.add(cTextField);
 621         panel.add(new JLabel("手机号: "));
 622         dTextField = new JTextField("",7);
 623         panel.add(dTextField);
 624 
 625         panel.add(new JLabel("交易金额: "));
 626         eTextField = new JTextField("",7);
 627         panel.add(eTextField);
 628         panel.add(new JLabel("订单状态: "));
 629         fTextField = new JTextField("",7);
 630         panel.add(fTextField);
 631 
 632         panel.add(new JLabel("购买商品: "));
 633         gTextField = new JTextField("",7);
 634         panel.add(gTextField);
 635 
 636         panel.add(new JLabel("商品数量: "));
 637         hTextField = new JTextField("",7);
 638         panel.add(hTextField);
 639 
 640 
 641         final JButton addButton = new JButton("添加");   //添加按钮
 642         addButton.addActionListener(new ActionListener(){//添加事件
 643             public void actionPerformed(ActionEvent e){
 644                 String []rowValues = {aTextField.getText(),bTextField.getText(),
 645                         cTextField.getText(),dTextField.getText(),
 646                         eTextField.getText(),fTextField.getText(),
 647                         gTextField.getText(),hTextField.getText()};
 648                 tableModel.addRow(rowValues);  //添加一行
 649                 int rowCount = table.getRowCount() +1;   //行数加上1
 650                 //同步数据库
 651                 DB=new database();
 652                 DB.order_add(aTextField.getText(),
 653                         bTextField.getText(),
 654                         cTextField.getText(),
 655                         dTextField.getText(),
 656                         eTextField.getText(),
 657                         fTextField.getText(),
 658                         gTextField.getText(),
 659                         hTextField.getText());
 660                 System.out.println("order.add");
 661 
 662             }
 663         });
 664         panel.add(addButton);
 665 
 666         final JButton updateButton = new JButton("修改");   //修改按钮
 667         updateButton.addActionListener(new ActionListener(){//添加事件
 668             public void actionPerformed(ActionEvent e){
 669                 int selectedRow = table.getSelectedRow();//获得选中行的索引
 670                 if(selectedRow!= -1)   //是否存在选中行
 671                 {
 672                     //修改指定的值:
 673                     tableModel.setValueAt(aTextField.getText(), selectedRow, 0);
 674                     tableModel.setValueAt(bTextField.getText(), selectedRow, 1);
 675                     tableModel.setValueAt(cTextField.getText(), selectedRow, 2);
 676                     tableModel.setValueAt(dTextField.getText(), selectedRow, 3);
 677                     tableModel.setValueAt(eTextField.getText(), selectedRow, 4);
 678                     tableModel.setValueAt(fTextField.getText(), selectedRow, 5);
 679                     tableModel.setValueAt(gTextField.getText(), selectedRow, 6);
 680                     tableModel.setValueAt(hTextField.getText(), selectedRow, 7);
 681 
 682                     DB=new database();
 683                     DB.order_update(aTextField.getText(),
 684                             bTextField.getText(),
 685                             cTextField.getText(),
 686                             dTextField.getText(),
 687                             eTextField.getText(),
 688                             fTextField.getText(),
 689                             gTextField.getText(),
 690                             hTextField.getText());
 691                     System.out.println("order.upgrate");
 692                 }
 693             }
 694         });
 695         panel.add(updateButton);
 696 
 697         final JButton delButton = new JButton("删除");
 698         delButton.addActionListener(new ActionListener(){//添加事件
 699             public void actionPerformed(ActionEvent e){
 700                 int selectedRow = table.getSelectedRow();//获得选中行的索引
 701                 if(selectedRow!=-1)  //存在选中行
 702                 {
 703                     tableModel.removeRow(selectedRow);  //删除行
 704                     DB=new database();
 705                     DB.order_del(aTextField.getText());
 706                 }
 707             }
 708         });
 709         panel.add(delButton);
 710 
 711         final JButton seaButton = new JButton("刷新列表");
 712         seaButton.addActionListener(new ActionListener(){
 713             private String[][] tableVales;//添加事件
 714             private int i=0,j=0;
 715             public void actionPerformed(ActionEvent e){
 716                 i=0;j=0;
 717                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
 718                 System.out.println(selectedRow);
 719                 DB =new database();
 720                 tableVales=DB.search_order_message();
 721                 while (selectedRow>-1){
 722                     tableModel.removeRow(selectedRow);
 723                     System.out.println(selectedRow);
 724                     selectedRow--;
 725                 }
 726                 while(tableVales[i][j]!=null)
 727                 {      tableModel.addRow(tableVales[i]);
 728                     i=i+1;
 729                 }
 730             }
 731         });
 732         panel.add(seaButton);
 733 
 734         final JButton sButton = new JButton("查询");
 735         sButton.addActionListener(new ActionListener(){
 736             private String[][] tableVales;//添加事件
 737             private int i=0,j=0;
 738             public void actionPerformed(ActionEvent e){
 739                 i=0;j=0;
 740                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
 741                 System.out.println(selectedRow);
 742                 DB =new database();
 743                 tableVales=DB.s_order_message(cTextField.getText());
 744 
 745                 while (selectedRow!=0){
 746                     tableModel.removeRow(selectedRow);
 747                     selectedRow--;
 748                 }
 749                 tableModel.removeRow(0);
 750                 while(tableVales[i][j]!=null)
 751                 {      tableModel.addRow(tableVales[i]);
 752                     i=i+1;
 753                 }
 754             }
 755         });
 756         panel.add(sButton);
 757 
 758         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 759         this.fresh();
 760         this.setBounds(30,30,1900,1000);
 761     }
 762 
 763 
 764     public void fresh(){
 765         int i=0,j=0;
 766         int selectedRow = table.getRowCount();//获得行数
 767         DB =new database();
 768         tableVales=DB.search_order_message();
 769         while (selectedRow!=0){
 770             tableModel.removeRow(selectedRow);
 771             selectedRow--;
 772         }
 773         while(tableVales[i][j]!=null)
 774         {      tableModel.addRow(tableVales[i]);
 775             i=i+1;
 776         }
 777     }
 778 
 779 
 780 }
 781 //厂商信息
 782 class frame8 extends JFrame  {
 783     private DefaultTableModel tableModel;   //表格模型对象
 784     private JTable table;
 785     private JTextField aTextField;
 786     private JTextField bTextField;
 787     private JTextField cTextField;
 788     private JTextField dTextField;
 789     private JTextField eTextField;
 790     private JTextField fTextField;
 791     private JTextField gTextField;
 792     private JTextField hTextField;
 793     database DB;
 794     String tableVales[][];
 795     public frame8()
 796     {    super();
 797         setTitle("订单信息管理");
 798         setBounds(100,100,500,400);
 799         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 800         String[] columnNames = {"id","公司名称","联系电话","地址","负责人","备注"};   //列名
 801         DB=new database();
 802         String [][]tableVales=new String[200][6]; //数据
 803         String [][]tableVale=null;
 804         tableModel = new DefaultTableModel(tableVale,columnNames);
 805         table = new JTable(tableModel);
 806         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
 807         getContentPane().add(scrollPane,BorderLayout.CENTER);
 808         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
 809         table.addMouseListener(new MouseAdapter(){    //鼠标事件
 810             public void mouseClicked(MouseEvent e){
 811                 int selectedRow = table.getSelectedRow(); //获得选中行索引
 812                 Object oa = tableModel.getValueAt(selectedRow, 0);
 813                 Object ob = tableModel.getValueAt(selectedRow, 1);
 814                 Object oc = tableModel.getValueAt(selectedRow, 2);
 815                 Object od = tableModel.getValueAt(selectedRow, 3);
 816                 Object oe = tableModel.getValueAt(selectedRow, 4);
 817                 Object of = tableModel.getValueAt(selectedRow, 5);
 818 
 819 
 820                 aTextField.setText(oa.toString());  //给文本框赋值
 821                 bTextField.setText(ob.toString());
 822                 cTextField.setText(oc.toString());  //给文本框赋值
 823                 dTextField.setText(od.toString());
 824                 eTextField.setText(oe.toString());  //给文本框赋值
 825                 fTextField.setText(of.toString());
 826 
 827 
 828             }
 829         });
 830         scrollPane.setViewportView(table);
 831         final JPanel panel = new JPanel();
 832         getContentPane().add(panel,BorderLayout.SOUTH);
 833 
 834         panel.add(new JLabel("id: "));
 835         aTextField = new JTextField("",7);
 836         panel.add(aTextField);
 837         panel.add(new JLabel("公司名称: "));
 838         bTextField = new JTextField("",7);
 839         panel.add(bTextField);
 840 
 841         panel.add(new JLabel("联系电话: "));
 842         cTextField = new JTextField("",7);
 843         panel.add(cTextField);
 844         panel.add(new JLabel("地址: "));
 845         dTextField = new JTextField("",7);
 846         panel.add(dTextField);
 847 
 848         panel.add(new JLabel("负责人: "));
 849         eTextField = new JTextField("",7);
 850         panel.add(eTextField);
 851         panel.add(new JLabel("备注: "));
 852         fTextField = new JTextField("",7);
 853         panel.add(fTextField);
 854 
 855 
 856 
 857 
 858         final JButton addButton = new JButton("添加");   //添加按钮
 859         addButton.addActionListener(new ActionListener(){//添加事件
 860             public void actionPerformed(ActionEvent e){
 861                 String []rowValues = {aTextField.getText(),bTextField.getText(),
 862                         cTextField.getText(),dTextField.getText(),
 863                         eTextField.getText(),fTextField.getText()};
 864                 tableModel.addRow(rowValues);  //添加一行
 865                 int rowCount = table.getRowCount() +1;   //行数加上1
 866                 //同步数据库
 867                 DB=new database();
 868                 DB.manu_add(aTextField.getText(),
 869                         bTextField.getText(),
 870                         cTextField.getText(),
 871                         dTextField.getText(),
 872                         eTextField.getText(),
 873                         fTextField.getText());
 874                 System.out.println("manu.add");
 875 
 876             }
 877         });
 878         panel.add(addButton);
 879 
 880         final JButton updateButton = new JButton("修改");   //修改按钮
 881         updateButton.addActionListener(new ActionListener(){//添加事件
 882             public void actionPerformed(ActionEvent e){
 883                 int selectedRow = table.getSelectedRow();//获得选中行的索引
 884                 if(selectedRow!= -1)   //是否存在选中行
 885                 {
 886                     //修改指定的值:
 887                     tableModel.setValueAt(aTextField.getText(), selectedRow, 0);
 888                     tableModel.setValueAt(bTextField.getText(), selectedRow, 1);
 889                     tableModel.setValueAt(cTextField.getText(), selectedRow, 2);
 890                     tableModel.setValueAt(dTextField.getText(), selectedRow, 3);
 891                     tableModel.setValueAt(eTextField.getText(), selectedRow, 4);
 892                     tableModel.setValueAt(fTextField.getText(), selectedRow, 5);
 893 
 894 
 895                     DB=new database();
 896                     DB.manu_update(aTextField.getText(),
 897                             bTextField.getText(),
 898                             cTextField.getText(),
 899                             dTextField.getText(),
 900                             eTextField.getText(),
 901                             fTextField.getText()
 902                     );
 903                     System.out.println("manu.upgrate");
 904                 }
 905             }
 906         });
 907         panel.add(updateButton);
 908 
 909         final JButton delButton = new JButton("删除");
 910         delButton.addActionListener(new ActionListener(){//添加事件
 911             public void actionPerformed(ActionEvent e){
 912                 int selectedRow = table.getSelectedRow();//获得选中行的索引
 913                 if(selectedRow!=-1)  //存在选中行
 914                 {
 915                     tableModel.removeRow(selectedRow);  //删除行
 916                     DB=new database();
 917                     System.out.println("iiiiid"+aTextField.getText());
 918                     DB.manu_del(aTextField.getText());
 919 
 920                 }
 921             }
 922         });
 923         panel.add(delButton);
 924 
 925         final JButton seaButton = new JButton("刷新列表");
 926         seaButton.addActionListener(new ActionListener(){
 927             private String[][] tableVales;//添加事件
 928             private int i=0,j=0;
 929             public void actionPerformed(ActionEvent e){
 930                 i=0;j=0;
 931                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
 932                 System.out.println(selectedRow);
 933                 DB =new database();
 934                 tableVales=DB.search_manu_message();
 935                 while (selectedRow>-1){
 936                     tableModel.removeRow(selectedRow);
 937                     System.out.println(selectedRow);
 938                     selectedRow--;
 939                 }
 940                 while(tableVales[i][j]!=null)
 941                 {      tableModel.addRow(tableVales[i]);
 942                     i=i+1;
 943                 }
 944             }
 945         });
 946         panel.add(seaButton);
 947         final JButton sButton = new JButton("查询");
 948         sButton.addActionListener(new ActionListener(){
 949             private String[][] tableVales;//添加事件
 950             private int i=0,j=0;
 951             public void actionPerformed(ActionEvent e){
 952                 i=0;j=0;
 953                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
 954                 System.out.println(selectedRow);
 955                 System.out.println("擦汗寻");
 956                 DB =new database();
 957                 tableVales=DB.s_manu_message(bTextField.getText());
 958                 System.out.println("寻");
 959 
 960                 while (selectedRow!=0){
 961                     tableModel.removeRow(selectedRow);
 962                     selectedRow--;
 963                 }
 964                 tableModel.removeRow(0);
 965                 while(tableVales[i][j]!=null)
 966                 {      tableModel.addRow(tableVales[i]);
 967                     i=i+1;
 968                 }
 969             }
 970         });
 971         panel.add(sButton);
 972 
 973         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 974         this.fresh();
 975         this.setBounds(30,30,1900,1000);
 976     }
 977 
 978 
 979     public void fresh(){
 980         int i=0,j=0;
 981         int selectedRow = table.getRowCount();//获得行数
 982         DB =new database();
 983         tableVales=DB.search_manu_message();
 984         while (selectedRow!=0){
 985             tableModel.removeRow(selectedRow);
 986             selectedRow--;
 987         }
 988         while(tableVales[i][j]!=null)
 989         {      tableModel.addRow(tableVales[i]);
 990             i=i+1;
 991         }
 992     }
 993 }
 994 //in
 995 class frame5 extends JFrame  {
 996     private DefaultTableModel tableModel;   //表格模型对象
 997     private JTable table;
 998     private JTextField aTextField;
 999     private JTextField bTextField;
1000     private JTextField cTextField;
1001     private JTextField dTextField;
1002     private JTextField eTextField;
1003     private JTextField fTextField;
1004     private JTextField gTextField;
1005     database DB;
1006     String tableVales[][];
1007     public frame5()
1008     {    super();
1009         setTitle("入库管理");
1010         setBounds(100,100,500,400);
1011         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1012         String[] columnNames = {"id","名称","数量","仓库","品牌","编号"};   //列名
1013         DB=new database();
1014         String [][]tableVales=new String[200][6]; //数据
1015         String [][]tableVale=null;
1016         tableModel = new DefaultTableModel(tableVale,columnNames);
1017         table = new JTable(tableModel);
1018         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
1019         getContentPane().add(scrollPane,BorderLayout.CENTER);
1020         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
1021         table.addMouseListener(new MouseAdapter(){    //鼠标事件
1022             public void mouseClicked(MouseEvent e){
1023                 int selectedRow = table.getSelectedRow(); //获得选中行索引
1024                 Object oa = tableModel.getValueAt(selectedRow, 0);
1025                 Object ob = tableModel.getValueAt(selectedRow, 1);
1026                 Object oc = tableModel.getValueAt(selectedRow, 2);
1027                 Object od = tableModel.getValueAt(selectedRow, 3);
1028                 Object oe = tableModel.getValueAt(selectedRow, 4);
1029                 Object of = tableModel.getValueAt(selectedRow, 5);
1030                // Object og = tableModel.getValueAt(selectedRow, 6);
1031 
1032                 aTextField.setText(oa.toString());  //给文本框赋值
1033                 bTextField.setText(ob.toString());
1034                 cTextField.setText(oc.toString());  //给文本框赋值
1035                 dTextField.setText(od.toString());
1036                 eTextField.setText(oe.toString());  //给文本框赋值
1037                 fTextField.setText(of.toString());
1038                // gTextField.setText(og.toString());  //给文本框赋值
1039 
1040             }
1041         });
1042         scrollPane.setViewportView(table);
1043         final JPanel panel = new JPanel();
1044         getContentPane().add(panel,BorderLayout.SOUTH);
1045 
1046         panel.add(new JLabel("id: "));
1047         aTextField = new JTextField("",10);
1048         panel.add(aTextField);
1049         panel.add(new JLabel("名称: "));
1050         bTextField = new JTextField("",10);
1051         panel.add(bTextField);
1052 
1053         panel.add(new JLabel("数量: "));
1054         cTextField = new JTextField("",10);
1055         panel.add(cTextField);
1056         panel.add(new JLabel("仓库: "));
1057         dTextField = new JTextField("",10);
1058         panel.add(dTextField);
1059 
1060         panel.add(new JLabel("品牌: "));
1061         eTextField = new JTextField("",10);
1062         panel.add(eTextField);
1063         panel.add(new JLabel("编号: "));
1064         fTextField = new JTextField("",10);
1065         panel.add(fTextField);
1066 
1067         final JButton addButton = new JButton("入库");   //添加按钮
1068         addButton.addActionListener(new ActionListener(){//添加事件
1069             public void actionPerformed(ActionEvent e){
1070                 String []rowValues = {aTextField.getText(),bTextField.getText(),
1071                         cTextField.getText(),dTextField.getText(),
1072                         eTextField.getText(),fTextField.getText(),
1073                         };
1074                 tableModel.addRow(rowValues);  //添加一行
1075                 int rowCount = table.getRowCount() +1;   //行数加上1
1076                 //同步数据库
1077                 DB=new database();
1078                 DB.store_add(aTextField.getText(),
1079                            bTextField.getText(),
1080                          cTextField.getText(),
1081                          dTextField.getText(),
1082                          eTextField.getText(),
1083                         fTextField.getText());
1084                       //  gTextField.getText());
1085                 System.out.println("store.add");
1086 
1087             }
1088         });
1089         panel.add(addButton);
1090 
1091         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1092         this.fresh();
1093         this.setBounds(30,30,1900,1000);
1094     }
1095 
1096 
1097     public void fresh(){
1098         int i=0,j=0;
1099         int selectedRow = table.getRowCount();//获得行数
1100         DB =new database();
1101         tableVales=DB.search_store_message();
1102         while (selectedRow!=0){
1103             tableModel.removeRow(selectedRow);
1104             selectedRow--;
1105         }
1106         while(tableVales[i][j]!=null)
1107         {      tableModel.addRow(tableVales[i]);
1108             i=i+1;
1109         }
1110     }
1111 
1112 
1113 }
1114 //out
1115 class frame6 extends JFrame  {
1116     private DefaultTableModel tableModel;   //表格模型对象
1117     private JTable table;
1118     private JTextField aTextField;
1119     private JTextField bTextField;
1120     private JTextField cTextField;
1121     private JTextField dTextField;
1122     private JTextField eTextField;
1123     private JTextField fTextField;
1124    // private JTextField gTextField;
1125     database DB;
1126     frame10 fm10;
1127     String tableVales[][];
1128     public frame6()
1129     {    super();
1130         setTitle("出库管理");
1131         setBounds(100,100,500,400);
1132         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1133         String[] columnNames = {"id","名称","数量","仓库","品牌","编号"};   //列名
1134         DB=new database();
1135         String [][]tableVales=new String[200][6]; //数据
1136         String [][]tableVale=null;
1137         tableModel = new DefaultTableModel(tableVale,columnNames);
1138         table = new JTable(tableModel);
1139         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
1140         getContentPane().add(scrollPane,BorderLayout.CENTER);
1141         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
1142         table.addMouseListener(new MouseAdapter(){    //鼠标事件
1143             public void mouseClicked(MouseEvent e){
1144                 int selectedRow = table.getSelectedRow(); //获得选中行索引
1145                 if(selectedRow!=-1){fresh();}
1146                 Object oa = tableModel.getValueAt(selectedRow, 0);
1147                 Object ob = tableModel.getValueAt(selectedRow, 1);
1148                 Object oc = tableModel.getValueAt(selectedRow, 2);
1149                 Object od = tableModel.getValueAt(selectedRow, 3);
1150                 Object oe = tableModel.getValueAt(selectedRow, 4);
1151                 Object of = tableModel.getValueAt(selectedRow, 5);
1152                 // Object og = tableModel.getValueAt(selectedRow, 6);
1153 
1154                 aTextField.setText(oa.toString());  //给文本框赋值
1155                 bTextField.setText(ob.toString());
1156                 cTextField.setText(oc.toString());  //给文本框赋值
1157                 dTextField.setText(od.toString());
1158                 eTextField.setText(oe.toString());  //给文本框赋值
1159                 fTextField.setText(of.toString());
1160                 // gTextField.setText(og.toString());  //给文本框赋值
1161 
1162             }
1163         });
1164         scrollPane.setViewportView(table);
1165         final JPanel panel = new JPanel();
1166         getContentPane().add(panel,BorderLayout.SOUTH);
1167 
1168         panel.add(new JLabel("id: "));
1169         aTextField = new JTextField("",10);
1170         panel.add(aTextField);
1171         panel.add(new JLabel("名称: "));
1172         bTextField = new JTextField("",10);
1173         panel.add(bTextField);
1174 
1175         panel.add(new JLabel("数量: "));
1176         cTextField = new JTextField("",10);
1177         panel.add(cTextField);
1178         panel.add(new JLabel("仓库: "));
1179         dTextField = new JTextField("",10);
1180         panel.add(dTextField);
1181 
1182         panel.add(new JLabel("品牌: "));
1183         eTextField = new JTextField("",10);
1184         panel.add(eTextField);
1185         panel.add(new JLabel("编号: "));
1186         fTextField = new JTextField("",10);
1187         panel.add(fTextField);
1188 
1189         final JButton updateButton = new JButton("出库");   //修改按钮
1190         updateButton.addActionListener(new ActionListener(){//添加事件
1191             public void actionPerformed(ActionEvent e){
1192                 int selectedRow = table.getSelectedRow();//获得选中行的索引
1193                 if(selectedRow!= -1)   //是否存在选中行
1194                 {
1195 
1196                     //修改指定的值:
1197                     tableModel.setValueAt(aTextField.getText(), selectedRow, 0);
1198                     tableModel.setValueAt(bTextField.getText(), selectedRow, 1);
1199                     tableModel.setValueAt(cTextField.getText(), selectedRow, 2);
1200                     tableModel.setValueAt(dTextField.getText(), selectedRow, 3);
1201                     tableModel.setValueAt(eTextField.getText(), selectedRow, 4);
1202                     tableModel.setValueAt(fTextField.getText(), selectedRow, 5);
1203                    // tableModel.setValueAt(gTextField.getText(), selectedRow, 6);
1204 
1205                     DB=new database();
1206                     DB.store_update(aTextField.getText(),
1207                             bTextField.getText(),
1208                             cTextField.getText(),
1209                             dTextField.getText(),
1210                             eTextField.getText(),
1211                             fTextField.getText()
1212                            // gTextField.getText()
1213                     );
1214 
1215                     System.out.println("store.upgrate");
1216                 }
1217             }
1218         });
1219         panel.add(updateButton);
1220 
1221         final JButton selectButton = new JButton("选择订单");   //修改按钮
1222         selectButton.addActionListener(new ActionListener(){//添加事件
1223             public void actionPerformed(ActionEvent e){
1224                 fm10 =new frame10();
1225                 System.out.println("555");
1226                 fm10.setVisible(true);
1227                 fresh();
1228 
1229             }
1230         });
1231         panel.add(selectButton);
1232 
1233        // this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1234 
1235 
1236         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1237         this.fresh();
1238         this.setBounds(30,30,1900,1000);
1239 
1240     }
1241 
1242 
1243     public void fresh(){
1244         int i=0,j=0;
1245         int selectedRow = table.getRowCount();//获得行数
1246         DB =new database();
1247         tableVales=DB.search_store_message();
1248         while (selectedRow!=0){
1249             tableModel.removeRow(selectedRow-1);
1250             selectedRow--;
1251         }
1252         while(tableVales[i][j]!=null)
1253         {      tableModel.addRow(tableVales[i]);
1254             i=i+1;
1255         }
1256     }
1257 
1258 
1259 }
1260 class frame11 extends JFrame  {
1261     private DefaultTableModel tableModel;   //表格模型对象
1262     private JTable table;
1263     private JTextField aTextField;
1264     private JTextField bTextField;
1265     private JTextField cTextField;
1266     private JTextField dTextField;
1267     private JTextField eTextField;
1268     private JTextField fTextField;
1269     // private JTextField gTextField;
1270     database DB;
1271     frame10 fm10;
1272     String tableVales[][];
1273     public frame11()
1274     {    super();
1275         setTitle("出库管理");
1276         setBounds(100,100,500,400);
1277         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1278         String[] columnNames = {"id","名称","数量","仓库","品牌","编号"};   //列名
1279         DB=new database();
1280         String [][]tableVales=new String[200][6]; //数据
1281         String [][]tableVale=null;
1282         tableModel = new DefaultTableModel(tableVale,columnNames);
1283         table = new JTable(tableModel);
1284         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
1285         getContentPane().add(scrollPane,BorderLayout.CENTER);
1286         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
1287         table.addMouseListener(new MouseAdapter(){    //鼠标事件
1288             public void mouseClicked(MouseEvent e){
1289                 int selectedRow = table.getSelectedRow(); //获得选中行索引
1290                 if(selectedRow!=-1){fresh();}
1291                 Object oa = tableModel.getValueAt(selectedRow, 0);
1292                 Object ob = tableModel.getValueAt(selectedRow, 1);
1293                 Object oc = tableModel.getValueAt(selectedRow, 2);
1294                 Object od = tableModel.getValueAt(selectedRow, 3);
1295                 Object oe = tableModel.getValueAt(selectedRow, 4);
1296                 Object of = tableModel.getValueAt(selectedRow, 5);
1297                 // Object og = tableModel.getValueAt(selectedRow, 6);
1298 
1299                 aTextField.setText(oa.toString());  //给文本框赋值
1300                 bTextField.setText(ob.toString());
1301                 cTextField.setText(oc.toString());  //给文本框赋值
1302                 dTextField.setText(od.toString());
1303                 eTextField.setText(oe.toString());  //给文本框赋值
1304                 fTextField.setText(of.toString());
1305                 // gTextField.setText(og.toString());  //给文本框赋值
1306 
1307             }
1308         });
1309         scrollPane.setViewportView(table);
1310         final JPanel panel = new JPanel();
1311         getContentPane().add(panel,BorderLayout.SOUTH);
1312 
1313         panel.add(new JLabel("id: "));
1314         aTextField = new JTextField("",10);
1315         panel.add(aTextField);
1316         panel.add(new JLabel("名称: "));
1317         bTextField = new JTextField("",10);
1318         panel.add(bTextField);
1319 
1320         panel.add(new JLabel("数量: "));
1321         cTextField = new JTextField("",10);
1322         panel.add(cTextField);
1323         panel.add(new JLabel("仓库: "));
1324         dTextField = new JTextField("",10);
1325         panel.add(dTextField);
1326 
1327         panel.add(new JLabel("品牌: "));
1328         eTextField = new JTextField("",10);
1329         panel.add(eTextField);
1330         panel.add(new JLabel("编号: "));
1331         fTextField = new JTextField("",10);
1332         panel.add(fTextField);
1333 
1334         final JButton updateButton = new JButton("出库");   //修改按钮
1335         updateButton.addActionListener(new ActionListener(){//添加事件
1336             public void actionPerformed(ActionEvent e){
1337                 int selectedRow = table.getSelectedRow();//获得选中行的索引
1338                 if(selectedRow!= -1)   //是否存在选中行
1339                 {
1340 
1341                     //修改指定的值:
1342                     tableModel.setValueAt(aTextField.getText(), selectedRow, 0);
1343                     tableModel.setValueAt(bTextField.getText(), selectedRow, 1);
1344                     tableModel.setValueAt(cTextField.getText(), selectedRow, 2);
1345                     tableModel.setValueAt(dTextField.getText(), selectedRow, 3);
1346                     tableModel.setValueAt(eTextField.getText(), selectedRow, 4);
1347                     tableModel.setValueAt(fTextField.getText(), selectedRow, 5);
1348                     // tableModel.setValueAt(gTextField.getText(), selectedRow, 6);
1349 
1350                     DB=new database();
1351                     DB.store_update(aTextField.getText(),
1352                             bTextField.getText(),
1353                             cTextField.getText(),
1354                             dTextField.getText(),
1355                             eTextField.getText(),
1356                             fTextField.getText()
1357                             // gTextField.getText()
1358                     );
1359 
1360                     System.out.println("store.upgrate");
1361                 }
1362             }
1363         });
1364         panel.add(updateButton);
1365 
1366 
1367 
1368         // this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1369 
1370 
1371         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1372         this.fresh();
1373         this.setBounds(30,30,1900,1000);
1374 
1375     }
1376 
1377 
1378     public void fresh(){
1379         int i=0,j=0;
1380         int selectedRow = table.getRowCount();//获得行数
1381         DB =new database();
1382         tableVales=DB.search_store_message();
1383         while (selectedRow!=0){
1384             tableModel.removeRow(selectedRow-1);
1385             selectedRow--;
1386         }
1387         while(tableVales[i][j]!=null)
1388         {      tableModel.addRow(tableVales[i]);
1389             i=i+1;
1390         }
1391     }
1392 
1393 
1394 }
1395 //用户管理
1396 class frame9 extends JFrame  {
1397     private DefaultTableModel tableModel;   //表格模型对象
1398     private JTable table;
1399     private JTextField aTextField;
1400     private JTextField bTextField;
1401 
1402     database DB;
1403     String tableVales[][];
1404     public frame9()
1405     {    super();
1406         setTitle("用户管理");
1407         setBounds(100,100,500,400);
1408         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1409         String[] columnNames = {"name","pwd"};   //列名
1410         DB=new database();
1411         String [][]tableVales=new String[200][7]; //数据
1412         String [][]tableVale=null;
1413         tableModel = new DefaultTableModel(tableVale,columnNames);
1414         table = new JTable(tableModel);
1415         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
1416         getContentPane().add(scrollPane,BorderLayout.CENTER);
1417         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
1418         table.addMouseListener(new MouseAdapter(){    //鼠标事件
1419             public void mouseClicked(MouseEvent e){
1420                 int selectedRow = table.getSelectedRow(); //获得选中行索引
1421                 Object oa = tableModel.getValueAt(selectedRow, 0);
1422                 Object ob = tableModel.getValueAt(selectedRow, 1);
1423 
1424 
1425                 aTextField.setText(oa.toString());  //给文本框赋值
1426                 bTextField.setText(ob.toString());
1427 
1428 
1429             }
1430         });
1431         scrollPane.setViewportView(table);
1432         final JPanel panel = new JPanel();
1433         getContentPane().add(panel,BorderLayout.SOUTH);
1434 
1435         panel.add(new JLabel("用户名: "));
1436         aTextField = new JTextField("",10);
1437         panel.add(aTextField);
1438         panel.add(new JLabel("密码: "));
1439         bTextField = new JTextField("",10);
1440         panel.add(bTextField);
1441 
1442         final JButton addButton = new JButton("添加");   //添加按钮
1443         addButton.addActionListener(new ActionListener(){//添加事件
1444             public void actionPerformed(ActionEvent e){
1445                 String []rowValues = {aTextField.getText(),bTextField.getText()};
1446                 tableModel.addRow(rowValues);  //添加一行
1447                 int rowCount = table.getRowCount() +1;   //行数加上1
1448                 //同步数据库
1449                 DB=new database();
1450                 DB.user_add(aTextField.getText(),
1451                         bTextField.getText()
1452                         );
1453                 System.out.println("phone.add");
1454 
1455             }
1456         });
1457         panel.add(addButton);
1458 
1459         final JButton updateButton = new JButton("修改");   //修改按钮
1460         updateButton.addActionListener(new ActionListener(){//添加事件
1461             public void actionPerformed(ActionEvent e){
1462                 int selectedRow = table.getSelectedRow();//获得选中行的索引
1463                 if(selectedRow!= -1)   //是否存在选中行
1464                 {
1465                     //修改指定的值:
1466                     tableModel.setValueAt(aTextField.getText(), selectedRow, 0);
1467                     tableModel.setValueAt(bTextField.getText(), selectedRow, 1);
1468 
1469                     DB=new database();
1470                     DB.user_update(aTextField.getText(),
1471                             bTextField.getText());
1472                     System.out.println("user.upgrate");
1473                 }
1474             }
1475         });
1476         panel.add(updateButton);
1477 
1478         final JButton delButton = new JButton("删除");
1479         delButton.addActionListener(new ActionListener(){//添加事件
1480             public void actionPerformed(ActionEvent e){
1481                 int selectedRow = table.getSelectedRow();//获得选中行的索引
1482                 if(selectedRow!=-1)  //存在选中行
1483                 {
1484                     tableModel.removeRow(selectedRow);  //删除行
1485                     DB=new database();
1486                     DB.user_del(aTextField.getText());
1487                 }
1488             }
1489         });
1490         panel.add(delButton);
1491 
1492         final JButton seaButton = new JButton("刷新列表");
1493         seaButton.addActionListener(new ActionListener(){
1494             private String[][] tableVales;//添加事件
1495             private int i=0,j=0;
1496             public void actionPerformed(ActionEvent e){
1497                 i=0;j=0;
1498                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1499                 System.out.println(selectedRow);
1500                 DB =new database();
1501                 tableVales=DB.search_user_message();
1502                 while (selectedRow>-1){
1503                     tableModel.removeRow(selectedRow);
1504                     System.out.println(selectedRow);
1505                     selectedRow--;
1506                 }
1507                 while(tableVales[i][j]!=null)
1508                 {      tableModel.addRow(tableVales[i]);
1509                     i=i+1;
1510                 }
1511             }
1512         });
1513         panel.add(seaButton);
1514         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1515         this.fresh();
1516         this.setBounds(30,30,1900,1000);
1517     }
1518 
1519 
1520     public void fresh(){
1521         int i=0,j=0;
1522         int selectedRow = table.getRowCount();//获得行数
1523         DB =new database();
1524         tableVales=DB.search_user_message();
1525         while (selectedRow!=0){
1526             tableModel.removeRow(selectedRow);
1527             selectedRow--;
1528         }
1529         while(tableVales[i][j]!=null)
1530         {      tableModel.addRow(tableVales[i]);
1531             i=i+1;
1532         }
1533     }
1534 
1535 
1536 }
1537 //选择订单进行出库
1538 class frame10 extends JFrame  {
1539     private DefaultTableModel tableModel;   //表格模型对象
1540     private JTable table;
1541     private JTextField aTextField;
1542     private JTextField bTextField;
1543     private JTextField cTextField;
1544     private JTextField dTextField;
1545     private JTextField eTextField;
1546     private JTextField fTextField;
1547     private JTextField gTextField;
1548     private JTextField hTextField;
1549     database DB;
1550     String tableVales[][];
1551     public frame10()
1552     {    super();
1553     this.setVisible(true);
1554         setTitle("订单信息管理");
1555         setBounds(100,100,500,400);
1556         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1557         String[] columnNames = {"id","编号","用户姓名","手机号","交易金额","订单状态","购买商品","商品数量"};   //列名
1558         DB=new database();
1559         String [][]tableVales=new String[200][8]; //数据
1560         String [][]tableVale=null;
1561         tableModel = new DefaultTableModel(tableVale,columnNames);
1562         table = new JTable(tableModel);
1563         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
1564         getContentPane().add(scrollPane,BorderLayout.CENTER);
1565         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
1566         table.addMouseListener(new MouseAdapter(){    //鼠标事件
1567             public void mouseClicked(MouseEvent e){
1568                 int selectedRow = table.getSelectedRow(); //获得选中行索引
1569                 Object oa = tableModel.getValueAt(selectedRow, 0);
1570                 Object ob = tableModel.getValueAt(selectedRow, 1);
1571                 Object oc = tableModel.getValueAt(selectedRow, 2);
1572                 Object od = tableModel.getValueAt(selectedRow, 3);
1573                 Object oe = tableModel.getValueAt(selectedRow, 4);
1574                 Object of = tableModel.getValueAt(selectedRow, 5);
1575                 Object og = tableModel.getValueAt(selectedRow, 6);
1576                 Object oh = tableModel.getValueAt(selectedRow, 7);
1577 
1578                 aTextField.setText(oa.toString());  //给文本框赋值
1579                 bTextField.setText(ob.toString());
1580                 cTextField.setText(oc.toString());  //给文本框赋值
1581                 dTextField.setText(od.toString());
1582                 eTextField.setText(oe.toString());  //给文本框赋值
1583                 fTextField.setText(of.toString());
1584                 gTextField.setText(og.toString());
1585                 hTextField.setText(oh.toString());//给文本框赋值
1586 
1587             }
1588         });
1589         scrollPane.setViewportView(table);
1590         final JPanel panel = new JPanel();
1591         getContentPane().add(panel,BorderLayout.SOUTH);
1592 
1593         panel.add(new JLabel("id: "));
1594         aTextField = new JTextField("",7);
1595         panel.add(aTextField);
1596         panel.add(new JLabel("编号: "));
1597         bTextField = new JTextField("",7);
1598         panel.add(bTextField);
1599 
1600         panel.add(new JLabel("用户姓名: "));
1601         cTextField = new JTextField("",7);
1602         panel.add(cTextField);
1603         //panel.add(new JLabel("手机号: "));
1604         dTextField = new JTextField("",7);
1605        // panel.add(dTextField);
1606 
1607         panel.add(new JLabel("交易金额: "));
1608         eTextField = new JTextField("",7);
1609      //   panel.add(eTextField);
1610      //   panel.add(new JLabel("订单状态: "));
1611         fTextField = new JTextField("",7);
1612       //  panel.add(fTextField);
1613 
1614         panel.add(new JLabel("购买商品: "));
1615         gTextField = new JTextField("",7);
1616         panel.add(gTextField);
1617 
1618         panel.add(new JLabel("商品数量: "));
1619         hTextField = new JTextField("",7);
1620         panel.add(hTextField);
1621 
1622 
1623         final JButton addButton = new JButton("选择订单");   //添加按钮
1624         addButton.addActionListener(new ActionListener(){//添加事件
1625             public void actionPerformed(ActionEvent e){
1626                 String a =aTextField.getText();
1627 
1628                 DB=new database();
1629                 DB.outstore(a);
1630                 System.out.println("order.select");
1631 
1632                 dis();
1633 
1634             }
1635         });
1636         panel.add(addButton);
1637 
1638 
1639         final JButton seaButton = new JButton("刷新列表");
1640         seaButton.addActionListener(new ActionListener(){
1641             private String[][] tableVales;//添加事件
1642             private int i=0,j=0;
1643             public void actionPerformed(ActionEvent e){
1644                 i=0;j=0;
1645                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1646                 System.out.println(selectedRow);
1647                 DB =new database();
1648                 tableVales=DB.search_order_message();
1649                 while (selectedRow>-1){
1650                     tableModel.removeRow(selectedRow);
1651                     System.out.println(selectedRow);
1652                     selectedRow--;
1653                 }
1654                 while(tableVales[i][j]!=null)
1655                 {      tableModel.addRow(tableVales[i]);
1656                     i=i+1;
1657                 }
1658             }
1659         });
1660         panel.add(seaButton);
1661         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1662         this.fresh();
1663         this.setBounds(30,30,1250,500);
1664     }
1665 
1666 public void dis(){
1667         this.dispose();
1668 }
1669     public void fresh(){
1670         int i=0,j=0;
1671         int selectedRow = table.getRowCount();//获得行数
1672         DB =new database();
1673         tableVales=DB.search_order_message();
1674         while (selectedRow!=0){
1675             tableModel.removeRow(selectedRow);
1676             selectedRow--;
1677         }
1678         while(tableVales[i][j]!=null)
1679         {      tableModel.addRow(tableVales[i]);
1680             i=i+1;
1681         }
1682     }
1683 
1684 
1685 }
1686 class frame12 extends JFrame  {
1687     private DefaultTableModel tableModel;   //表格模型对象
1688     private JTable table;
1689     private JTextField aTextField;
1690     private JTextField bTextField;
1691     private JTextField cTextField;
1692     private JTextField dTextField;
1693     private JTextField eTextField;
1694     private JTextField fTextField;
1695     private JTextField gTextField;
1696     database DB;
1697     String tableVales[][];
1698     public frame12()
1699     {    super();
1700         setTitle("查询信息");
1701         setBounds(100,100,500,400);
1702         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1703         String[] columnNames = {"id","品牌","型号","厂商","批次","进价","售价"};   //列名
1704         DB=new database();
1705         String [][]tableVales=new String[200][7]; //数据
1706         String [][]tableVale=null;
1707         tableModel = new DefaultTableModel(tableVale,columnNames);
1708         table = new JTable(tableModel);
1709         JScrollPane scrollPane = new JScrollPane(table);   //支持滚动
1710         getContentPane().add(scrollPane,BorderLayout.CENTER);
1711         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);  //单选
1712 
1713         table.addMouseListener(new MouseAdapter(){    //鼠标事件
1714             public void mouseClicked(MouseEvent e){
1715                 int selectedRow = table.getSelectedRow(); //获得选中行索引
1716              /*   Object oa = tableModel.getValueAt(selectedRow, 0);
1717                 Object ob = tableModel.getValueAt(selectedRow, 1);
1718                 Object oc = tableModel.getValueAt(selectedRow, 2);
1719                 Object od = tableModel.getValueAt(selectedRow, 3);
1720                 Object oe = tableModel.getValueAt(selectedRow, 4);
1721                 Object of = tableModel.getValueAt(selectedRow, 5);
1722                 Object og = tableModel.getValueAt(selectedRow, 6);
1723 
1724                 aTextField.setText(oa.toString());  //给文本框赋值
1725                 bTextField.setText(ob.toString());
1726                 cTextField.setText(oc.toString());  //给文本框赋值
1727                 dTextField.setText(od.toString());
1728                 eTextField.setText(oe.toString());  //给文本框赋值
1729                 fTextField.setText(of.toString());
1730                 gTextField.setText(og.toString());  //给文本框赋值
1731 */
1732             }
1733         });
1734         scrollPane.setViewportView(table);
1735         final JPanel panel = new JPanel();
1736         getContentPane().add(panel,BorderLayout.SOUTH);
1737 
1738        /* panel.add(new JLabel("id: "));
1739         aTextField = new JTextField("",10);
1740       //  panel.add(aTextField);
1741        // panel.add(new JLabel("品牌: "));
1742         bTextField = new JTextField("",10);
1743         //panel.add(bTextField);
1744 
1745         //panel.add(new JLabel("型号: "));
1746         cTextField = new JTextField("",10);
1747         //panel.add(cTextField);
1748         //panel.add(new JLabel("厂商: "));
1749         dTextField = new JTextField("",10);
1750         //panel.add(dTextField);
1751 
1752         //panel.add(new JLabel("批次: "));
1753         eTextField = new JTextField("",10);
1754         //panel.add(eTextField);
1755         //panel.add(new JLabel("进价: "));
1756         fTextField = new JTextField("",10);
1757         //panel.add(fTextField);
1758 
1759         //panel.add(new JLabel("售价: "));
1760         gTextField = new JTextField("",10);
1761         //panel.add(gTextField);*/
1762 
1763 
1764 
1765         final JButton seaButton = new JButton("查询手机信息");
1766         seaButton.addActionListener(new ActionListener(){
1767             private String[][] tableVales;//添加事件
1768             private int i=0,j=0;
1769             public void actionPerformed(ActionEvent e){
1770                 i=0;j=0;
1771                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1772                 System.out.println(selectedRow);
1773                 DB =new database();
1774                 tableVales=DB.search_phone_message();
1775                 while (selectedRow>-1){
1776                     tableModel.removeRow(selectedRow);
1777                     System.out.println(selectedRow);
1778                     selectedRow--;
1779                 }
1780                 while(tableVales[i][j]!=null)
1781                 {      tableModel.addRow(tableVales[i]);
1782                     i=i+1;
1783                 }
1784             }
1785         });
1786 
1787         final JButton seaButton2 = new JButton("查询厂商信息");
1788         seaButton.addActionListener(new ActionListener(){
1789             private String[][] tableVales;//添加事件
1790             private int i=0,j=0;
1791             public void actionPerformed(ActionEvent e){
1792                 i=0;j=0;
1793                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1794                 System.out.println(selectedRow);
1795                 DB =new database();
1796                 tableVales=DB.search_manu_message();
1797                 while (selectedRow>-1){
1798                     tableModel.removeRow(selectedRow);
1799                     System.out.println(selectedRow);
1800                     selectedRow--;
1801                 }
1802                 while(tableVales[i][j]!=null)
1803                 {      tableModel.addRow(tableVales[i]);
1804                     i=i+1;
1805                 }
1806             }
1807         });
1808         panel.add(seaButton2);
1809 
1810         final JButton seaButton3= new JButton("查询订单信息");
1811         seaButton.addActionListener(new ActionListener(){
1812             private String[][] tableVales;//添加事件
1813             private int i=0,j=0;
1814             public void actionPerformed(ActionEvent e){
1815                 i=0;j=0;
1816                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1817                 System.out.println(selectedRow);
1818                 DB =new database();
1819                 tableVales=DB.search_order_message();
1820                 while (selectedRow>-1){
1821                     tableModel.removeRow(selectedRow);
1822                     System.out.println(selectedRow);
1823                     selectedRow--;
1824                 }
1825                 while(tableVales[i][j]!=null)
1826                 {      tableModel.addRow(tableVales[i]);
1827                     i=i+1;
1828                 }
1829             }
1830         });
1831         panel.add(seaButton3);
1832 
1833         final JButton seaButton4= new JButton("查询库存信息");
1834         seaButton.addActionListener(new ActionListener(){
1835             private String[][] tableVales;//添加事件
1836             private int i=0,j=0;
1837             public void actionPerformed(ActionEvent e){
1838                 i=0;j=0;
1839                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1840                 System.out.println(selectedRow);
1841                 DB =new database();
1842                 tableVales=DB.search_order_message();
1843                 while (selectedRow>-1){
1844                     tableModel.removeRow(selectedRow);
1845                     System.out.println(selectedRow);
1846                     selectedRow--;
1847                 }
1848                 while(tableVales[i][j]!=null)
1849                 {      tableModel.addRow(tableVales[i]);
1850                     i=i+1;
1851                 }
1852             }
1853         });
1854         panel.add(seaButton4);
1855 
1856         final JButton seaButton5= new JButton("查询用户信息");
1857         seaButton.addActionListener(new ActionListener(){
1858             private String[][] tableVales;//添加事件
1859             private int i=0,j=0;
1860             public void actionPerformed(ActionEvent e){
1861                 i=0;j=0;
1862                 int selectedRow = table.getRowCount()-1;//获得选中行的索引
1863                 System.out.println(selectedRow);
1864                 DB =new database();
1865                 tableVales=DB.search_order_message();
1866                 while (selectedRow>-1){
1867                     tableModel.removeRow(selectedRow);
1868                     System.out.println(selectedRow);
1869                     selectedRow--;
1870                 }
1871                 while(tableVales[i][j]!=null)
1872                 {      tableModel.addRow(tableVales[i]);
1873                     i=i+1;
1874                 }
1875             }
1876         });
1877         panel.add(seaButton5);
1878 
1879 
1880         this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1881        // this.fresh();
1882         this.setBounds(30,30,1900,1000);
1883     }
1884 
1885 
1886     public void fresh(){
1887         int i=0,j=0;
1888         int selectedRow = table.getRowCount();//获得行数
1889         DB =new database();
1890         tableVales=DB.search_phone_message();
1891         while (selectedRow!=0){
1892             tableModel.removeRow(selectedRow);
1893             selectedRow--;
1894         }
1895         while(tableVales[i][j]!=null)
1896         {      tableModel.addRow(tableVales[i]);
1897             i=i+1;
1898         }
1899     }
1900 
1901 
1902 }
1903 class database{
1904     public database(){}
1905     public void create() {
1906         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
1907         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
1908         // MySQL 8.0 以上版本 - JDBC 驱动名及数据库 URL
1909         // String JDriver= "com.mysql.cj.jdbc.Driver";
1910         // String conURL = "jdbc:mysql://localhost:3306/RUNOOB?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
1911         // 数据库的用户名与密码,需要根据自己的设置
1912         String USER = "wth";                     //MySql用户名
1913         String PASS = "1234";          //MySql密码,要采用你的密码
1914         try {
1915             Class.forName(JDriver);  //加载JDBC驱动程序
1916         }
1917         catch(java.lang.ClassNotFoundException e) {
1918             System.out.println("ForName :" + e.getMessage( ));
1919         }
1920         try {
1921             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
1922             Statement s=con.createStatement( );  //建立Statement类对象
1923             String query = "create table person ( "
1924                     + "id char(10),"
1925                     + "num char(10),"
1926                     + "name char(15),"
1927                     + "gender char(10),"
1928                     + "age char(10),"
1929                     + "Java char(10),"
1930                     + "Data_Structure char(10),"
1931                     + "Data_base char(10),"
1932                     + "score integer"
1933                     + ")";  //创建一个学生表person
1934             s.executeUpdate(query);  //执行SQL命令
1935 
1936             s.close( );  //释放Statement所连接的数据库及JDBC资源
1937             con.close( );  //关闭与数据库的连线
1938         }
1939         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
1940     }
1941     public void order_add(String a1,String a2,String a3,String a4,String a5,String a6,String a7,String a8) {
1942         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
1943         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
1944 
1945         String USER = "wth";       //MySql用户名
1946         String PASS = "1234";   //MySql密码,要采用你的密码
1947         try {
1948             Class.forName(JDriver);  //加载JDBC驱动程序
1949         }
1950         catch(java.lang.ClassNotFoundException e) {
1951             System.out.println("ForName :" + e.getMessage( ));
1952         }
1953         try {
1954             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
1955             Statement s=con.createStatement( );  //建立Statement类对象
1956             String r1="insert into `order`  values('"+a1+"','"+a2+"','"+a3+"','"+a4+"','"+a5+"','"+a6+"','"+a7+"','"+a8+"')";
1957             System.out.println(r1);
1958             // String r2="insert into person values("+"'0004','2018112001','高','女','29','70','90','89','259')";
1959             // String r3="insert into person values("+"'0005','2018112002','李','男','25','90','60','89','229')";
1960             s.executeUpdate(r1);       //  s.executeUpdate(r2);        s.executeUpdate(r3);
1961 
1962             s.close( );  //释放Statement所连接的数据库及JDBC资源
1963             con.close( );  //关闭与数据库的连线
1964         }
1965         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
1966     }
1967     public void order_del(String ID) {
1968         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
1969         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
1970 
1971         String USER = "wth";       //MySql用户名
1972         String PASS = "1234";   //MySql密码,要采用你的密码
1973         try {
1974             Class.forName(JDriver);  //加载JDBC驱动程序
1975         }
1976         catch(java.lang.ClassNotFoundException e) {
1977             System.out.println("ForName :" + e.getMessage( ));
1978         }
1979         try {
1980             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
1981             Statement s=con.createStatement( );  //建立Statement类对象
1982             String sql="delete from `order` where id="+ID;
1983 
1984             s.executeUpdate(sql);
1985             s.close( );  //释放Statement所连接的数据库及JDBC资源
1986             con.close( );  //关闭与数据库的连线
1987         }
1988         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
1989     }
1990     public void order_update(String a1,String a2,String a3,String a4,String a5,String a6,String a7,String a8) {
1991         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
1992         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
1993 
1994         String USER = "wth";       //MySql用户名
1995         String PASS = "1234";   //MySql密码,要采用你的密码
1996         String ID="0003";
1997         try {
1998             Class.forName(JDriver);  //加载JDBC驱动程序
1999         }
2000         catch(java.lang.ClassNotFoundException e) {
2001             System.out.println("ForName :" + e.getMessage( ));
2002         }
2003         try {
2004             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2005             Statement s=con.createStatement( );  //建立Statement类对象
2006             String sql="update `order` set "+"id="+a1+", num='"+a2+"', user_name='"+a3+"', phone='"+
2007                     a4+"', money='"+a5+"', status='"+a6+"', goods='"+a7+"', numbers='"+a8+
2008                     "' where id='"+a1+"'";
2009             System.out.println(sql);
2010             s.executeUpdate(sql);
2011             s.close( );  //释放Statement所连接的数据库及JDBC资源
2012             con.close( );  //关闭与数据库的连线
2013         }
2014         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2015     }
2016     public String[][] search_order_message() {
2017         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2018         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2019         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2020         String USER = "wth";
2021         String PASS = "1234";
2022         String results[][]=new String[200][8];
2023         //String[ ] id={"0002","0003"};
2024         //int[ ] score={89,60};
2025         int i=0;
2026         int j=0;
2027         try {
2028             Class.forName(JDriver);  //加载JDBC驱动程序
2029         }
2030         catch(java.lang.ClassNotFoundException e) {
2031             System.out.println("ForName :" + e.getMessage( ));
2032         }
2033         try {
2034             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2035         /*    PreparedStatement ps=con.prepareStatement(
2036             "UPDATE person set score=? where id=? ");
2037             int i=0,idlen=id.length;
2038             do{ ps.setInt(1,score[i]);
2039                  ps.setString(2,id[i]);
2040                  ps.executeUpdate( );//执行SQL修改命令
2041                  ++i;
2042             }while(i<id.length);
2043             ps.close( );
2044             */
2045             //查询数据库并把数据表的内容输出到屏幕上
2046             Statement s=con.createStatement( );
2047             ResultSet rs=s.executeQuery("select * from `order`");
2048 
2049             while(rs.next( )) {
2050                 results[i][0]= rs.getString("id");
2051                 results[i][1]=rs.getString("num");
2052                 results[i][2]=rs.getString("user_name");
2053                 results[i][3]=rs.getString("phone");
2054                 results[i][4]=rs.getString("money");
2055                 results[i][5]=rs.getString("status");
2056                 results[i][6]=rs.getString("goods");
2057                 results[i][7]=rs.getString("numbers");
2058                 i=i+1;
2059             }
2060             System.out.println(results);
2061             s.close( );  //释放Statement所连接的数据库及JDBC资源
2062             con.close( );  //关闭与数据库的连线
2063 
2064         }
2065         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2066         return results;
2067     }
2068     public void manu_add(String a1,String a2,String a3,String a4,String a5,String a6) {
2069         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2070         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2071 
2072         String USER = "wth";       //MySql用户名
2073         String PASS = "1234";   //MySql密码,要采用你的密码
2074         try {
2075             Class.forName(JDriver);  //加载JDBC驱动程序
2076         }
2077         catch(java.lang.ClassNotFoundException e) {
2078             System.out.println("ForName :" + e.getMessage( ));
2079         }
2080         try {
2081             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2082             Statement s=con.createStatement( );  //建立Statement类对象
2083             String r1="insert into `manu`  values('"+a1+"','"+a2+"','"+a3+"','"+a4+"','"+a5+"','"+a6+"')";
2084             System.out.println(r1);
2085             // String r2="insert into person values("+"'0004','2018112001','高','女','29','70','90','89','259')";
2086             // String r3="insert into person values("+"'0005','2018112002','李','男','25','90','60','89','229')";
2087             s.executeUpdate(r1);       //  s.executeUpdate(r2);        s.executeUpdate(r3);
2088 
2089             s.close( );  //释放Statement所连接的数据库及JDBC资源
2090             con.close( );  //关闭与数据库的连线
2091         }
2092         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2093     }
2094     public void manu_del(String ID) {
2095         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2096         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2097 
2098         String USER = "wth";       //MySql用户名
2099         String PASS = "1234";   //MySql密码,要采用你的密码
2100         try {
2101             Class.forName(JDriver);  //加载JDBC驱动程序
2102         }
2103         catch(java.lang.ClassNotFoundException e) {
2104             System.out.println("ForName :" + e.getMessage( ));
2105         }
2106         try {
2107             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2108             Statement s=con.createStatement( );  //建立Statement类对象
2109             String sql="delete from `manu` where id='"+ID+"'";
2110             System.out.println(sql);
2111             s.executeUpdate(sql);
2112             s.close( );  //释放Statement所连接的数据库及JDBC资源
2113             con.close( );  //关闭与数据库的连线
2114         }
2115         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2116     }
2117     public void manu_update(String a1,String a2,String a3,String a4,String a5,String a6) {
2118         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2119         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2120 
2121         String USER = "wth";       //MySql用户名
2122         String PASS = "1234";   //MySql密码,要采用你的密码
2123         String ID="0003";
2124         try {
2125             Class.forName(JDriver);  //加载JDBC驱动程序
2126         }
2127         catch(java.lang.ClassNotFoundException e) {
2128             System.out.println("ForName :" + e.getMessage( ));
2129         }
2130         try {
2131             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2132             Statement s=con.createStatement( );  //建立Statement类对象
2133             String sql="update `manu` set "+"id="+a1+", name='"+a2+"', phone='"+a3+"', address='"+
2134                     a4+"', person='"+a5+"', remarks='"+a6+
2135                     "' where id='"+a1+"'";
2136             System.out.println(sql);
2137             s.executeUpdate(sql);
2138             s.close( );  //释放Statement所连接的数据库及JDBC资源
2139             con.close( );  //关闭与数据库的连线
2140         }
2141         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2142     }
2143     public String[][] search_manu_message() {
2144         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2145         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2146         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2147         String USER = "wth";
2148         String PASS = "1234";
2149         String results[][]=new String[200][6];
2150         //String[ ] id={"0002","0003"};
2151         //int[ ] score={89,60};
2152         int i=0;
2153         int j=0;
2154         try {
2155             Class.forName(JDriver);  //加载JDBC驱动程序
2156         }
2157         catch(java.lang.ClassNotFoundException e) {
2158             System.out.println("ForName :" + e.getMessage( ));
2159         }
2160         try {
2161             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2162         /*    PreparedStatement ps=con.prepareStatement(
2163             "UPDATE person set score=? where id=? ");
2164             int i=0,idlen=id.length;
2165             do{ ps.setInt(1,score[i]);
2166                  ps.setString(2,id[i]);
2167                  ps.executeUpdate( );//执行SQL修改命令
2168                  ++i;
2169             }while(i<id.length);
2170             ps.close( );
2171             */
2172             //查询数据库并把数据表的内容输出到屏幕上
2173             Statement s=con.createStatement( );
2174             ResultSet rs=s.executeQuery("select * from `manu`");
2175 
2176             while(rs.next( )) {
2177                 results[i][0]= rs.getString("id");
2178                 results[i][1]=rs.getString("name");
2179                 results[i][2]=rs.getString("phone");
2180                 results[i][3]=rs.getString("address");
2181                 results[i][4]=rs.getString("person");
2182                 results[i][5]=rs.getString("remarks");
2183 
2184                 i=i+1;
2185             }
2186             System.out.println(results);
2187             s.close( );  //释放Statement所连接的数据库及JDBC资源
2188             con.close( );  //关闭与数据库的连线
2189 
2190         }
2191         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2192         return results;
2193     }
2194     public void store_add(String a1,String a2,String a3,String a4,String a5,String a6) {
2195         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2196         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2197 
2198         String USER = "wth";       //MySql用户名
2199         String PASS = "1234";   //MySql密码,要采用你的密码
2200         try {
2201             Class.forName(JDriver);  //加载JDBC驱动程序
2202         }
2203         catch(java.lang.ClassNotFoundException e) {
2204             System.out.println("ForName :" + e.getMessage( ));
2205         }
2206         try {
2207             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2208             Statement s=con.createStatement( );  //建立Statement类对象
2209             String r1="insert into store values("+Integer.parseInt(a1)+",'"+a2+"','"+a3+"','"+a4+"','"+a5+"','"+a6+"')";
2210             System.out.println(r1);
2211             // String r2="insert into person values("+"'0004','2018112001','高','女','29','70','90','89','259')";
2212             // String r3="insert into person values("+"'0005','2018112002','李','男','25','90','60','89','229')";
2213             s.executeUpdate(r1);       //  s.executeUpdate(r2);        s.executeUpdate(r3);
2214 
2215             s.close( );  //释放Statement所连接的数据库及JDBC资源
2216             con.close( );  //关闭与数据库的连线
2217         }
2218         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2219     }
2220     public void store_update(String a1,String a2,String a3,String a4,String a5,String a6) {
2221         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2222         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2223 
2224         String USER = "wth";       //MySql用户名
2225         String PASS = "1234";   //MySql密码,要采用你的密码
2226         String ID="0003";
2227         try {
2228             Class.forName(JDriver);  //加载JDBC驱动程序
2229         }
2230         catch(java.lang.ClassNotFoundException e) {
2231             System.out.println("ForName :" + e.getMessage( ));
2232         }
2233         try {
2234             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2235             Statement s=con.createStatement( );  //建立Statement类对象
2236             String sql="update store set "+"id="+Integer.parseInt(a1)+", name='"+a2+"', num='"+a3+"', warehouse='"+
2237                     a4+"', band='"+a5+"', number='"+a6+
2238                     "' where id="+Integer.parseInt(a1);
2239             System.out.println(sql);
2240             s.executeUpdate(sql);
2241             s.close( );  //释放Statement所连接的数据库及JDBC资源
2242             con.close( );  //关闭与数据库的连线
2243         }
2244         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2245     }
2246     public void phone_add(String a1,String a2,String a3,String a4,String a5,String a6,String a7) {
2247         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2248         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2249 
2250         String USER = "wth";       //MySql用户名
2251         String PASS = "1234";   //MySql密码,要采用你的密码
2252         try {
2253             Class.forName(JDriver);  //加载JDBC驱动程序
2254         }
2255         catch(java.lang.ClassNotFoundException e) {
2256             System.out.println("ForName :" + e.getMessage( ));
2257         }
2258         try {
2259             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2260             Statement s=con.createStatement( );  //建立Statement类对象
2261             String r1="insert into phone values("+"'"+a1+"','"+a2+"','"+a3+"','"+a4+"','"+a5+"','"+a6+"','"+a7+"','1')";
2262             System.out.println(r1);
2263 
2264             s.executeUpdate(r1);       //  s.executeUpdate(r2);        s.executeUpdate(r3);
2265 
2266             s.close( );  //释放Statement所连接的数据库及JDBC资源
2267             con.close( );  //关闭与数据库的连线
2268         }
2269         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2270     }
2271     public void phone_del(String ID) {
2272         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2273         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2274 
2275         String USER = "wth";       //MySql用户名
2276         String PASS = "1234";   //MySql密码,要采用你的密码
2277         try {
2278             Class.forName(JDriver);  //加载JDBC驱动程序
2279         }
2280         catch(java.lang.ClassNotFoundException e) {
2281             System.out.println("ForName :" + e.getMessage( ));
2282         }
2283         try {
2284             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2285             Statement s=con.createStatement( );  //建立Statement类对象
2286             String sql="delete from phone where id='"+ID+"'";
2287 
2288             s.executeUpdate(sql);
2289             s.close( );  //释放Statement所连接的数据库及JDBC资源
2290             con.close( );  //关闭与数据库的连线
2291         }
2292         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2293     }
2294     public void phone_update(String a1,String a2,String a3,String a4,String a5,String a6,String a7) {
2295         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2296         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2297 
2298         String USER = "wth";       //MySql用户名
2299         String PASS = "1234";   //MySql密码,要采用你的密码
2300         String ID="0003";
2301         try {
2302             Class.forName(JDriver);  //加载JDBC驱动程序
2303         }
2304         catch(java.lang.ClassNotFoundException e) {
2305             System.out.println("ForName :" + e.getMessage( ));
2306         }
2307         try {
2308             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2309             Statement s=con.createStatement( );  //建立Statement类对象
2310             String sql="update phone set "+"id='"+a1+"', 品牌='"+a2+"', 型号='"+a3+"', 厂商='"+
2311                     a4+"', 批次='"+a5+"', 序列号='"+a6+"', 生产日期='"+a7+
2312                     "' where id='"+a1+"'";
2313             System.out.println(sql);
2314             s.executeUpdate(sql);
2315             s.close( );  //释放Statement所连接的数据库及JDBC资源
2316             con.close( );  //关闭与数据库的连线
2317         }
2318         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2319     }
2320     public String[][] search_phone_message() {
2321         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2322         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2323         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2324         String USER = "wth";
2325         String PASS = "1234";
2326         String results[][]=new String[200][7];
2327         //String[ ] id={"0002","0003"};
2328         //int[ ] score={89,60};
2329         int i=0;
2330         int j=0;
2331         try {
2332             Class.forName(JDriver);  //加载JDBC驱动程序
2333         }
2334         catch(java.lang.ClassNotFoundException e) {
2335             System.out.println("ForName :" + e.getMessage( ));
2336         }
2337         try {
2338             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2339         /*    PreparedStatement ps=con.prepareStatement(
2340             "UPDATE person set score=? where id=? ");
2341             int i=0,idlen=id.length;
2342             do{ ps.setInt(1,score[i]);
2343                  ps.setString(2,id[i]);
2344                  ps.executeUpdate( );//执行SQL修改命令
2345                  ++i;
2346             }while(i<id.length);
2347             ps.close( );
2348             */
2349             //查询数据库并把数据表的内容输出到屏幕上
2350             Statement s=con.createStatement( );
2351             ResultSet rs=s.executeQuery("select * from phone");
2352 
2353             while(rs.next( )) {
2354                 results[i][0]= rs.getString("id");
2355                 results[i][1]=rs.getString("品牌");
2356                 results[i][2]=rs.getString("型号");
2357                 results[i][3]=rs.getString("厂商");
2358                 results[i][4]=rs.getString("批次");
2359                 results[i][5]=rs.getString("序列号");
2360                 results[i][6]=rs.getString("生产日期");
2361                 i=i+1;
2362             }
2363             System.out.println(results);
2364             s.close( );  //释放Statement所连接的数据库及JDBC资源
2365             con.close( );  //关闭与数据库的连线
2366 
2367         }
2368         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2369         return results;
2370     }
2371     public String[][] search_store_message() {
2372         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2373         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2374         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2375         String USER = "wth";
2376         String PASS = "1234";
2377         String results[][]=new String[200][6];
2378         //String[ ] id={"0002","0003"};
2379         //int[ ] score={89,60};
2380         int i=0;
2381         int j=0;
2382         try {
2383             Class.forName(JDriver);  //加载JDBC驱动程序
2384         }
2385         catch(java.lang.ClassNotFoundException e) {
2386             System.out.println("ForName :" + e.getMessage( ));
2387         }
2388         try {
2389             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2390         /*    PreparedStatement ps=con.prepareStatement(
2391             "UPDATE person set score=? where id=? ");
2392             int i=0,idlen=id.length;
2393             do{ ps.setInt(1,score[i]);
2394                  ps.setString(2,id[i]);
2395                  ps.executeUpdate( );//执行SQL修改命令
2396                  ++i;
2397             }while(i<id.length);
2398             ps.close( );
2399             */
2400             //查询数据库并把数据表的内容输出到屏幕上
2401             Statement s=con.createStatement( );
2402             ResultSet rs=s.executeQuery("select * from store");
2403 
2404             while(rs.next( )) {
2405                 results[i][0]= rs.getString("id");
2406                 results[i][1]=rs.getString("name");
2407                 results[i][2]=rs.getString("num");
2408                 results[i][3]=rs.getString("warehouse");
2409                 results[i][4]=rs.getString("band");
2410                 results[i][5]=rs.getString("number");
2411                // results[i][6]=rs.getString("生产日期");
2412                 i=i+1;
2413             }
2414             System.out.println(results);
2415             s.close( );  //释放Statement所连接的数据库及JDBC资源
2416             con.close( );  //关闭与数据库的连线
2417 
2418         }
2419         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2420         return results;
2421     }
2422     public boolean user_verify(String name,String pwd) {
2423         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2424         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2425 
2426         String USER = "wth";       //MySql用户名
2427         String PASS = "1234";   //MySql密码,要采用你的密码
2428 
2429 
2430         try {
2431             Class.forName(JDriver);  //加载JDBC驱动程序
2432         }
2433         catch(java.lang.ClassNotFoundException e) {
2434             System.out.println("ForName :" + e.getMessage( ));
2435         }
2436         try {
2437             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2438             Statement s=con.createStatement( );  //建立Statement类对象
2439             String sql="select * from user where name='"+name+"' and pwd= '"+pwd+"';";
2440             ResultSet rs = s.executeQuery(sql);
2441 
2442 
2443             if(rs.next()){
2444                 return true;
2445             }
2446             s.close( );  //释放Statement所连接的数据库及JDBC资源
2447             con.close( );  //关闭与数据库的连线
2448 
2449         }
2450         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2451         return false;
2452     }
2453     public void user_register(String name,String pwd) {
2454         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2455         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2456 
2457         String USER = "wth";       //MySql用户名
2458         String PASS = "1234";   //MySql密码,要采用你的密码
2459         try {
2460             Class.forName(JDriver);  //加载JDBC驱动程序
2461         }
2462         catch(java.lang.ClassNotFoundException e) {
2463             System.out.println("ForName :" + e.getMessage( ));
2464         }
2465         try {
2466             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2467             Statement s=con.createStatement( );  //建立Statement类对象
2468             //String r1="insert into person values("+"'0003','2018112000','王','男','21','90','90','89','269')";
2469             String sql="insert into user values('"+name+"','"+pwd+"');";
2470            // System.out.println(sql);
2471             s.executeUpdate(sql);
2472 
2473             s.close( );  //释放Statement所连接的数据库及JDBC资源
2474             con.close( );  //关闭与数据库的连线
2475         }
2476         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2477     }
2478     public void user_add(String a1,String a2) {
2479         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2480         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2481 
2482         String USER = "wth";       //MySql用户名
2483         String PASS = "1234";   //MySql密码,要采用你的密码
2484         try {
2485             Class.forName(JDriver);  //加载JDBC驱动程序
2486         }
2487         catch(java.lang.ClassNotFoundException e) {
2488             System.out.println("ForName :" + e.getMessage( ));
2489         }
2490         try {
2491             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2492             Statement s=con.createStatement( );  //建立Statement类对象
2493             String r1="insert into user values("+"'"+a1+"','"+a2+"')";
2494             System.out.println(r1);
2495             // String r2="insert into person values("+"'0004','2018112001','高','女','29','70','90','89','259')";
2496             // String r3="insert into person values("+"'0005','2018112002','李','男','25','90','60','89','229')";
2497             s.executeUpdate(r1);       //  s.executeUpdate(r2);        s.executeUpdate(r3);
2498 
2499             s.close( );  //释放Statement所连接的数据库及JDBC资源
2500             con.close( );  //关闭与数据库的连线
2501         }
2502         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2503     }
2504     public void user_del(String ID) {
2505         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2506         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2507 
2508         String USER = "wth";       //MySql用户名
2509         String PASS = "1234";   //MySql密码,要采用你的密码
2510         try {
2511             Class.forName(JDriver);  //加载JDBC驱动程序
2512         }
2513         catch(java.lang.ClassNotFoundException e) {
2514             System.out.println("ForName :" + e.getMessage( ));
2515         }
2516         try {
2517             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2518             Statement s=con.createStatement( );  //建立Statement类对象
2519             String sql="delete from user where name='"+ID+"'";
2520 
2521             s.executeUpdate(sql);
2522             s.close( );  //释放Statement所连接的数据库及JDBC资源
2523             con.close( );  //关闭与数据库的连线
2524         }
2525         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2526     }
2527     public void user_update(String a1,String a2) {
2528         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2529         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2530 
2531         String USER = "wth";       //MySql用户名
2532         String PASS = "1234";   //MySql密码,要采用你的密码
2533         String ID="0003";
2534         try {
2535             Class.forName(JDriver);  //加载JDBC驱动程序
2536         }
2537         catch(java.lang.ClassNotFoundException e) {
2538             System.out.println("ForName :" + e.getMessage( ));
2539         }
2540         try {
2541             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2542             Statement s=con.createStatement( );  //建立Statement类对象
2543             String sql="update user set "+"name='"+a1+"', pwd='"+a2+
2544                     "' where name='"+a1+"'";
2545             System.out.println(sql);
2546             s.executeUpdate(sql);
2547             s.close( );  //释放Statement所连接的数据库及JDBC资源
2548             con.close( );  //关闭与数据库的连线
2549         }
2550         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2551     }
2552     public String[][] search_user_message() {
2553         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2554         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2555         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2556         String USER = "wth";
2557         String PASS = "1234";
2558         String results[][]=new String[200][2];
2559         //String[ ] id={"0002","0003"};
2560         //int[ ] score={89,60};
2561         int i=0;
2562         int j=0;
2563         try {
2564             Class.forName(JDriver);  //加载JDBC驱动程序
2565         }
2566         catch(java.lang.ClassNotFoundException e) {
2567             System.out.println("ForName :" + e.getMessage( ));
2568         }
2569         try {
2570             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2571         /*    PreparedStatement ps=con.prepareStatement(
2572             "UPDATE person set score=? where id=? ");
2573             int i=0,idlen=id.length;
2574             do{ ps.setInt(1,score[i]);
2575                  ps.setString(2,id[i]);
2576                  ps.executeUpdate( );//执行SQL修改命令
2577                  ++i;
2578             }while(i<id.length);
2579             ps.close( );
2580             */
2581             //查询数据库并把数据表的内容输出到屏幕上
2582             Statement s=con.createStatement( );
2583             ResultSet rs=s.executeQuery("select * from user");
2584 
2585             while(rs.next( )) {
2586                 results[i][0]= rs.getString("name");
2587                 results[i][1]=rs.getString("pwd");
2588 
2589                 i=i+1;
2590             }
2591             System.out.println(results);
2592             s.close( );  //释放Statement所连接的数据库及JDBC资源
2593             con.close( );  //关闭与数据库的连线
2594 
2595         }
2596         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2597         return results;
2598     }
2599     public  void outstore(String a){
2600         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2601         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2602         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2603         String USER = "wth";
2604         String PASS = "1234";
2605         String results[]=new String[2];
2606         String aa[]=new String[20];
2607         String bb[]=new String[20];
2608         //String[ ] id={"0002","0003"};
2609         //int[ ] score={89,60};
2610         int i=0;
2611         int j=0;
2612         try {
2613             Class.forName(JDriver);  //加载JDBC驱动程序
2614         }
2615         catch(java.lang.ClassNotFoundException e) {
2616             System.out.println("ForName :" + e.getMessage( ));
2617         }
2618         try {
2619             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2620         /*    PreparedStatement ps=con.prepareStatement(
2621             "UPDATE person set score=? where id=? ");
2622             int i=0,idlen=id.length;
2623             do{ ps.setInt(1,score[i]);
2624                  ps.setString(2,id[i]);
2625                  ps.executeUpdate( );//执行SQL修改命令
2626                  ++i;
2627             }while(i<id.length);
2628             ps.close( );
2629             */
2630             //查询数据库并把数据表的内容输出到屏幕上
2631             Statement s=con.createStatement( );
2632             ResultSet rs=s.executeQuery("select * from `order`"+" where id ="+a);
2633 
2634             while(rs.next( )) {
2635                 results[0]=rs.getString("goods");
2636                 results[1]=rs.getString("numbers");
2637                 aa=results[0].split("[\\,]+"); // { "a", "b", "c" }
2638                 //System.out.println(aa[0]);
2639                 bb=results[1].split("[\\,]+"); // { "a", "b", "c" }
2640                 for(i=0;i<aa.length;i++){
2641                    System.out.println(aa[i]);
2642 
2643                     this.change_store(aa[i],bb[i]);
2644 
2645                 }
2646 
2647 
2648             }
2649             //System.out.println(results);
2650             s.close( );  //释放Statement所连接的数据库及JDBC资源
2651             con.close( );  //关闭与数据库的连线
2652 
2653         }
2654         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2655 
2656     }
2657     public void change_store(String name,String NM){
2658 
2659         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2660         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2661         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2662         String USER = "wth";
2663         String PASS = "1234";
2664         String results[][]=new String[200][6];
2665         String iid;
2666         String NUM="";
2667         //int[ ] score={89,60};
2668         int i=0;
2669         int j=0;
2670         try {
2671             Class.forName(JDriver);  //加载JDBC驱动程序
2672         }
2673         catch(java.lang.ClassNotFoundException e) {
2674             System.out.println("ForName :" + e.getMessage( ));
2675         }
2676         try {
2677             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2678             //查询数据库并把数据表的内容输出到屏幕上
2679             Statement s=con.createStatement( );
2680             ResultSet rs=s.executeQuery("select * from store "+"where name= '"+name+"'");
2681 
2682             while(rs.next( )) {
2683                iid= rs.getString("id");
2684                NUM=rs.getString("num");
2685                System.out.println(rs.getString("id"));
2686                 System.out.println(rs.getString("name"));
2687 
2688                 int N=Integer.parseInt(NUM);
2689                 int M=Integer.parseInt(NM);
2690                 NM=Integer.toString(N-M);
2691                 String sql="update store set "+"num='"+NM+
2692                         "' where id="+iid;
2693                 System.out.println(sql);
2694                 this.xiugai(sql);
2695 
2696             }
2697 
2698             s.close( );  //释放Statement所连接的数据库及JDBC资源
2699             con.close( );  //关闭与数据库的连线
2700 
2701         }
2702         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2703 
2704     }
2705     public void xiugai(String sql){
2706         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2707         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2708 
2709         String USER = "wth";       //MySql用户名
2710         String PASS = "1234";   //MySql密码,要采用你的密码
2711         String ID="0003";
2712         try {
2713             Class.forName(JDriver);  //加载JDBC驱动程序
2714         }
2715         catch(java.lang.ClassNotFoundException e) {
2716             System.out.println("ForName :" + e.getMessage( ));
2717         }
2718         try {
2719             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2720             Statement s=con.createStatement( );  //建立Statement类对象
2721 
2722             System.out.println(sql);
2723             s.executeUpdate(sql);
2724             s.close( );  //释放Statement所连接的数据库及JDBC资源
2725             con.close( );  //关闭与数据库的连线
2726         }
2727         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2728     }
2729     public String[][] s_phone_message(String a){
2730         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2731         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2732         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2733         String USER = "wth";
2734         String PASS = "1234";
2735         String results[][]=new String[200][7];
2736         //String[ ] id={"0002","0003"};
2737         //int[ ] score={89,60};
2738         int i=0;
2739         int j=0;
2740         try {
2741             Class.forName(JDriver);  //加载JDBC驱动程序
2742         }
2743         catch(java.lang.ClassNotFoundException e) {
2744             System.out.println("ForName :" + e.getMessage( ));
2745         }
2746         try {
2747             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2748             Statement s=con.createStatement( );
2749             ResultSet rs=s.executeQuery("select * from phone where 品牌='"+a+"'");
2750             System.out.println("select * from phone where '品牌'='"+a+"'");
2751             System.out.println("哈哈哈哈");
2752             while(rs.next( )) {
2753                 results[i][0]= rs.getString("id");
2754                 System.out.println(results[i][0]);
2755                 results[i][1]=rs.getString("品牌");
2756                 System.out.println(results[i][1]);
2757                 results[i][2]=rs.getString("型号");
2758                 System.out.println(results[i][2]);
2759                 results[i][3]=rs.getString("厂商");
2760                 System.out.println(results[i][3]);
2761                 results[i][4]=rs.getString("批次");
2762                 System.out.println(results[i][4]);
2763                 results[i][5]=rs.getString("序列号");
2764                 System.out.println(results[i][5]);
2765                 results[i][6]=rs.getString("生产日期");
2766                 System.out.println(results[i][6]);
2767                 i=i+1;
2768             }
2769             System.out.println(results);
2770             s.close( );  //释放Statement所连接的数据库及JDBC资源
2771             con.close( );  //关闭与数据库的连线
2772 
2773         }
2774         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2775         return results;
2776     }
2777     public String[][] s_order_message(String a){
2778         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2779         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2780         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2781         String USER = "wth";
2782         String PASS = "1234";
2783         String results[][]=new String[200][8];
2784         //String[ ] id={"0002","0003"};
2785         //int[ ] score={89,60};
2786         int i=0;
2787         int j=0;
2788         try {
2789             Class.forName(JDriver);  //加载JDBC驱动程序
2790         }
2791         catch(java.lang.ClassNotFoundException e) {
2792             System.out.println("ForName :" + e.getMessage( ));
2793         }
2794         try {
2795             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2796             Statement s=con.createStatement( );
2797             ResultSet rs=s.executeQuery("select * from `order` where user_name='"+a+"'");
2798             System.out.println("select * from `order` where user_name='"+a+"'");
2799 
2800             while(rs.next( )) {
2801                 results[i][0]= rs.getString("id");
2802                 results[i][1]=rs.getString("num");
2803                 results[i][2]=rs.getString("user_name");
2804                 results[i][3]=rs.getString("phone");
2805                 results[i][4]=rs.getString("money");
2806                 results[i][5]=rs.getString("status");
2807                 results[i][6]=rs.getString("goods");
2808                 results[i][7]=rs.getString("numbers");
2809                 i=i+1;
2810             }
2811             System.out.println(results);
2812             s.close( );  //释放Statement所连接的数据库及JDBC资源
2813             con.close( );  //关闭与数据库的连线
2814 
2815         }
2816         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2817         return results;
2818     }
2819     public String[][] s_manu_message(String a){
2820         String JDriver = "com.mysql.jdbc.Driver";  //声明JDBC驱动程序对象
2821         //String conURL="jdbc:odbc:TestDB";  //定义JDBC的URL对象
2822         String conURL= "jdbc:mysql://127.0.0.1:3306/RUNOOB?useUnicode=true&characterEncoding=utf-8&useSSL=false";
2823         String USER = "wth";
2824         String PASS = "1234";
2825         String results[][]=new String[200][8];
2826         //String[ ] id={"0002","0003"};
2827         //int[ ] score={89,60};
2828         int i=0;
2829         int j=0;
2830         try {
2831             Class.forName(JDriver);  //加载JDBC驱动程序
2832         }
2833         catch(java.lang.ClassNotFoundException e) {
2834             System.out.println("ForName :" + e.getMessage( ));
2835         }
2836         try {
2837             Connection con=DriverManager.getConnection(conURL,USER,PASS);  //连接数据库URL
2838             Statement s=con.createStatement( );
2839             ResultSet rs=s.executeQuery("select * from `manu` where name='"+a+"'");
2840             System.out.println("select * from `order` where user_name='"+a+"'");
2841 
2842             while(rs.next( )) {
2843                 results[i][0]= rs.getString("id");
2844                 results[i][1]=rs.getString("name");
2845                 results[i][2]=rs.getString("phone");
2846                 results[i][3]=rs.getString("address");
2847                 results[i][4]=rs.getString("person");
2848                 results[i][5]=rs.getString("remarks");
2849                 i=i+1;
2850             }
2851             System.out.println(results);
2852             s.close( );  //释放Statement所连接的数据库及JDBC资源
2853             con.close( );  //关闭与数据库的连线
2854 
2855         }
2856         catch(SQLException e){ System.out.println("SQLException: " +e.getMessage( ));  }
2857         return results;
2858     }
2859 }

 

5 心得与体会

经过了一个学期的java学习,让我又多了一项技能。java不同于c/c++语言,java本身有着丰富的包无论你要做什么,你都能找到相应的包,比如要做一个GUI界面,那么就可以调用awt或者是swing的包,这两个包中有着丰富的控件,label、button、textfield等等。再编写相应的业务逻辑就可以设计出完整的GUI程序。除了java自带的包,还可以去Github找到别人编写的GUI包,在在自己的程序中进行导入,就可以完成一个功能完善的软件。如果是从底层写起,像C语言编程。工作量会非常的大。java 在IT界有着非常重要的地位,java丰富的软件生态,以及拥有着庞大的用户群体,使得java在具有开发效率的同时开发出的程序运行速度也很快。

在这次的课程设计中,从开始不知道从何写起,到设计出完整的框架。我在网络上查询软件系统的设计,学习如何让软件设计得简洁高效,以及学习各种技术细节。在登陆界面的获得账号密码后如何到数据库中进行匹配,注册后将信息插入数据库,如何实现窗口的弹出和销毁等。遇到不懂的问题我就会去查手册,查一些技术达人的博客,学习他们如何解决问题的。在设计代码之初我希望各个模块间的耦合度越少越好,所以我用databases这个类封装所有的数据库操作,将每一个界面都封装成一个独立的类。这样会使整个的代码逻辑非常的清晰。在编程的时候,我需要哪些功能我就写到这些独立的类中。一旦程序有错误时我也很快能够找出。

在进行数据库的编程过程中,会遇到好多技术上的问题,比如在数据库创建order表时会报错,经过查找资料发现order是数据库的一个保留字,在其他教程中以`order`这种写法来创建table。整个项目断断续续写了一周,我就思考了下这样一个几千行的代码遇到问题已经难以查找,在未来去设计更复杂、功能更完善的系统时,一定要将整个系统分为一个个的子模块,定义好相应的借口规范,可以尝试去写技术手册,详细记录各种接口。以后的程序一定要规范,多多练习将冗杂的代码进行优化封装,并且可以尝试设计一些更复杂的系统。

   通过本学期的java学习,真的让我懂了很多软件开发相关的知识。让我也知道了各种编程语言之间是紧密联系的。学会一个其他的就可以触类旁通、举一反三。从这门课我也领悟到计算机思维,无论编写什么程序,要始终运用计算机思维去思考和解决问题,才会有更扎实的基础。

   感谢时代的进步、技术的发展才让我们文明发展。在此向java之父——James Gosling致敬。

 

上一篇:Android开发(3)-Android如何保存EditText中的字符串内容


下一篇:[转]集成学习中的Stacking方法