<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>Home Page</title> <link rel="shortcut icon" href="Image/Train.ico" /> <script type="text/javascript" src="script/jquery-1.3.1.min.js"></script> <script type="text/javascript">
$(document).ready(function() { //Execute the slideShow slideShow();
});
function slideShow() {
//Set the opacity of all images to 0 $('#gallery a').css({opacity: 0.0}); //Get the first image and display it (set it to full opacity) $('#gallery a:first').css({opacity: 1.0}); //Set the caption background to semi-transparent $('#gallery .caption').css({opacity: 0.7});
//Resize the width of the caption according to the image width $('#gallery .caption').css({width: $('#gallery a').find('img').css('width')}); //Get the caption of the first image from REL attribute and display it $('#gallery .content').html($('#gallery a:first').find('img').attr('rel')) .animate({opacity: 0.7}, 400); //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds setInterval('gallery()',2500); }
function gallery() { //if no IMGs have the show class, grab the first image var current = ($('#gallery a.show')? $('#gallery a.show') : $('#gallery a:first'));
//Get next image, if it reached the end of the slideshow, rotate it back to the first image var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first')); //Get next image caption var caption = next.find('img').attr('rel'); //Set the fade in effect for the next image, show class has higher z-index next.css({opacity: 0.0}) .addClass('show') .animate({opacity: 1.0}, 1000);
//Hide the current image current.animate({opacity: 0.0}, 1000) .removeClass('show'); //Set the opacity to 0 and height to 1px $('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 }); //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect $('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 ); //Display the content $('#gallery .content').html(caption); }
</script> <style type="text/css"> body{ font-family:arial }
.clear { clear:both }
#gallery { position:relative; height:360px } #gallery a { float:left; position:absolute; } #gallery a img { border:none; } #gallery a.show { z-index:500 }
#gallery .caption { z-index:600; background-color:#000; color:#ffffff; height:100px; width:100%; position:absolute; bottom:0; }
#gallery .caption .content { margin:5px } #gallery .caption .content h3 { margin:0; padding:0; color:#1DCCEF; }
</style> </head> <body> <form id="form1" runat="server" > <div style="width: 258px; margin-left: auto; margin-right:auto; height: 113px;"> <asp:Login ID="Login1" Style="margin:auto" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt" Font-Bold="True" OnAuthenticate="Login1_Authenticate" TitleText="Log In To PRS" LoginButtonText="Sign In"> <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" /> <LoginButtonStyle Font-Bold="True" /> </asp:Login> <b ><u>New Registration:</u></b> <asp:LinkButton ID="lnkSignUp" runat="server" PostBackUrl="~/Passenger_Registration.aspx" Font-Bold="True" Style="z-index: 50; left: 510px; position: absolute; top: 138px" Width="77px">Sign Up</asp:LinkButton> </div> <br /><br /> <table> <tr> <td> <div id="gallery">
<a href="#" class="show"> <img src="Image/Train6.jpeg" alt="Flowing Rock" width="400" height="260" title="" alt="" rel="<h3>Wel Come To PRS(Passenger Reservation System)</h3>LifeLine of The Nation....."/> </a> <a href="#"> <img src="Image/Train1.jpeg" alt="Grass Blades" width="400" height="260" title="" alt="" rel="<h3>At Your Service</h3>The All Weather Route with Center to Center Convenience . "/> </a> <a href="#"> <img src="Image/Train2.jpeg"alt="Ladybug" width="400" height="260" title="" alt="" rel="<h3>Rail Road</h3>The Standard Railroad of the World."/> </a>
<a href="#"> <img src="Image/Train3.jpeg"alt="Lightning" width="400" height="260" title="" rel="<h3>Old Reliable</h3>But the Railroad Always Runs ."/> </a> <a href="#"> <img src="Image/Train4.jpeg"alt="Lotus" width="400" height="260" title="" alt="" rel="<h3>Lotus</h3>Room to Move, Think, Relax ."/> </a> <a href="#"> <img src="Image/Train5.jpeg"alt="Mojave" width="400" height="260" title="" alt="" rel="<h3>Western Railways</h3>Good Ideas Make a Great Railway."/> </a> <div class="caption"><div class="content"></div></div> </div> <div class="clear"></div> </td> </tr> </table> <iframe src="marqeePage.htm" width="400" height="260" style="z-index: 100; left: 573px; position: absolute; top: 170px"></iframe> </form> </body> </html>
|
Default.aspx.cs
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page { ConnClass conn = new ConnClass(); protected void Page_Load(object sender, EventArgs e) {
} #region Login ctrl protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { try { string unm = Login1.UserName.ToUpper(); //unm.ToUpper(); if (unm == "ADMIN") { string UserNm = Login1.UserName; string Pwd = Login1.Password; string connect = conn.GetConnection(); SqlConnection scon = new SqlConnection(connect); SqlCommand cmd = new SqlCommand("dbo.SP_Login", scon); // calling thr sp cmd.CommandType = CommandType.StoredProcedure; scon.Open(); DataSet ds = new DataSet(); cmd.Parameters.Add("@UName", System.Data.SqlDbType.VarChar, 50).Value = UserNm; cmd.Parameters.Add("@Pwd", System.Data.SqlDbType.VarChar, 50).Value = Pwd; SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(ds); for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { Session["UserName"] = UserNm;
string MainURL = "Admin.aspx? url1=" + ds.Tables[0].Rows[i]["PassengerId"];
Response.Redirect(MainURL); } } else { string UserNm = Login1.UserName; string Pwd = Login1.Password; string connect = conn.GetConnection(); SqlConnection scon = new SqlConnection(connect); SqlCommand cmd = new SqlCommand("dbo.SP_Login", scon); // calling thr sp cmd.CommandType = CommandType.StoredProcedure; scon.Open(); DataSet ds = new DataSet(); cmd.Parameters.Add("@UName", System.Data.SqlDbType.VarChar, 50).Value = UserNm; cmd.Parameters.Add("@Pwd", System.Data.SqlDbType.VarChar, 50).Value = Pwd; SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(ds); for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { Session["UserName"] = UserNm;
string MainURL = "BookTrains.aspx? url1=" + ds.Tables[0].Rows[i]["PassengerId"];
Response.Redirect(MainURL);
} } } catch (Exception er) { Response.Write(er); }
} #endregion }
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Passenger_Registration.aspx.cs" Inherits="Passenger_Registration" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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"> <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript"> function ValtxtUserNm(obj1) { var txtAdvanceSearch; txtAdvanceSearch=document.getElementById(obj1); if(txtAdvanceSearch.value =="" || txtAdvanceSearch.value == null) { alert('User Name Can Not Left Blank'); document.getElementById("txtUserNm").focus(); return false; } } </script> <title>Passenger Registration Page</title> <link rel="shortcut icon" href="Image/Train.ico" /> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="smMasterNew" EnablePageMethods="true" ScriptMode="Release" LoadScriptsBeforeUI="false" EnablePartialRendering="true" runat="server"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table> <tr> <td> <asp:Label ID="Label1" runat="server" Text="User Name" Font-Bold="True"></asp:Label> </td> <td style="width: 332px"> <%--<div id="checkusername" runat="server" Visible="false"></div>--%> <asp:TextBox ID="txtUserNm" runat="server" OnTextChanged="txtUserNm_TextChanged" AutoPostBack="True"> </asp:TextBox> <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtUserNm" ErrorMessage="*"></asp:RequiredFieldValidator>--%> <asp:Label ID="lblStatus" runat="server"></asp:Label> </td> </tr> <tr> <td> <asp:Label ID="lblPassword" runat="server" Text="Password" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="txtPassword"></asp:RequiredFieldValidator> <asp:Label ID="lblhelp1" runat="server"/> <asp:Label ID="lblError" runat="server"></asp:Label> <cc1:PasswordStrength ID="PasswordStrength1" TargetControlID="txtPassword" PreferredPasswordLength="5" runat="server" StrengthIndicatorType="BarIndicator" PrefixText="Strength:" HelpStatusLabelID="lblhelp1" BarBorderCssClass="BarBorder" TextStrengthDescriptionStyles="VeryPoorStrength;WeakStrength; AverageStrength;GoodStrength;ExcellentStrength"> </cc1:PasswordStrength> </td> </tr> <tr> <td> <asp:Label ID="lblConfirmPassword" runat="server" Text="Confirm Password" Font-Bold="True"> </asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtConfPwd" runat="server" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="txtConfPwd"> </asp:RequiredFieldValidator> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword" ControlToValidate="txtConfPwd" ErrorMessage="Password did not match"></asp:CompareValidator> <cc1:PasswordStrength ID="pwdStrength" TargetControlID="txtConfPwd" StrengthIndicatorType="Text" PrefixText="Strength:" HelpStatusLabelID="lblhelp" PreferredPasswordLength="5" TextStrengthDescriptions="Very Poor;Weak;Average;Good;Excellent" TextStrengthDescriptionStyles="VeryPoorStrength;WeakStrength;AverageStrength; GoodStrength;ExcellentStrength" runat="server" /> </td> </tr> <tr> <td> <asp:Label ID="lblFName" runat="server" Text="First Name" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtFName" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblLastNm" runat="server" Text="Last Name" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtLastNm" runat="server"></asp:TextBox></td> </tr> <tr> <td style="height: 24px"> <asp:Label ID="lblDOB" runat="server" Text="Date of Birth" Font-Bold="True"></asp:Label></td> <td style="width: 332px; height: 24px"> <asp:DropDownList ID="ddlDOBDay" runat="server"> </asp:DropDownList> <asp:DropDownList ID="ddlDOBMonth" runat="server"> </asp:DropDownList> <asp:DropDownList ID="ddlDOBYear" runat="server"> </asp:DropDownList></td> </tr> <tr> <td style="height: 21px"> <asp:Label ID="lblCountry" runat="server" Text="Country" Font-Bold="True"></asp:Label></td> <td style="width: 332px; height: 21px"> <asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblState" runat="server" Text="State" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlState_SelectedIndexChanged"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblCity" runat="server" Text="City" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:DropDownList ID="ddlCity" runat="server"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblEmail" runat="server" Text="Email ID" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblMobile" runat="server" Text="Mobile" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtMobileNo" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblPincode" runat="server" Text="Pincode" Font-Bold="True"></asp:Label></td> <td style="width: 332px"> <asp:TextBox ID="txtPincode" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:Button ID="btnRegisterUser" runat="server" Text="Registere User" OnClick="btnRegisterUser_Click" Font-Bold="True" /></td> <%--OnClientClick="javascript:ValtxtUserNm()" --%> <td style="width: 332px"> <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" Font-Bold="True" /></td> </tr> </table> </ContentTemplate></asp:UpdatePanel> <asp:Label ID="lblGuestUser" runat="server" ForeColor="RoyalBlue" Style="z-index: 100; left: 505px; position: absolute; top: 19px"></asp:Label> </div> <div> <asp:LinkButton ID="lnksignin" runat="server" PostBackUrl="~/Default.aspx"> Go to sign in page</asp:LinkButton> </div> </form> </body> </html>
|
Passenger_Registration.aspx.cs
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;
public partial class Passenger_Registration : System.Web.UI.Page { ConnClass connect = new ConnClass(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { fillddlCountry(); fillDay(ddlDOBDay); fillMonth(ddlDOBMonth); fillYear(ddlDOBYear); } lblGuestUser.Text = "Wel-Come-<b>Guest</b>"; btnRegisterUser.Attributes.Add("onclick", "return ValtxtUserNm('"+txtUserNm.ClientID+"')"); } #region fillDays private void fillDay(DropDownList ddlList) { ddlList.Items.Add(new ListItem("Day", "Day")); ddlList.SelectedIndex = 0; int totalDay = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); for (int day = 1; day <= totalDay; day++) { ddlList.Items.Add(new ListItem(day.ToString(),day.ToString())); } } #endregion #region fill Month private void fillMonth(DropDownList ddlList) { ddlList.Items.Add(new ListItem("Month", "Month")); ddlList.SelectedIndex=0; DateTime month=Convert.ToDateTime("1/1/2000"); for (int mon = 0; mon < 12; mon++) { DateTime NxtMon = month.AddMonths(mon); ddlList.Items.Add(new ListItem(NxtMon.ToString("MMMM"),NxtMon.ToString("MMMM"))); } } #endregion #region Fill Year private void fillYear(DropDownList ddlList) { ddlList.Items.Add(new ListItem("Year", "Year")); ddlList.SelectedIndex = 0; int initialYear = 1960; for (int yr = initialYear; yr <= Convert.ToInt32(DateTime.Now.Year); yr++) { ddlList.Items.Add(new ListItem(yr.ToString(), yr.ToString())); } } #endregion #region fill Country private void fillddlCountry() { string sqlconn = connect.GetConnection(); string Qry = "select * from CountryMaster"; SqlDataAdapter sda = new SqlDataAdapter(Qry,sqlconn); DataSet ds = new DataSet(); sda.Fill(ds); ddlCountry.DataSource = ds; ddlCountry.DataTextField = "CountryName"; ddlCountry.DataValueField = "CountryID"; ddlCountry.DataBind(); ddlCountry.Items.Insert(0, "Select Country"); } # endregion #region Button Reg Click protected void btnRegisterUser_Click(object sender, EventArgs e) { try { if (lblStatus.Text == "UserName Available" && txtUserNm.Text!="" && txtPassword.Text!="" && txtPassword.Text.Length>5) { string unm = txtUserNm.Text.ToUpper(); string pwd = txtPassword.Text; string fnm = txtFName.Text.ToUpper(); string lnm = txtLastNm.Text.ToUpper(); DateTime dob = Convert.ToDateTime(ddlDOBDay.SelectedItem.Text + ddlDOBMonth.SelectedItem.Text + ddlDOBYear.SelectedItem.Text); string d = dob.ToString("d"); string country = Convert.ToString(ddlCountry.SelectedItem); string state = Convert.ToString(ddlState.SelectedItem); string city = Convert.ToString(ddlCity.SelectedItem); string email = txtEmail.Text; string mob = txtMobileNo.Text; int pin = Convert.ToInt32(txtPincode.Text); string sqlconn = connect.GetConnection(); string qry = "Insert Into PassengerInfo values('" + unm + "', '" + pwd + "','" + fnm + "', '" + lnm + "','" + d + "','" + email + "','" + mob + "','" + country + "', '" + state + "','" + city + "'," + pin + ")"; SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn); DataSet ds = new DataSet(); sda.Fill(ds, "PassengerInfo"); Response.Write("<script language='javascript' type='text/javascript'> alert('Record Inserted Successfully')</script>"); ClearForm(); Response.Redirect("Default.aspx"); } else { lblError.Text = "Can Not Blank & Charecter Must be 5 "; } } catch (Exception) {
} } #endregion #region fill state protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e) { filldllState(); }
private void filldllState() { if (ddlCountry.SelectedValue != "Select Country") { string sqlconn = connect.GetConnection(); string qry = "select * from StateMaster where CountryID="+ddlCountry.SelectedValue; SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn); DataSet ds = new DataSet(); sda.Fill(ds); ddlState.DataSource = ds; ddlState.DataTextField = "StateName"; ddlState.DataValueField = "StateID"; ddlState.DataBind(); ddlState.Items.Insert(0, "Select State"); } } #endregion end state #region fill city protected void ddlState_SelectedIndexChanged(object sender, EventArgs e) { if (ddlCountry.SelectedValue != "Select State") { string sqlconn = connect.GetConnection(); string qry = "select * from CityMaster where stateID=" + ddlState.SelectedValue + " and CountryID=" + ddlCountry.SelectedValue; SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn); DataSet ds = new DataSet(); sda.Fill(ds); ddlCity.DataSource = ds; ddlCity.DataTextField = "CityName"; ddlCity.DataValueField="CityID"; ddlCity.DataBind(); ddlCity.Items.Insert(0,"Select City"); } } #endregion #region Cancel Button Click protected void btnCancel_Click(object sender, EventArgs e) { ClearForm(); } #endregion #region ClearForm Function private void ClearForm() { txtUserNm.Text = ""; txtPassword.Text = ""; txtFName.Text = ""; txtLastNm.Text = ""; ddlDOBDay.SelectedValue = "Day"; ddlDOBMonth.SelectedValue = "Month"; ddlDOBYear.SelectedValue = "Year"; ddlCountry.SelectedValue = "Select Country"; ddlState.SelectedValue = "Select State"; ddlCity.SelectedValue = "Select City"; txtEmail.Text = ""; txtMobileNo.Text = ""; txtPincode.Text = ""; } #endregion
#region UserName Textbox Change Event protected void txtUserNm_TextChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUserNm.Text)) { string scon = connect.GetConnection(); string nm = txtUserNm.Text; string qry = "select UserName from PassengerInfo where UserName='" + nm + "'"; SqlConnection conn = new SqlConnection(scon); conn.Open(); SqlCommand cmd = new SqlCommand(qry, conn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { //checkusername.Visible = true; lblStatus.Text = "UserName Already Taken"; } else { //checkusername.Visible = true; lblStatus.Text = "UserName Available"; } conn.Close(); } } #endregion }
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Admin.aspx.cs" Inherits="Admin" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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">
<%--<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>--%> <script type="text/javascript" src="script/jquery-1.3.1.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $('a#showhidetrigger').click(function() { $('#showhidetarget').toggle(400); }); }); </script> <script type="text/javascript"> $(document).ready(function(){ $('a#A1').click(function(){ $('#showpassenger').toggle(400); }); }); </script> <%-- <script language="javascript" type="text/javascript"> function chkTxtntBlank() { $find("modelPopupExtender1").show(); } </script>--%> <title>Admin Page</title> <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="Image/Train.ico" /> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="smMasterNew" EnablePageMethods="true" ScriptMode="Release" LoadScriptsBeforeUI="false" EnablePartialRendering="true" runat="server"> </asp:ScriptManager> <asp:LoginStatus ID="LoginStatus1" runat="server" LoginText="Logout" LogoutPageUrl="~/Default.aspx" Style="z-index: 100; left: 688px; position: absolute; top: 19px" OnLoggingOut="LoginStatus1_LoggingOut" /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add New Train" /> <a id="showhidetrigger" href="#">show/hide Train Information</a> <div id="showhidetarget"> <asp:Label ID="lblresult" runat="server"/><asp:Button ID="btnShowPopup" runat="server" style="display:none" /> <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopup" CancelControlID="btnCancel" BackgroundCssClass="modalBackground"></cc1:ModalPopupExtender> <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="230px" Width="333px"> <table cellpadding="0" cellspacing="0" align="center"> <tr style="background-color:#D55500"> <td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger" align="center">Train Details</td> </tr> <tr> <td style="width: 100px; height: 19px;"> <b> Train Number</b></td> <td style="width: 106px; height: 24px;"> <asp:TextBox ID="txtTrainNo" runat="server"/> </td> </tr> <tr> <td style="width: 100px; height: 19px;"> <b> Train Name</b></td> <td style="width: 106px; height: 24px;"> <asp:TextBox ID="txtTrainName" runat="server"/></td> </tr> <tr> <td style="width: 100px; height: 24px;"> <b> Source Station</b></td> <td style="width: 106px; height: 24px;"> <asp:TextBox ID="txtSourceStat" runat="server"/></td> </tr> <tr> <td style="width: 100px; height: 19px;"> <b> Destination Station</b></td> <td style="width: 106px; height: 24px;"> <asp:TextBox ID="txtDestStat" runat="server"/></td> </tr> <tr> <td style="width: 100px; height: 19px;"> <b> Amount</b></td> <td style="width: 106px; height: 24px;"> <asp:TextBox ID="txtAmt" runat="server"/></td> </tr> <tr> <td style="width: 100px; height: 24px;"> <asp:Button ID="btnAddNew" runat="server" Text="Add New" OnClick="btnAddNew_Click" OnClientClick="javascript:chkTxtntBlank()" /></td> <td style="width: 106px; height: 24px;"> <asp:Button ID="btnCancel" runat="server" Text="Cancel" /></td> <td style="width: 1px"></td> </tr> </table> </asp:Panel> <asp:GridView ID="GridView1" runat="server" DataKeyNames="TrainID" AutoGenerateColumns="False" Caption="List of Train Information" OnRowCancelingEdit="GridView1_RowCancelingEdit" CssClass="mGrid" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" PageSize="4" Height="159px" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" AllowSorting="True" OnSorting="GridView1_Sorting"> <Columns> <asp:CommandField ShowEditButton="True" ShowDeleteButton="True"/> <asp:BoundField DataField="TrainID" HeaderText="Train ID" SortExpression="TrainID" /> <asp:BoundField DataField="TrainNumber" HeaderText="Train No" SortExpression="TrainNumber" /> <asp:BoundField DataField="TrainName" HeaderText="Train Name" SortExpression="TrainName" /> <asp:BoundField DataField="SourceStationName" HeaderText="Source Station" SortExpression="SourceStationName" /> <asp:BoundField DataField="DestinationStationName" HeaderText="Destination Station" SortExpression="DestinationStationName" /> <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" /> </Columns> </asp:GridView> </div> <br /> <a id="A1" href="#">show/hide Passenger Information</a> <div id="showpassenger"> <asp:GridView ID="grdPassengerInfo" runat="server" AutoGenerateColumns="false" Caption="List of Passenger Info" CssClass="mGrid" PageSize="4" AllowPaging="True" OnPageIndexChanging="grdPassengerInfo_PageIndexChanging" AllowSorting="True" OnSorting="grdPassengerInfo_Sorting" > <Columns> <asp:BoundField DataField="PassengerId" HeaderText="Passenger ID" > <HeaderStyle CssClass="HideGridCol" /> <ItemStyle CssClass="HideGridCol" /> </asp:BoundField> <asp:BoundField DataField="UserName" HeaderText="User Name" SortExpression="UserName" /> <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" /> <asp:BoundField DataField="DOB" HeaderText="Date of Birth" SortExpression="DOB" /> <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" /> <asp:BoundField DataField="MobileNo" HeaderText="Mobile No" SortExpression="MobileNo" /> <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" /> <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" /> <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /> </Columns> </asp:GridView> </div> </form> </body> </html>
|
Admin.aspx.cs
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;
public partial class Admin : System.Web.UI.Page { ConnClass connect = new ConnClass(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { showTrainGrid(); showPassengerGrid();
} }
#region ShowPassenger Info private DataSet showPassengerGrid() { string scon = connect.GetConnection(); SqlConnection conn = new SqlConnection(scon); conn.Open(); string qry = "select * from PassengerInfo"; SqlCommand cmd = new SqlCommand(qry, conn); //SqlDataReader sdr = cmd.ExecuteReader(); //if (sdr.HasRows) //{ // while (sdr.Read()) // { // grdPassengerInfo.DataSource = sdr; // grdPassengerInfo.DataBind(); // } //} SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.TableMappings.Add("Table", "PassengerInfo"); DataSet ds = new DataSet("PassengerInfo"); sda.Fill(ds); grdPassengerInfo.DataSource = ds; grdPassengerInfo.DataBind(); if (grdPassengerInfo.Columns.Count > 0) { grdPassengerInfo.Columns[1].Visible = false; } return ds; //conn.Close(); } #endregion #region gridTrain rowEditing protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { //GridViewRow grd = (GridViewRow)GridView1.Rows[e.NewEditIndex]; GridView1.EditIndex = e.NewEditIndex; showTrainGrid(); } #endregion #region show Train Info private DataSet showTrainGrid() { string scon = connect.GetConnection(); SqlConnection conn = new SqlConnection(scon); conn.Open(); string qry = "select * from Train"; SqlCommand cmd = new SqlCommand(qry, conn); //SqlDataReader sdr = cmd.ExecuteReader(); //if (sdr.HasRows) //{ // while (sdr.Read()) // { // GridView1.DataSource = sdr; // GridView1.DataBind(); // } //} SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.TableMappings.Add("Table", "Train"); DataSet ds = new DataSet("Train"); sda.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); if (GridView1.Columns.Count > 0) { GridView1.Columns[1].Visible = false; } return ds; // conn.Close(); } #endregion #region Gridrow deleting protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { ViewState["TrainID"] = GridView1.DataKeys[GridView1.SelectedIndex]; string scon = connect.GetConnection(); string query = "select * from TrainBookingDetails"; SqlDataAdapter sda = new SqlDataAdapter(query, scon); DataSet ds = new DataSet(); sda.Fill(ds); } #endregion #region Grid Updating protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string trainid=(GridView1.DataKeys[e.RowIndex].Value.ToString()); string trainNo=((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text; string trainNm = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text; string source = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text; string destination = ((TextBox)GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text; string amt = ((TextBox)GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text; string scon = connect.GetConnection(); SqlConnection conn=new SqlConnection(scon); conn.Open(); string qry="Update Train set TrainNumber="+trainNo+" ,TrainName='"+trainNm+"', SourceStationName='"+source+"',DestinationStationName='"+destination+"',Amount="+amt+" where TrainID="+trainid+""; SqlCommand cmd = new SqlCommand(qry, conn); //cmd.ExecuteNonQuery(); //conn.Close(); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); sda.Fill(ds); GridView1.EditIndex = -1; showTrainGrid(); } #endregion #region grid Cancling protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; showTrainGrid(); } #endregion #region Add New Train protected void btnAddNew_Click(object sender, EventArgs e) { if (txtTrainNo.Text != "" && txtTrainName.Text != "" && txtSourceStat.Text != "" && txtDestStat.Text != "" && txtAmt.Text != "") { int trainNo = Convert.ToInt32(txtTrainNo.Text); string trainNM = txtTrainName.Text; string sourceSta = txtSourceStat.Text; string DestStat = txtDestStat.Text; double amt = Convert.ToDouble(txtAmt.Text); string scon = connect.GetConnection(); string qry = "Insert Into Train (TrainNumber,TrainName, SourceStationName,DestinationStationName,Amount) Values(" + trainNo + ",'" + trainNM + "','" + sourceSta + "','" + DestStat + "'," + amt + ")"; SqlDataAdapter sda = new SqlDataAdapter(qry, scon); DataSet ds = new DataSet(); sda.Fill(ds); txtTrainNo.Text = ""; txtTrainName.Text = ""; txtSourceStat.Text = ""; txtDestStat.Text = ""; txtAmt.Text = ""; showTrainGrid(); } else { this.ModalPopupExtender1.Show(); } } #endregion #region Popup extender protected void Button1_Click(object sender, EventArgs e) { this.ModalPopupExtender1.Show(); } #endregion #region gridTrain page indexing protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; showTrainGrid(); } #endregion #region grid Passenger Page Indexing protected void grdPassengerInfo_PageIndexChanging(object sender, GridViewPageEventArgs e) { grdPassengerInfo.PageIndex = e.NewPageIndex; showPassengerGrid(); } #endregion protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e) { LoginStatus n = new LoginStatus(); n.Page.Session.Abandon(); } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; if (GridViewSortDirection == SortDirection.Ascending) { GridViewSortDirection = SortDirection.Descending; SortGridTrainView(sortExpression, DESCENDING); } else { GridViewSortDirection = SortDirection.Ascending; SortGridTrainView(sortExpression, ASCENDING); } }
private void SortGridTrainView(string sortExpression, string Direction) { DataTable dtable = showTrainGrid().Tables[0]; DataView dv = new DataView(dtable); dv.Sort = sortExpression + Direction; GridView1.DataSource = dv; GridView1.DataBind(); } private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; protected void grdPassengerInfo_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; if (GridViewSortDirection == SortDirection.Ascending) { GridViewSortDirection = SortDirection.Descending; SortGridView(sortExpression, DESCENDING); } else { GridViewSortDirection = SortDirection.Ascending; SortGridView(sortExpression, ASCENDING); } }
private void SortGridView(string sortExpression, string Direction) { DataTable dt = showPassengerGrid().Tables[0];
DataView dv = new DataView(dt); dv.Sort = sortExpression + Direction; grdPassengerInfo.DataSource = dv; grdPassengerInfo.DataBind();
} public SortDirection GridViewSortDirection { get { if (ViewState["sortDirection"] == null) ViewState["sortDirection"] = SortDirection.Ascending; return (SortDirection)ViewState["sortDirection"]; } set { ViewState["sortDirection"] = value; } }
}
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BookingDetails.aspx.cs" Inherits="BookingDetails" %>
<!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>Booking Details</title> <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="Image/Train.ico" /> </head> <body> <form id="form1" runat="server"> <h1>List of Trains are Booked by <asp:Label ID="lblsession" runat="server" ForeColor="RoyalBlue"></asp:Label>...</h1> <div> <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Default.aspx" Style="z-index: 100; left: 883px; position: absolute; top: 32px" LoginText="Logout" /> <asp:GridView ID="grdPassengerInfo" runat="server" AutoGenerateColumns="False" AllowPaging="True" CssClass="mGrid" PageSize="5" OnPageIndexChanging="grdPassengerInfo_PageIndexChanging" OnRowDeleting="grdPassengernfo_RowDeleting" AllowSorting="True" AutoGenerateDeleteButton="True" OnSorting="grdPassengerInfo_Sorting"> <Columns> <asp:BoundField DataField="TrainBookingID" HeaderText="TrainBookingID"> <HeaderStyle CssClass="HideGridCol" /> <ItemStyle CssClass="HideGridCol" /> </asp:BoundField > <asp:BoundField DataField="FirstName" HeaderText="Fist Name" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" /> <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" /> <asp:BoundField DataField="MobileNo" HeaderText="Mobile No." SortExpression="MobileNo" /> <asp:BoundField DataField="TrainNumber" HeaderText="Train Number" SortExpression="TrainNumber" /> <asp:BoundField DataField="TrainName" HeaderText="Train Name" SortExpression="TrainName" /> <asp:BoundField DataField="SourceStation" HeaderText="Source Station" SortExpression="SourceStation" /> <asp:BoundField DataField="DestinationStation" HeaderText="Destination Station" SortExpression="DestinationStation" /> <asp:BoundField DataField="PaymentBy" HeaderText="Payment By" SortExpression="PaymentBy" /> <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" /> </Columns> </asp:GridView> </div> </form> </body> </html>
|
BookingDetails.aspx.cs
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Diagnostics; using System.Collections.Generic;
public partial class BookingDetails : System.Web.UI.Page { ConnClass connect = new ConnClass(); #region Page_Load protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string scon = connect.GetConnection(); string uid = Request.QueryString["PassengerId"]; string qry = "select * from TrainBookingDetails where status='" + 0 + "' and PassengerID=" + uid; SqlDataAdapter sda = new SqlDataAdapter(qry, scon); DataSet ds = new DataSet(); sda.Fill(ds); grdPassengerInfo.DataSource = ds; grdPassengerInfo.DataBind(); if (grdPassengerInfo.Columns.Count > 0) { grdPassengerInfo.Columns[0].Visible = false; } } Response.Cache.SetAllowResponseInBrowserHistory(true); lblsession.Text=Convert.ToString(Session["UserName"]); } #endregion #region fill grid private DataSet bindGrid() { string scon = connect.GetConnection(); string uid = Request.QueryString["PassengerId"]; string qry = "select * from TrainBookingDetails where status='" + false + "' and PassengerID=" + uid; SqlDataAdapter sda = new SqlDataAdapter(qry, scon); DataSet ds = new DataSet(); sda.Fill(ds); grdPassengerInfo.DataSource = ds; grdPassengerInfo.DataBind(); if (grdPassengerInfo.Columns.Count > 0) { grdPassengerInfo.Columns[1].Visible = false; //hide grid column at run time } return ds; } #endregion #region pageIndexing protected void grdPassengerInfo_PageIndexChanging(object sender, GridViewPageEventArgs e) { grdPassengerInfo.PageIndex = e.NewPageIndex; bindGrid(); } #endregion protected void grdPassengerInfo_RowDeleting(object sender, GridViewDeleteEventArgs e) { //GridViewRow row = (GridViewRow)grdPassengerInfo.Rows[e.RowIndex-1]; //string scon = connect.GetConnection(); ////string qry = "delete from TrainBookingDetails where TrainBookingID=" + row.Cells[1].Text + ""; //string qry = "Update TrainBookingDetails set [Status]='"+true+"' where TrainBookingID=" + row.Cells[1].Text + ""; //SqlDataAdapter sda = new SqlDataAdapter(qry, scon); //DataSet ds = new DataSet(); //sda.Fill(ds); //bindGrid(); } #region grid row deleting protected void grdPassengernfo_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = (GridViewRow)grdPassengerInfo.Rows[e.RowIndex]; string scon = connect.GetConnection(); //string qry = "delete from TrainBookingDetails where TrainBookingID=" + row.Cells[1].Text + ""; string qry = "Update TrainBookingDetails set [Status]='" + true + "' where TrainBookingID=" + row.Cells[1].Text + ""; SqlDataAdapter sda = new SqlDataAdapter(qry, scon); DataSet ds = new DataSet(); sda.Fill(ds); bindGrid(); } #endregion
private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; protected void grdPassengerInfo_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending) { GridViewSortDirection = SortDirection.Descending; SortGridView(sortExpression, DESCENDING); } else { GridViewSortDirection = SortDirection.Ascending; SortGridView(sortExpression, ASCENDING); } } private void SortGridView(string sortExpression, string direction) { // You can cache the DataTable for improving performance DataTable dt = bindGrid().Tables[0]; DataView dv = new DataView(dt); dv.Sort = sortExpression + direction; grdPassengerInfo.DataSource = dv; grdPassengerInfo.DataBind(); } public SortDirection GridViewSortDirection { get { if (ViewState["sortDirection"] == null) ViewState["sortDirection"] = SortDirection.Ascending;
return (SortDirection)ViewState["sortDirection"]; } set { ViewState["sortDirection"] = value; } } }
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BookTrains.aspx.cs" Inherits="PassengerProfile" %>
<!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> <link rel="shortcut icon" href="Image/Train.ico" /> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="lblHi" runat="server" Text="Hi" style="z-index: 102; left: 662px; position: absolute; top: 18px"></asp:Label> <asp:Label ID="lblName" runat="server" Text="" style="z-index: 101; left: 687px; position: absolute; top: 17px"></asp:Label><br /> <asp:LinkButton ID="lnkeditProfile" runat="server">Book Train</asp:LinkButton> <table> <tr> <td> <asp:Label ID="lblFName" runat="server" Text="First Name" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtFName" runat="server" ReadOnly="True"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblLName" runat="server" Text="Last Name" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtLName" runat="server" ReadOnly="True"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblCountry" runat="server" Text="Country" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblState" runat="server" Text="State" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlState_SelectedIndexChanged"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblCity" runat="server" Text="City" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="True" > </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblPincode" runat="server" Text="PinCode" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtPincode" runat="server" ReadOnly="True"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblMob" runat="server" Text="Mobile Number" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtMobNo" runat="server" ReadOnly="True"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblEmail" runat="server" Text="Email" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtEmail" runat="server" ReadOnly="True"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblTrainName" runat="server" Text="Train Name" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlTrainName" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlTrainName_SelectedIndexChanged"> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlTrainName" ErrorMessage=" Select Train Name" InitialValue="Select Train" ToolTip="Select Train Name">*</asp:RequiredFieldValidator></td> </tr> <tr> <td> <asp:Label ID="lblTrainNo" runat="server" Text="Train Number" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtTrainNo" runat="server" ReadOnly="True"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="lblSourceStation" runat="server" Text="Source Station" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlSourceStation" runat="server"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblDestinationStation" runat="server" Text="Destination Station" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlDestinationStation" runat="server"> </asp:DropDownList></td> </tr> <tr> <td> <asp:Label ID="lblPaymentBy" runat="server" Text="Payment By" Font-Bold="True"> </asp:Label></td> <td style="width: 199px"> <asp:DropDownList ID="ddlPaymentBy" runat="server"> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlPaymentBy" ErrorMessage=" Select Card Type" InitialValue="Select Card Type" ToolTip="Select Card Type">*</asp:RequiredFieldValidator></td> </tr> <tr> <td> <asp:Label ID="lblAmount" runat="server" Text="Amount" Font-Bold="True"></asp:Label></td> <td style="width: 199px"> <asp:TextBox ID="txtAmount" runat="server" ReadOnly="True"></asp:TextBox></td> </tr>
<tr> <td> <asp:Button ID="btnBKTrainTk" runat="server" Text="Book Train Ticket" OnClick="btnBKTrainTk_Click" Font-Bold="True" /></td> <td style="width: 199px"> <asp:LinkButton ID="lnkEdit" runat="server" OnClick="lnkEdit_Click"> Edit UserInfo</asp:LinkButton> <asp:LinkButton ID="lnkUpdate" runat="server" OnClick="lnkUpdate_Click"> Update UserInfo</asp:LinkButton></td> </tr> </table> </div> <asp:ValidationSummary ID="ValidationSummary1" runat="server" /> </form> </body> </html>
|
BookTrains.aspx.cs
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Collections.Specialized;
public partial class PassengerProfile : System.Web.UI.Page { ConnClass connect = new ConnClass(); #region Page_Load protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string unm = Convert.ToString(Session["UserName"]); lblName.Text = unm; lnkEdit.Text = "Edit User Info"; lnkUpdate.Visible = false; if (Request.QueryString["url1"] != "") { HttpRequest q = Request; NameValueCollection n = q.QueryString; if (n.HasKeys()) { int uid = Convert.ToInt32(n.Get(0)); string sqlCon = connect.GetConnection(); SqlConnection scon = new SqlConnection(sqlCon); string qry = "select * from PassengerInfo where PassengerId=" + uid; SqlCommand cmd = new SqlCommand(qry, scon); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt);
if (dt.Rows.Count > 0) { txtFName.Text = dt.Rows[0]["FirstName"].ToString(); txtLName.Text = dt.Rows[0]["LastName"].ToString();
ddlCountry.DataSource = dt; ddlCountry.DataTextField = "Country"; ddlCountry.DataValueField = "PassengerId"; ddlCountry.DataBind();
ddlState.DataSource = dt; ddlState.DataTextField = "State"; ddlState.DataValueField = "PassengerId"; ddlState.DataBind();
ddlCity.DataSource = dt; ddlCity.DataTextField = "City"; ddlCity.DataValueField = "PassengerId"; ddlCity.DataBind();
txtPincode.Text = dt.Rows[0]["Pincode"].ToString(); txtMobNo.Text = dt.Rows[0]["MobileNo"].ToString(); txtEmail.Text = dt.Rows[0]["Email"].ToString(); } }
} fillTrainInfo(); ddlPaymentBy.Items.Add("Credit Card"); ddlPaymentBy.Items.Add("Debit Card"); ddlPaymentBy.Items.Insert(0, "Select Card Type"); } } #endregion #region Fill Train Dropdown private void fillTrainInfo() { string sqlCon = connect.GetConnection(); SqlConnection scon = new SqlConnection(sqlCon); string query = "select * from Train"; SqlCommand cmd = new SqlCommand(query, scon); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count > 0) { ddlTrainName.DataSource = dt; ddlTrainName.DataTextField = "TrainName"; ddlTrainName.DataValueField = "TrainID"; ddlTrainName.DataBind(); ddlTrainName.Items.Insert(0, "Select Train"); } } #endregion #region Fill All Train Info protected void ddlTrainName_SelectedIndexChanged(object sender, EventArgs e) { if (ddlTrainName.SelectedValue != "Select Train") { string sqlconn = connect.GetConnection(); SqlConnection scon = new SqlConnection(sqlconn); string qry = "select * from Train where TrainID=" + ddlTrainName.SelectedValue; ViewState["TRAINID"] = ddlTrainName.SelectedValue; int trainid = Convert.ToInt32(ViewState["TRAINID"]); SqlCommand cmd = new SqlCommand(qry, scon); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count > 0) { txtTrainNo.Text = dt.Rows[0]["TrainNumber"].ToString();
ddlSourceStation.DataSource = dt; ddlSourceStation.DataTextField = "SourceStationName"; ddlSourceStation.DataValueField = "TrainID"; ddlSourceStation.DataBind();
ddlDestinationStation.DataSource = dt; ddlDestinationStation.DataTextField = "DestinationStationName"; ddlDestinationStation.DataValueField = "TrainID"; ddlDestinationStation.DataBind();
txtAmount.Text = dt.Rows[0]["Amount"].ToString(); } } } #endregion #region Insert Book Train info protected void btnBKTrainTk_Click(object sender, EventArgs e) { string fnm = txtFName.Text; string lnm = txtLName.Text; string country = Convert.ToString(ddlCountry.SelectedItem); string state = Convert.ToString(ddlState.SelectedItem); string city = Convert.ToString(ddlCity.SelectedItem); int pin = Convert.ToInt32(txtPincode.Text); string mob = txtMobNo.Text; string email = txtEmail.Text; string trainNm = Convert.ToString(ddlTrainName.SelectedItem); int trainNo = Convert.ToInt32(txtTrainNo.Text); string soureceStation= Convert.ToString(ddlSourceStation.SelectedItem); string DestStation= Convert.ToString(ddlDestinationStation.SelectedItem); string payBy = Convert.ToString(ddlPaymentBy.SelectedItem); double amt = Convert.ToDouble (txtAmount.Text); int trainid = Convert.ToInt32(ViewState["TRAINID"]); if (Request.QueryString["url1"] != "") { HttpRequest q = Request; NameValueCollection n = q.QueryString; if (n.HasKeys()) { int uid = Convert.ToInt32(n.Get(0)); string scon = connect.GetConnection(); string query = "insert into TrainBookingDetails(FirstName,LastName,Country,State,City, MobileNo,Email,PinCode,TrainNumber,TrainName,SourceStation,DestinationStation,PaymentBy, Amount,TrainID,PassengerID,status)values('" + fnm + "','" + lnm + "','" + country + "', '" + state + "','" + city + "','" + mob + "','" + email + "'," + pin + "," + trainNo + ", '" + trainNm + "','" + soureceStation + "','" + DestStation + "', '" + payBy + "'," + amt + "," + trainid + "," + uid + ","+0+")"; SqlDataAdapter sda = new SqlDataAdapter(query, scon); DataSet ds = new DataSet(); sda.Fill(ds); Response.Write("<script language='javascript' type='text/javascript'>alert('Train Booked Successfully..') </script>"); string url = "BookingDetails.aspx?PassengerId=" + uid; Response.Redirect(url); } } } private void ClaearForm() { txtFName.Text=""; txtLName.Text=""; ddlCountry.SelectedIndex = -1; ddlState.SelectedIndex = -1; ddlCity.SelectedIndex = -1; txtPincode.Text = ""; txtMobNo.Text=""; txtEmail.Text=""; ddlTrainName.SelectedValue = "Select Train"; txtTrainNo.Text = ""; ddlSourceStation.SelectedIndex = -1; ddlDestinationStation.SelectedIndex = -1; ddlPaymentBy.SelectedValue = "Select Card Type"; txtAmount.Text=""; } #endregion
#region edit user profile protected void lnkEdit_Click(object sender, EventArgs e) { txtFName.ReadOnly = false; txtLName.ReadOnly = false;
string sqlconn = connect.GetConnection(); string Qry = "select * from CountryMaster"; SqlDataAdapter sda = new SqlDataAdapter(Qry, sqlconn); DataSet ds = new DataSet(); sda.Fill(ds); ddlCountry.DataSource = ds; ddlCountry.DataTextField = "CountryName"; ddlCountry.DataValueField = "CountryID"; ddlCountry.DataBind(); ddlCountry.Items.Insert(0, "Select Country");
txtPincode.ReadOnly = false; txtMobNo.ReadOnly = false; txtEmail.ReadOnly = false; btnBKTrainTk.Visible = false; lnkEdit.Visible = false; lnkUpdate.Visible = true; } #endregion #region fill state protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e) { if (ddlCountry.SelectedValue != "Select Country") { string sqlconn = connect.GetConnection(); string qry = "select * from StateMaster where CountryID=" + ddlCountry.SelectedValue; SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn); DataSet ds = new DataSet(); sda.Fill(ds); ddlState.DataSource = ds; ddlState.DataTextField = "StateName"; ddlState.DataValueField = "StateID"; ddlState.DataBind(); ddlState.Items.Insert(0, "Select State"); } } #endregion #region Fill City protected void ddlState_SelectedIndexChanged(object sender, EventArgs e) { if (ddlCountry.SelectedValue != "Select State") { string sqlconn = connect.GetConnection(); string qry = "select * from CityMaster where stateID=" + ddlState.SelectedValue + "and CountryID=" + ddlCountry.SelectedValue; SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn); DataSet ds = new DataSet(); sda.Fill(ds); ddlCity.DataSource = ds; ddlCity.DataTextField = "CityName"; ddlCity.DataValueField = "CityID"; ddlCity.DataBind(); ddlCity.Items.Insert(0, "Select City"); } } #endregion #region update UserInfo protected void lnkUpdate_Click(object sender, EventArgs e) { if (Request.QueryString["url1"] != "") { HttpRequest q = Request; NameValueCollection n = q.QueryString; if (n.HasKeys()) { int uid = Convert.ToInt32(n.Get(0)); string fnm = txtFName.Text; string lnm = txtLName.Text; string country = Convert.ToString(ddlCountry.SelectedItem); string state = Convert.ToString(ddlState.SelectedItem); string city = Convert.ToString(ddlCity.SelectedItem); int pin = Convert.ToInt32(txtPincode.Text); string mob = txtMobNo.Text; string email = txtEmail.Text;
string scon = connect.GetConnection(); string qry="Update PassengerInfo Set FirstName='"+fnm+"', LastName='"+lnm+"', Country='"+country+"',State='"+state+"',City='"+city+"', Pincode="+pin+",MobileNo='"+mob+"', Email='"+email+"' where PassengerId="+uid+""; SqlDataAdapter sda = new SqlDataAdapter(qry, scon); DataSet ds = new DataSet(); sda.Fill(ds); Response.Write("Updated...."); } lnkEdit.Visible = true; btnBKTrainTk.Visible = true; lnkUpdate.Visible = false; } } #endregion protected void btnCancel_Click(object sender, EventArgs e) { // ClaearForm(); } }
|