<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.tool.SzDateHelp" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="net.sz600.flow.*" %>
<%@ include file="/sessionInfo.jsp"%>
<%
    //是否来自弹出窗口的修改？
    String sWin  = SzConvert.strWriteData(request.getParameter("win"));
    String sWinName  = SzConvert.strWriteData(request.getParameter("winName"));
    //获取提交的参数
    String sType = SzConvert.toZeroStr(request.getParameter("type"));
    String sPage = SzConvert.toZeroStr(request.getParameter("page"));
    String sSearch = SzConvert.strWriteData(request.getParameter("txtSearch"));
    String sPKEY = SzConvert.toZeroStr(request.getParameter("PKEY"));
%>
<form name="formHidden" method="post">
  <input type="hidden" name="page" value="<%=sPage%>">
  <input type="hidden" name="txtSearch" value="<%=sSearch%>">
  <input type="hidden" name="PKEY" value="<%=sPKEY%>">
  <input type="hidden" name="type" value="<%=sType%>">
  <input type="hidden" name="win" value="<%=sWin%>">  
  <input type="hidden" name="winName" value="<%=sWinName%>">   
</form>
<%
    String sOPERATOR = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));

    LcStep lcStep = new LcStep();
    boolean flag = false;
    String sUrl = "index.jsp";
    String sMessage = "";
    if (sOPERATOR.equals("delete")) {
        String sKEY = SzConvert.toZeroStr(request.getParameter("KEY"));
        flag = lcStep.deleteByKey(sKEY);        
    } else {
        if (sOPERATOR.equals("add")) {
            flag = lcStep.add(request);
        } else if (sOPERATOR.equals("update")) {
            flag = lcStep.update(request);
        } else if (sOPERATOR.equals("updateDraft")) {
        	  flag = lcStep.updateDraft(request);
        }
    }
    sMessage = SzOut.getMessage();

    if (flag) {
        out.println(SzPageHelp.jsAlert("操作成功"));
        //out.println(SzPageHelp.jsGoUrl(sUrl));
        if (sWin.equals("win")) {        	
        	//关闭本窗口，刷新父窗口
        	if (sOPERATOR.equals("delete")) {
        		out.println("<script language='javascript'>");	
        		out.println("  var oWindow = window.dialogArguments;");
        		out.println("  oWindow.document.location.reload(); ");
        		out.println("  oWindow.parent.document.formUpdate.hiddenSave.value='YES'; ");
        		out.println("  oWindow.parent.document.formUpdate.saveButtonUpdate.click(); ");
        		out.println("  window.close(); ");
        		out.println("</script>");
        	} else {
        	%>
        	<script language='javascript'>
        	var oWindow = window.dialogArguments;
        	oWindow.document.location.reload();
			oWindow.parent.document.formUpdate.hiddenSave.value='YES';   
			oWindow.parent.document.formUpdate.saveButtonUpdate.click();
			window.close();		
				     
        		//out.println("<script language='javascript'>");        		
        		//out.println("  var oWindow = window.opener.dialogArguments;");
        		//out.println("  eval('oWindow.document.formList.submit();');");
        		//out.println("  window.opener.close();");
       			//out.println("  var oWindow = window.dialogArguments;");
        		//out.println("  eval('oWindow.document.location.reload();');");   
        		//out.println("  eval('oWindow.parent.document.formUpdate.hiddenSave.value=YES;');");
        		//out.println("  eval('oWindow.parent.document.formUpdate.saveButtonUpdate.click();');");
        		//out.println("  window.close();");
        		//out.println("</script>");        		
        	<%        		
        	} //if (sOPERATOR.equals("delete"))               	
        } else {
        	out.println(SzPageHelp.jsFormSubmit("formHidden",sUrl));
        } //if (sWin.equals("win")) {  
    } else {
        out.println(SzPageHelp.jsAlertBack(sMessage));
    }
%>
