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

📄 sysdeptdel.java.svn-base

📁 用JSP JAVA 做的 系统 只是初来扎到还望西黄!别乱来哦!
💻 SVN-BASE
字号:
package com.chis.model.user;

import java.util.List;

import com.stframe.dao.DaoUtil;
import com.stframe.form.ActionForm;
import com.stframe.form.DataForm;
import com.stframe.servlet.ActionInstance;
/**
 * 删除部门
 * @author baobao
 *
 */
public class SysDeptDel extends ActionInstance{

	public int execute(ActionForm af) throws Exception {
		String shbdwbh =af.getHttpSession().getAttribute("HBDWBH").toString();
		String deptid = af.getHttpRequest().getParameter("id");
		
		//判断是否有下级部门
		DataForm deptdf = new DataForm("DEPT","ID");
		String deptsql = "SELECT * FROM DEPT WHERE ID='"+deptid+"' and CROP_ID='"+shbdwbh+"'";
		DataForm dfone = (DataForm)DaoUtil.select(af.getConnection(),deptsql,deptdf).get(0);
		if("0".equals(dfone.get("PARENT_ID")))
		{
			String dtsql = "SELECT * FROM DEPT WHERE PARENT_ID='"+deptid+"' AND CROP_ID='"+shbdwbh+"'";
			List deptlistone = DaoUtil.select(af.getConnection(),dtsql,deptdf);
			if(deptlistone.size()>0)
			{
				af.getHttpRequest().setAttribute("result","该部门尚有下属部门在使用,不能删除");
				return 0;
			}else
			{
				DaoUtil.execute(af.getConnection(),"DELETE FROM DEPT WHERE ID='"+deptid+"'");
				af.getHttpRequest().setAttribute("result","删除部门");
				af.getHttpRequest().setAttribute("goto","Selevet.do?action=BASE_SYSDEPT_LIST");
				af.getHttpRequest().setAttribute("CMD",af.getHttpRequest().getParameter("CMD"));
				return 1;
			}
		}else{
			//是否存在用户
			DataForm userdf = new DataForm("SYS_USER","ID");
			String dtsqltwo = "SELECT * FROM SYS_USER WHERE DEPTARTMENT_ID='"+deptid+"' AND CORP_ID='"+shbdwbh+"'";
			List deptlisttwo = DaoUtil.select(af.getConnection(),dtsqltwo,userdf);
			if(deptlisttwo.size()>0)
			{
				af.getHttpRequest().setAttribute("result","该部门下尚有用户,不能删除");
				return 0;			
			}else
			{
				DaoUtil.execute(af.getConnection(),"DELETE FROM DEPT WHERE ID='"+deptid+"'");
				af.getHttpRequest().setAttribute("result","删除部门");
				af.getHttpRequest().setAttribute("goto","Selevet.do?action=BASE_SYSDEPT_LIST");
				af.getHttpRequest().setAttribute("CMD",af.getHttpRequest().getParameter("CMD"));
				return 1;
			}	
		}
	}

}

⌨️ 快捷键说明

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