Zdravím pánové Mám takový celkem jednoduchý prográmek, který se zabývá správou parkování. Konkrétně je na jedné stránce řešeno přidávání a upravování parkovacích lokalit. Na další stránce seznam parkovacích lokalit s filtrem a na třetí stránce zamlouvání parkovacích míst v příslušné lokalitě. To jen tak na úvod, no a ted k jádru problému, potřebuji při rezervování parkovacího místa v příslušné lokalitě aby program ověřil, zda není překročena kapacita v daném časovém období. Například parkoviště xy má 10 míst a teď od 1.1.2009 do 1.2.2009 tam bude stát 9 aut a od 1.1.2009 do 1.5.2009 jedno auto a od 1.3 do 1.5 9 aut... prostě abych nepřekročil limit 10 na příslušný den. Zde je jsou kody ke stránce kde zamlouvání míst probíhá
<%@ Page Language="VB" MasterPageFile="~/modParking/modParking.master" AutoEventWireup="false" CodeFile="ReservationDetail.aspx.vb" Inherits="modParking_ReservationDetail" title="Untitled Page" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphModParkingContent" Runat="Server">
<br/>
<br/>
<table style="width: 400px; border-collapse: collapse; border: 1px solid #000080">
<tr>
<td bgcolor="Blue" colspan="2">
Detail rezervace</td>
</tr>
<tr>
<td align="right">
parkoviště</td>
<td align="left">
<asp:DropDownList ID="ddlParkingPlace" runat="server"
DataSourceID="sqlDsPlaces" DataTextField="iParkingPlaceName"
DataValueField="iParkingPlaceId" Width="267px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right">
vozidlo</td>
<td align="left">
<asp:TextBox ID="tbREG" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
Enabled="True" ServiceMethod="REGComlete" MinimumPrefixLength="1"
ServicePath="modParkingWebService.asmx" TargetControlID="tbREG" >
</cc1:AutoCompleteExtender>
</td>
</tr>
<tr>
<td align="right">
od</td>
<td align="left">
<asp:TextBox ID="tbFrom" runat="server" AutoPostBack="True"></asp:TextBox>
<cc1:CalendarExtender ID="tbFrom_CalendarExtender" runat="server"
Enabled="True" TargetControlID="tbFrom">
</cc1:CalendarExtender>
</td>
</tr>
<tr align="right">
<td>
do</td>
<td align="left">
<asp:TextBox ID="tbTo" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="tbTo_CalendarExtender" runat="server" Enabled="True"
TargetControlID="tbTo">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td align="right" valign="top">
poznámka</td>
<td align="left">
<asp:TextBox ID="tbRemark" runat="server" Rows="4" TextMode="MultiLine"
Width="270px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" valign="top">
</td>
<td align="left">
<asp:Label ID="lblErrMsg" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnCancel" runat="server" Text="Zrušit" />
<asp:Button ID="btnSave" runat="server" Text="Založit" />
</td>
</tr>
</table>
<br />
<asp:SqlDataSource ID="sqlDsPlaces" runat="server"
ConnectionString="<%$ ConnectionStrings:intranetConnectionString %>"
SelectCommand="SELECT [iParkingPlaceId], [iParkingPlaceName] FROM [iParkingPlaces] WHERE ([iParkingPlaceEnabled] = @iParkingPlaceEnabled)">
<SelectParameters>
<asp:Parameter DefaultValue="True" Name="iParkingPlaceEnabled" Type="Boolean" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="sqlDsReservations" runat="server"
ConnectionString="<%$ ConnectionStrings:intranetConnectionString %>"
DeleteCommand="DELETE FROM [iParkingReservations] WHERE [iParkingReservationId] = @iParkingReservationId"
InsertCommand="INSERT INTO [iParkingReservations] ([iCreated], [iCreatedBy],[iParkingPlaceId], [iParkinReservationREG], [iParkingReservationFrom], [iParkingReservationTo], [iParkingReservationRemark]) VALUES (GetDate(), @iCreatedBy, @iParkingPlaceId, @iParkinReservationREG, @iParkingReservationFrom, @iParkingReservationTo, @iParkingReservationRemark)"
SelectCommand="SELECT [iParkingReservationId], [iParkingPlaceId], [iParkinReservationREG], [iParkingReservationFrom], [iParkingReservationTo], [iParkingReservationRemark] FROM [iParkingReservations] WHERE ([iParkingReservationId] = @iParkingReservationId)"
UpdateCommand="UPDATE [iParkingReservations] SET [iModifiedBy] = @iModifiedBy, [iModified] = GetDate(),
[iParkingPlaceId] = @iParkingPlaceId, [iParkinReservationREG] = @iParkinReservationREG, [iParkingReservationFrom] = @iParkingReservationFrom, [iParkingReservationTo] = @iParkingReservationTo, [iParkingReservationRemark] = @iParkingReservationRemark WHERE [iParkingReservationId] = @iParkingReservationId">
<SelectParameters>
<asp:QueryStringParameter Name="iParkingReservationId" QueryStringField="id"
Type="Int64" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="iParkingReservationId" Type="Int64" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="iParkingPlaceId" Type="Int64" />
<asp:Parameter Name="iParkinReservationREG" Type="String" />
<asp:Parameter Name="iParkingReservationFrom" Type="DateTime" />
<asp:Parameter Name="iParkingReservationTo" Type="DateTime" />
<asp:Parameter Name="iParkingReservationRemark" Type="String" />
<asp:Parameter Name="iParkingReservationId" Type="Int64" />
<asp:SessionParameter Name="iModifiedBy" SessionField="UserId" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID="ddlParkingPlace" Name="iParkingPlaceId"
PropertyName="SelectedValue" Type="Int64" />
<asp:ControlParameter ControlID="tbREG" Name="iParkinReservationREG"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="tbFrom" Name="iParkingReservationFrom"
PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="tbTo" Name="iParkingReservationTo"
PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="tbRemark" Name="iParkingReservationRemark"
PropertyName="Text" Type="String" />
<asp:SessionParameter Name="iCreatedBy" SessionField="UserId" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
Imports System.Data
Partial Class modParking_ReservationDetail
Inherits System.Web.UI.Page
Protected Sub ddlParkingPlace_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlParkingPlace.DataBound
If Request("ACTION") = "NEW" Then
ddlParkingPlace.Enabled = True
Else
Dim dv As DataView = sqlDsReservations.Select(DataSourceSelectArguments.Empty)
tbFrom.Text = dv.Table.Rows(0)("iParkingReservationFrom").ToString()
tbTo.Text = dv.Table.Rows(0)("iParkingReservationTo").ToString()
tbREG.Text = dv.Table.Rows(0)("iParkingReservatonREG").ToString()
tbRemark.Text = dv.Table.Rows(0)("iParkingReservationRemark").ToString()
ddlParkingPlace.Items.FindByValue(dv.Table.Rows(0)("iParkingPlaceId").ToString()).Selected = True
ddlParkingPlace.Enabled = False
End If
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
'test disposable parking places
Dim p As New cParking()
Dim q As String
q = p.CheckDisposablePlace(ddlParkingPlace.SelectedValue, tbFrom.Text, tbTo.Text)
lblErrMsg.Text = q
If q.Length = 0 Then 'nonzero length of error message
If Request("ACTION") = "NEW" Then
sqlDsReservations.Insert()
Else
sqlDsReservations.Update()
End If
Response.Redirect("~/modParking/ReservationsList.aspx")
End If
End Sub
Protected Sub tbFrom_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbFrom.TextChanged
tbTo.Text = tbFrom.Text
End Sub
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Response.Redirect("~/modParking/ReservationsList.aspx")
End Sub
End Class
|