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

📄 createmenu.java

📁 学生project 火车时刻查询系统 软件工程文档-英文。对需要软件工程文档的朋友有写帮助
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    String v = "select * from Routes";                    PreparedStatement s = conn.prepareStatement(v);                    ResultSet rs= s.executeQuery();                    int j = 0;                    while (rs.next())                    {                        Edges_create[j][0]=rs.getInt("start_station");                        Edges_create[j][1]=rs.getInt("end_station");                        Edges_create[j][2]=rs.getInt("weight");                        j++;                    }                                        for (int k=0; k<j; k++)                    {                        for (int i=0; i<2; i++)                        {                            int a = Edges_create[k][i];                            v = "select Name from Stations where Num = "+a+"";                            s = conn.prepareStatement(v);                            rs= s.executeQuery();                            while (rs.next())                            {                                if ( i == 0 )                                ta_create.append(rs.getString("Name").trim() + " --> ");                                if ( i == 1 )                                ta_create.append(rs.getString("Name").trim());                            }                        }                        int b = Edges_create[k][2];                        String p = Integer.toString(b);                        ta_create.append("    Time Consuming: " + p + "\n");                    }                }catch(Exception e1){}            }      },            al5_create = new ActionListener()      {            public void actionPerformed(ActionEvent e)            {                t_create.setEditable(true);                t_create.selectAll();                t_create.cut();                t_create.setEditable(false);                ta_create.selectAll();                ta_create.cut();                c1_addCon.setSelectedItem(description_create[0]);                c2_addCon.setSelectedItem(description_create[0]);                c1_addCon.setEnabled(false);                c2_addCon.setEnabled(false);                t1_addStation.setEditable(true);                t1_addStation.selectAll();                t1_addStation.cut();                t1_addStation.setEditable(false);                t1_addCon.setEditable(false);                          }      },            al1_addStation = new ActionListener()      {          public void actionPerformed(ActionEvent e)          {                try                    {                        Arrays.fill(Names_create,"");                        Driver driver = (Driver) Class.forName("com.jnetdirect.jsql.JSQLDriver").newInstance();                        String connectStr = "jdbc:JSQLConnect://127.0.0.1/database=G6/user=sa";                        Connection  conn = driver.connect(connectStr, new Properties());                        Statement stmt = conn.createStatement();                            DatabaseMetaData db=conn.getMetaData();                        String v = "select * from Stations";                        PreparedStatement s = conn.prepareStatement(v);                        ResultSet rs = s.executeQuery();                        int i=1;                        while (rs.next())                        {                            Names_create[i] = rs.getString("Name").trim();                            i++;                        }                                                String s1 = t1_addStation.getText().toLowerCase();                        if ( s1.equals("") )                        JOptionPane.showMessageDialog(null,                          "Please input a station name",                           "Error!", JOptionPane.ERROR_MESSAGE);                                                else                        {                            boolean goodID = true;                            for (int j=1; j<Names_create.length; j++)                            {                                if ( s1.equals(Names_create[j]) )                                goodID = false;                            }                                                    if ( goodID )                            {                                ta_create.append("New Station:" + s1 + "\n");                                v = "insert into Stations(Name) values('"+s1+"')";                                s = conn.prepareStatement(v);                                s.executeUpdate();                            }                                                   else                             {                                JOptionPane.showMessageDialog(null,                                  "The station you input has been in the database",                                   "Error!", JOptionPane.ERROR_MESSAGE);                                t1_addStation.selectAll();                                t1_addStation.cut();                            }                        }                    }catch(Exception e1){}                }      },            al2_addStation = new ActionListener()      {          public void actionPerformed(ActionEvent e)          {               t1_addStation.selectAll();               t1_addStation.cut();          }      },            al1_addCon = new ActionListener()      {           public void actionPerformed(ActionEvent e)           {               try               {                    Driver driver = (Driver) Class.forName("com.jnetdirect.jsql.JSQLDriver").newInstance();                    String connectStr = "jdbc:JSQLConnect://127.0.0.1/database=G6/user=sa";                    Connection  conn = driver.connect(connectStr, new Properties());                    Statement stmt = conn.createStatement();                        DatabaseMetaData db = conn.getMetaData();                    boolean goodID1 = true;                    String s1 = (String)c1_addCon.getSelectedItem();                    String s2 = (String)c2_addCon.getSelectedItem();                    if ( s1.equals("") && !s2.equals("") )                    {                        goodID1 = false;                        JOptionPane.showMessageDialog(null,                           "Please select a departure station",                           "Error!", JOptionPane.ERROR_MESSAGE);                    }                                        if ( !s1.equals("") && s2.equals("") )                    {                        goodID1 = false;                        JOptionPane.showMessageDialog(null,                           "Please select a destination station",                           "Error!", JOptionPane.ERROR_MESSAGE);                    }                                        if ( s1.equals("") && s2.equals("") )                    {                        goodID1 = false;                        JOptionPane.showMessageDialog(null,                           "Please select the departure and destination stations",                           "Error!", JOptionPane.ERROR_MESSAGE);                    }                                        if ( s1.equals(s2) && goodID1 )                    {                        goodID1 = false;                        JOptionPane.showMessageDialog(null,                           "The departure and destination station can not be same!",                           "Error!", JOptionPane.ERROR_MESSAGE);                    }                                        if ( goodID1 )                     {                        boolean goodID = true;                        String s3 = t1_addCon.getText();                        if ( s3.equals("") )                        {                            goodID = false;                            JOptionPane.showMessageDialog(null,                               "Please specify the Time Consuming!",                               "Error!", JOptionPane.ERROR_MESSAGE);                        }                                                if ( goodID )                        {                            String v = "select Num from Stations where Name = '"+s1+"'";                            PreparedStatement s = conn.prepareStatement(v);                            ResultSet rs = s.executeQuery();                            while (rs.next())                            {                                NumStart_create = rs.getInt("Num");                            }                                               v = "select Num from Stations where Name = '"+s2+"'";                            s = conn.prepareStatement(v);                            rs = s.executeQuery();                            while (rs.next())                            {                                NumEnd_create = rs.getInt("Num");                            }                                                int a = NumStart_create;                            int b = NumEnd_create;                            int c = Integer.parseInt(s3);                                                v = "select end_station from Routes where start_station = "+NumStart_create+"";                            s = conn.prepareStatement(v);                            rs = s.executeQuery();                            while (rs.next())                            {                                if ( NumEnd_create == rs.getInt("end_station") )                                goodID = false;                            }                                                                                      if ( goodID )                            {                                v = "insert into Routes values('"+a+"','"+b+"','"+c+"')";                                 s = conn.prepareStatement(v);                                s.executeUpdate();                                ta_create.append("New Connection: " + s1  + " --> " +                                   s2 + "   Time Consuming: " + s3 + "\n");                            }                                                if ( !goodID )                            {                                JOptionPane.showMessageDialog(null,                                   "The Connection you input is already in the database!",                                   "Error!", JOptionPane.ERROR_MESSAGE);                            }                        }                    }                }catch(Exception e1){}           }      },            al2_addCon = new ActionListener()      {           public void actionPerformed(ActionEvent e)           {                c1_addCon.setSelectedItem(description_create[0]);                c2_addCon.setSelectedItem(description_create[0]);                t1_addCon.selectAll();                t1_addCon.cut();           }      };}      

⌨️ 快捷键说明

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