Y
YMPN
Dear All,
Need your help on this issue that I have with asp.net application. I
would really appreciate your help.
I am using Formview to save data into the database, Fields are
(date_from, date_to, time_from, Time_To - All are datetime format and a
roomNumber taken from a value in dropdownlist)
My requirement is simple; I want to prevent other user making
reservation on the specific room with the same dates and times and
within those range.
How will I use sqldatasource insert or any other ways of inserting to
prevent duplicate..
I am sorry for the confusion, i am new to asp.net
Here is the code i am using: -------
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="insert2.aspx.vb" Inherits="adminaccess_insert2" %>
<%@ Register Assembly="eWorld.UI, Version=2.0.3.2310, Culture=neutral,
PublicKeyToken=24d65337282035f2"
Namespace="eWorld.UI" TagPrefix="ew" %>
<%@ Import Namespace="System.Net.Mail" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString3 %>"
InsertCommand="INSERT INTO [ReservationInfo]
([Date_From], [Date_To], [Time_From], [Time_To], [RoomNo])
VALUES
(@Date_From, @Date_To, @Time_From, @Time_To, @RoomNo)" >
<InsertParameters>
<asparameter Name="Date_From" Type="DateTime" />
<asparameter Name="Date_To" Type="DateTime" />
<asparameter Name="Time_From" Type="DateTime" />
<asparameter Name="Time_To" Type="DateTime" />
<asparameter Name="RoomNo" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="Id"
DataSourceID="SqlDataSource1" DefaultMode="Insert">
<InsertItemTemplate>
Date_From:
<br />
<ew:CalendarPopup ID="Date_From" runat="server"
PostedDate=""
SelectedDate='<%# Bind("Date_From") %>'
ImageUrl="~/images/calendar4.jpg"
ControlDisplay="TextBoxImage"
UpperBoundDate="12/31/9999 23:59:59"
Culture="(Default)" Text="Select Date
From">
<ButtonStyle Font-Names="verdana"
Font-Size="8pt"
BackColor="#DEE37F" />
</ew:CalendarPopup>
<br />
<br />
Date_To:
<br />
<ew:CalendarPopup ID="Date_To" runat="server"
PostedDate="" SelectedDate='<%# Bind("Date_To") %>'
ImageUrl="~/images/calendar4.jpg"
ControlDisplay="TextBoxImage" UpperBoundDate="12/31/9999 23:59:59"
Culture="(Default)" Text="Select Date To">
<ButtonStyle Font-Names="verdana"
Font-Size="8pt" BackColor="#DEE37F" />
</ew:CalendarPopup>
<br />
<br />
Time From:
<br />
<ew:TimePicker ID="Time_From" runat="server"
ImageUrl="~/images/calendar3.jpg" NumberOfColumns="3"
LowerBoundTime="12/30/1899 07:00:00"
UpperBoundTime="12/30/1899 23:00:00"
ControlDisplay="TextBoxImage"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" EnableViewState="true"
SelectedValue='<%# Bind("Time_From", "{t}")
%>'
PostedTime="7:00 PM"
SelectedTime="12/30/1899 19:00:00"
Text="Select Time Start">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
Time To:
<br />
<ew:TimePicker ID="Time_To" runat="server"
ImageUrl="~/images/calendar3.jpg"
ControlDisplay="TextBoxImage"
NumberOfColumns="3" LowerBoundTime="11/25/3506 07:00:00"
UpperBoundTime="11/25/3506 23:00:00"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" SelectedValue='<%#
Bind("Time_To", "{0:t}") %>' PostedTime="7:00 PM"
SelectedTime="11/25/3506 19:00:28"
Text="Select Time Ends">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
RoomNo:
<aspropDownList ID="RoomNo" runat="server"
DataSourceID="SqlDataSource3" DataTextField="RoomNo"
AppendDataBoundItems="true"
DataValueField="RoomNo" SelectedValue='<%# Bind("RoomNo") %>'>
<asp:ListItem Selected="True">Pls. Select
Your Room No.</asp:ListItem>
</aspropDownList><br />
<br />
<%-- Start of DataSource --%>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString %>"
SelectCommand="SELECT * FROM
[RoomInfo]"></asp:SqlDataSource>
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"
Height="18px" Visible="False"></asp:Label>
</form>
</body>
</html>
Need your help on this issue that I have with asp.net application. I
would really appreciate your help.
I am using Formview to save data into the database, Fields are
(date_from, date_to, time_from, Time_To - All are datetime format and a
roomNumber taken from a value in dropdownlist)
My requirement is simple; I want to prevent other user making
reservation on the specific room with the same dates and times and
within those range.
How will I use sqldatasource insert or any other ways of inserting to
prevent duplicate..
I am sorry for the confusion, i am new to asp.net
Here is the code i am using: -------
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="insert2.aspx.vb" Inherits="adminaccess_insert2" %>
<%@ Register Assembly="eWorld.UI, Version=2.0.3.2310, Culture=neutral,
PublicKeyToken=24d65337282035f2"
Namespace="eWorld.UI" TagPrefix="ew" %>
<%@ Import Namespace="System.Net.Mail" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString3 %>"
InsertCommand="INSERT INTO [ReservationInfo]
([Date_From], [Date_To], [Time_From], [Time_To], [RoomNo])
VALUES
(@Date_From, @Date_To, @Time_From, @Time_To, @RoomNo)" >
<InsertParameters>
<asparameter Name="Date_From" Type="DateTime" />
<asparameter Name="Date_To" Type="DateTime" />
<asparameter Name="Time_From" Type="DateTime" />
<asparameter Name="Time_To" Type="DateTime" />
<asparameter Name="RoomNo" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="Id"
DataSourceID="SqlDataSource1" DefaultMode="Insert">
<InsertItemTemplate>
Date_From:
<br />
<ew:CalendarPopup ID="Date_From" runat="server"
PostedDate=""
SelectedDate='<%# Bind("Date_From") %>'
ImageUrl="~/images/calendar4.jpg"
ControlDisplay="TextBoxImage"
UpperBoundDate="12/31/9999 23:59:59"
Culture="(Default)" Text="Select Date
From">
<ButtonStyle Font-Names="verdana"
Font-Size="8pt"
BackColor="#DEE37F" />
</ew:CalendarPopup>
<br />
<br />
Date_To:
<br />
<ew:CalendarPopup ID="Date_To" runat="server"
PostedDate="" SelectedDate='<%# Bind("Date_To") %>'
ImageUrl="~/images/calendar4.jpg"
ControlDisplay="TextBoxImage" UpperBoundDate="12/31/9999 23:59:59"
Culture="(Default)" Text="Select Date To">
<ButtonStyle Font-Names="verdana"
Font-Size="8pt" BackColor="#DEE37F" />
</ew:CalendarPopup>
<br />
<br />
Time From:
<br />
<ew:TimePicker ID="Time_From" runat="server"
ImageUrl="~/images/calendar3.jpg" NumberOfColumns="3"
LowerBoundTime="12/30/1899 07:00:00"
UpperBoundTime="12/30/1899 23:00:00"
ControlDisplay="TextBoxImage"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" EnableViewState="true"
SelectedValue='<%# Bind("Time_From", "{t}")
%>'
PostedTime="7:00 PM"
SelectedTime="12/30/1899 19:00:00"
Text="Select Time Start">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
Time To:
<br />
<ew:TimePicker ID="Time_To" runat="server"
ImageUrl="~/images/calendar3.jpg"
ControlDisplay="TextBoxImage"
NumberOfColumns="3" LowerBoundTime="11/25/3506 07:00:00"
UpperBoundTime="11/25/3506 23:00:00"
PopupLocation="Bottom" PopupWidth="170px"
PopupHeight="178px" SelectedValue='<%#
Bind("Time_To", "{0:t}") %>' PostedTime="7:00 PM"
SelectedTime="11/25/3506 19:00:28"
Text="Select Time Ends">
<SelectedTimeStyle BackColor="Khaki"
ForeColor="Black" />
<TimeStyle BackColor="SteelBlue"
ForeColor="White" />
<ButtonStyle BackColor="#DEE37F"
Font-Names="verdana" Font-Size="8pt" />
</ew:TimePicker>
<br />
<br />
RoomNo:
<aspropDownList ID="RoomNo" runat="server"
DataSourceID="SqlDataSource3" DataTextField="RoomNo"
AppendDataBoundItems="true"
DataValueField="RoomNo" SelectedValue='<%# Bind("RoomNo") %>'>
<asp:ListItem Selected="True">Pls. Select
Your Room No.</asp:ListItem>
</aspropDownList><br />
<br />
<%-- Start of DataSource --%>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$
ConnectionStrings:RoomReservationConnectionString %>"
SelectCommand="SELECT * FROM
[RoomInfo]"></asp:SqlDataSource>
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"
Height="18px" Visible="False"></asp:Label>
</form>
</body>
</html>