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

<!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 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 type="text/javascript">
       function ftp(info)
        {
          var file=document.getElementById(info);
          file.outerHTML=file.outerHTML;
          return true;
        }
         /* 
      *CheckFilePath()验证附件为不为空
      *创建人：typ
      *创建时间：2010-12-21
      */
      function CheckFilePath()
      {
        var FilePath=document.getElementById("<%=fupFilePath.ClientID %>");
        if(FilePath.value=="")
         {
            alert('请先浏览要上传的附件！');return false ;       
         }
      }
    </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('Window1');if (win) {win.hide();}  
		alert("请使用微软IE内核的浏览器，如：傲游、世界之窗、360、搜狗、TT等！");			
		}
}
    </script>
</head>
<body style="background-color: #5f6268"  onload="window_onload();">
    <form id="myform" name="myform" action="#" runat="server">
    <% //获取服务器的地址
        string URL = this.Session["URL"].ToString();
        string ID;
        string DocType;
        string DocTitle = "";
        //起草文件,则ID为NULL,否则为记录的主键
        ID = Request.QueryString["ID"];
        if (ID == null || ID == "")
        {
            //获取新建文件的类型         
            DocType = "doc";
        }
        else
        {
            //获取DocTitle
            DocTitle = Request.QueryString["DocTitle"];
            //获取文件的 类型       
            DocType = "doc";
        }
 %>
    <center>
        <table cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <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">

                        <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>

                    </div>
                    <div style="background-image: url('icon/1.png'); width: 880px; height: 10px">
                    </div>
                </td>
                <td valign="top" align="center">
                    <div style="background-image: url('icon/left-top.png'); width: 317px; height: 10px">
                    </div>
                    <div style="background-image: url('icon/left-c.png'); width: 317px;">
                        <input name="UpdateId" size="14" id="UpdateId" style="display: none" runat="server" />
                        <input name="Account" size="14" id="Account" 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" />
                        <table>
                            <tr>
                                <td colspan="2">
                                    <table>
                                        <tr>
                                            <td>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <div style="width: 49px">
                                                                标题：</div>
                                                        </td>
                                                        <td align="left">
                                                            <input name="TitleInfo" id="TitleInfo" runat="server" style="width: 241px" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            附件：
                                                        </td>
                                                        <td align="left">
                                                            <table cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td>
                                                                        <asp:FileUpload ID="fupFilePath" runat="server" Style="cursor: pointer;" Height="20px"
                                                                            Width="158px" onkeypress="return false;" onkeydown="return false;" oncontextmenu="return false;" />
                                                                    </td>
                                                                    <td>
                                                                        <asp:Button ID="btUpLoad" runat="server" Text="上传" OnClientClick="return CheckFilePath();"
                                                                            ToolTip="上传浏览的附件" OnClick="btUpLoad_Click" Font-Size="12px" />
                                                                    </td>
                                                                    <td>
                                                                        <input id="Button1" type="button" value="清除" title="清除所浏览的附件" onclick="return ftp('fupFilePath');"
                                                                            style="font-size: 12px" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                        </td>
                                                        <td>
                                                            <table cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td align="left">
                                                                        <asp:DropDownList ID="ddlFilesView" runat="server" Visible="False" Font-Size="12px"
                                                                            Width="220px">
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                    <td>
                                                                        <div style="font-size: 14px;">
                                                                            <asp:ImageButton ID="ibtDelete" runat="server" OnClick="ibtDelete_Click" ImageUrl="~/FlowPage/images/delete.gif"
                                                                                ToolTip="删除您刚刚上传的附件" Visible="False" OnClientClick="return confirm('您确定要删除这个附件吗？');"
                                                                                Style="margin-left: 3px;" />
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                        </td>
                                                        <td align="left" style="font-size: 12px">
                                                            (注:上传单个文件最大为50M)
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            备注：
                                                        </td>
                                                        <td align="left">
                                                            <textarea name="Notes" id="Notes" runat="server" rows="2" style="width: 241px; overflow: auto;
                                                                font-size: 12px"></textarea>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <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>
                    </div>
                    <div style="background-image: url('icon/left-dw.png'); width: 317px; height: 10px">
                    </div>
                </td>
            </tr>
        </table>
    </center>

    <script language="javascript" type="text/javascript">
    function CloseDoc()
    {
       document.all.WebOffice1.Close();
        var win = parent.Ext.getCmp('Window1');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() 
     {  
        document.all.WebOffice1.ShowToolBar = 0; // 0 隐藏 1 显示
        if(myform.UpdateId.value=="")
          {
     	     document.all.WebOffice1.LoadOriginalFile("<%=URL %>/GetDoc.aspx?WorkFlowViewXMLId="+myform.WorkFlowViewXMLId.value,"doc");
 	         document.all.WebOffice1.SetTrackRevisions(1);
             document.all.WebOffice1.ShowRevisions(0);//隐藏修订
          }
        else
         {
             document.all.WebOffice1.LoadOriginalFile("<%=URL %>/GetUser_Cerate_WorkFlowNew.aspx?UpdateId="+myform.UpdateId.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("ID","<%=ID%>");
	 <%
	 }
	 %>	
	 var UpLoadInfo;
	 try{
	      var ddlFilesView=document.getElementById('<%=ddlFilesView.ClientID %>');
	      for(var i=0;i<ddlFilesView.length;i++)
	       {
	         UpLoadInfo+=ddlFilesView.options[i].text+"↑";
	       }
	 }catch(e){
	       UpLoadInfo="";
	 }
	document.all.WebOffice1.HttpAddPostString("TitleInfo",escape(myform.TitleInfo.value));
	document.all.WebOffice1.HttpAddPostString("DocType","<%=DocType%>");
	document.all.WebOffice1.HttpAddPostString("WorkFlowViewXMLId",myform.WorkFlowViewXMLId.value);
	document.all.WebOffice1.HttpAddPostString("Notes",escape(myform.Notes.value));
	document.all.WebOffice1.HttpAddPostString("Account",escape(myform.Account.value));
	document.all.WebOffice1.HttpAddPostString("UpLoadInfo",escape(UpLoadInfo));
	document.all.WebOffice1.HttpAddPostString("UpdateId",myform.UpdateId.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 %>/AddUser_Cerate_WorkFlowNew.aspx");

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

}
    </script>

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