package com.seavision.PermissionManage.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.seavision.PermissionManage.common.BaseAction;
import com.seavision.PermissionManage.components.CompanyManage;
import com.seavision.PermissionManage.components.LogManage;
import com.seavision.PermissionManage.help.DaoFectory;
import com.seavision.PermissionManage.vo.CompanyVO;
import com.seavision.PermissionManage.vo.UserLoginVO;
/**
 * @author ��Ԩ��
 * @param String
 *            companyName String company_p String companyAddress String
 *            companyPhone String companyAuthority String companyNet String
 *            companyState String companyType
 * @���� �༭��˾��Ϣaction
 * @���������� ���ҳ�洫���Ĺ�˾�IJ�����ӹ�˾��¼,����ҳ����ת�� �ɹ�����SUCCESS ʧ�ܷ���FALSE
 */
public class CompanyNewAction extends BaseAction {
	public ActionForward execute(ActionMapping actionMapping,
			ActionForm actionForm, HttpServletRequest request,
			HttpServletResponse response) {
		try {
			// ��ʼ��Action
			String companyName = "";
			String company_p = "";
			String companyAddress = "";
			String companyPhone = "";
			String companyAuthority = "";
			String companyNet = "";
			String companyState = "1";
			String companyType = "";
			String url = "";
			String ipAddress = ""; // ip��ַ
			String operator = ""; // ������
			// boolean b = false; // �����ж��û�Ȩ��
			String b1 = ""; // ������תҳ��
			String message = "";
			this.initializeAction(request, "CompanyNewAction");
			// ��session��ȡ����
			UserLoginVO userLoginVO = new UserLoginVO();
			userLoginVO = (UserLoginVO)this.getAttribute("userLoginVO");
			operator = userLoginVO.getUserName();
			// ��request�л�ȡ����
			companyName = request.getParameter("companyName");
			company_p = request.getParameter("company_pId");
			companyAddress = request.getParameter("companyAddress");
			companyPhone = request.getParameter("companyPhone");
			companyAuthority = request.getParameter("companyAuthorityId");
			companyNet = request.getParameter("companyNet");
			companyState = request.getParameter("companyState");
			companyType = request.getParameter("companyType");
			// url = request.getParameter("url");
			ipAddress = request.getRemoteAddr();
			url = request.getRequestURI();
			// session������
			if (this.check(userLoginVO)) {
				message += "�û������벻��,�����µ�½!";
				return this.moveToFailure(message, "logon", actionMapping);
			}
			// �ж��û�Ȩ��
			// UrlBalanceManage ubm = new UrlBalanceManage();
			// b = ubm.urlBalance(url);
			// if (!b) {
			// message += "��û�д�Ȩ��";
			// return this.moveToFailure(message, "FALSE", actionMapping);
			// }
			// �жϹ�˾���Ƿ�Ϊnull
			if (check(companyName)) {
				message += "��˾��Ʋ���Ϊ�գ�";
				return this.moveToFailure(message, "FALSE", actionMapping);
			}
			
			// �ж��ϼ���˾����Ƿ�Ϊnull
			if (company_p == null || company_p.trim().length() == 0||company_p.equals("��ѡ��")) {
				company_p = "0";
			}
			// �жϹ�˾��ַ�Ƿ�Ϊnull
			if (check(companyAddress)) {
				companyAddress = "";
			}
			// �жϹ�˾�绰�Ƿ�Ϊnull
			if (check(companyPhone)) {
				companyPhone = "";
			}
			// �жϹ�˾�������Ƿ�Ϊnull
			if (check(companyAuthority)) {
				companyAuthority = "";
			}else if(companyAuthority.equals("��ѡ��")){
				companyAuthority = "0";
			}
			// �жϹ�˾��ַ�Ƿ�Ϊnull
			if (check(companyNet)) {
				companyNet = "";
			}
			// �жϹ�˾״̬����Ƿ�Ϊnull
			if (check(companyState)) {
				companyState = "0";
			}
			// �жϹ�˾�����Ƿ�Ϊnull
			if (check(companyType)) {
				companyType = "";
			}
			// �ж�url�Ƿ�Ϊnull
			if (check(url)) {
				message = "url����Ϊ�գ�";
				return this.moveToFailure(message, "FALSE", actionMapping);
			}
			// �ж�ip��ַ����Ϊ��
			if (check(ipAddress)) {
				message = "ip��ַ����Ϊ�գ�";
				return this.moveToFailure(message, "FALSE", actionMapping);
			}
			// �жϲ����˲���Ϊ��
			if (check(operator)) {
				message = "�����˲���Ϊ�գ�";
				return this.moveToFailure(message, "FALSE", actionMapping);
			}
			// ��װ��vo
			CompanyVO company = new CompanyVO();
			company.setCompanyName(companyName);
			company.setCompany_p(Integer.parseInt(company_p));
			company.setCompanyAddress(companyAddress);
			company.setCompanyPhone(companyPhone);
			company.setCompanyAuthority(companyAuthority);
			company.setCompanyNet(companyNet);
			company.setCompanyState(Integer.parseInt(companyState));
			company.setCompanyType(companyType);
			// �����������,����ҵ��������
			CompanyManage cm = DaoFectory.getCompanyManage();
			List list1 = cm.getCompanyList();
			CompanyVO company1 = new CompanyVO();
			for(int i=0;i<list1.size();i++){
				company1 = (CompanyVO)list1.get(i);
				String companyName1 = company1.getCompanyName();
				if(companyName1.trim().equals(companyName)){
					message = "��˾��������";
					return this.moveToFailure(message, "FALSE", actionMapping);
				}
			}
			if(!company_p.equals("0")){
				b1 = cm.saveDepartmentRelation(company);
			}else{
				b1 = cm.saveCompany(company);			
			}
			// д����־
			LogManage lm = DaoFectory.getLogManage();
			lm.addLog(operator, url, ipAddress, "newCompany");
			// ͨ���ֵ�����ж�ҳ����ת
			if (b1.equals("success")) {
				return this.moveToSuccess("SUCCESS", actionMapping);
			} else {
				return this.moveToFailure("����ʧ��", "FALSE", actionMapping);
			}
		} catch (Exception e) {
			return this.moveToError(e.getMessage(), "error", actionMapping);
		}
	}
}
 最近下载更多
最近下载更多
                
                liusha625184071     LV13
                2021年6月10日
            
            
        
                白帅帅     LV5
                2021年4月26日
            
            
        
                nianchenzi     LV5
                2021年2月20日
            
            
        
                myfz0662     LV10
                2020年6月17日
            
            
        
                981210X     LV2
                2020年5月14日
            
            
        
                liucen01     LV2
                2020年4月17日
            
            
        
                jiang1997     LV6
                2020年1月3日
            
            
        
                wrwrwrwr     LV1
                2019年11月25日
            
            
        
                我是大斌     LV7
                2019年11月7日
            
            
        
                yangfeng666     LV10
                2019年11月1日
            
            
         最近浏览更多
最近浏览更多
                
                ttg2025     LV3
                7月15日
            
            
        
                wuying8208     LV15
                2024年10月23日
            
            
        
                 dsadasdwf     LV12
                2023年10月23日
            
            
        
                1997akkk     LV5
                2023年8月8日
            
            
        
                hongdongdong     LV14
                2023年6月17日
            
            
        
                Klingspr    
                2023年6月9日
            
            
                    暂无贡献等级
            
        
                hbsoft2008     LV16
                2022年12月6日
            
            
        
                ioncecon     LV1
                2022年5月30日
            
            
        
                xiao小果     LV13
                2022年4月1日
            
            
        
                li521010    
                2022年3月14日
            
            
                    暂无贡献等级
            
        
 
                 
     
    