userbusiness.java

来自「企业进销存源码」· Java 代码 · 共 67 行

JAVA
67
字号
package com.business;

import java.util.HashMap;

import com.business.vo.User;
import com.dao.util.DaoImp;
import com.web.util.WebTools;

/**
 * @author Administrator
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class UserBusiness {
	public String getNameById(String id) throws Exception{
		try{
			String str = "select userName from users where userid = '"+id+"'";
			DaoImp dao = new DaoImp();
			return WebTools.showEx(dao.find(str).get("USERNAME"));
		}catch(Exception e){
			return "";
		}
	}
	
	public void add(User vo) throws Exception{
		try{
			String str = "insert into Users(userId,userName,userPwd,roleId,userPhone,userAddress) values('"+vo.getUserId()+"','"+vo.getUserName()+"','"+vo.getUserPwd()+"',"+vo.getRoleId()+",'"+vo.getUserPhone()+"','"+vo.getUserAddress()+"')";
			DaoImp dao = new DaoImp();
			dao.insert(str);
		}catch(Exception e){
			throw e;
		}
	}
	public void edit(User vo) throws Exception{
		try{
			String str = "update users set username = '"+vo.getUserName()+"',userPwd = '"+vo.getUserPwd()+"',roleId = "+vo.getRoleId()+",userPhone = '"+vo.getUserPhone()+"',userAddress = '"+vo.getUserAddress()+"' where userId = '"+vo.getUserId()+"'";
			DaoImp dao = new DaoImp();
			dao.insert(str);
		}catch(Exception e){
			throw e;
		}
	}
	public void remove(User vo) throws Exception{
		try{
			String str = "delete from Users where userId = '"+vo.getUserId()+"'";
			DaoImp dao = new DaoImp();
			dao.insert(str);
		}catch(Exception e){
			throw e;
		}
	} 
	
	public HashMap find(String key) throws Exception{
		try{
			String str = "select * from Users where userId = '"+key+"'";
			DaoImp dao = new DaoImp();
			return dao.find(str);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	} 
}

⌨️ 快捷键说明

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