<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="WorkRecord.aspx.cs" Inherits="TEC_Forms_WorkRecord" Title="<%$ Resources: SiteMapLocalizations, TEC_Forms_WorkRecord %>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script language="javascript" type="text/javascript" src="~/SEST/Script/OpenSubPage.js">
        // open sub page
    </script>
    <script language="javascript" type="text/javascript" src="/SEST/Script/HScript.js">
        // open sub page
    </script>

    <script language="javascript" type="text/javascript">
        function txtFAB_onclick(FABID, JobNo){
            //var sSelected = $(ID).value.replace(/\n/, ",");
            //$(ToolID).value = "";
            
			// 開新視窗
			newWin = window.open("../../SubPages/SelectionPage.aspx?SelectValue=FABs&EnableManualInput=False&JobNo=" + $(JobNo).value + "&AssignObjName=" + FABID, "SelectionPage", config="top=50,left=50,width=670,height=310,resizable=no,scrollbars=no")
			newWin.focus();
        }

 		// 供子視窗呼叫以改變父視窗的Select物件的函數
		function changeSelectValue( objName, values){	
			oSel = $(objName);
			var sValues = "";
			for (var i=0; i< values.length; i++)
				sValues += "," + values[i];
			oSel.value = sValues.substring(1).replace(/,/g, "\n");			
		}
   </script>
<center>
<%--    <asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#E7E7FF" DataSourceID="ObjectDataSource1"
        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingItemStyle BackColor="#F7F7F7" />
        <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderTemplate>
            My Header
        </HeaderTemplate>
        <ItemTemplate>
            <asp:Label ID="lbl" Text='<%# Eval("Journalist").ToString() + " ( " + Eval("RecordDateTime").ToString() + " ) : <br>●" + Eval("Action").ToString()%>' runat="server"></asp:Label>
        </ItemTemplate>
    </asp:DataList>
--%>    
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" PageSize="40"
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="WorkRecordID" DataSourceID="ObjectDataSource1"
        ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnDataBound="GridView1_DataBound"  >
        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

        <Columns>
            <asp:CommandField ShowSelectButton="True" SelectText="<%$ Resources: Universal, WorkRecord_SelectToModify %>"
                ShowDeleteButton="True" DeleteText="<%$ Resources: Universal, Data_Delete %>" />
            <asp:BoundField DataField="WorkRecordID" />
            <asp:BoundField DataField="RecordDateTime" HeaderText="<%$ Resources: Universal, WorksList_RecordTime %>" />
            <asp:BoundField DataField="Journalist" HeaderText="<%$ Resources: Universal, Msg_Writer %>" />
            <asp:BoundField DataField="Action" HeaderText="<%$ Resources: Universal, Comm_Contents %>" ItemStyle-Width="400px" />

<%--            <asp:TemplateField >
                <ItemTemplate>
                    <asp:Label ID="lblWorkRecordID" runat="server" Text='<%# Eval("WorkRecordID") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ resources:Universal, WorksList_RecordTime %>" SortExpression="RecordDateTime">
                <ItemTemplate>
                    <asp:Label ID="lblRecordDateTime" runat="server" Text='<%# Eval("RecordDateTime") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ resources:Universal, Msg_Writer %>" SortExpression="Journalist">
                <ItemTemplate>
                    <asp:Label ID="lblJournalist" runat="server" Text='<%# Eval("Journalist") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ resources:Universal, Comm_Contents %>">
                <ItemTemplate>
                    <asp:Label ID="lblAction" runat="server" Text='<%# Eval("Action") %>' />
                </ItemTemplate>
                <ItemStyle Width="300px" />
            </asp:TemplateField>
--%><%--            <asp:TemplateField HeaderText="<%$ resources:Universal, Msg_AttachFile %>">
                <ItemTemplate>
                    <asp:Label ID="lblAttachFile" runat="server" Text='<%# Eval("AttachFile") %>' />
                </ItemTemplate>
            </asp:TemplateField>
--%>        </Columns>
     
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
   
   <asp:Button ID="btnAddNew" Text="<%$ Resources: Universal, WorkRecord_AddNew %>" runat="Server" OnClick="btnAddNew_Click" /> 

 
    <table id="tblForm" cellpadding="0" cellspacing="0" runat="Server" style="border-right: #3399ff 3px solid;
        border-top: #3399ff 3px solid; border-left: #3399ff 3px solid; border-bottom: #3399ff 3px solid;
        background-color: #cbd2ff">
        <tr>
            <td class="titleRow" colspan="2">
                <asp:Label ID="lblTitle" runat="server" Text="<%$ Resources: Universal, Msg_Title_WorkRcord %>"></asp:Label></td>
        </tr>
        <tr>
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label1" runat="server" Text="<%$ Resources: Universal, Msg_Writer %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtRecorder" runat="server" OnPreRender="txtApplicant_PreRender" Width="388px" Enabled="false"></asp:TextBox>

                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="txtRecorder"
                    ErrorMessage="<%$ Resources: Universal, Msg_Remind_Writer %>" ValidationGroup="ValidationControls">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label8" runat="server" Text="<%$ Resources: Universal, WorksList_WorkID %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtWorkID" runat="server" Width="388px" Enabled="False"></asp:TextBox>
                </td>
        </tr>
        <tr>
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label5" runat="server" Text="<%$ Resources: Universal, JobNo_ID %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtJobNo" runat="server" Width="388px"></asp:TextBox>
                <asp:HyperLink ID="hlJobNo" runat="Server" ImageUrl="~\imanges\more.gif" Target="_blank"></asp:HyperLink>
            </td>
        </tr>
        <tr>
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label4" runat="server" Text="<%$ Resources: Universal, Comm_FABID %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtFABID" runat="server" Width="388px"></asp:TextBox>
                <asp:HyperLink ID="hlFABID" runat="Server" ImageUrl="~\imanges\more.gif" Target="_blank"></asp:HyperLink>
            </td>
        </tr>
        <tr>
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label7" runat="server" Text="<%$ Resources: Universal, SES_ToolNo %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtToolID" runat="server" Width="388px"></asp:TextBox>
                <asp:HyperLink ID="hlToolID" runat="Server" ImageUrl="~\imanges\more.gif" Target="_blank"></asp:HyperLink>
            </td>
        </tr>
        <tr id="trWorkDate" runat="Server">
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label2" runat="server" Text="<%$ Resources: Universal, WorkRecord_WorkDate %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtWorkStartDate" runat="server" Width="80px"></asp:TextBox>
                <asp:Label ID="Label11" Text="(2001/01/01)" ForeColor="red" runat="server"></asp:Label>
                &nbsp;&nbsp;To&nbsp;&nbsp;
                <asp:TextBox ID="txtWorkEndDate" runat="server" Width="80px"></asp:TextBox>
                <asp:Label Text="(2001/01/01)" ForeColor="red" runat="server"></asp:Label>
            </td>
        </tr>
        <tr id="trResponsibility" runat="Server">
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label9" runat="server" Text="<%$ Resources: Universal, WorksList_Responsibility %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtResponsibility" runat="server" Width="388px" TextMode="multiLine" Rows="3"></asp:TextBox>
                <asp:HyperLink ImageUrl="~\imanges\more.gif" ID="hlResponsibility" Target="_blank" runat="Server"></asp:HyperLink>
            </td>
        </tr>
        <tr id="trDescription" runat="Server">
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label10" runat="server" Text="<%$ Resources: Universal, Comm_Description %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtDescription" runat="server" Width="388px" TextMode="multiLine" Rows="4" Enabled="false"></asp:TextBox>
            </td>
        </tr>
        <tr id="trContents" runat="Server">
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label3" runat="server" Text="<%$ Resources: Universal, Msg_WorkContent %>"></asp:Label></td>
            <td align="left" class="whiteEdge" style="width: 429px">
                <asp:TextBox ID="txtContents" runat="server" Height="138px" Rows="4" TextMode="MultiLine" Width="388px"></asp:TextBox></td>
        </tr>
        <tr id="trAddFiles" runat="Server">
            <td class="whiteEdge" style="width: 86px">
                <asp:Label ID="Label6" runat="server" Text="<%$ Resources: Universal, Msg_AttachFile %>"></asp:Label><br /></td>
            <td id="tdMyFiles" align="left" class="whiteEdge" style="width: 429px" runat="Server">
                <asp:FileUpload ID="FileSaveToServer" runat="Server" Width="393px" /></td>
        </tr>
        <tr id="trFilesList">
            <td class="whiteEdge" colspan="2">
               <asp:GridView ID="gvAttachFile" AutoGenerateColumns="False" DataSourceID="ObjectDataSource2" DataKeyNames="FilesStorageID" 
                   runat="server" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnRowDataBound="gvAttachFile_RowDataBound" OnRowDeleting="gvAttachFile_RowDeleting" >
                   <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                   <RowStyle BackColor="White" ForeColor="#330099" Font-Size="Small" />
                   <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                   <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                   <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" Font-Size="Small" />
                   <Columns>
                        <asp:CommandField ShowDeleteButton="True" DeleteText="<%$ Resources: Universal, Data_Delete %>" />
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label ID="lblWorkID" Text='<%# Bind("FilesStorageID") %>' runat="Server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources: Universal, Comm_CreateDate %>">
                            <ItemTemplate>
                                <asp:Label ID="lblExpectStartDate" Text='<%# Bind("CreateDate") %>' runat="Server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<%$ Resources: Universal, Msg_AttachFile %>">
                            <ItemTemplate>
                                <asp:Label ID="lblExpectEndDate" Text='<%# Bind("FileName") %>' runat="Server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:HyperLink ID="hyLink" Text="Link" NavigateUrl='<%# Bind("PhysicalPath") %>' runat="Server"></asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                   </Columns>
               </asp:GridView>
            </td>
        </tr>
        <tr>
            <td align="center" class="bottomRow" colspan="2">
                <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="<%$ Resources: Universal, Data_Submit %>" ValidationGroup="ValidationControls" />
                <asp:Button ID="btnNext" runat="server" OnClick="btnNext_Click" Text="<%$ Resources: Universal, Comm_NextStep %>" />
                <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="<%$ Resources: Universal, Data_Update %>" />
            </td>
        </tr>
    </table>

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="TEC_WorkRecordData" SelectMethod="Select" DeleteMethod="Delete">
        <SelectParameters>
            <asp:QueryStringParameter Name="Condition" QueryStringField="WorkID" Type="String" DefaultValue="-1" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="WorkRecordID" Type="String" />
        </DeleteParameters>
    </asp:ObjectDataSource>
    
    
        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" TypeName="Common_FilesStorageData"
        SelectMethod="Select" OldValuesParameterFormatString="original_{0}" DeleteMethod="Delete" >

        <DeleteParameters>
            <asp:Parameter Name="original_FilesStorageID" Type="String" />
        </DeleteParameters>
        <SelectParameters>
            <asp:Parameter Name="PageName" DefaultValue="WorkRecord" Type="String" />
            <asp:Parameter Name="PageKeys" DefaultValue="NoKey" Type="String" />
        </SelectParameters>
        </asp:ObjectDataSource>
    </center>
</asp:Content>

