ddca7db43f3ef9970577d60452dcdf367d5fcfbc.svn-base 2.2 KB
package yxy.timer.webservice.interfaces.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

import yxy.timer.tool.DBUtil;
import yxy.timer.webservice.interfaces.CustomerTypeWebservice;

@WebService(targetNamespace="http://CustomerTypeWebservice.interfaces.webservice.timer.yxy/",serviceName="typeWebservice")
public class CustomerTypeWebserviceImpl implements CustomerTypeWebservice 
{
	@WebResult(name="result")
	@WebMethod
	public String deleteCustomerType(@WebParam(name="type_id",targetNamespace="http://CustomerTypeWebservice.interfaces.webservice.timer.yxy/")int type_id) 
	{
		String result = "";
		
		if(type_id == 0)
		{
			result = "error";
			
			return result;
		}
		
		try
		{
			Connection connection;
			
			PreparedStatement  pst;
			
			//获取数据库的连接
			connection = DBUtil.getConnection("dataSource");
			
			String sql = "delete from yxy_customer_type where id="+type_id;
			
			pst = connection.prepareStatement(sql);
			
			pst.executeUpdate(sql);
			
			result = "success";
			
			return result;
		}
		
		catch(Exception e)
		{
			e.printStackTrace();
			
			result = "error";
			
			return result;
		}
	}

	@WebResult(name="result")
	@WebMethod
	public String updateCustomerType(@WebParam(name="type_id",targetNamespace="http://CustomerTypeWebservice.interfaces.webservice.timer.yxy/")int type_id, 
			@WebParam(name="type_name",targetNamespace="http://CustomerTypeWebservice.interfaces.webservice.timer.yxy/")String type_name)
	{
		String result = "";
		
		if(type_id == 0 || type_name==null)
		{
			result = "error";
			
			return result;
		}
		
		try
		{
			Connection connection;
			
			PreparedStatement  pst;
			
			//获取数据库的连接
			connection = DBUtil.getConnection("dataSource");
			
			String sql = "update yxy_customer_type set type_name='"+type_name+"' where id="+type_id;
			
			pst = connection.prepareStatement(sql);
			
			pst.executeUpdate(sql);
			
			result = "success";
			
			return result;
		}
		
		catch(Exception e)
		{
			e.printStackTrace();
			
			result = "error";
			
			return result;
		}
	}
}