Compare commits
5 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
45c4c0b4a4 | 2 years ago |
|
|
a9c1c89dc1 | 2 years ago |
|
|
48abe58dc5 | 2 years ago |
|
|
edd18ef917 | 2 years ago |
|
|
50d3ec9eee | 2 years ago |
@ -0,0 +1,105 @@
|
||||
package com.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.entity.Carlyx;
|
||||
import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.Statement;
|
||||
import com.utils.DBUtilhxr;
|
||||
|
||||
public class CarDaolyx {
|
||||
// 添加表信息
|
||||
public void addCar(Carlyx car)throws Exception {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql="insert into car_info"
|
||||
+"(car_id,model,color,manufactory,factory_date,price)"
|
||||
+"values(?,?,?,?,?,?)";
|
||||
PreparedStatement psmt = con.prepareStatement(sql);
|
||||
psmt.setInt(1, car.getCar_id());
|
||||
psmt.setString(2, car.getModel());
|
||||
psmt.setString(3, car.getColor());
|
||||
psmt.setString(4, car.getManufactory());
|
||||
psmt.setString(5, car.getFactory_date());
|
||||
psmt.setString(6, car.getPrice());
|
||||
try {
|
||||
psmt.executeUpdate();
|
||||
JOptionPane.showMessageDialog(null, "数据插入成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "数据插入失败 ","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
con.close();
|
||||
}
|
||||
//删除汽车信息
|
||||
public void delCar(int car_id ) throws SQLException {
|
||||
Connection con=(Connection) DBUtilhxr.getConnection();
|
||||
String sql="" +
|
||||
"DELETE FROM car_info "+
|
||||
"WHERE car_id = ?";
|
||||
// 预编译sql语句
|
||||
PreparedStatement psmt = con.prepareStatement(sql);
|
||||
psmt.setInt(1, car_id);
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据删除成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据删除失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
// 修改Car信息
|
||||
public void changeCar(Carlyx car) throws SQLException {
|
||||
// System.out.println(car.getCar_id()+car.getColor()+car.getModel()+car.getManufactory()+car.getFactory_date()+car.getPrice());
|
||||
String model = car.getModel();
|
||||
String color = car.getColor();
|
||||
String manufactory = car.getManufactory();
|
||||
String factory_date= car.getFactory_date();
|
||||
String price = car.getPrice();
|
||||
Integer car_id = car.getCar_id();
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql = "update car_info "
|
||||
+ "set model=\""+model+"\","
|
||||
+ "color=\""+color+"\","
|
||||
+"manufactory=\""+manufactory+"\","
|
||||
+"factory_date=\""+factory_date+"\","
|
||||
+ "price=\""+price+"\" "
|
||||
+"where car_id ="+car_id+";";
|
||||
Statement psmt = (Statement) con.createStatement();
|
||||
try {
|
||||
psmt.executeUpdate(sql);
|
||||
JOptionPane.showMessageDialog(null, "数据修改成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据修改失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
}
|
||||
// 查询表信息
|
||||
public List<Carlyx> query() throws Exception{
|
||||
Connection con=(Connection) DBUtilhxr.getConnection();
|
||||
Statement stmt=(Statement) con.createStatement();
|
||||
ResultSet rs= stmt.executeQuery("select car_id,model,color,manufactory,"+
|
||||
"factory_date,price from car_info");
|
||||
List<Carlyx> carList = new ArrayList<Carlyx>();
|
||||
Carlyx car=null;
|
||||
while (rs.next()) {
|
||||
car = new Carlyx();
|
||||
car.setCar_id(Integer.parseInt(rs.getString("car_id")));
|
||||
car.setModel(rs.getString("model"));
|
||||
car.setColor(rs.getString("color"));
|
||||
car.setManufactory(rs.getString("manufactory"));
|
||||
car.setFactory_date(rs.getString("factory_date"));
|
||||
car.setPrice(rs.getString("price"));
|
||||
carList.add(car);
|
||||
}
|
||||
return carList;
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.dao;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.entity.Guesthxr;
|
||||
import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.PreparedStatement;
|
||||
import com.mysql.jdbc.Statement;
|
||||
import com.utils.DBUtilhxr;
|
||||
|
||||
public class GuestDaohxr {
|
||||
// 增加客户信息
|
||||
public void addGuest(Guesthxr guest) throws Exception {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql = "insert into guest_info" + "(guest_name,contact_inf,address,business_re)" + "values(?,?,?,?)";
|
||||
PreparedStatement psmt = (PreparedStatement) con.prepareStatement(sql);
|
||||
psmt.setString(1, guest.getGuest_name());
|
||||
psmt.setString(2, guest.getContact_information());
|
||||
psmt.setString(3, guest.getAddress());
|
||||
psmt.setString(4, guest.getBusiness_record());
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据添加成功", "tips", JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据添加失败", "tips", JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
//删除客户信息
|
||||
public void delGuest(String guest_name) throws SQLException {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql = "delete from guest_info where guest_name = ?";
|
||||
PreparedStatement psmt = (PreparedStatement) con.prepareStatement(sql);
|
||||
psmt.setString(1, guest_name);
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据删除成功", "tips", JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据删除失败", "tips", JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 修改客户信息
|
||||
public void changeGuest(Guesthxr guest) throws SQLException {
|
||||
String contact_inf = guest.getContact_information();
|
||||
String address = guest.getAddress();
|
||||
String business_re = guest.getBusiness_record();
|
||||
String guest_name = guest.getGuest_name();
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql = "update guest_info" + " set contact_inf=\"" + contact_inf + "\"," + "address=\"" + address + "\","
|
||||
+ "business_re=\"" + business_re + "\"" + " where guest_name=\"" + guest_name + "\";";
|
||||
Statement stm = (Statement) con.createStatement();
|
||||
|
||||
try {
|
||||
stm.execute(sql);
|
||||
JOptionPane.showMessageDialog(null, "数据修改成功", "tips", JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据修改失败", "tips", JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 查询表信息
|
||||
public List<Guesthxr> query() throws Exception {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
Statement stmt = (Statement) con.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select guest_name,contact_inf,address,business_re" + " from guest_info");
|
||||
List<Guesthxr> carList = new ArrayList<Guesthxr>();
|
||||
Guesthxr guest = null;
|
||||
while (rs.next()) {
|
||||
guest = new Guesthxr();
|
||||
guest.setGuest_name(rs.getString("guest_name"));
|
||||
guest.setContact_information(rs.getString("contact_inf"));
|
||||
guest.setAddress(rs.getString("address"));
|
||||
guest.setBusiness_record(rs.getString("business_re"));
|
||||
|
||||
carList.add(guest);
|
||||
}
|
||||
return carList;
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
package com.main;
|
||||
|
||||
import com.view.Loginhxr;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Loginhxr lg =new Loginhxr();
|
||||
lg.loginGUi(null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.entity.Saleyzz;
|
||||
import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.Statement;
|
||||
import com.utils.DBUtilhxr;
|
||||
|
||||
public class SaleDaoyzz {
|
||||
//添加销售信息
|
||||
public void addSale(Saleyzz sale) throws Exception {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql="insert into sales_info"
|
||||
+"(sale_date,car_type,color,number,handler)"
|
||||
+"values(?,?,?,?,?)";
|
||||
PreparedStatement psmt = con.prepareStatement(sql);
|
||||
psmt.setString(1, sale.getSale_date());
|
||||
psmt.setString(2, sale.getCar_type());
|
||||
psmt.setString(3, sale.getColor());
|
||||
psmt.setInt(4, sale.getNumber());
|
||||
psmt.setString(5, sale.getHandler());
|
||||
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据添加成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据添加失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
}
|
||||
//删除销售信息
|
||||
public void delSale(String sale_date) throws SQLException{
|
||||
Connection con=(Connection) DBUtilhxr.getConnection();
|
||||
String sql="" +
|
||||
"DELETE FROM sales_info "+
|
||||
"WHERE sale_date = ?";
|
||||
// 预编译sql语句
|
||||
PreparedStatement psmt = con.prepareStatement(sql);
|
||||
psmt.setString(1, sale_date);
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据删除成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据删除失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
}
|
||||
//修改销售信息
|
||||
public void changeSale(Saleyzz sale)throws SQLException {
|
||||
String sale_date=sale.getSale_date();
|
||||
String car_type =sale.getCar_type();
|
||||
String color = sale.getColor();
|
||||
Integer number = sale.getNumber();
|
||||
String handler=sale.getHandler();
|
||||
Connection con=(Connection) DBUtilhxr.getConnection();
|
||||
String sql= "update sales_info"
|
||||
+" set sale_date=\""+sale_date+"\","
|
||||
+ "car_type=\""+car_type+"\","
|
||||
+ "color=\""+color+"\","
|
||||
+ "number=\""+number+"\""
|
||||
+ " where handler=\""+handler+"\";";
|
||||
Statement stm = (Statement) con.createStatement();
|
||||
try {
|
||||
stm.execute(sql);
|
||||
JOptionPane.showMessageDialog(null, "数据修改成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据修改失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
}
|
||||
// 查询表信息
|
||||
public List<Saleyzz> query() throws Exception {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
Statement stmt = (Statement) con.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select sale_date,car_type,color,number,handler from sales_info");
|
||||
List<Saleyzz> saleList = new ArrayList<Saleyzz>();
|
||||
Saleyzz sale = null;
|
||||
while (rs.next()) {
|
||||
sale = new Saleyzz();
|
||||
sale.setSale_date(rs.getString("sale_date"));
|
||||
sale.setCar_type(rs.getString("car_type"));
|
||||
sale.setColor(rs.getString("color"));
|
||||
sale.setNumber(rs.getInt("number"));
|
||||
sale.setHandler(rs.getString("handler"));
|
||||
saleList.add(sale);
|
||||
}
|
||||
return saleList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.dao;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.entity.Userdyh;
|
||||
import com.utils.DBUtilhxr;
|
||||
|
||||
public class UserDaodyh {
|
||||
public static List<Userdyh> query() throws Exception{
|
||||
Connection con = DBUtilhxr.getConnection();
|
||||
Statement stmt = con.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select id,user,password from user_info");
|
||||
List<Userdyh> userList = new ArrayList<Userdyh>();
|
||||
Userdyh user = null;
|
||||
// 如果对象中有数据,就会循环打印出来
|
||||
while (rs.next()){
|
||||
user = new Userdyh(); // 调用模型层
|
||||
user.setID(rs.getInt("id"));
|
||||
user.setUserName(rs.getString("user"));
|
||||
user.setPassword(rs.getString("password"));
|
||||
userList.add(user);
|
||||
}
|
||||
return userList;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
package com.dao;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import com.entity.Workerdyh;
|
||||
import com.mysql.jdbc.Connection;
|
||||
import com.mysql.jdbc.Statement;
|
||||
import com.utils.DBUtilhxr;
|
||||
|
||||
public class WorkerDaodyh {
|
||||
//添加员工信息
|
||||
public void addWorker(Workerdyh worker) throws Exception {
|
||||
Connection con= (Connection) DBUtilhxr.getConnection();
|
||||
String sql="insert into worker_info"
|
||||
+"(worker_id,name,sex,age,origin,education)"
|
||||
+"values(?,?,?,?,?,?)";
|
||||
PreparedStatement psmt = con.prepareStatement(sql);
|
||||
psmt.setInt(1, worker.getWorker_id());
|
||||
psmt.setString(2, worker.getName());
|
||||
psmt.setString(3, worker.getSex());
|
||||
psmt.setString(4, worker.getAge());
|
||||
psmt.setString(5, worker.getOrigin());
|
||||
psmt.setString(6, worker.getEducation());
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据添加成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据添加失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
}
|
||||
//删除员工信息
|
||||
public void delWorker(int worker_id) throws SQLException {
|
||||
Connection con=(Connection) DBUtilhxr.getConnection();
|
||||
String sql=
|
||||
"delete from worker_info where worker_id = ?";
|
||||
PreparedStatement psmt=con.prepareStatement(sql);
|
||||
psmt.setInt(1,worker_id);
|
||||
try {
|
||||
psmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "数据删除成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据删除失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
//更新员工信息
|
||||
public void changeWorker(Workerdyh worker) throws SQLException {
|
||||
String name = worker.getName();
|
||||
String sex= worker.getSex();
|
||||
String age = worker.getAge();
|
||||
String origin = worker.getOrigin();
|
||||
String education = worker.getEducation();
|
||||
Integer worker_id = worker.getWorker_id();
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
String sql ="update worker_info"
|
||||
+" set name =\""+name+"\","
|
||||
+ "sex = \""+sex+"\","
|
||||
+ "age = \""+age+"\","
|
||||
+ "origin =\""+origin+"\","
|
||||
+ "education =\""+education+"\""
|
||||
+" where worker_id ="+worker_id+";";
|
||||
Statement smt = (Statement) con.createStatement();
|
||||
try {
|
||||
smt.execute(sql);
|
||||
JOptionPane.showMessageDialog(null, "数据更新成功","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
JOptionPane.showMessageDialog(null, "数据更新失败","tips",JOptionPane.PLAIN_MESSAGE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// 查询表信息
|
||||
public List<Workerdyh> query() throws Exception {
|
||||
Connection con = (Connection) DBUtilhxr.getConnection();
|
||||
Statement stmt = (Statement) con.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select worker_id,name,sex,age,origin,education from worker_info");
|
||||
List<Workerdyh> workerList = new ArrayList<Workerdyh>();
|
||||
Workerdyh worker = null;
|
||||
while (rs.next()) {
|
||||
worker = new Workerdyh();
|
||||
worker.setWorker_id(Integer.parseInt(rs.getString("worker_id")));
|
||||
worker.setName(rs.getString("name"));
|
||||
worker.setSex(rs.getString("sex"));
|
||||
worker.setAge(rs.getString("age"));
|
||||
worker.setOrigin(rs.getString("origin"));
|
||||
worker.setEducation(rs.getString("education"));
|
||||
|
||||
workerList.add(worker);
|
||||
}
|
||||
return workerList;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue