<%@ Page language="vb" Codebehind="TimeEntry.aspx.vb" AutoEventWireup="false" Inherits="ASPNET.StarterKit.TimeTracker.Web.TimeEntry"%>
<%@ Register TagPrefix="TimeTrack" TagName="Banner" Src="Banner.ascx"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>TimeEntry</title>
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="styles.css" type="text/css" rel="stylesheet">
		<script language="javascript" src="script.js" type="text/javascript"></script>
	</HEAD>
	<body>
		<form id="TimeEntry" method="post" runat="server">
			<table cellSpacing="0" cellPadding="0" width="100%" border="0">
				<tr>
					<td vAlign="top" background="images/bars.gif" height="46"><timetrack:banner id="Banner1" runat="server"></timetrack:banner></td>
				</tr>
				<tr>
					<td class="tab-active" vAlign="top" height="15"><IMG height="15" src="images/spacer.gif" width="15"></td>
				</tr>
			</table>
			<table cellSpacing="0" cellPadding="0" width="100%" border="0">
				<tr>
					<td width="8"><IMG height="8" src="images/spacer.gif" width="8"></td>
					<td style="WIDTH: 197px" vAlign="top" width="197">
						<!-- Left Panel -->
						<table cellSpacing="0" cellPadding="0" width="206" border="0">
							<tr>
								<td style="WIDTH: 225px" vAlign="top">
									<table class="tan-border" style="WIDTH: 215px; HEIGHT: 47px" cellSpacing="12" cellPadding="0" width="215" border="0">
										<tr>
											<td><span class="header-gray">截至本週:</span></td>
											<td><asp:textbox id="WeekEnding" runat="server" CssClass="standard-text" Width="68px" ReadOnly="True" BorderStyle="None" BorderWidth="0px" AutoPostBack="True" Columns="12"></asp:textbox></td>
											<td><A href="javascript:OpenCalendar('WeekEnding', true)"><IMG src="images/icon-calendar.gif" align="absBottom" border="0"></A>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td style="WIDTH: 225px" vAlign="top" height="11"><IMG height="1" src="images/spacer.gif" width="1"></td>
							</tr>
							<tr>
								<td style="WIDTH: 225px" vAlign="top">
									<table class="tan-border" style="WIDTH: 215px; HEIGHT: 332px" cellSpacing="12" cellPadding="0" width="215" border="0">
										<tr vAlign="top">
											<td class="header-gray">新增時程表項目</td>
										</tr>
										<tr vAlign="top">
											<td>專案&nbsp;
												<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" Display="Dynamic" ErrorMessage="必須輸入專案。" ControlToValidate="ProjectList"></asp:requiredfieldvalidator><br>
												<asp:dropdownlist id="ProjectList" runat="server" CssClass="standard-text" Width="175px" AutoPostBack="True"></asp:dropdownlist></td>
										</tr>
										<tr vAlign="top">
											<td>
												<table cellSpacing="0" cellPadding="0" border="0">
													<tr>
														<td>類別</td>
														<td width="10"><IMG height="1" src="images/spacer.gif" width="15"></td>
														<td>日期</td>
														<td width="10"><IMG height="1" src="images/spacer.gif" width="15"></td>
														<td>時數</td>
													</tr>
													<tr>
														<td><asp:dropdownlist id="CategoryList" runat="server" CssClass="standard-text" Width="60px"></asp:dropdownlist></td>
														<td>&nbsp;</td>
														<td><asp:dropdownlist id="Days" runat="server" CssClass="standard-text" Width="48px"></asp:dropdownlist></td>
														<td>&nbsp;</td>
														<td><asp:textbox id="Hours" runat="server" CssClass="standard-text" Width="37px" Columns="5"></asp:textbox></td>
													</tr>
													<tr>
														<td colSpan="5"><asp:requiredfieldvalidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="必須輸入時數。" ControlToValidate="Hours" display="Dynamic"></asp:requiredfieldvalidator><asp:comparevalidator id="CompareValidator1" runat="server" Display="Dynamic" ErrorMessage="時數(Hours)必須是數值。" ControlToValidate="Hours" Operator="DataTypeCheck" Type="Currency"></asp:comparevalidator>
															<asp:RangeValidator id="RangeValidator1" runat="server" ErrorMessage="時數超出範圍。" ControlToValidate="Hours" MaximumValue="24" MinimumValue="0" Type="Double"></asp:RangeValidator></td>
													</tr>
												</table>
											</td>
										</tr>
										<tr vAlign="top">
											<td>描述<br>
												<asp:textbox id="Description" runat="server" CssClass="standard-text" Width="175px" Columns="30" TextMode="MultiLine" Rows="9" MaxLength="255"></asp:textbox></td>
										</tr>
										<tr vAlign="top">
											<td align="left"><asp:button id="AddEntry" runat="server" CssClass="standard-text" Text="新增項目" CausesValidation="False"></asp:button><IMG height="8" src="images/spacer.gif" width="8">
												<asp:button id="Cancel" runat="server" CssClass="standard-text" Text="取消" CausesValidation="False"></asp:button></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td style="WIDTH: 225px" vAlign="top" height="11"><IMG height="1" src="images/spacer.gif" width="1"></td>
							</tr>
							<tr>
								<td style="WIDTH: 225px" vAlign="top">
									<table class="tan-border" style="WIDTH: 215px; HEIGHT: 81px" cellSpacing="0" cellPadding="0" width="214" border="0">
										<tr vAlign="top">
											<td height="12"><IMG height="1" src="images/spacer.gif" width="1"></td>
										</tr>
										<tr vAlign="top">
											<td class="header-gray"><IMG height="1" src="images/spacer.gif" width="11"> 時數合計
											</td>
										</tr>
										<tr vAlign="top">
											<td height="12"><IMG height="1" src="images/spacer.gif" width="1"></td>
										</tr>
										<tr vAlign="top">
											<td><asp:image id="TimeGraph" Runat="server" ImageUrl="TimeEntryBarChart.aspx?xValues=星期一|星期二|星期三|星期四|星期五|星期六|星期日&amp;yValues=0|0|0|0|0|0|0"></asp:image></td>
										</tr>
										<tr vAlign="top">
											<td height="12"><IMG height="1" src="images/spacer.gif" width="1"></td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
						<!-- End Left Panel --></td>
					<td width="11"><IMG height="11" src="images/spacer.gif" width="11"></td>
					<td vAlign="top">
						<!-- Right Panel -->
						<table class="tan-border" height="570" cellSpacing="11" cellPadding="0" width="100%" border="0">
							<tr vAlign="top">
								<td height="15"><span class="header-gray">時程表:</span>&nbsp;
									<asp:dropdownlist id="UserList" runat="server" CssClass="standard-text" Width="150px" AutoPostBack="True" DataValueField="UserID" DataTextField="Name"></asp:dropdownlist></td>
							</tr>
							<tr>
								<td vAlign="top"><asp:datagrid id="TimeEntryGrid" runat="server" Width="100%" BorderStyle="None" CellPadding="2" AutoGenerateColumns="False" Font-Name="Verdana" FontSize="11px" AllowSorting="True" DataKeyField="EntryLogID" BorderColor="White" Font-Names="Verdana">
										<HeaderStyle Font-Bold="True" CssClass="grid-header"></HeaderStyle>
										<Columns>
											<asp:TemplateColumn SortExpression="EntryDate" HeaderText="日期">
												<HeaderStyle HorizontalAlign="Center" Width="80px" CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
												<ItemStyle HorizontalAlign="Center" CssClass="grid-first-item"></ItemStyle>
												<ItemTemplate>
													<asp:label ID="EntryDay" Text='&nbsp;<%# DataBinder.Eval(Container, "DataItem.EntryDate", "{0:ddd}") %>' Runat="server" Width='40px' />
												</ItemTemplate>
												<EditItemTemplate>
													<asp:dropdownlist Width="48px" ID="EntryDays" CssClass="Standard-text" DataSource='<%# _dayListTable %>' DataTextField = "Day" DataValueField = "Date" Runat="server">
													</asp:dropdownlist>
												</EditItemTemplate>
											</asp:TemplateColumn>
											<asp:TemplateColumn SortExpression="ProjectName" HeaderText="專案">
												<HeaderStyle HorizontalAlign="Center" Width="40px" CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
												<ItemStyle Width="108px" CssClass="grid-item"></ItemStyle>
												<ItemTemplate>
													<asp:label ID="EntryProject" Text='&nbsp;<%# DataBinder.Eval(Container, "DataItem.ProjectName") %>' Runat="server" />
													<asp:label ID="EntryProjectID" Text='<%# DataBinder.Eval(Container, "DataItem.ProjectID") %>' Runat="server" Visible="False" />
												</ItemTemplate>
												<EditItemTemplate>
													<asp:dropdownlist Width="100px" ID="EntryProjects" AutoPostBack="True" CssClass="Standard-text" DataSource='<%# ListUserProjects() %>' DataTextField="Name" DataValueField="ProjectID" Runat="server" OnSelectedIndexChanged="UserProjects_OnChange" />
												</EditItemTemplate>
											</asp:TemplateColumn>
											<asp:TemplateColumn SortExpression="CategoryName" HeaderText="類別">
												<HeaderStyle HorizontalAlign="Center" Width="40px" CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
												<ItemStyle Width="88px" CssClass="grid-item"></ItemStyle>
												<ItemTemplate>
													<asp:label ID="EntryCategory" Text='&nbsp;<%# DataBinder.Eval(Container, "DataItem.CategoryName") %>' Runat="server" />
												</ItemTemplate>
												<EditItemTemplate>
													<asp:dropdownlist Width="80px" ID="EntryCategories" CssClass="Standard-text" DataSource='<%# ListGridCategories(_userInput.ProjectID) %>' DataTextField="Abbreviation" DataValueField="CategoryID" Runat="server">
													</asp:dropdownlist>
												</EditItemTemplate>
											</asp:TemplateColumn>
											<asp:TemplateColumn SortExpression="Duration" HeaderText="時數">
												<HeaderStyle HorizontalAlign="Center" Width="40px" CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
												<ItemStyle HorizontalAlign="Right" Width="50px" CssClass="grid-item"></ItemStyle>
												<ItemTemplate>
													<asp:label ID="EntryDuration" Text='&nbsp;<%# DataBinder.Eval(Container.DataItem, "Duration", "{0:f}") %>' Runat="server" />
												</ItemTemplate>
												<EditItemTemplate>
													<asp:textbox Width="40px" AutoPostBack=false CssClass="Standard-text" Runat="server" ID="EntryHours" Text='<%# _userInput.Duration %>' />
													<asp:requiredfieldvalidator id="RequiredFieldValidatorGridHours" runat="server" ErrorMessage="必須輸入時數。" ControlToValidate="EntryHours" Display="Dynamic"></asp:requiredfieldvalidator>
													<asp:comparevalidator id="CompareValidatorGridHours" runat="server" ErrorMessage="時數必須是數值。" ControlToValidate="EntryHours" Display="Dynamic" Type="Currency" Operator="DataTypeCheck"></asp:comparevalidator>
												</EditItemTemplate>
											</asp:TemplateColumn>
											<asp:TemplateColumn SortExpression="Description" HeaderText="描述">
												<HeaderStyle HorizontalAlign="Left" CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
												<ItemStyle CssClass="grid-item"></ItemStyle>
												<ItemTemplate>
													<asp:label ID="GridDescription" Text='&nbsp;<%# DataBinder.Eval(Container, "DataItem.Description") %>' Runat="server" />
												</ItemTemplate>
												<EditItemTemplate>
													<asp:textbox runat="server" CssClass="Standard-text" ID="EntryDescription" Text='<%# _userInput.Description %>' Width="250" MaxLength="255">
													</asp:textbox>
												</EditItemTemplate>
											</asp:TemplateColumn>
											<asp:TemplateColumn HeaderText="編輯">
												<HeaderStyle HorizontalAlign="Center" Width="40px" CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
												<ItemStyle CssClass="grid-edit-column"></ItemStyle>
												<ItemTemplate>
													<asp:imagebutton runat="server" ImageUrl="images/icon-pencil.gif" AlternateText="Edit" CommandName="Edit" CausesValidation="false" ID="Imagebutton1" NAME="Imagebutton1"></asp:imagebutton>
													<img src="images/spacer.gif" width="3">
													<asp:imagebutton Runat="server" ImageUrl="images/icon-delete.gif" AlternateText="Delete" CommandName="Delete" CausesValidation="False" ID="Imagebutton2" NAME="Imagebutton2"></asp:imagebutton>
												</ItemTemplate>
												<EditItemTemplate>
													<asp:imagebutton runat="server" ImageUrl="images/icon-floppy.gif" AlternateText="Update" CommandName="Update" CausesValidation="False" ID="Imagebutton3" NAME="Imagebutton3"></asp:imagebutton>
													<img src="images/spacer.gif" width="3">
													<asp:imagebutton runat="server" ImageUrl="images/icon-pencil-x.gif" AlternateText="Cancel" CommandName="Cancel" CausesValidation="False" ID="Imagebutton4" NAME="Imagebutton4"></asp:imagebutton>
												</EditItemTemplate>
											</asp:TemplateColumn>
										</Columns>
									</asp:datagrid></td>
							</tr>
						</table>
						<!-- End Right Panel --></td>
					<td width="11"><IMG height="11" src="images/spacer.gif" width="11"></td>
				</tr>
				<tr>
					<td vAlign="top" colSpan="5" height="15"><IMG height="15" src="images/spacer.gif" width="15"></td>
				</tr>
			</table>
		</form>
	</body>
</HTML>
