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