This commit is contained in:
xixu-me committed 2024-05-29 17:07:05 +08:00
1 parent e534efa80e
commit 93ba2c358d
20 files changed
+58 -58

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -5
View File
@@ -13,7 +13,7 @@ public class PasswordChange {
static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT"; static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
public static void main(String[] args) { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
@@ -21,7 +21,7 @@ public class PasswordChange {
Class.forName("com.mysql.cj.jdbc.Driver"); Class.forName("com.mysql.cj.jdbc.Driver");
conn = DriverManager.getConnection(DBURL); conn = DriverManager.getConnection(DBURL);
System.out.print("请输入用户名:"); System.out.print("请输入用户名:");
String username = scanner.nextLine(); String username = sc.nextLine();
String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?"; String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?";
pstmt = conn.prepareStatement(checkUserSql); pstmt = conn.prepareStatement(checkUserSql);
pstmt.setString(1, username); pstmt.setString(1, username);
@@ -31,7 +31,7 @@ public class PasswordChange {
return; return;
} }
System.out.print("请输入当前用户的原密码:"); System.out.print("请输入当前用户的原密码:");
String oldPassword = scanner.nextLine(); String oldPassword = sc.nextLine();
String checkPasswordSql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=MD5(?)"; String checkPasswordSql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=MD5(?)";
pstmt = conn.prepareStatement(checkPasswordSql); pstmt = conn.prepareStatement(checkPasswordSql);
pstmt.setString(1, username); pstmt.setString(1, username);
@@ -44,14 +44,14 @@ public class PasswordChange {
String newPassword; String newPassword;
while (true) { while (true) {
System.out.print("请设置新的密码:"); System.out.print("请设置新的密码:");
newPassword = scanner.nextLine(); newPassword = sc.nextLine();
if (!isPasswordComplex(newPassword)) if (!isPasswordComplex(newPassword))
System.out.println("您的密码不符合复杂性要求(密码长度不少于6个字符,至少有一个小写字母,至少有一个大写字母,至少一个数字),请重新输入:"); System.out.println("您的密码不符合复杂性要求(密码长度不少于6个字符,至少有一个小写字母,至少有一个大写字母,至少一个数字),请重新输入:");
else else
break; break;
} }
System.out.print("请输入确认密码:"); System.out.print("请输入确认密码:");
String confirmPassword = scanner.nextLine(); String confirmPassword = sc.nextLine();
if (!newPassword.equals(confirmPassword)) { if (!newPassword.equals(confirmPassword)) {
System.out.println("两次输入的密码必须一致,请重新输入确认密码:"); System.out.println("两次输入的密码必须一致,请重新输入确认密码:");
return; return;
@@ -12,7 +12,7 @@ public class ProductAdditionAndInquiry {
private static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT"; private static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
public static void main(String[] args) { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
int choice; int choice;
try (Connection conn = DriverManager.getConnection(DBURL)) { try (Connection conn = DriverManager.getConnection(DBURL)) {
do { do {
@@ -21,14 +21,14 @@ public class ProductAdditionAndInquiry {
System.out.println("2、查询商品"); System.out.println("2、查询商品");
System.out.println("3、退出"); System.out.println("3、退出");
System.out.print("请选择(1-3):"); System.out.print("请选择(1-3):");
choice = scanner.nextInt(); choice = sc.nextInt();
scanner.nextLine(); sc.nextLine();
switch (choice) { switch (choice) {
case 1: case 1:
addProduct(scanner, conn); addProduct(sc, conn);
break; break;
case 2: case 2:
queryProduct(scanner, conn); queryProduct(sc, conn);
break; break;
case 3: case 3:
System.out.println("退出系统"); System.out.println("退出系统");
@@ -42,9 +42,9 @@ public class ProductAdditionAndInquiry {
} }
} }
private static void addProduct(Scanner scanner, Connection conn) throws SQLException { private static void addProduct(Scanner sc, Connection conn) throws SQLException {
System.out.print("请输入商品信息(格式:条形码,商品名称,单价,供应商):"); System.out.print("请输入商品信息(格式:条形码,商品名称,单价,供应商):");
String input = scanner.nextLine(); String input = sc.nextLine();
String[] productInfo = input.split(","); String[] productInfo = input.split(",");
String tiaoma = productInfo[0]; String tiaoma = productInfo[0];
PreparedStatement checkStmt = conn.prepareStatement("SELECT COUNT(*) FROM t_shangping WHERE tiaoma = ?"); PreparedStatement checkStmt = conn.prepareStatement("SELECT COUNT(*) FROM t_shangping WHERE tiaoma = ?");
@@ -65,9 +65,9 @@ public class ProductAdditionAndInquiry {
System.out.println("增加成功"); System.out.println("增加成功");
} }
private static void queryProduct(Scanner scanner, Connection conn) throws SQLException { private static void queryProduct(Scanner sc, Connection conn) throws SQLException {
System.out.print("请输入查询的商品名称:"); System.out.print("请输入查询的商品名称:");
String nameQuery = scanner.nextLine(); String nameQuery = sc.nextLine();
PreparedStatement queryStmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE mingcheng LIKE ?"); PreparedStatement queryStmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE mingcheng LIKE ?");
queryStmt.setString(1, "%" + nameQuery + "%"); queryStmt.setString(1, "%" + nameQuery + "%");
ResultSet rs = queryStmt.executeQuery(); ResultSet rs = queryStmt.executeQuery();
+3 -3
View File
@@ -13,7 +13,7 @@ public class UserLogin {
static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT"; static final String DBURL = "jdbc:mysql://localhost:3306/xiaoshou?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
public static void main(String[] args) { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
@@ -25,9 +25,9 @@ public class UserLogin {
while (attempts < 3 && !loginSuccess) { while (attempts < 3 && !loginSuccess) {
System.out.println("欢迎使用阳光超市收银系统,请登陆"); System.out.println("欢迎使用阳光超市收银系统,请登陆");
System.out.print("请输入用户名: "); System.out.print("请输入用户名: ");
String username = scanner.nextLine(); String username = sc.nextLine();
System.out.print("请输入密码: "); System.out.print("请输入密码: ");
String password = scanner.nextLine(); String password = sc.nextLine();
String sql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=?"; String sql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, username); pstmt.setString(1, username);
+13 -13
View File
@@ -16,7 +16,7 @@ import jxl.write.WritableWorkbook;
public class Test { public class Test {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
WritableWorkbook book = Workbook.createWorkbook(new File("src/excel/求职简历.xls")); WritableWorkbook book = Workbook.createWorkbook(new File("src/excel/求职简历.xls"));
WritableFont font = new WritableFont(WritableFont.createFont("SimSun"), 11); WritableFont font = new WritableFont(WritableFont.createFont("SimSun"), 11);
WritableCellFormat borderFormat = new WritableCellFormat(font); WritableCellFormat borderFormat = new WritableCellFormat(font);
@@ -52,29 +52,29 @@ public class Test {
sheet.addCell(new Label(0, 18, "专长", borderFormat)); sheet.addCell(new Label(0, 18, "专长", borderFormat));
sheet.setRowView(0, 520); sheet.setRowView(0, 520);
System.out.println("姓名:"); System.out.println("姓名:");
sheet.addCell(new Label(1, 1, scanner.next(), borderFormat)); sheet.addCell(new Label(1, 1, sc.next(), borderFormat));
System.out.println("性别:"); System.out.println("性别:");
sheet.addCell(new Label(3, 1, scanner.next(), borderFormat)); sheet.addCell(new Label(3, 1, sc.next(), borderFormat));
System.out.println("籍贯:"); System.out.println("籍贯:");
sheet.addCell(new Label(5, 1, scanner.next(), borderFormat)); sheet.addCell(new Label(5, 1, sc.next(), borderFormat));
System.out.println("出生日期:"); System.out.println("出生日期:");
sheet.addCell(new Label(1, 2, scanner.next(), borderFormat)); sheet.addCell(new Label(1, 2, sc.next(), borderFormat));
System.out.println("民族:"); System.out.println("民族:");
sheet.addCell(new Label(3, 2, scanner.next(), borderFormat)); sheet.addCell(new Label(3, 2, sc.next(), borderFormat));
System.out.println("邮箱:"); System.out.println("邮箱:");
sheet.addCell(new Label(5, 2, scanner.next(), borderFormat)); sheet.addCell(new Label(5, 2, sc.next(), borderFormat));
System.out.println("家庭地址:"); System.out.println("家庭地址:");
sheet.addCell(new Label(1, 3, scanner.next(), borderFormat)); sheet.addCell(new Label(1, 3, sc.next(), borderFormat));
System.out.println("政治面貌:"); System.out.println("政治面貌:");
sheet.addCell(new Label(1, 4, scanner.next(), borderFormat)); sheet.addCell(new Label(1, 4, sc.next(), borderFormat));
System.out.println("电话:"); System.out.println("电话:");
sheet.addCell(new Label(3, 4, scanner.next(), borderFormat)); sheet.addCell(new Label(3, 4, sc.next(), borderFormat));
System.out.println("专业:"); System.out.println("专业:");
sheet.addCell(new Label(5, 4, scanner.next(), borderFormat)); sheet.addCell(new Label(5, 4, sc.next(), borderFormat));
System.out.println("个人简介:"); System.out.println("个人简介:");
sheet.addCell(new Label(0, 8, scanner.next(), borderFormat)); sheet.addCell(new Label(0, 8, sc.next(), borderFormat));
System.out.println("特长:"); System.out.println("特长:");
sheet.addCell(new Label(0, 19, scanner.next(), borderFormat)); sheet.addCell(new Label(0, 19, sc.next(), borderFormat));
for (int i = 0; i <= 5; i++) for (int i = 0; i <= 5; i++)
for (int j = 5; j <= 6; j++) for (int j = 5; j <= 6; j++)
sheet.addCell(new Label(i, j, " ", borderFormat)); sheet.addCell(new Label(i, j, " ", borderFormat));
+6 -6
View File
@@ -17,23 +17,23 @@ public class Cashier {
Connection conn = DriverManager.getConnection(DBURL); Connection conn = DriverManager.getConnection(DBURL);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
boolean continueCashier = true; boolean continueCashier = true;
int sequence = 0; int sequence = 0;
String lastDate = ""; String lastDate = "";
while (continueCashier) { while (continueCashier) {
System.out.println("欢迎使用阳光超市收银系统"); System.out.println("欢迎使用阳光超市收银系统");
System.out.print("请输入商品条形码(6位数字字符):"); System.out.print("请输入商品条形码(6位数字字符):");
String barcode = scanner.nextLine(); String barcode = sc.nextLine();
pstmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE tiaoma = ?"); pstmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE tiaoma = ?");
pstmt.setString(1, barcode); pstmt.setString(1, barcode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
System.out.print("输入商品数量:"); System.out.print("输入商品数量:");
int quantity = scanner.nextInt(); int quantity = sc.nextInt();
scanner.nextLine(); sc.nextLine();
System.out.print("请输入收银员:"); System.out.print("请输入收银员:");
String cashier = scanner.nextLine(); String cashier = sc.nextLine();
String productName = rs.getString("mingcheng"); String productName = rs.getString("mingcheng");
double price = rs.getDouble("danjia"); double price = rs.getDouble("danjia");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -59,7 +59,7 @@ public class Cashier {
} else } else
System.out.println("您输入的商品条形码不存在,请确认后重新输入"); System.out.println("您输入的商品条形码不存在,请确认后重新输入");
System.out.print("是否继续收银(y/n):"); System.out.print("是否继续收银(y/n):");
String choice = scanner.nextLine(); String choice = sc.nextLine();
if ("n".equalsIgnoreCase(choice)) if ("n".equalsIgnoreCase(choice))
continueCashier = false; continueCashier = false;
} }
@@ -19,14 +19,14 @@ public class CashierStatistics {
Connection conn = DriverManager.getConnection(DBURL); Connection conn = DriverManager.getConnection(DBURL);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String inputDate; String inputDate;
Date saleDate = null; Date saleDate = null;
boolean validDate = false; boolean validDate = false;
while (!validDate) { while (!validDate) {
System.out.print("请输入销售日期(yyyy-mm-dd):"); System.out.print("请输入销售日期(yyyy-mm-dd):");
inputDate = scanner.nextLine(); inputDate = sc.nextLine();
try { try {
saleDate = sdf.parse(inputDate); saleDate = sdf.parse(inputDate);
validDate = true; validDate = true;
@@ -61,7 +61,7 @@ public class CashierStatistics {
String continueInput; String continueInput;
do { do {
System.out.print("是否继续查询(y/n):"); System.out.print("是否继续查询(y/n):");
continueInput = scanner.nextLine(); continueInput = sc.nextLine();
if ("n".equalsIgnoreCase(continueInput)) { if ("n".equalsIgnoreCase(continueInput)) {
System.out.println("程序成功退出"); System.out.println("程序成功退出");
break; break;
+2 -2
View File
@@ -22,13 +22,13 @@ public class DataInput {
Connection conn = DriverManager.getConnection(DBURL); Connection conn = DriverManager.getConnection(DBURL);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
System.out.println("====超市商品管理维护===="); System.out.println("====超市商品管理维护====");
System.out.println("1、从excel中导入数据"); System.out.println("1、从excel中导入数据");
System.out.println("2、从文本文件导入数据"); System.out.println("2、从文本文件导入数据");
System.out.println("3、返回主菜单"); System.out.println("3、返回主菜单");
System.out.print("请选择(1-3):"); System.out.print("请选择(1-3):");
int choice = scanner.nextInt(); int choice = sc.nextInt();
int cnt = 0; int cnt = 0;
switch (choice) { switch (choice) {
case 1: case 1:
+5 -5
View File
@@ -17,9 +17,9 @@ public class PasswordChange {
Connection conn = DriverManager.getConnection(DBURL); Connection conn = DriverManager.getConnection(DBURL);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
System.out.print("请输入用户名:"); System.out.print("请输入用户名:");
String username = scanner.nextLine(); String username = sc.nextLine();
String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?"; String checkUserSql = "SELECT xingming FROM t_yong WHERE yonghuming=?";
pstmt = conn.prepareStatement(checkUserSql); pstmt = conn.prepareStatement(checkUserSql);
pstmt.setString(1, username); pstmt.setString(1, username);
@@ -29,7 +29,7 @@ public class PasswordChange {
return; return;
} }
System.out.print("请输入当前用户的原密码:"); System.out.print("请输入当前用户的原密码:");
String oldPassword = scanner.nextLine(); String oldPassword = sc.nextLine();
String checkPasswordSql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=MD5(?)"; String checkPasswordSql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=MD5(?)";
pstmt = conn.prepareStatement(checkPasswordSql); pstmt = conn.prepareStatement(checkPasswordSql);
pstmt.setString(1, username); pstmt.setString(1, username);
@@ -42,14 +42,14 @@ public class PasswordChange {
String newPassword; String newPassword;
while (true) { while (true) {
System.out.print("请设置新的密码:"); System.out.print("请设置新的密码:");
newPassword = scanner.nextLine(); newPassword = sc.nextLine();
if (!isPasswordComplex(newPassword)) if (!isPasswordComplex(newPassword))
System.out.println("您的密码不符合复杂性要求(密码长度不少于6个字符,至少有一个小写字母,至少有一个大写字母,至少一个数字),请重新输入:"); System.out.println("您的密码不符合复杂性要求(密码长度不少于6个字符,至少有一个小写字母,至少有一个大写字母,至少一个数字),请重新输入:");
else else
break; break;
} }
System.out.print("请输入确认密码:"); System.out.print("请输入确认密码:");
String confirmPassword = scanner.nextLine(); String confirmPassword = sc.nextLine();
if (!newPassword.equals(confirmPassword)) { if (!newPassword.equals(confirmPassword)) {
System.out.println("两次输入的密码必须一致,请重新输入确认密码:"); System.out.println("两次输入的密码必须一致,请重新输入确认密码:");
return; return;
@@ -15,7 +15,7 @@ public class ProductAdditionAndInquiry {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class.forName(DBDRIVER); Class.forName(DBDRIVER);
Connection conn = DriverManager.getConnection(DBURL); Connection conn = DriverManager.getConnection(DBURL);
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
int choice; int choice;
do { do {
System.out.println("===超市商品管理维护===="); System.out.println("===超市商品管理维护====");
@@ -23,14 +23,14 @@ public class ProductAdditionAndInquiry {
System.out.println("2、查询商品"); System.out.println("2、查询商品");
System.out.println("3、退出"); System.out.println("3、退出");
System.out.print("请选择(1-3):"); System.out.print("请选择(1-3):");
choice = scanner.nextInt(); choice = sc.nextInt();
scanner.nextLine(); sc.nextLine();
switch (choice) { switch (choice) {
case 1: case 1:
addProduct(scanner, conn); addProduct(sc, conn);
break; break;
case 2: case 2:
queryProduct(scanner, conn); queryProduct(sc, conn);
break; break;
case 3: case 3:
System.out.println("退出系统"); System.out.println("退出系统");
@@ -42,9 +42,9 @@ public class ProductAdditionAndInquiry {
conn.close(); conn.close();
} }
private static void addProduct(Scanner scanner, Connection conn) throws SQLException { private static void addProduct(Scanner sc, Connection conn) throws SQLException {
System.out.print("请输入商品信息(格式:条形码,商品名称,单价,供应商):"); System.out.print("请输入商品信息(格式:条形码,商品名称,单价,供应商):");
String input = scanner.nextLine(); String input = sc.nextLine();
String[] productInfo = input.split(","); String[] productInfo = input.split(",");
String tiaoma = productInfo[0]; String tiaoma = productInfo[0];
PreparedStatement checkStmt = conn.prepareStatement("SELECT COUNT(*) FROM t_shangping WHERE tiaoma = ?"); PreparedStatement checkStmt = conn.prepareStatement("SELECT COUNT(*) FROM t_shangping WHERE tiaoma = ?");
@@ -65,9 +65,9 @@ public class ProductAdditionAndInquiry {
System.out.println("增加成功"); System.out.println("增加成功");
} }
private static void queryProduct(Scanner scanner, Connection conn) throws SQLException { private static void queryProduct(Scanner sc, Connection conn) throws SQLException {
System.out.print("请输入查询的商品名称:"); System.out.print("请输入查询的商品名称:");
String nameQuery = scanner.nextLine(); String nameQuery = sc.nextLine();
PreparedStatement queryStmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE mingcheng LIKE ?"); PreparedStatement queryStmt = conn.prepareStatement("SELECT * FROM t_shangping WHERE mingcheng LIKE ?");
queryStmt.setString(1, "%" + nameQuery + "%"); queryStmt.setString(1, "%" + nameQuery + "%");
ResultSet rs = queryStmt.executeQuery(); ResultSet rs = queryStmt.executeQuery();
+3 -3
View File
@@ -17,15 +17,15 @@ public class UserLogin {
Connection conn = DriverManager.getConnection(DBURL); Connection conn = DriverManager.getConnection(DBURL);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Scanner scanner = new Scanner(System.in); Scanner sc = new Scanner(System.in);
int attempts = 0; int attempts = 0;
boolean loginSuccess = false; boolean loginSuccess = false;
while (attempts < 3 && !loginSuccess) { while (attempts < 3 && !loginSuccess) {
System.out.println("欢迎使用阳光超市收银系统,请登陆"); System.out.println("欢迎使用阳光超市收银系统,请登陆");
System.out.print("请输入用户名: "); System.out.print("请输入用户名: ");
String username = scanner.nextLine(); String username = sc.nextLine();
System.out.print("请输入密码: "); System.out.print("请输入密码: ");
String password = scanner.nextLine(); String password = sc.nextLine();
String sql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=?"; String sql = "SELECT xingming FROM t_yong WHERE yonghuming=? AND mima=?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, username); pstmt.setString(1, username);