Skip to content

Add files via upload #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 系统开发/lib/sqlite-jdbc-3.7.2.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
609 changes: 609 additions & 0 deletions 系统开发/src/com/company/Administrator.java

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions 系统开发/src/com/company/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.company;


import static java.lang.System.exit;

public class Main {

public static void main(String[] args) {
// write your code here
SqLite mysql=new SqLite();
mysql.create();
Start s=new Start();
s.start();

}

}
88 changes: 88 additions & 0 deletions 系统开发/src/com/company/SqLite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.company;
import java.sql.*;


public class SqLite {

public void create(){
Connection c = null;
Statement stmt = null;
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
// System.out.println("Opened database successfully");
stmt = c.createStatement();
// String sql9 = "DROP TABLE IF EXISTS USER";
// stmt.executeUpdate(sql9);
String sql = "CREATE TABLE IF NOT EXISTS USER " +
"(ID TEXT PRIMARY KEY NOT NULL," +
" NAME TEXT NOT NULL," +
" PASSWORD TEXT NOT NULL," +
" TYPE INT NOT NULL," +
" LEVEL INT NOT NULL," +
" RETIME TEXT NOT NULL," +
" MONEY INT NOT NULL," +
" PHONE TEXT NOT NULL," +
" MAILBOX TEXT NOT NULL)";
stmt.executeUpdate(sql);


// String sql99 = "DROP TABLE IF EXISTS COMMODITY";
// stmt.executeUpdate(sql99);

String sql1 = "CREATE TABLE IF NOT EXISTS COMMODITY " +
"(ID TEXT PRIMARY KEY NOT NULL," +
"PRODUCT TEXT NOT NULL," +
"FACTORY TEXT NOT NULL," +
"DATE TEXT NOT NULL," +
"TYPE TEXT NOT NULL," +
"INPRICE INT NOT NULL," +
"OUTPRICE INT NOT NULL," +
"NUMS INT NOT NULL)";

stmt.executeUpdate(sql1);



String sql2 = "CREATE TABLE IF NOT EXISTS SHOPCART " +
"(USERNAME TEXT NOT NULL," +
" PRODUCT TEXT NOT NULL," +
" PRICE INT NOT NULL," +
" AMOUNT INT NOT NULL)";

stmt.executeUpdate(sql2);


String sql3 = "CREATE TABLE IF NOT EXISTS HISTORY " +
"(USERNAME TEXT NOT NULL," +
" PRODUCT TEXT NOT NULL," +
" AMOUNT INT NOT NULL," +
" TOTALPRICE INT NOT NULL," +
" TIME TEXT NOT NULL)";

stmt.executeUpdate(sql3);

// String sql9 = "DELETE FROM SHOPCART";
// stmt.executeUpdate(sql9);
// String deleteQuery10 = "DELETE FROM HISTORY";
// stmt.executeUpdate(deleteQuery10);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
// System.out.println("Table created successfully");
}








}



48 changes: 48 additions & 0 deletions 系统开发/src/com/company/Start.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.company;

import java.util.InputMismatchException;
import java.util.Scanner;

import static java.lang.System.exit;

public class Start {

public void start(){

Scanner input = new Scanner(System.in);

User user=new User();
Administrator administrator=new Administrator();

boolean mis = true;


while (mis) {
try {
System.out.println("***************START***************");
System.out.print("请选择身份————1.管理员 2.用户 (按‘0’退出系统)>");
int choose = input.nextInt();

if (choose == 1) {
administrator.administratorLogin();
mis = false;
} else if (choose == 2) {
user.userLogin();
mis = false;
} else if (choose == 0) {
System.exit(1);
} else {
System.out.println("输入有误,请重新输入");
}
} catch (InputMismatchException e) {
System.out.println("输入有误,请重新输入");
input.nextLine(); // 清空输入缓冲区
}
}


}



}
Loading