<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CreateDoc.aspx.cs" Inherits="WorkFlow.FlowPage.CreateDoc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <link href="css/ext-all.css" rel="stylesheet" type="text/css" />

    <script src="../js/ToolTip.js" type="text/javascript"></script>

    <script type="text/javascript">
       //返回IE版本
function getIEVersonNumber()
{
	var ua = navigator.userAgent;
	var msieOffset = ua.indexOf("MSIE ");
	if(msieOffset < 0)
		return 0;
	return parseFloat(ua.substring(msieOffset + 5, ua.indexOf(";", msieOffset)));
}
   function window_onload()
{
		if(navigator.appName == "Netscape" || navigator.appName == "Opera" || getIEVersonNumber() <= 5)
		{ 
		 var win = parent.Ext.getCmp('Window5');if (win) {win.hide();}  
		alert("请使用微软IE内核的浏览器，如：傲游、世界之窗、360、搜狗、TT等！");			
		}
}
    </script>

</head>
<body style="background-color: #5f6268" onload="window_onload();">
    <form id="form1" name="myform" action="#">
    <% //获取服务器的地址
        string URL = this.Session["URL"].ToString();
        string ID;
        string DocType;
        string DocTitle = "";
        //起草文件,则ID为NULL,否则为记录的主键
        ID = Request.QueryString["ID"];
        if (ID == null || ID == "")
        {
            //获取新建文件的类型         
            DocType = Request.Form["DocType"];
        }
        else
        {
            //获取DocTitle
            DocTitle = Request.QueryString["DocTitle"];
            //获取文件的 类型       
            DocType = Request.QueryString["DocType"];
        }
 %>
    <img alt="" onmouseout="wsug(event, 0)" onmouseover="wsug(event, '区域内容功能使用部分内容不被修改具体操作如下：<br/>1： 录入内容后，单击“工具”菜单，找到“保护文档”选项，<br/>打开“保护文档”设置项。 <br/><br/>2：将“编辑限制”项中的“仅允许在文档中进行此类编辑”选中，<br/>并设置为“未做任何更改（只读）”。<br/><br/>3： 选中需要填写答案的部分（可以利用按住“Ctrl”键同时选择多个不连续的部分），<br/>接着将“例外项”中的“每个人”设置项选中。<br/><br/>4： 单击“启动强制保护”，设置好密码，保存就可以了。')"
        src="images/help.png" style="margin-right: 6px" />
    <center>
        <input name="UpdateType" id="UpdateType" style="display: none" runat="server" />
        <input name="DocTitle" size="14" id="Text1" style="display: none" />
        <input name="WorkFlowViewXMLId" id="WorkFlowViewXMLId" style="display: none" runat="server" />
        <div style="background-image: url('icon/1new.png'); width: 880px; height: 10px">
        </div>
        <div style="background-image: url('icon/2.png'); width: 880px; text-align: center">
            <div id="NameTitle" runat="server" style="color: #2a6583; font-weight: bold; font-size: 34px;">
            </div>

            <script language="javascript" type="text/javascript" for="WebOffice1" event="NotifyCtrlReady">
                           WebOffice1_NotifyCtrlReady();
                         </script>

            <script language="javascript" type="text/javascript">
                            var s = ""
                            s += "<object id=WebOffice1 height=586 width='99%' style='LEFT: 0px; TOP: 0px'  classid='clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5' codebase=WebOffice.cab#V6,0,2,0>"
                            s +="<param name='_ExtentX' value='6350'><param name='_ExtentY' value='6350'>"
                            s +="</OBJECT>"
                            document.write(s)
            </script>

            <table width="100%">
                <tr>
                    <td align="center">
                        <table style="margin-top: 6px; width: 300px">
                            <tr>
                                <td>
                                    <input type="button" value=" 保 存 " onclick="return SaveDoc()" title="保存表单内容" class="button" />
                                </td>
                                <td>
                                    <input type="button" value=" 关 闭 " onclick="return CloseDoc()" title="关闭表单界面" class="button" />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </div>
        <div style="background-image: url('icon/1.png'); width: 880px; height: 10px">
        </div>
    </center>

    <script language="javascript" type="text/javascript">
    function CloseDoc()
    {
       document.all.WebOffice1.Close();
        var win = parent.Ext.getCmp('Window5');if (win) {win.hide();}  
    }
        function window_onunload() {
	        document.all.WebOffice1.Close();
        }
        // -----------------------------== 修订文档 ==------------------------------------ //
        function ProtectRevision() {
	        document.all.WebOffice1.SetTrackRevisions(1) 
        }

        // -----------------------------== 隐藏修订 ==------------------------------------ //
        function UnShowRevisions() {
	        document.all.WebOffice1.ShowRevisions(0);
        }
        // --------------------------== 显示当前修订 ==---------------------------------- //
        function ShowRevisions() {
	        document.all.WebOffice1.ShowRevisions(1);
        }
        // -------------------------== 接受当前所有修订 ------------------------------ //
        function AcceptAllRevisions() {
            document.all.WebOffice1.SetTrackRevisions(4);
        }     
     function WebOffice1_NotifyCtrlReady() 
     {
        if(myform.UpdateType.value=="")
          {
     	     document.all.WebOffice1.LoadOriginalFile("", "doc");
          }
        else
         {
             document.all.WebOffice1.LoadOriginalFile("<%=URL %>/GetDoc.aspx?WorkFlowViewXMLId="+myform.WorkFlowViewXMLId.value,"doc");
 	         document.all.WebOffice1.SetTrackRevisions(1);
             document.all.WebOffice1.ShowRevisions(0);//隐藏修订
         }
	
     }
// -----------------------------== 保存文档 ==------------------------------------ //
function SaveDoc() {
	//恢复被屏蔽的菜单项和快捷键
    document.all.WebOffice1.SetToolBarButton2("Standard",1,3);
    document.all.WebOffice1.SetToolBarButton2("Standard",2,3);
    document.all.WebOffice1.SetToolBarButton2("Standard",3,3);
    document.all.WebOffice1.SetToolBarButton2("Standard",6,3);           
        //恢复文件菜单项
        document.all.WebOffice1.SetToolBarButton2("Menu Bar",1,4);
        //恢复 保存快捷键(Ctrl+S) 
        document.all.WebOffice1.SetKeyCtrl(595,0,0);
        //恢复 打印快捷键(Ctrl+P) 
        document.all.WebOffice1.SetKeyCtrl(592,0,0);

//初始化Http引擎
	document.all.WebOffice1.HttpInit();			
//添加相应的Post元素
	<%
	if(ID != ""){          
	%>
	document.all.WebOffice1.SetTrackRevisions(0);
	document.all.WebOffice1.ShowRevisions(0);
	 <%
	 }
	 %>	
	document.all.WebOffice1.HttpAddPostString("DocTitle", myform.DocTitle.value);
	document.all.WebOffice1.HttpAddPostString("DocType","<%=DocType%>");
	document.all.WebOffice1.HttpAddPostString("WorkFlowViewXMLId",myform.WorkFlowViewXMLId.value);
	document.all.WebOffice1.HttpAddPostString("UpdateType",myform.UpdateType.value);
	//把当前文档添加到Post元素列表中，文件的标识符䶿DocContent
	document.all.WebOffice1.HttpAddPostCurrFile("DocContent","");		// 涓婁紶鏂囦欢
	var vtRet;
    //HttpPost执行上传的动仿WebOffice支持Http的直接上传，在upload.aspx的页面中,解析Post过去的数慿
    //拆分出Post元素和文件数据，可以有选择性的保存到数据库中，或保存在服务器的文件中⾿
	//HttpPost的返回值，根据upload.aspx中的设置，返回upload.aspx中Response.Write回来的数据
	vtRet = document.all.WebOffice1.HttpPost("<%=URL %>/upload.aspx");

 	//alert(vtRet);
 	if("succeed" == vtRet){
 	  myform.UpdateType.value="";
 	  myform.WorkFlowViewXMLId.value="";
 	  var win = parent.Ext.getCmp('Window5');if (win) {win.hide();}
		alert("保存成功");	
	}else{
		alert("保存失败");
	}
	 document.all.WebOffice1.Close();  
	 var win = parent.Ext.getCmp('Window5');if (win) {win.hide();} 
}
    </script>

    <span style="color: red; display: none">服务器地址:<%=this.Session["URL"].ToString() %>
    </span>
    <!-- --------------------===  Weboffice初始化完成事件--------------------- -->
    </form>
</body>
</html>
