购物管理系统

开发工具:Eclipse  Mysql 8.0.1

开发语言:java

功能:

功能一:本系统功能有用户的注册登录,未注册用户不能使用本系统。

功能二:本系统在登录时会根据用户名自动判断是否已经添加个人详细身份信息,没有就会提示添加,每次登陆都会提示,直到添加。已经添加的用户可以在主功能界面选择编辑个人信息进行编辑修改。

功能三:本系统可以对购物记录进行增删改查操作,切在输入上做了处理,对于只能输入数字的框已经将键盘输入限制在数字,用户自身无法输入其他字符。

功能四:本系统会对各类购物进行金额清算,用户可以在主功能界面选择相应的功能按钮查看。

功能wu:对所有输入都进行处理判断,确保用户输入符合类型的数据(例如,电话号码:必须11位,开头三位为常见开头,纯数字,不符合要求,系统会自动判断,不符合弹出弹窗告诉用户输入不合法,重新输入)

下面是部分代码:

 

//插入记录函数

public void Insertmemary(String userid,String goodstype,int goodsprice,String shoppingtype,String shoppingtime) {

String userid1="\'"+id2+"\'";

String goodstype1 = "\'"+goodstype+"\'";

String shoppingtype1 = "\'"+shoppingtype+"\'";

String shoppingtime1 = "\'"+shoppingtime+"\'";

String driver1 = "com.mysql.cj.jdbc.Driver";

String url = "jdbc:mysql://localhost:3306/xqxqxq?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";

String username = "root";

String password = "root123";

Connection conn = null;

Statement stmt = null;

try{

      //STEP 2: Register JDBC driver

      Class.forName(driver1);     

      conn = DriverManager.getConnection(url, username, password);

      System.out.println("Connected database successfully...");

      stmt = conn.createStatement();           

      String sql = "INSERT INTO Shoppingmemary (Userid,Goodstype,Goodsprice,Shoppingtype,Shoppingtime)" +

                   "VALUES ("+userid1+","+ goodstype1+","+goodsprice+","+shoppingtype1+","+shoppingtime1+")";

      stmt.executeUpdate(sql);

      System.out.println("Successful insert table");

   }catch(SQLException se){

      //Handle errors for JDBC

      se.printStackTrace();

   }catch(Exception e){

      //Handle errors for Class.forName

      e.printStackTrace();

   }finally{

      //finally block used to close resources

      try{

         if(stmt!=null)

            conn.close();

      }catch(SQLException se){

      }// do nothing

      try{

         if(conn!=null)

            conn.close();

      }catch(SQLException se){

         se.printStackTrace();

      }//end finally try

   }//end try

 

}

 

}

 

全部代码本人放在了我的github上:下面是链接,大家可以自行下载

https://github.com/jiang-congcong/Shopping-management-system

 

 

猜你喜欢

转载自blog.csdn.net/congcong7267/article/details/82770965
今日推荐