Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="adminTourDates.aspx.cs" Inherits="adminTourDates" %>
- <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
- </asp:Content>
- <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
- <h3>Tour Date Admin Page</h3>
- <br />
- <p>Artist/Band</p>
- <asp:TextBox ID="artistText" runat="server"></asp:TextBox>
- <br />
- <p>Venue Playing</p>
- <asp:TextBox ID="venueText" runat="server"></asp:TextBox>
- <br />
- <br />
- <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" Width="350px">
- <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
- <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" />
- <OtherMonthDayStyle ForeColor="#999999" />
- <SelectedDayStyle BackColor="#333399" ForeColor="White" />
- <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
- <TodayDayStyle BackColor="#CCCCCC" />
- </asp:Calendar>
- <br />
- <asp:Label ID="calander_selected" runat="server" Text="" ForeColor="#CC00CC"></asp:Label>
- <asp:Label ID="errorLabel" runat="server" Text=""></asp:Label>
- <br />
- <p>Time Playing</p>
- hours: <asp:TextBox ID="hoursText" runat="server" Width="50px"></asp:TextBox>
- <br />
- minutes: <asp:TextBox ID="minutesText" runat="server" Width="50px"></asp:TextBox>
- <br />
- <asp:Label ID="timeLabel" runat="server" Text="" ForeColor="#CC00CC"></asp:Label>
- <br />
- <asp:Label ID="saveLabel" runat="server" Text=""></asp:Label>
- <br />
- <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" style="height: 48px" />
- <br />
- <br />
- <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="id" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None">
- <AlternatingRowStyle BackColor="White" />
- <Columns>
- <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" />
- <asp:BoundField DataField="artist" HeaderText="artist" SortExpression="artist" />
- <asp:BoundField DataField="venue" HeaderText="venue" SortExpression="venue" />
- <asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
- <asp:BoundField DataField="time" HeaderText="time" SortExpression="time" />
- <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
- </Columns>
- <EditRowStyle BackColor="#2461BF" />
- <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
- <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
- <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
- <RowStyle BackColor="#EFF3FB" />
- <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
- <SortedAscendingCellStyle BackColor="#F5F7FB" />
- <SortedAscendingHeaderStyle BackColor="#6D95E1" />
- <SortedDescendingCellStyle BackColor="#E9EBEF" />
- <SortedDescendingHeaderStyle BackColor="#4870BE" />
- </asp:GridView>
- <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [tblTour] WHERE [id] = @id" InsertCommand="INSERT INTO [tblTour] ([venue], [date], [time], [artist]) VALUES (@venue, @date, @time, @artist)" SelectCommand="SELECT * FROM [tblTour]" UpdateCommand="UPDATE [tblTour] SET [venue] = @venue, [date] = @date, [time] = @time, [artist] = @artist WHERE [id] = @id">
- <DeleteParameters>
- <asp:Parameter Name="id" Type="Int32" />
- </DeleteParameters>
- <InsertParameters>
- <asp:Parameter Name="venue" Type="String" />
- <asp:Parameter DbType="Date" Name="date" />
- <asp:Parameter Name="time" Type="DateTime" />
- <asp:Parameter Name="artist" Type="String" />
- </InsertParameters>
- <UpdateParameters>
- <asp:Parameter Name="venue" Type="String" />
- <asp:Parameter DbType="Date" Name="date" />
- <asp:Parameter Name="time" Type="DateTime" />
- <asp:Parameter Name="artist" Type="String" />
- <asp:Parameter Name="id" Type="Int32" />
- </UpdateParameters>
- </asp:SqlDataSource>
- </asp:Content>
- ######################################################################################################################################################################################################################################################################
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System.Configuration;
- public partial class adminTourDates : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Page.IsPostBack == true)
- {
- errorLabel.Text = ("working");
- }
- /*Labels*/
- calander_selected.Text = Calendar1.SelectedDate.ToShortDateString();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
- var hours = int.Parse(hoursText.Text);
- var minutes = int.Parse(minutesText.Text);
- TimeSpan timeSpan = new TimeSpan(hours, minutes, 00);
- saveLabel.Text = "details entered into db";
- {
- //validation so cannot be attacked with SQL injection
- SqlCommand xp = new SqlCommand("Insert into tblTour(venue, artist, date, time) Values(@venue, @artist, @date, @time )", connect);
- xp.Parameters.AddWithValue("@venue", venueText.Text);
- xp.Parameters.AddWithValue("@artist", artistText.Text);
- xp.Parameters.AddWithValue("@date", Calendar1.SelectedDate.ToShortDateString());
- xp.Parameters.AddWithValue("@time", timeSpan);
- connect.Open();
- xp.ExecuteNonQuery();
- connect.Close();
- if (IsPostBack)
- {
- venueText.Text = "";
- artistText.Text = "";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement