package BranchesMgr.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import BranchesMgr.dao.BranchesDao;
import BranchesMgr.dao.CityAreaDao;
import BranchesMgr.dao.impl.BranchesDaoImpl;
import BranchesMgr.dao.impl.CityAreaDaoImpl;
import BranchesMgr.entity.Branches;
import BranchesMgr.entity.CityArea;

public class updateServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		PrintWriter out = response.getWriter();
			String name=request.getParameter("name");
			int cityid=Integer.parseInt(request.getParameter("city")); 
			String address=request.getParameter("address");
			String telephone=request.getParameter("telephone");
			Branches breach=new Branches();
			breach.setName(name);
			breach.setCityAreatyid(cityid);
			breach.setAddress(address);
			breach.setTelephone(telephone);
			BranchesDao breadao=new BranchesDaoImpl();
			int rel=breadao.UpdateBranches(breach);
			if(rel>0){
				out.print("<script>alert('修改成功!');location.href='BrancheseServlet';</script>");
			}else{
				out.print("<script>alert('修改失败!');location.href='BrancheseServlet';</script>");
			}
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}
	

}