⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilsserviceimpl.java

📁 一个简单的Ext例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void delGoods(Goods goods) {
		// TODO 自动生成方法存根
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "delete from Goods ";
			str += "where id='"+goods.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void updateGoods(Goods goods) {
		// TODO 自动生成方法存根
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "update Goods set ";
			str += "goodsName='"+goods.getGoodsName()+"',";
			str += "prices="+goods.getPrices()+",";
			str += "goodsNote='"+goods.getGoodsNote()+"'";
			str += "where id='"+goods.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}

	public List listOther(String str) {
		// 查询其他资金列表
		System.out.println(str);
		ArrayList<Other> it = new ArrayList<Other>();
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(str);
			//conn.commit();
			while(rs.next()){
				Other em = new Other();
				em.setId(rs.getString("id"));
				em.setName(rs.getString("name"));
				em.setCost(rs.getInt("cost"));
				em.setTimes(rs.getString("times"));
				em.setCourse(rs.getString("course"));
				em.setType(rs.getInt("type"));
				it.add(em);
			}
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		return it;
	}
	public void addOther(Other other) {
		// 新增其他支出
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			String id = "other"+getRandomString(10);
			String str = "insert into Other values (";
			str += "'"+id+"',";
			str += "'"+other.getName()+"',";
			str += other.getCost()+",";
			str += "'"+other.getTimes()+"',";
			str += "'"+other.getCourse()+"',"+other.getType()+")";
			System.out.println(str);
			Statement stmt = conn.createStatement();
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void delOther(Other other) {
		// 
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "delete from Other ";
			str += "where id='"+other.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void updateOther(Other other) {
		// TODO 自动生成方法存根
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "update Other set ";
			str += "name='"+other.getName()+"',";
			str += "cost="+other.getCost()+", ";
			str += "times='"+other.getTimes()+"',";
			str += "course='"+other.getCourse()+"', ";
			str += "type="+other.getType();
			str += "where id='"+other.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}

	public void addSalary(Salary salary) {
		// TODO 自动生成方法存根
	}
	public List checkSalary(String str) {
		// 查询工资信息
		System.out.println(str);
		ArrayList<Salary> it = new ArrayList<Salary>();
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(str);
			//conn.commit();
			while(rs.next()){
				Salary em = new Salary();
				em.setId(rs.getString("id"));
				em.setPersonName(rs.getString("personName"));
				em.setSalary(rs.getInt("salary"));
				em.setTimes(rs.getString("times"));
				em.setLeave(rs.getInt("leave"));
				em.setOvertime(rs.getInt("overtime"));
				it.add(em);
			}
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		return it;
	}
	
	public List checkSubsidies(String str) {
		System.out.println(str);
		// TODO 自动生成方法存根
		ArrayList<Subsidies> it = new ArrayList<Subsidies>();
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(str);
			//conn.commit();
			while(rs.next()){
				Subsidies sub = new Subsidies();
				sub.setId(rs.getString("id"));
				sub.setPersonName(rs.getString("personName"));
				sub.setBeginTime(rs.getString("beginTime"));
				sub.setEndTime(rs.getString("endTime"));
				sub.setAddress(rs.getString("address"));
				sub.setCourse(rs.getString("course"));
				sub.setCost(rs.getInt("cost"));
				sub.setSalary(rs.getInt("salary"));
				sub.setDays(rs.getInt("days"));
				sub.setHours(rs.getInt("hours"));
				sub.setType(rs.getInt("type"));
				it.add(sub);
			}
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		return it;
	}
	public void addSubsidies(Subsidies subsidies) {
		//新增员工事件处理 
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			String id = "subsidies"+getRandomString(10);
			String str = "insert into EmployeerService values (";
			str += "'"+id+"',";
			str += "'"+subsidies.getPersonName()+"',";
			str += "'"+subsidies.getBeginTime()+"',";
			str += "'"+subsidies.getEndTime()+"',";
			str += "'"+subsidies.getAddress()+"',";
			str += "'"+subsidies.getCourse()+"',";
			str += subsidies.getCost()+",";
			str += subsidies.getSalary()+",";
			str += subsidies.getDays()+",";
			str += subsidies.getHours()+",";
			str += subsidies.getType()+",'','','','','')";
			System.out.println(str);
			Statement stmt = conn.createStatement();
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void delSubsidies(Subsidies subsidies) {
		// TODO 自动生成方法存根
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "delete from EmployeerService ";
			str += "where id='"+subsidies.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void updateSubsidies(Subsidies subsidies) {
		// TODO 自动生成方法存根
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "update EmployeerService set ";
			str += "personName='"+subsidies.getPersonName()+"',";
			str += "beginTime='"+subsidies.getBeginTime()+"',";
			str += "endTime='"+subsidies.getEndTime()+"',";
			str += "address='"+subsidies.getAddress()+"',";
			str += "course='"+subsidies.getCourse()+"',";
			str += "cost="+subsidies.getCost()+",";
			str += "salary="+subsidies.getSalary()+",";
			str += "days="+subsidies.getDays()+",";
			str += "hours="+subsidies.getHours()+",";
			str += "type="+subsidies.getType();
			str += "where id='"+subsidies.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}

	public void addOrder(Order order) {
		// 新增订单信息
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			String id = "order"+getRandomString(10);
			String str = "insert into Orders values (";
			str += "'"+id+"',";
			str += "'"+order.getCustomerName()+"',";
			str += "'"+order.getGoodsName()+"',";
			str += order.getCount()+",";
			str += "'"+order.getTimes()+"',";
			str += order.getPrices()+",";
			str += "'"+order.getGoodsNote()+"',";
			str += order.getType()+")";
			System.out.println(str);
			Statement stmt = conn.createStatement();
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public List checkOrder(String str) {
		// TODO 自动生成方法存根
		System.out.println(str);
		ArrayList<Order> it = new ArrayList<Order>();
		try {
			if(conn == null)System.out.println("conn is null");
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(str);
			//conn.commit();
			while(rs.next()){
				Order order = new Order();
				order.setId(rs.getString("id"));
				order.setCustomerName(rs.getString("customerName"));
				order.setGoodsName(rs.getString("goodsName"));
				order.setGoodsNote(rs.getString("goodsNote"));
				order.setCount(rs.getInt("counts"));
				order.setTimes(rs.getString("times"));
				order.setPrices(rs.getInt("prices"));
				order.setType(rs.getInt("type"));
				it.add(order);
			}
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		return it;
	}
	public void delOrder(Order order) {
		// TODO 自动生成方法存根
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "delete from Orders ";
			str += "where id='"+order.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
	public void updateOrder(Order order) {
		// 更新
		try {
			//conn.setAutoCommit(false);
			Statement stmt = conn.createStatement();
			String str = "update Orders set ";
			str += "customerName='"+order.getCustomerName()+"',";
			str += "goodsName='"+order.getGoodsName()+"',";
			str += "counts="+order.getCount()+",";
			str += "times='"+order.getTimes()+"',";
			str += "prices="+order.getPrices()+",";
			str += "type="+order.getType()+",";
			str += "goodsNote='"+order.getGoodsNote()+"'";
			str += "where id='"+order.getId()+"'";
			System.out.println(str);
			stmt.executeUpdate(str);
			//conn.commit();
			conn.close();
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}

	public static String getRandomString(int length) { 
	    StringBuffer buffer = new StringBuffer("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); 
	    StringBuffer sb = new StringBuffer(); 
	    Random r = new Random(); 
	    int range = buffer.length(); 
	    for (int i = 0; i < length; i ++) { 
	        sb.append(buffer.charAt(r.nextInt(range))); 
	    } 
	    return sb.toString(); 
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -