Passenger Reservation System(PRS)

  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"  
  2. Inherits="_Default" %>  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  5. <html xmlns="http://www.w3.org/1999/xhtml">  
  6.   
  7. <head runat="server">  
  8.     <title>Home Page</title>  
  9.     <link rel="shortcut icon" href="Image/Train.ico" />  
  10.     <script type="text/javascript" src="script/jquery-1.3.1.min.js"></script>  
  11.     <script type="text/javascript">  
  12.         $(document).ready(function() {  
  13.             //Execute the slideShow  
  14.             slideShow();  
  15.         });  
  16.   
  17.         function slideShow() {  
  18.             //Set the opacity of all images to 0  
  19.             $('#gallery a').css({  
  20.                 opacity: 0.0  
  21.             });  
  22.             //Get the first image and display it (set it to full opacity)  
  23.             $('#gallery a:first').css({  
  24.                 opacity: 1.0  
  25.             });  
  26.             //Set the caption background to semi-transparent  
  27.             $('#gallery .caption').css({  
  28.                 opacity: 0.7  
  29.             });  
  30.             //Resize the width of the caption according to the image width  
  31.             $('#gallery .caption').css({  
  32.                 width: $('#gallery a').find('img').css('width')  
  33.             });  
  34.             //Get the caption of the first image from REL attribute and display it  
  35.             $('#gallery .content').html($('#gallery a:first').find('img').attr('rel')).animate({  
  36.                 opacity: 0.7  
  37.             }, 400);  
  38.             //Call the gallery function to run the slideshow,  
  39.             6000 = change to next image after 6 seconds  
  40.             setInterval('gallery()', 2500);  
  41.         }  
  42.   
  43.         function gallery() {  
  44.             //if no IMGs have the show class, grab the first image  
  45.             var current = ($('#gallery a.show') ? $('#gallery a.show') : $('#gallery a:first'));  
  46.             //Get next image, if it reached the end of the slideshow,  
  47.             rotate it back to the first image  
  48.             var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#gallery a:first') : current.next()) : $('#gallery a:first'));  
  49.             //Get next image caption  
  50.             var caption = next.find('img').attr('rel');  
  51.             //Set the fade in effect for the next image, show class has higher z-index  
  52.             next.css({  
  53.                 opacity: 0.0  
  54.             }).addClass('show').animate({  
  55.                 opacity: 1.0  
  56.             }, 1000);  
  57.             //Hide the current image  
  58.             current.animate({  
  59.                 opacity: 0.0  
  60.             }, 1000).removeClass('show');  
  61.             //Set the opacity to 0 and height to 1px  
  62.             $('#gallery .caption').animate({  
  63.                 opacity: 0.0  
  64.             }, {  
  65.                 queue: false,  
  66.                 duration: 0  
  67.             }).animate({  
  68.                 height: '1px'  
  69.             }, {  
  70.                 queue: true,  
  71.                 duration: 300  
  72.             });  
  73.             //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect  
  74.             $('#gallery .caption').animate({  
  75.                 opacity: 0.7  
  76.             }, 100).animate({  
  77.                 height: '100px'  
  78.             }, 500);  
  79.             //Display the content  
  80.             $('#gallery .content').html(caption);  
  81.         }  
  82.     </script>  
  83.     <style type="text/css">  
  84.         body {  
  85.             font-family: arial  
  86.         }  
  87.   
  88.         .clear {  
  89.             clear: both  
  90.         }  
  91.  
  92.         #gallery {  
  93.             position: relative;  
  94.             height: 360px  
  95.         }  
  96.  
  97.         #gallery a {  
  98.             float: left;  
  99.             position: absolute;  
  100.         }  
  101.  
  102.         #gallery a img {  
  103.             border: none;  
  104.         }  
  105.  
  106.         #gallery a.show {  
  107.             z-index: 500  
  108.         }  
  109.  
  110.         #gallery .caption {  
  111.             z-index: 600;  
  112.             background-color: #000;  
  113.             color: #ffffff;  
  114.             height: 100px;  
  115.             width: 100%;  
  116.             position: absolute;  
  117.             bottom: 0;  
  118.         }  
  119.  
  120.         #gallery .caption .content {  
  121.             margin: 5px  
  122.         }  
  123.  
  124.         #gallery .caption .content h3 {  
  125.             margin: 0;  
  126.             padding: 0;  
  127.             color: #1DCCEF;  
  128.         }  
  129.     </style>  
  130. </head>  
  131.   
  132. <body>  
  133.     <form id="form1" runat="server">  
  134.         <div style="width: 258px; margin-left: auto; margin-right:auto; height: 113px;">  
  135.             <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">  
  136.                 <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />  
  137.                 <LoginButtonStyle Font-Bold="True" />  
  138.             </asp:Login>  
  139.             <b><u>New Registration:</u></b>  
  140.             <asp:LinkButton ID="lnkSignUp" runat="server" PostBackUrl="~/Passenger_Registration.aspx" Font-Bold="True" Style="z-index: 50; left: 510px; position:  
  141. absolute; top: 138px" Width="77px">Sign Up</asp:LinkButton>  
  142.         </div>  
  143.         <br /><br />  
  144.         <table>  
  145.             <tr>  
  146.                 <td>  
  147.                     <div id="gallery">  
  148.                         <a href="#" class="show">  
  149.                             <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....." />  
  150.                         </a>  
  151.                         <a href="#">  
  152.                             <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 . " />  
  153.                         </a>  
  154.                         <a href="#">  
  155.                             <img src="Image/Train2.jpeg" alt="Ladybug" width="400" height="260" title="" alt="" rel="<h3>Rail Road</h3>The Standard Railroad of the World." />  
  156.                         </a>  
  157.                         <a href="#">  
  158.                             <img src="Image/Train3.jpeg" alt="Lightning" width="400" height="260" title="" rel="<h3>Old Reliable</h3>But the Railroad Always Runs ." />  
  159.                         </a>  
  160.                         <a href="#">  
  161.                             <img src="Image/Train4.jpeg" alt="Lotus" width="400" height="260" title="" alt="" rel="<h3>Lotus</h3>Room to Move, Think, Relax ." />  
  162.                         </a>  
  163.                         <a href="#">  
  164.                             <img src="Image/Train5.jpeg" alt="Mojave" width="400" height="260" title="" alt="" rel="<h3>Western Railways</h3>Good Ideas Make a Great Railway." />  
  165.                         </a>  
  166.                         <div class="caption">  
  167.                             <div class="content"></div>  
  168.                         </div>  
  169.                     </div>  
  170.                     <div class="clear"></div>  
  171.                 </td>  
  172.             </tr>  
  173.         </table>  
  174.         <iframe src="marqeePage.htm" width="400" height="260" style="z-index: 100; left: 573px;  
  175. position: absolute; top: 170px"></iframe>  
  176.     </form>  
  177. </body>  
  178.   
  179. </html>  
Default.aspx.cs
  1.  using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Web;  
  5. using System.Web.Security;  
  6. using System.Web.UI;  
  7. using System.Web.UI.WebControls;  
  8. using System.Web.UI.WebControls.WebParts;  
  9. using System.Web.UI.HtmlControls;  
  10. using System.Data.SqlClient;  
  11.   
  12. public partial class _Default : System.Web.UI.Page   
  13. {  
  14.     ConnClass conn = new ConnClass();  
  15.     protected void Page_Load(object sender, EventArgs e)  
  16.     {  
  17.    
  18.   
  19.     }  
  20.     #region Login ctrl  
  21.     protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)  
  22.     {  
  23.         try  
  24.         {  
  25.             string unm = Login1.UserName.ToUpper();  
  26.             //unm.ToUpper();  
  27.             if (unm == "ADMIN")  
  28.             {  
  29.                 string UserNm = Login1.UserName;  
  30.                 string Pwd = Login1.Password;  
  31.                 string connect = conn.GetConnection();  
  32.                 SqlConnection scon = new SqlConnection(connect);  
  33.                 SqlCommand cmd =   
  34. new SqlCommand("dbo.SP_Login", scon); // calling thr sp  
  35.                 cmd.CommandType = CommandType.StoredProcedure;  
  36.                 scon.Open();  
  37.                 DataSet ds = new DataSet();  
  38.                 cmd.Parameters.Add("@UName",   
  39. System.Data.SqlDbType.VarChar, 50).Value = UserNm;  
  40.                 cmd.Parameters.Add("@Pwd",  
  41.  System.Data.SqlDbType.VarChar, 50).Value = Pwd;  
  42.                 SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  43.                 sda.Fill(ds);  
  44.                 for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)  
  45.                 {  
  46.                     Session["UserName"] = UserNm;  
  47.   
  48.                     string MainURL = "Admin.aspx?  
  49.  url1=" + ds.Tables[0].Rows[i]["PassengerId"];  
  50.   
  51.                     Response.Redirect(MainURL);  
  52.    
  53.                 }  
  54.             }  
  55.             else  
  56.             {  
  57.                 string UserNm = Login1.UserName;  
  58.                 string Pwd = Login1.Password;  
  59.                 string connect = conn.GetConnection();  
  60.                 SqlConnection scon = new SqlConnection(connect);  
  61.                 SqlCommand cmd =   
  62. new SqlCommand("dbo.SP_Login", scon); // calling thr sp  
  63.                 cmd.CommandType = CommandType.StoredProcedure;  
  64.                 scon.Open();  
  65.                 DataSet ds = new DataSet();  
  66.                 cmd.Parameters.Add("@UName",   
  67. System.Data.SqlDbType.VarChar, 50).Value = UserNm;  
  68.                 cmd.Parameters.Add("@Pwd",  
  69.  System.Data.SqlDbType.VarChar, 50).Value = Pwd;  
  70.                 SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  71.                 sda.Fill(ds);  
  72.                 for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)  
  73.                 {  
  74.                     Session["UserName"] = UserNm;  
  75.   
  76.                     string MainURL = "BookTrains.aspx?   
  77. url1=" + ds.Tables[0].Rows[i]["PassengerId"];  
  78.   
  79.                     Response.Redirect(MainURL);  
  80.   
  81.                 }  
  82.             }  
  83.         }  
  84.    
  85.         catch (Exception er)  
  86.         {  
  87.             Response.Write(er);  
  88.         }  
  89.   
  90.     }  
  91.     #endregion  
  92. }  
  1.  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Passenger_Registration.aspx.cs"   
  2. Inherits="Passenger_Registration" %>  
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>  
  4.   
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
  6. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  7.   
  8. <html xmlns="http://www.w3.org/1999/xhtml" >  
  9. <head runat="server">  
  10. <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />  
  11. <script language="javascript" type="text/javascript">  
  12. function ValtxtUserNm(obj1)  
  13. {  
  14.      var txtAdvanceSearch;  
  15.      txtAdvanceSearch=document.getElementById(obj1);  
  16.      if(txtAdvanceSearch.value =="" || txtAdvanceSearch.value == null)  
  17.     {  
  18.     alert('User Name Can Not Left Blank');  
  19.     document.getElementById("txtUserNm").focus();  
  20.     return false;  
  21.     }  
  22.    
  23. }  
  24. </script>  
  25.     <title>Passenger Registration Page</title>  
  26. <link rel="shortcut icon" href="Image/Train.ico" />  
  27. </head>  
  28. <body>  
  29.     <form id="form1" runat="server">  
  30.     <asp:ScriptManager ID="smMasterNew" EnablePageMethods="true" ScriptMode="Release"  
  31.             LoadScriptsBeforeUI="false" EnablePartialRendering="true" runat="server">  
  32.     </asp:ScriptManager>  
  33.     <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
  34.         <ContentTemplate>  
  35.     <table>         
  36.     <tr>  
  37.     <td>  
  38.         <asp:Label ID="Label1" runat="server" Text="User Name" Font-Bold="True"></asp:Label>  
  39.     </td>  
  40.     <td style="width: 332px">  
  41.     <%--<div id="checkusername" runat="server"  Visible="false"></div>--%>  
  42.         <asp:TextBox ID="txtUserNm" runat="server"   
  43. OnTextChanged="txtUserNm_TextChanged" AutoPostBack="True">  
  44. </asp:TextBox>  
  45.         <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"   
  46. ControlToValidate="txtUserNm"  
  47.             ErrorMessage="*"></asp:RequiredFieldValidator>--%>  
  48.             <asp:Label ID="lblStatus" runat="server"></asp:Label>  
  49.             </td>  
  50.     </tr>  
  51.     <tr>  
  52.     <td>  
  53.         <asp:Label ID="lblPassword" runat="server" Text="Password" Font-Bold="True"></asp:Label></td>  
  54.     <td style="width: 332px">  
  55.         <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>  
  56.         <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"   
  57. ErrorMessage="*" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>  
  58. <asp:Label ID="lblhelp1" runat="server"/>   
  59.         <asp:Label ID="lblError" runat="server"></asp:Label>  
  60.    
  61.         <cc1:PasswordStrength ID="PasswordStrength1" TargetControlID="txtPassword"   
  62.               PreferredPasswordLength="5" runat="server" StrengthIndicatorType="BarIndicator"  
  63.               PrefixText="Strength:" HelpStatusLabelID="lblhelp1" BarBorderCssClass="BarBorder"  
  64.               TextStrengthDescriptionStyles="VeryPoorStrength;WeakStrength;  
  65. AverageStrength;GoodStrength;ExcellentStrength">  
  66.         </cc1:PasswordStrength>  
  67.         </td>  
  68.     </tr>  
  69.     <tr>  
  70.     <td>  
  71.         <asp:Label ID="lblConfirmPassword" runat="server" Text="Confirm Password" Font-Bold="True">  
  72. </asp:Label></td>  
  73.     <td style="width: 332px">  
  74.         <asp:TextBox ID="txtConfPwd" runat="server" TextMode="Password"></asp:TextBox>   
  75.         <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"   
  76. ErrorMessage="*" ControlToValidate="txtConfPwd">  
  77.         </asp:RequiredFieldValidator>  
  78.         <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"  
  79.             ControlToValidate="txtConfPwd" ErrorMessage="Password did not match"></asp:CompareValidator>  
  80.    
  81.         <cc1:PasswordStrength ID="pwdStrength" TargetControlID="txtConfPwd" StrengthIndicatorType="Text"   
  82.              PrefixText="Strength:" HelpStatusLabelID="lblhelp" PreferredPasswordLength="5"   
  83.              TextStrengthDescriptions="Very Poor;Weak;Average;Good;Excellent"   
  84. TextStrengthDescriptionStyles="VeryPoorStrength;WeakStrength;AverageStrength;  
  85. GoodStrength;ExcellentStrength" runat="server" />  
  86.             </td>  
  87.     </tr>  
  88.     <tr>  
  89.     <td>  
  90.         <asp:Label ID="lblFName" runat="server" Text="First Name" Font-Bold="True"></asp:Label></td>  
  91.     <td style="width: 332px">  
  92.         <asp:TextBox ID="txtFName" runat="server"></asp:TextBox></td>  
  93.     </tr>  
  94.     <tr>  
  95.     <td>  
  96.         <asp:Label ID="lblLastNm" runat="server" Text="Last Name" Font-Bold="True"></asp:Label></td>  
  97.     <td style="width: 332px">  
  98.         <asp:TextBox ID="txtLastNm" runat="server"></asp:TextBox></td>  
  99.     </tr>  
  100.     <tr>  
  101.     <td style="height: 24px">  
  102.         <asp:Label ID="lblDOB" runat="server" Text="Date of Birth" Font-Bold="True"></asp:Label></td>  
  103.     <td style="width: 332px; height: 24px">  
  104.         <asp:DropDownList ID="ddlDOBDay" runat="server">  
  105.         </asp:DropDownList>  
  106.         <asp:DropDownList ID="ddlDOBMonth" runat="server">  
  107.         </asp:DropDownList>  
  108.         <asp:DropDownList ID="ddlDOBYear" runat="server">  
  109.         </asp:DropDownList></td>  
  110.     </tr>  
  111.     <tr>  
  112.     <td style="height: 21px">  
  113.         <asp:Label ID="lblCountry" runat="server" Text="Country" Font-Bold="True"></asp:Label></td>  
  114.     <td style="width: 332px; height: 21px">  
  115.         <asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True"  
  116.  OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged">  
  117.         </asp:DropDownList></td>  
  118.     </tr>  
  119.     <tr>  
  120.     <td>  
  121.         <asp:Label ID="lblState" runat="server" Text="State" Font-Bold="True"></asp:Label></td>  
  122.     <td style="width: 332px">  
  123.         <asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True"   
  124. OnSelectedIndexChanged="ddlState_SelectedIndexChanged">  
  125.         </asp:DropDownList></td>  
  126.     </tr>  
  127.     <tr>  
  128.     <td>  
  129.         <asp:Label ID="lblCity" runat="server" Text="City" Font-Bold="True"></asp:Label></td>  
  130.     <td style="width: 332px">  
  131.         <asp:DropDownList ID="ddlCity" runat="server">  
  132.         </asp:DropDownList></td>  
  133.     </tr>  
  134.     <tr>  
  135.     <td>  
  136.         <asp:Label ID="lblEmail" runat="server" Text="Email ID" Font-Bold="True"></asp:Label></td>  
  137.     <td style="width: 332px">  
  138.         <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td>  
  139.     </tr>  
  140.     <tr>  
  141.     <td>  
  142.         <asp:Label ID="lblMobile" runat="server" Text="Mobile" Font-Bold="True"></asp:Label></td>  
  143.     <td style="width: 332px">  
  144.         <asp:TextBox ID="txtMobileNo" runat="server"></asp:TextBox></td>  
  145.     </tr>  
  146.     <tr>  
  147.     <td>  
  148.         <asp:Label ID="lblPincode" runat="server" Text="Pincode" Font-Bold="True"></asp:Label></td>  
  149.     <td style="width: 332px">  
  150.         <asp:TextBox ID="txtPincode" runat="server"></asp:TextBox></td>  
  151.     </tr>  
  152.     <tr>  
  153.     <td>  
  154.         <asp:Button ID="btnRegisterUser" runat="server" Text="Registere User"  
  155.  OnClick="btnRegisterUser_Click" Font-Bold="True" /></td>  
  156.         <%--OnClientClick="javascript:ValtxtUserNm()" --%>  
  157.    
  158.     <td style="width: 332px">  
  159.         <asp:Button ID="btnCancel" runat="server" Text="Cancel"   
  160. OnClick="btnCancel_Click" Font-Bold="True" /></td>  
  161.     </tr>  
  162.     </table>  
  163.     </ContentTemplate></asp:UpdatePanel>  
  164.         <asp:Label ID="lblGuestUser" runat="server" ForeColor="RoyalBlue" Style="z-index: 100;  
  165.             left: 505px; position: absolute; top: 19px"></asp:Label>  
  166.     </div>  
  167.     <div>  
  168.         <asp:LinkButton ID="lnksignin" runat="server" PostBackUrl="~/Default.aspx">  
  169. Go to sign in page</asp:LinkButton>   
  170.     </div>  
  171.     </form>  
  172. </body>  
  173. </html>  
Passenger_Registration.aspx.cs
  1. using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Collections;  
  5. using System.Web;  
  6. using System.Web.Security;  
  7. using System.Web.UI;  
  8. using System.Web.UI.WebControls;  
  9. using System.Web.UI.WebControls.WebParts;  
  10. using System.Web.UI.HtmlControls;  
  11. using System.Data.SqlClient;  
  12.   
  13. public partial class Passenger_Registration : System.Web.UI.Page  
  14. {  
  15.     ConnClass connect = new ConnClass();  
  16.     protected void Page_Load(object sender, EventArgs e)  
  17.     {  
  18.         if (!IsPostBack)  
  19.         {  
  20.    
  21.             fillddlCountry();              
  22.             fillDay(ddlDOBDay);  
  23.             fillMonth(ddlDOBMonth);  
  24.             fillYear(ddlDOBYear);  
  25.         }  
  26.         lblGuestUser.Text = "Wel-Come-<b>Guest</b>";  
  27.         btnRegisterUser.Attributes.Add("onclick",  
  28.  "return ValtxtUserNm('"+txtUserNm.ClientID+"')");  
  29.     }  
  30.     #region fillDays  
  31.     private void fillDay(DropDownList ddlList)  
  32.     {  
  33.         ddlList.Items.Add(new ListItem("Day""Day"));  
  34.         ddlList.SelectedIndex = 0;  
  35.         int totalDay = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);  
  36.         for (int day = 1; day <= totalDay; day++)  
  37.         {  
  38.             ddlList.Items.Add(new ListItem(day.ToString(),day.ToString()));  
  39.         }  
  40.     }  
  41.     #endregion  
  42.     #region fill Month  
  43.     private void fillMonth(DropDownList ddlList)  
  44.     {  
  45.         ddlList.Items.Add(new ListItem("Month""Month"));  
  46.         ddlList.SelectedIndex=0;  
  47.         DateTime month=Convert.ToDateTime("1/1/2000");  
  48.         for (int mon = 0; mon < 12; mon++)  
  49.         {  
  50.             DateTime NxtMon = month.AddMonths(mon);  
  51.             ddlList.Items.Add(new ListItem(NxtMon.ToString("MMMM"),NxtMon.ToString("MMMM")));  
  52.         }  
  53.     }  
  54. #endregion  
  55.     #region Fill Year  
  56.     private void fillYear(DropDownList ddlList)  
  57.     {  
  58.         ddlList.Items.Add(new ListItem("Year""Year"));  
  59.         ddlList.SelectedIndex = 0;  
  60.         int initialYear = 1960;  
  61.         for (int yr = initialYear; yr <= Convert.ToInt32(DateTime.Now.Year); yr++)  
  62.         {  
  63.             ddlList.Items.Add(new ListItem(yr.ToString(), yr.ToString()));  
  64.         }  
  65.     }  
  66.     #endregion   
  67.     #region fill Country  
  68.     private void fillddlCountry()  
  69.     {  
  70.    
  71.         string sqlconn = connect.GetConnection();  
  72.         string Qry = "select * from CountryMaster";  
  73.         SqlDataAdapter sda = new SqlDataAdapter(Qry,sqlconn);  
  74.         DataSet ds = new DataSet();  
  75.         sda.Fill(ds);  
  76.         ddlCountry.DataSource = ds;  
  77.         ddlCountry.DataTextField = "CountryName";  
  78.         ddlCountry.DataValueField = "CountryID";  
  79.         ddlCountry.DataBind();  
  80.         ddlCountry.Items.Insert(0, "Select Country");  
  81.     }  
  82.     # endregion  
  83.     #region Button Reg Click  
  84.     protected void btnRegisterUser_Click(object sender, EventArgs e)  
  85.     {  
  86.         try  
  87.         {  
  88.             if (lblStatus.Text == "UserName Available" && txtUserNm.Text!=""  
  89.  && txtPassword.Text!="" && txtPassword.Text.Length>5)  
  90.             {  
  91.                 string unm = txtUserNm.Text.ToUpper();  
  92.                 string pwd = txtPassword.Text;  
  93.                 string fnm = txtFName.Text.ToUpper();  
  94.                 string lnm = txtLastNm.Text.ToUpper();  
  95.                 DateTime dob = Convert.ToDateTime(ddlDOBDay.SelectedItem.Text   
  96. + ddlDOBMonth.SelectedItem.Text + ddlDOBYear.SelectedItem.Text);  
  97.                 string d = dob.ToString("d");  
  98.                 string country = Convert.ToString(ddlCountry.SelectedItem);  
  99.                 string state = Convert.ToString(ddlState.SelectedItem);  
  100.                 string city = Convert.ToString(ddlCity.SelectedItem);  
  101.                 string email = txtEmail.Text;  
  102.                 string mob = txtMobileNo.Text;  
  103.                 int pin = Convert.ToInt32(txtPincode.Text);  
  104.                 string sqlconn = connect.GetConnection();  
  105.                 string qry = "Insert Into PassengerInfo values('" + unm + "',  
  106. '" + pwd + "','" + fnm + "',  
  107. '" + lnm + "','" + d + "','" + email + "','" + mob + "','" + country + "',  
  108. '" + state + "','" + city + "'," + pin + ")";  
  109.                 SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn);  
  110.                 DataSet ds = new DataSet();  
  111.                 sda.Fill(ds, "PassengerInfo");  
  112.                 Response.Write("<script language='javascript' type='text/javascript'>  
  113. alert('Record Inserted Successfully')</script>");  
  114.                 ClearForm();  
  115.                 Response.Redirect("Default.aspx");  
  116.             }  
  117.             else  
  118.             {  
  119.                 lblError.Text = "Can Not Blank & Charecter Must be 5 ";                               
  120.             }  
  121.         }  
  122.         catch (Exception)  
  123.         {  
  124.   
  125.         }  
  126.     }  
  127.     #endregion  
  128.     #region fill state  
  129.     protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)  
  130.     {  
  131.         filldllState();  
  132.     }  
  133.   
  134.     private void filldllState()  
  135.     {  
  136.         if (ddlCountry.SelectedValue != "Select Country")  
  137.         {  
  138.             string sqlconn = connect.GetConnection();  
  139.             string qry = "select * from StateMaster where CountryID="+ddlCountry.SelectedValue;  
  140.             SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn);  
  141.             DataSet ds = new DataSet();  
  142.             sda.Fill(ds);  
  143.             ddlState.DataSource = ds;  
  144.             ddlState.DataTextField = "StateName";  
  145.             ddlState.DataValueField = "StateID";  
  146.             ddlState.DataBind();  
  147.             ddlState.Items.Insert(0, "Select State");  
  148.         }  
  149.     }  
  150.     #endregion end state  
  151.     #region fill city  
  152.     protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)  
  153.     {  
  154.         if (ddlCountry.SelectedValue != "Select State")  
  155.         {  
  156.             string sqlconn = connect.GetConnection();  
  157.             string qry = "select * from CityMaster   
  158. where stateID=" + ddlState.SelectedValue + "  
  159. and CountryID=" + ddlCountry.SelectedValue;  
  160.             SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn);  
  161.             DataSet ds = new DataSet();  
  162.             sda.Fill(ds);  
  163.             ddlCity.DataSource = ds;  
  164.             ddlCity.DataTextField = "CityName";  
  165.             ddlCity.DataValueField="CityID";  
  166.             ddlCity.DataBind();  
  167.             ddlCity.Items.Insert(0,"Select City");  
  168.         }  
  169.     }  
  170.     #endregion  
  171.     #region Cancel Button Click  
  172.     protected void btnCancel_Click(object sender, EventArgs e)  
  173.     {  
  174.         ClearForm();  
  175.     }  
  176.     #endregion  
  177.     #region ClearForm Function  
  178.     private void ClearForm()  
  179.     {  
  180.         txtUserNm.Text = "";  
  181.         txtPassword.Text = "";  
  182.         txtFName.Text = "";  
  183.         txtLastNm.Text = "";  
  184.         ddlDOBDay.SelectedValue = "Day";  
  185.         ddlDOBMonth.SelectedValue = "Month";  
  186.         ddlDOBYear.SelectedValue = "Year";  
  187.         ddlCountry.SelectedValue = "Select Country";  
  188.         ddlState.SelectedValue = "Select State";  
  189.         ddlCity.SelectedValue = "Select City";  
  190.         txtEmail.Text = "";  
  191.         txtMobileNo.Text = "";  
  192.         txtPincode.Text = "";  
  193.     }  
  194.     #endregion  
  195.  
  196.     #region UserName Textbox Change Event  
  197.     protected void txtUserNm_TextChanged(object sender, EventArgs e)  
  198.     {  
  199.         if (!string.IsNullOrEmpty(txtUserNm.Text))  
  200.         {  
  201.             string scon = connect.GetConnection();  
  202.             string nm = txtUserNm.Text;  
  203.             string qry = "select UserName from PassengerInfo where UserName='" + nm + "'";  
  204.             SqlConnection conn = new SqlConnection(scon);  
  205.             conn.Open();  
  206.             SqlCommand cmd = new SqlCommand(qry, conn);  
  207.             SqlDataReader dr = cmd.ExecuteReader();  
  208.             if (dr.HasRows)  
  209.             {  
  210.                 //checkusername.Visible = true;  
  211.                 lblStatus.Text = "UserName Already Taken";  
  212.             }  
  213.             else  
  214.             {  
  215.                 //checkusername.Visible = true;  
  216.                 lblStatus.Text = "UserName Available";  
  217.             }  
  218.             conn.Close();  
  219.         }  
  220.     }  
  221.     #endregion  
  222. }  
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Admin.aspx.cs" Inherits="Admin" %>  
  2. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>  
  3.   
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  6.   
  7. <html xmlns="http://www.w3.org/1999/xhtml" >  
  8. <head runat="server">  
  9.   
  10.  <%--<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>--%>  
  11.  <script type="text/javascript" src="script/jquery-1.3.1.min.js"></script>  
  12.  <script type="text/javascript">  
  13.   $(document).ready(function () {              
  14.             $('a#showhidetrigger').click(function() {  
  15.                 $('#showhidetarget').toggle(400);  
  16.             });  
  17.         });  
  18.  </script>  
  19.    
  20. <script type="text/javascript">  
  21. $(document).ready(function(){  
  22.     $('a#A1').click(function(){  
  23.     $('#showpassenger').toggle(400);  
  24.     });  
  25.     });  
  26. </script>  
  27.   <%--  <script language="javascript" type="text/javascript">  
  28.     function chkTxtntBlank()  
  29.     {  
  30.     $find("modelPopupExtender1").show();  
  31.    
  32.     }  
  33.     </script>--%>  
  34.     <title>Admin Page</title>  
  35.     <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />  
  36.     <link rel="shortcut icon" href="Image/Train.ico" />  
  37. </head>  
  38. <body>  
  39.    <form id="form1" runat="server">  
  40.     <asp:ScriptManager ID="smMasterNew" EnablePageMethods="true" ScriptMode="Release"  
  41.             LoadScriptsBeforeUI="false" EnablePartialRendering="true" runat="server">  
  42.     </asp:ScriptManager>  
  43.        <asp:LoginStatus ID="LoginStatus1" runat="server" LoginText="Logout" LogoutPageUrl="~/Default.aspx"  
  44.            Style="z-index: 100; left: 688px; position: absolute; top: 19px" OnLoggingOut="LoginStatus1_LoggingOut" />  
  45.         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add New Train" />  
  46.         <a id="showhidetrigger" href="#">show/hide Train Information</a>  
  47.         <div id="showhidetarget">       
  48.         <asp:Label ID="lblresult" runat="server"/><asp:Button ID="btnShowPopup" runat="server" style="display:none" />          
  49.             <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"   
  50. TargetControlID="btnShowPopup" PopupControlID="pnlpopup"  
  51.                 CancelControlID="btnCancel" BackgroundCssClass="modalBackground"></cc1:ModalPopupExtender>  
  52.                     <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="230px" Width="333px">                
  53.                           <table cellpadding="0" cellspacing="0" align="center">  
  54.                             <tr style="background-color:#D55500">  
  55.                                 <td colspan="2" style=" height:10%; color:White;   
  56. font-weight:bold; font-size:larger" align="center">Train Details</td>  
  57.                             </tr>  
  58.                             <tr>  
  59.                                 <td style="width: 100px; height: 19px;">  
  60.                                     <b> Train Number</b></td>  
  61.                                 <td style="width: 106px; height: 24px;">  
  62.                                     <asp:TextBox ID="txtTrainNo" runat="server"/>  
  63.                                     </td>                                  
  64.                            </tr>  
  65.                            <tr>  
  66.                                <td style="width: 100px; height: 19px;">  
  67.                                     <b> Train Name</b></td>  
  68.                                <td style="width: 106px; height: 24px;">  
  69.                                     <asp:TextBox ID="txtTrainName" runat="server"/></td>  
  70.                           </tr>  
  71.                           <tr>   
  72.                               <td style="width: 100px; height: 24px;">  
  73.                                    <b> Source Station</b></td>  
  74.                               <td style="width: 106px; height: 24px;">  
  75.                                    <asp:TextBox ID="txtSourceStat" runat="server"/></td>  
  76.                          </tr>  
  77.                          <tr>   
  78.                              <td style="width: 100px; height: 19px;">  
  79.                                   <b> Destination Station</b></td>  
  80.                              <td style="width: 106px; height: 24px;">  
  81.                                   <asp:TextBox ID="txtDestStat" runat="server"/></td>  
  82.                        </tr>    
  83.                        <tr>                  
  84.                             <td style="width: 100px; height: 19px;">  
  85.                                  <b> Amount</b></td>  
  86.                             <td style="width: 106px; height: 24px;">  
  87.                                  <asp:TextBox ID="txtAmt" runat="server"/></td>  
  88.                       </tr>  
  89.                       <tr>                                                                            
  90.                             <td style="width: 100px; height: 24px;">  
  91.                                 <asp:Button ID="btnAddNew" runat="server" Text="Add New" OnClick="btnAddNew_Click"   
  92. OnClientClick="javascript:chkTxtntBlank()" /></td>  
  93.                             <td style="width: 106px; height: 24px;">  
  94.                                 <asp:Button ID="btnCancel" runat="server" Text="Cancel" /></td>  
  95.                             <td style="width: 1px"></td>  
  96.                     </tr>  
  97.                   </table>  
  98.             </asp:Panel>  
  99.    
  100.         <asp:GridView ID="GridView1" runat="server" DataKeyNames="TrainID" AutoGenerateColumns="False"   
  101.         Caption="List of Train Information" OnRowCancelingEdit="GridView1_RowCancelingEdit" CssClass="mGrid"   
  102.         OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"   
  103. PageSize="4" Height="159px" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging"   
  104. AllowSorting="True" OnSorting="GridView1_Sorting">  
  105.           <Columns>          
  106.              <asp:CommandField ShowEditButton="True" ShowDeleteButton="True"/>          
  107.              <asp:BoundField DataField="TrainID" HeaderText="Train ID" SortExpression="TrainID" />  
  108.              <asp:BoundField DataField="TrainNumber" HeaderText="Train No" SortExpression="TrainNumber" />                  
  109.              <asp:BoundField DataField="TrainName" HeaderText="Train Name" SortExpression="TrainName" />  
  110.              <asp:BoundField DataField="SourceStationName" HeaderText="Source Station"   
  111. SortExpression="SourceStationName" />  
  112.              <asp:BoundField DataField="DestinationStationName" HeaderText="Destination Station"   
  113. SortExpression="DestinationStationName" />  
  114.              <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />                       
  115.           </Columns>                      
  116.         </asp:GridView>                  
  117.     </div>           
  118.     <br />  
  119.         <a id="A1" href="#">show/hide Passenger Information</a>  
  120.     <div id="showpassenger">       
  121.         <asp:GridView ID="grdPassengerInfo" runat="server" AutoGenerateColumns="false"   
  122.           Caption="List of Passenger Info" CssClass="mGrid" PageSize="4" AllowPaging="True"  
  123.  OnPageIndexChanging="grdPassengerInfo_PageIndexChanging" AllowSorting="True" OnSorting="grdPassengerInfo_Sorting" >  
  124.             <Columns>  
  125.                 <asp:BoundField DataField="PassengerId" HeaderText="Passenger ID" >  
  126.                 <HeaderStyle CssClass="HideGridCol" />  
  127.                 <ItemStyle CssClass="HideGridCol" />  
  128.                 </asp:BoundField>  
  129.                 <asp:BoundField DataField="UserName" HeaderText="User Name" SortExpression="UserName" />  
  130.                 <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />  
  131.                 <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />  
  132.                 <asp:BoundField DataField="DOB" HeaderText="Date of Birth" SortExpression="DOB" />  
  133.                 <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />  
  134.                 <asp:BoundField DataField="MobileNo" HeaderText="Mobile No" SortExpression="MobileNo" />  
  135.                 <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />  
  136.                 <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />  
  137.                 <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />  
  138.             </Columns>  
  139.       </asp:GridView>  
  140.     </div>  
  141.   </form>  
  142. </body>  
  143. </html>  
Admin.aspx.cs
  1. using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Collections;  
  5. using System.Web;  
  6. using System.Web.Security;  
  7. using System.Web.UI;  
  8. using System.Web.UI.WebControls;  
  9. using System.Web.UI.WebControls.WebParts;  
  10. using System.Web.UI.HtmlControls;  
  11. using System.Data.SqlClient;  
  12.   
  13. public partial class Admin : System.Web.UI.Page  
  14. {  
  15.     ConnClass connect = new ConnClass();  
  16.     protected void Page_Load(object sender, EventArgs e)  
  17.     {  
  18.         if (!IsPostBack)  
  19.         {  
  20.             showTrainGrid();  
  21.             showPassengerGrid();                        
  22.   
  23.         }  
  24.     }  
  25.  
  26.     #region ShowPassenger Info  
  27.     private DataSet showPassengerGrid()  
  28.     {  
  29.         string scon = connect.GetConnection();  
  30.         SqlConnection conn = new SqlConnection(scon);  
  31.         conn.Open();  
  32.         string qry = "select * from PassengerInfo";  
  33.         SqlCommand cmd = new SqlCommand(qry, conn);  
  34.         //SqlDataReader sdr = cmd.ExecuteReader();  
  35.         //if (sdr.HasRows)  
  36.         //{  
  37.         //    while (sdr.Read())  
  38.         //    {  
  39.         //        grdPassengerInfo.DataSource = sdr;  
  40.         //        grdPassengerInfo.DataBind();  
  41.         //    }  
  42.         //}  
  43.         SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  44.         sda.TableMappings.Add("Table""PassengerInfo");  
  45.         DataSet ds = new DataSet("PassengerInfo");  
  46.         sda.Fill(ds);  
  47.         grdPassengerInfo.DataSource = ds;  
  48.         grdPassengerInfo.DataBind();  
  49.         if (grdPassengerInfo.Columns.Count > 0)  
  50.         {  
  51.             grdPassengerInfo.Columns[1].Visible = false;  
  52.         }  
  53.         return ds;  
  54.         //conn.Close();  
  55.     }  
  56.     #endregion  
  57.     #region gridTrain rowEditing  
  58.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)  
  59.     {  
  60.         //GridViewRow grd = (GridViewRow)GridView1.Rows[e.NewEditIndex];  
  61.         GridView1.EditIndex = e.NewEditIndex;  
  62.         showTrainGrid();  
  63.     }  
  64.     #endregion  
  65.     #region show Train Info  
  66.     private DataSet showTrainGrid()  
  67.     {  
  68.         string scon = connect.GetConnection();  
  69.         SqlConnection conn = new SqlConnection(scon);  
  70.         conn.Open();  
  71.         string qry = "select * from Train";  
  72.         SqlCommand cmd = new SqlCommand(qry, conn);  
  73.         //SqlDataReader sdr = cmd.ExecuteReader();  
  74.         //if (sdr.HasRows)  
  75.         //{  
  76.         //    while (sdr.Read())  
  77.         //    {  
  78.         //        GridView1.DataSource = sdr;  
  79.         //        GridView1.DataBind();  
  80.         //    }  
  81.         //}  
  82.         SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  83.         sda.TableMappings.Add("Table""Train");  
  84.         DataSet ds = new DataSet("Train");  
  85.         sda.Fill(ds);  
  86.          GridView1.DataSource = ds;  
  87.         GridView1.DataBind();  
  88.         if (GridView1.Columns.Count > 0)  
  89.         {  
  90.             GridView1.Columns[1].Visible = false;              
  91.         }  
  92.         return ds;  
  93.        // conn.Close();  
  94.     }  
  95.     #endregion  
  96.     #region Gridrow deleting  
  97.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)  
  98.     {  
  99.         ViewState["TrainID"] = GridView1.DataKeys[GridView1.SelectedIndex];  
  100.         string scon = connect.GetConnection();  
  101.         string query = "select * from TrainBookingDetails";  
  102.         SqlDataAdapter sda = new SqlDataAdapter(query, scon);  
  103.         DataSet ds = new DataSet();  
  104.         sda.Fill(ds);  
  105.     }  
  106.     #endregion  
  107.     #region Grid Updating  
  108.     protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)  
  109.     {  
  110.         string trainid=(GridView1.DataKeys[e.RowIndex].Value.ToString());  
  111.         string trainNo=((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;  
  112.         string trainNm = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;  
  113.         string source = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;  
  114.         string destination = ((TextBox)GridView1.Rows[e.RowIndex].Cells[5].Controls[0]).Text;  
  115.         string amt = ((TextBox)GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text;  
  116.         string scon = connect.GetConnection();  
  117.         SqlConnection conn=new SqlConnection(scon);  
  118.         conn.Open();  
  119.         string qry="Update Train set TrainNumber="+trainNo+" ,TrainName='"+trainNm+"',  
  120. SourceStationName='"+source+"',DestinationStationName='"+destination+"',Amount="+amt+"   
  121. where TrainID="+trainid+"";  
  122.         SqlCommand cmd = new SqlCommand(qry, conn);  
  123.         //cmd.ExecuteNonQuery();  
  124.         //conn.Close();  
  125.         SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  126.         DataSet ds = new DataSet();  
  127.         sda.Fill(ds);  
  128.         GridView1.EditIndex = -1;  
  129.         showTrainGrid();  
  130.     }  
  131.     #endregion  
  132.     #region grid Cancling  
  133.     protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)  
  134.     {  
  135.         GridView1.EditIndex = -1;  
  136.         showTrainGrid();  
  137.     }  
  138.     #endregion  
  139.     #region Add New Train  
  140.     protected void btnAddNew_Click(object sender, EventArgs e)  
  141.     {  
  142.         if (txtTrainNo.Text != "" && txtTrainName.Text != "" &&   
  143. txtSourceStat.Text != "" && txtDestStat.Text != "" && txtAmt.Text != "")  
  144.         {  
  145.             int trainNo = Convert.ToInt32(txtTrainNo.Text);  
  146.             string trainNM = txtTrainName.Text;  
  147.             string sourceSta = txtSourceStat.Text;  
  148.             string DestStat = txtDestStat.Text;  
  149.             double amt = Convert.ToDouble(txtAmt.Text);  
  150.             string scon = connect.GetConnection();  
  151.             string qry = "Insert Into Train (TrainNumber,TrainName,  
  152. SourceStationName,DestinationStationName,Amount)   
  153. Values(" + trainNo + ",'" + trainNM + "','" + sourceSta + "','" + DestStat + "'," + amt + ")";  
  154.             SqlDataAdapter sda = new SqlDataAdapter(qry, scon);  
  155.             DataSet ds = new DataSet();  
  156.             sda.Fill(ds);  
  157.             txtTrainNo.Text = "";  
  158.             txtTrainName.Text = "";  
  159.             txtSourceStat.Text = "";  
  160.             txtDestStat.Text = "";  
  161.             txtAmt.Text = "";  
  162.             showTrainGrid();  
  163.         }  
  164.         else  
  165.         {  
  166.             this.ModalPopupExtender1.Show();              
  167.         }  
  168.     }  
  169.     #endregion  
  170.     #region Popup extender  
  171.     protected void Button1_Click(object sender, EventArgs e)  
  172.     {  
  173.         this.ModalPopupExtender1.Show();  
  174.     }  
  175. #endregion  
  176.     #region gridTrain page indexing  
  177.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)  
  178.     {  
  179.         GridView1.PageIndex = e.NewPageIndex;  
  180.         showTrainGrid();  
  181.     }  
  182.     #endregion  
  183.     #region grid Passenger Page Indexing  
  184.     protected void grdPassengerInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)  
  185.     {  
  186.         grdPassengerInfo.PageIndex = e.NewPageIndex;  
  187.         showPassengerGrid();  
  188.     }  
  189.     #endregion  
  190.     protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)  
  191.     {  
  192.         LoginStatus n = new LoginStatus();  
  193.         n.Page.Session.Abandon();          
  194.     }  
  195.     protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)  
  196.     {  
  197.         string sortExpression = e.SortExpression;  
  198.         if (GridViewSortDirection == SortDirection.Ascending)  
  199.         {  
  200.             GridViewSortDirection = SortDirection.Descending;  
  201.             SortGridTrainView(sortExpression, DESCENDING);  
  202.         }  
  203.         else  
  204.         {  
  205.             GridViewSortDirection = SortDirection.Ascending;  
  206.             SortGridTrainView(sortExpression, ASCENDING);  
  207.         }  
  208.     }  
  209.   
  210.     private void SortGridTrainView(string sortExpression, string Direction)  
  211.     {  
  212.                 DataTable  dtable = showTrainGrid().Tables[0];  
  213.                 DataView dv = new DataView(dtable);  
  214.                 dv.Sort = sortExpression + Direction;  
  215.                 GridView1.DataSource = dv;  
  216.                 GridView1.DataBind();  
  217.     }  
  218.     private const string ASCENDING = " ASC";  
  219.     private const string DESCENDING = " DESC";  
  220.     protected void grdPassengerInfo_Sorting(object sender, GridViewSortEventArgs e)  
  221.     {  
  222.         string sortExpression = e.SortExpression;  
  223.         if (GridViewSortDirection == SortDirection.Ascending)  
  224.         {  
  225.             GridViewSortDirection = SortDirection.Descending;  
  226.             SortGridView(sortExpression, DESCENDING);  
  227.         }  
  228.         else  
  229.         {  
  230.             GridViewSortDirection = SortDirection.Ascending;  
  231.             SortGridView(sortExpression, ASCENDING);  
  232.         }  
  233.     }  
  234.   
  235.     private void SortGridView(string sortExpression, string Direction)  
  236.     {  
  237.         DataTable dt = showPassengerGrid().Tables[0];  
  238.   
  239.             DataView dv = new DataView(dt);  
  240.             dv.Sort = sortExpression + Direction;  
  241.             grdPassengerInfo.DataSource = dv;  
  242.             grdPassengerInfo.DataBind();  
  243.    
  244.   
  245.    
  246.     }  
  247.     public SortDirection GridViewSortDirection  
  248.     {  
  249.         get  
  250.         {  
  251.             if (ViewState["sortDirection"] == null)  
  252.                 ViewState["sortDirection"] = SortDirection.Ascending;  
  253.             return (SortDirection)ViewState["sortDirection"];  
  254.         }  
  255.         set  
  256.         {  
  257.             ViewState["sortDirection"] = value;  
  258.         }  
  259.     }  
  260.   
  261. }  
  262.   
  263.   
  264.  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="BookingDetails.aspx.cs" Inherits="BookingDetails" %>  
  265.   
  266. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0  
  267.  Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  268.   
  269. <html xmlns="http://www.w3.org/1999/xhtml" >  
  270. <head runat="server">  
  271.     <title>Booking Details</title>  
  272.      <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />  
  273.     <link rel="shortcut icon" href="Image/Train.ico" />  
  274. </head>  
  275. <body>  
  276.     <form id="form1" runat="server">  
  277.     <h1>List of Trains are Booked by   
  278.         <asp:Label ID="lblsession" runat="server"  ForeColor="RoyalBlue"></asp:Label>...</h1>  
  279.     <div>  
  280.         <asp:LoginStatus ID="LoginStatus1" runat="server"   
  281. LogoutAction="Redirect" LogoutPageUrl="~/Default.aspx"  
  282.             Style="z-index: 100; left: 883px; position: absolute; top: 32px" LoginText="Logout" />  
  283.         <asp:GridView ID="grdPassengerInfo" runat="server"   
  284. AutoGenerateColumns="False" AllowPaging="True" CssClass="mGrid"   
  285.         PageSize="5" OnPageIndexChanging="grdPassengerInfo_PageIndexChanging"  
  286.  OnRowDeleting="grdPassengernfo_RowDeleting" AllowSorting="True"   
  287. AutoGenerateDeleteButton="True" OnSorting="grdPassengerInfo_Sorting">  
  288.         <Columns>  
  289.         <asp:BoundField DataField="TrainBookingID" HeaderText="TrainBookingID">  
  290.        <HeaderStyle CssClass="HideGridCol" />  
  291.         <ItemStyle CssClass="HideGridCol" />  
  292.         </asp:BoundField >  
  293.         <asp:BoundField DataField="FirstName" HeaderText="Fist Name" SortExpression="FirstName" />  
  294.         <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />  
  295.         <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />  
  296.         <asp:BoundField DataField="MobileNo" HeaderText="Mobile No." SortExpression="MobileNo" />  
  297.         <asp:BoundField DataField="TrainNumber" HeaderText="Train Number" SortExpression="TrainNumber" />  
  298.         <asp:BoundField DataField="TrainName" HeaderText="Train Name" SortExpression="TrainName" />  
  299.         <asp:BoundField DataField="SourceStation" HeaderText="Source Station" SortExpression="SourceStation" />  
  300.         <asp:BoundField DataField="DestinationStation"   
  301. HeaderText="Destination Station" SortExpression="DestinationStation" />  
  302.         <asp:BoundField DataField="PaymentBy" HeaderText="Payment By" SortExpression="PaymentBy" />  
  303.         <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />  
  304.         </Columns>          
  305.         </asp:GridView>  
  306.     </div>  
  307.     </form>  
  308. </body>  
  309. </html>  
BookingDetails.aspx.cs
  1. using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Collections;  
  5. using System.Web;  
  6. using System.Web.Security;  
  7. using System.Web.UI;  
  8. using System.Web.UI.WebControls;  
  9. using System.Web.UI.WebControls.WebParts;  
  10. using System.Web.UI.HtmlControls;  
  11. using System.Data.SqlClient;  
  12. using System.Diagnostics;  
  13. using System.Collections.Generic;  
  14.   
  15. public partial class BookingDetails : System.Web.UI.Page  
  16. {  
  17.     ConnClass connect = new ConnClass();  
  18.     #region Page_Load  
  19.     protected void Page_Load(object sender, EventArgs e)  
  20.     {  
  21.         if (!IsPostBack)  
  22.         {  
  23.             string scon = connect.GetConnection();  
  24.             string uid = Request.QueryString["PassengerId"];  
  25.             string qry = "select * from TrainBookingDetails  
  26.  where status='" + 0 + "' and  PassengerID=" + uid;  
  27.             SqlDataAdapter sda = new SqlDataAdapter(qry, scon);  
  28.             DataSet ds = new DataSet();  
  29.             sda.Fill(ds);  
  30.             grdPassengerInfo.DataSource = ds;  
  31.             grdPassengerInfo.DataBind();  
  32.             if (grdPassengerInfo.Columns.Count > 0)  
  33.             {  
  34.                 grdPassengerInfo.Columns[0].Visible = false;  
  35.             }  
  36.         }  
  37.         Response.Cache.SetAllowResponseInBrowserHistory(true);  
  38.         lblsession.Text=Convert.ToString(Session["UserName"]);  
  39.     }  
  40. #endregion  
  41.     #region fill grid  
  42.     private DataSet bindGrid()  
  43.     {  
  44.         string scon = connect.GetConnection();  
  45.         string uid = Request.QueryString["PassengerId"];  
  46.         string qry = "select * from TrainBookingDetails  
  47.  where status='" + false + "' and  PassengerID=" + uid;  
  48.         SqlDataAdapter sda = new SqlDataAdapter(qry, scon);  
  49.         DataSet ds = new DataSet();  
  50.         sda.Fill(ds);  
  51.         grdPassengerInfo.DataSource = ds;  
  52.         grdPassengerInfo.DataBind();  
  53.         if (grdPassengerInfo.Columns.Count > 0)  
  54.         {  
  55.             grdPassengerInfo.Columns[1].Visible = false;  //hide grid column at run time  
  56.    
  57.         }  
  58.         return ds;  
  59.     }  
  60.     #endregion  
  61.     #region pageIndexing  
  62.     protected void grdPassengerInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)  
  63.     {  
  64.         grdPassengerInfo.PageIndex = e.NewPageIndex;  
  65.         bindGrid();  
  66.     }  
  67.     #endregion  
  68.    
  69.     protected void grdPassengerInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)  
  70.     {  
  71.         //GridViewRow row = (GridViewRow)grdPassengerInfo.Rows[e.RowIndex-1];          
  72.         //string scon = connect.GetConnection();  
  73.         ////string qry = "delete from TrainBookingDetails   
  74. where TrainBookingID=" + row.Cells[1].Text + "";  
  75.         //string qry = "Update TrainBookingDetails set [Status]='"+true+"'   
  76. where  TrainBookingID=" + row.Cells[1].Text + "";  
  77.         //SqlDataAdapter sda = new SqlDataAdapter(qry, scon);  
  78.         //DataSet ds = new DataSet();  
  79.         //sda.Fill(ds);  
  80.         //bindGrid();  
  81.     }  
  82.   
  83.      #region grid row deleting  
  84.     protected void grdPassengernfo_RowDeleting(object sender, GridViewDeleteEventArgs e)  
  85.     {  
  86.         GridViewRow row = (GridViewRow)grdPassengerInfo.Rows[e.RowIndex];  
  87.         string scon = connect.GetConnection();  
  88.         //string qry = "delete from TrainBookingDetails   
  89. where TrainBookingID=" + row.Cells[1].Text + "";  
  90.         string qry = "Update TrainBookingDetails set [Status]='" + true + "'   
  91. where  TrainBookingID=" + row.Cells[1].Text + "";  
  92.         SqlDataAdapter sda = new SqlDataAdapter(qry, scon);  
  93.         DataSet ds = new DataSet();  
  94.         sda.Fill(ds);  
  95.         bindGrid();  
  96.     }  
  97.      #endregion  
  98.   
  99.     private const string ASCENDING = " ASC";  
  100.     private const string DESCENDING = " DESC";  
  101.     protected void grdPassengerInfo_Sorting(object sender, GridViewSortEventArgs e)  
  102.     {  
  103.         string sortExpression = e.SortExpression;  
  104.   
  105.         if (GridViewSortDirection == SortDirection.Ascending)  
  106.         {  
  107.             GridViewSortDirection = SortDirection.Descending;  
  108.             SortGridView(sortExpression, DESCENDING);  
  109.         }  
  110.         else  
  111.         {  
  112.             GridViewSortDirection = SortDirection.Ascending;  
  113.             SortGridView(sortExpression, ASCENDING);  
  114.         }     
  115.    
  116.     }  
  117.     private void SortGridView(string sortExpression, string direction)  
  118.     {  
  119.         //  You can cache the DataTable for improving performance  
  120.         DataTable dt = bindGrid().Tables[0];  
  121.         DataView dv = new DataView(dt);  
  122.         dv.Sort = sortExpression + direction;  
  123.         grdPassengerInfo.DataSource = dv;  
  124.         grdPassengerInfo.DataBind();      
  125.     }  
  126.     public SortDirection GridViewSortDirection  
  127.     {  
  128.         get  
  129.         {  
  130.             if (ViewState["sortDirection"] == null)  
  131.                 ViewState["sortDirection"] = SortDirection.Ascending;  
  132.   
  133.             return (SortDirection)ViewState["sortDirection"];  
  134.         }  
  135.         set { ViewState["sortDirection"] = value; }  
  136.     }  
  137. }  
  138.   
  139.   
  140.  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="BookTrains.aspx.cs" Inherits="PassengerProfile" %>  
  141.   
  142. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0   
  143. Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  144.   
  145. <html xmlns="http://www.w3.org/1999/xhtml" >  
  146. <head runat="server">  
  147.     <title>Untitled Page</title>  
  148.      <link rel="shortcut icon" href="Image/Train.ico" />  
  149. </head>  
  150. <body>  
  151.     <form id="form1" runat="server">  
  152.     <div>  
  153.     <asp:Label ID="lblHi" runat="server" Text="Hi" style="z-index: 102; left:   
  154. 662px; position: absolute; top: 18px"></asp:Label>  
  155.     <asp:Label ID="lblName" runat="server" Text="" style="z-index: 101; left: 687px;   
  156. position: absolute; top: 17px"></asp:Label><br />      
  157.     <asp:LinkButton ID="lnkeditProfile" runat="server">Book Train</asp:LinkButton>   
  158.     <table>  
  159.     <tr>  
  160.     <td>  
  161.         <asp:Label ID="lblFName" runat="server" Text="First Name" Font-Bold="True"></asp:Label></td>  
  162.     <td style="width: 199px">  
  163.         <asp:TextBox ID="txtFName" runat="server" ReadOnly="True"></asp:TextBox></td>  
  164.     </tr>  
  165.      <tr>  
  166.     <td>  
  167.         <asp:Label ID="lblLName" runat="server" Text="Last Name" Font-Bold="True"></asp:Label></td>  
  168.     <td style="width: 199px">  
  169.         <asp:TextBox ID="txtLName" runat="server" ReadOnly="True"></asp:TextBox></td>  
  170.     </tr>  
  171.      <tr>  
  172.     <td>  
  173.         <asp:Label ID="lblCountry" runat="server" Text="Country" Font-Bold="True"></asp:Label></td>  
  174.     <td style="width: 199px">  
  175.         <asp:DropDownList ID="ddlCountry" runat="server"   
  176. AutoPostBack="True" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged">  
  177.         </asp:DropDownList></td>  
  178.     </tr>  
  179.      <tr>  
  180.     <td>  
  181.         <asp:Label ID="lblState" runat="server" Text="State" Font-Bold="True"></asp:Label></td>  
  182.     <td style="width: 199px">  
  183.         <asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True"   
  184. OnSelectedIndexChanged="ddlState_SelectedIndexChanged">  
  185.         </asp:DropDownList></td>  
  186.     </tr>  
  187.      <tr>  
  188.     <td>  
  189.         <asp:Label ID="lblCity" runat="server" Text="City" Font-Bold="True"></asp:Label></td>  
  190.     <td style="width: 199px">  
  191.         <asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="True" >  
  192.         </asp:DropDownList></td>  
  193.     </tr>  
  194.     <tr>  
  195.     <td>  
  196.         <asp:Label ID="lblPincode" runat="server" Text="PinCode" Font-Bold="True"></asp:Label></td>  
  197.     <td style="width: 199px">  
  198.         <asp:TextBox ID="txtPincode" runat="server" ReadOnly="True"></asp:TextBox></td>  
  199.     </tr>  
  200.      <tr>  
  201.     <td>  
  202.         <asp:Label ID="lblMob" runat="server" Text="Mobile Number" Font-Bold="True"></asp:Label></td>  
  203.     <td style="width: 199px">  
  204.         <asp:TextBox ID="txtMobNo" runat="server" ReadOnly="True"></asp:TextBox></td>  
  205.     </tr>  
  206.          <tr>  
  207.     <td>  
  208.         <asp:Label ID="lblEmail" runat="server" Text="Email" Font-Bold="True"></asp:Label></td>  
  209.     <td style="width: 199px">  
  210.         <asp:TextBox ID="txtEmail" runat="server" ReadOnly="True"></asp:TextBox></td>  
  211.     </tr>  
  212.          <tr>  
  213.     <td>  
  214.         <asp:Label ID="lblTrainName" runat="server" Text="Train Name"   
  215. Font-Bold="True"></asp:Label></td>  
  216.     <td style="width: 199px">  
  217.         <asp:DropDownList ID="ddlTrainName" runat="server" AutoPostBack="True"   
  218.                 OnSelectedIndexChanged="ddlTrainName_SelectedIndexChanged">  
  219.         </asp:DropDownList>  
  220.         <asp:RequiredFieldValidator ID="RequiredFieldValidator1"  
  221.  runat="server" ControlToValidate="ddlTrainName"  
  222.             ErrorMessage=" Select Train Name"  
  223.             InitialValue="Select Train" ToolTip="Select Train Name">*</asp:RequiredFieldValidator></td>  
  224.     </tr>  
  225.          <tr>  
  226.     <td>  
  227.         <asp:Label ID="lblTrainNo" runat="server" Text="Train Number" Font-Bold="True"></asp:Label></td>  
  228.     <td style="width: 199px">  
  229.         <asp:TextBox ID="txtTrainNo" runat="server" ReadOnly="True"></asp:TextBox></td>  
  230.     </tr>  
  231.          <tr>  
  232.     <td>  
  233.         <asp:Label ID="lblSourceStation" runat="server"   
  234. Text="Source Station" Font-Bold="True"></asp:Label></td>  
  235.     <td style="width: 199px">  
  236.         <asp:DropDownList ID="ddlSourceStation" runat="server">  
  237.         </asp:DropDownList></td>  
  238.     </tr>  
  239.     <tr>  
  240.     <td>  
  241.         <asp:Label ID="lblDestinationStation" runat="server"   
  242. Text="Destination Station" Font-Bold="True"></asp:Label></td>  
  243.     <td style="width: 199px">  
  244.         <asp:DropDownList ID="ddlDestinationStation" runat="server">  
  245.         </asp:DropDownList></td>  
  246.     </tr>  
  247.     <tr>  
  248.     <td>  
  249.         <asp:Label ID="lblPaymentBy" runat="server" Text="Payment By" Font-Bold="True">  
  250. </asp:Label></td>  
  251.     <td style="width: 199px">  
  252.         <asp:DropDownList ID="ddlPaymentBy" runat="server">  
  253.         </asp:DropDownList>  
  254.         <asp:RequiredFieldValidator ID="RequiredFieldValidator2"  
  255.  runat="server" ControlToValidate="ddlPaymentBy"  
  256.             ErrorMessage=" Select Card Type" InitialValue="Select Card Type"  
  257.               ToolTip="Select Card Type">*</asp:RequiredFieldValidator></td>  
  258.     </tr>  
  259.         <tr>  
  260.     <td>  
  261.         <asp:Label ID="lblAmount" runat="server" Text="Amount" Font-Bold="True"></asp:Label></td>  
  262.     <td style="width: 199px">  
  263.         <asp:TextBox ID="txtAmount" runat="server" ReadOnly="True"></asp:TextBox></td>  
  264.     </tr>  
  265.   
  266.      <tr>  
  267.     <td>  
  268.         <asp:Button ID="btnBKTrainTk" runat="server"   
  269. Text="Book Train Ticket" OnClick="btnBKTrainTk_Click" Font-Bold="True" /></td>  
  270.     <td style="width: 199px">  
  271.          <asp:LinkButton ID="lnkEdit" runat="server" OnClick="lnkEdit_Click">  
  272. Edit UserInfo</asp:LinkButton>  
  273.         <asp:LinkButton ID="lnkUpdate" runat="server" OnClick="lnkUpdate_Click">  
  274. Update UserInfo</asp:LinkButton></td>  
  275.     </tr>  
  276.     </table>  
  277.     </div>  
  278.         <asp:ValidationSummary ID="ValidationSummary1" runat="server" />  
  279.     </form>  
  280. </body>  
  281. </html>  
BookTrains.aspx.cs
  1. using System;  
  2. using System.Data;  
  3. using System.Configuration;  
  4. using System.Collections;  
  5. using System.Web;  
  6. using System.Web.Security;  
  7. using System.Web.UI;  
  8. using System.Web.UI.WebControls;  
  9. using System.Web.UI.WebControls.WebParts;  
  10. using System.Web.UI.HtmlControls;  
  11. using System.Data.SqlClient;  
  12. using System.Collections.Specialized;  
  13.   
  14. public partial class PassengerProfile : System.Web.UI.Page  
  15. {  
  16.     ConnClass connect = new ConnClass();  
  17.     #region Page_Load  
  18.     protected void Page_Load(object sender, EventArgs e)  
  19.     {  
  20.         if (!IsPostBack)  
  21.         {  
  22.             string unm = Convert.ToString(Session["UserName"]);  
  23.             lblName.Text = unm;  
  24.             lnkEdit.Text = "Edit User Info";  
  25.             lnkUpdate.Visible = false;  
  26.             if (Request.QueryString["url1"] != "")  
  27.             {  
  28.                 HttpRequest q = Request;  
  29.                 NameValueCollection n = q.QueryString;  
  30.                 if (n.HasKeys())  
  31.                 {  
  32.              int uid = Convert.ToInt32(n.Get(0));  
  33.            string sqlCon = connect.GetConnection();  
  34.              SqlConnection scon = new SqlConnection(sqlCon);  
  35.           string qry = "select * from PassengerInfo where PassengerId=" + uid;  
  36.           SqlCommand cmd = new SqlCommand(qry, scon);  
  37.             SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  38.              DataTable dt = new DataTable();  
  39.                sda.Fill(dt);  
  40.   
  41.             if (dt.Rows.Count > 0)  
  42.                 {  
  43.                   txtFName.Text = dt.Rows[0]["FirstName"].ToString();  
  44.             txtLName.Text = dt.Rows[0]["LastName"].ToString();  
  45.   
  46.               ddlCountry.DataSource = dt;  
  47.                ddlCountry.DataTextField = "Country";  
  48.                ddlCountry.DataValueField = "PassengerId";  
  49.                ddlCountry.DataBind();  
  50.   
  51.                   ddlState.DataSource = dt;  
  52.               ddlState.DataTextField = "State";  
  53.                 ddlState.DataValueField = "PassengerId";  
  54.              ddlState.DataBind();  
  55.   
  56.          ddlCity.DataSource = dt;  
  57.                ddlCity.DataTextField = "City";  
  58.                ddlCity.DataValueField = "PassengerId";  
  59.                 ddlCity.DataBind();  
  60.   
  61.                 txtPincode.Text = dt.Rows[0]["Pincode"].ToString();  
  62.                  txtMobNo.Text = dt.Rows[0]["MobileNo"].ToString();  
  63.                   txtEmail.Text = dt.Rows[0]["Email"].ToString();  
  64.            }  
  65.          }  
  66.   
  67.             }  
  68.             fillTrainInfo();  
  69.             ddlPaymentBy.Items.Add("Credit Card");  
  70.             ddlPaymentBy.Items.Add("Debit Card");  
  71.             ddlPaymentBy.Items.Insert(0, "Select Card Type");  
  72.         }  
  73.    
  74.     }  
  75.     #endregion  
  76.     #region Fill Train Dropdown  
  77.     private void fillTrainInfo()  
  78.     {  
  79.         string sqlCon = connect.GetConnection();  
  80.         SqlConnection scon = new SqlConnection(sqlCon);  
  81.         string query = "select * from Train";  
  82.         SqlCommand cmd = new SqlCommand(query, scon);  
  83.         SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  84.         DataTable dt = new DataTable();  
  85.         sda.Fill(dt);  
  86.         if (dt.Rows.Count > 0)  
  87.         {  
  88.             ddlTrainName.DataSource = dt;  
  89.             ddlTrainName.DataTextField = "TrainName";  
  90.             ddlTrainName.DataValueField = "TrainID";  
  91.             ddlTrainName.DataBind();  
  92.             ddlTrainName.Items.Insert(0, "Select Train");              
  93.         }  
  94.     }  
  95.     #endregion  
  96.     #region Fill All Train Info  
  97.     protected void ddlTrainName_SelectedIndexChanged(object sender, EventArgs e)  
  98.     {  
  99.         if (ddlTrainName.SelectedValue != "Select Train")  
  100.         {  
  101.      string sqlconn = connect.GetConnection();  
  102.     SqlConnection scon = new SqlConnection(sqlconn);  
  103.      string qry = "select * from Train where TrainID=" + ddlTrainName.SelectedValue;  
  104.    ViewState["TRAINID"] = ddlTrainName.SelectedValue;  
  105.       int trainid = Convert.ToInt32(ViewState["TRAINID"]);  
  106.     SqlCommand cmd = new SqlCommand(qry, scon);  
  107.      SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  108.      DataTable dt = new DataTable();  
  109.      sda.Fill(dt);  
  110.     if (dt.Rows.Count > 0)  
  111.      {  
  112.         txtTrainNo.Text = dt.Rows[0]["TrainNumber"].ToString();  
  113.   
  114.         ddlSourceStation.DataSource = dt;  
  115.          ddlSourceStation.DataTextField = "SourceStationName";  
  116.        ddlSourceStation.DataValueField = "TrainID";  
  117.      ddlSourceStation.DataBind();  
  118.   
  119.      ddlDestinationStation.DataSource = dt;  
  120.        ddlDestinationStation.DataTextField = "DestinationStationName";  
  121.        ddlDestinationStation.DataValueField = "TrainID";  
  122.     ddlDestinationStation.DataBind();  
  123.   
  124.                 txtAmount.Text = dt.Rows[0]["Amount"].ToString();  
  125.             }  
  126.         }  
  127.     }  
  128.     #endregion   
  129.     #region Insert Book Train info  
  130.     protected void btnBKTrainTk_Click(object sender, EventArgs e)  
  131.     {  
  132.         string fnm = txtFName.Text;  
  133.         string lnm = txtLName.Text;  
  134.         string country = Convert.ToString(ddlCountry.SelectedItem);  
  135.         string state = Convert.ToString(ddlState.SelectedItem);  
  136.         string city = Convert.ToString(ddlCity.SelectedItem);  
  137.         int pin = Convert.ToInt32(txtPincode.Text);  
  138.         string mob = txtMobNo.Text;  
  139.         string email = txtEmail.Text;  
  140.         string trainNm = Convert.ToString(ddlTrainName.SelectedItem);  
  141.         int trainNo = Convert.ToInt32(txtTrainNo.Text);  
  142.         string soureceStation= Convert.ToString(ddlSourceStation.SelectedItem);  
  143.         string DestStation= Convert.ToString(ddlDestinationStation.SelectedItem);  
  144.         string payBy = Convert.ToString(ddlPaymentBy.SelectedItem);  
  145.         double amt = Convert.ToDouble (txtAmount.Text);  
  146.         int trainid = Convert.ToInt32(ViewState["TRAINID"]);  
  147.          if (Request.QueryString["url1"] != "")  
  148.             {  
  149.                 HttpRequest q = Request;  
  150.                 NameValueCollection n = q.QueryString;  
  151.                 if (n.HasKeys())  
  152.                 {  
  153.          int uid = Convert.ToInt32(n.Get(0));                  
  154.         string scon = connect.GetConnection();  
  155.     string query = "insert into TrainBookingDetails(FirstName,LastName,Country,State,City,  
  156.    MobileNo,Email,PinCode,TrainNumber,TrainName,SourceStation,DestinationStation,PaymentBy,  
  157.     Amount,TrainID,PassengerID,status)values('" + fnm + "','" + lnm + "','" + country + "',  
  158.     '" + state + "','" + city + "','" + mob + "','" + email + "'," + pin + "," + trainNo + ",  
  159.    '" + trainNm + "','" + soureceStation + "','" + DestStation + "',  
  160.         '" + payBy + "'," + amt + "," + trainid + "," + uid + ","+0+")";  
  161.           SqlDataAdapter sda = new SqlDataAdapter(query, scon);  
  162.                     DataSet ds = new DataSet();  
  163.                     sda.Fill(ds);  
  164.                     Response.Write("<script language='javascript'   
  165. type='text/javascript'>alert('Train Booked Successfully..')  
  166.                     </script>");  
  167.                     string url = "BookingDetails.aspx?PassengerId=" + uid;  
  168.                     Response.Redirect(url);  
  169.                 }  
  170.     }  
  171. }  
  172.     private void ClaearForm()  
  173.     {  
  174.         txtFName.Text="";  
  175.         txtLName.Text="";  
  176.         ddlCountry.SelectedIndex = -1;  
  177.         ddlState.SelectedIndex = -1;  
  178.         ddlCity.SelectedIndex = -1;  
  179.         txtPincode.Text = "";  
  180.         txtMobNo.Text="";  
  181.         txtEmail.Text="";  
  182.         ddlTrainName.SelectedValue = "Select Train";  
  183.         txtTrainNo.Text = "";  
  184.         ddlSourceStation.SelectedIndex = -1;  
  185.         ddlDestinationStation.SelectedIndex = -1;  
  186.         ddlPaymentBy.SelectedValue = "Select Card Type";  
  187.         txtAmount.Text="";  
  188.     }  
  189.     #endregion  
  190.  
  191.     #region edit user profile  
  192. protected void lnkEdit_Click(object sender, EventArgs e)  
  193.     {         
  194.         txtFName.ReadOnly = false;  
  195.         txtLName.ReadOnly = false;  
  196.   
  197.         string sqlconn = connect.GetConnection();  
  198.         string Qry = "select * from CountryMaster";  
  199.         SqlDataAdapter sda = new SqlDataAdapter(Qry, sqlconn);  
  200.         DataSet ds = new DataSet();  
  201.         sda.Fill(ds);  
  202.         ddlCountry.DataSource = ds;  
  203.         ddlCountry.DataTextField = "CountryName";  
  204.         ddlCountry.DataValueField = "CountryID";  
  205.         ddlCountry.DataBind();  
  206.         ddlCountry.Items.Insert(0, "Select Country");  
  207.   
  208.         txtPincode.ReadOnly = false;  
  209.         txtMobNo.ReadOnly = false;  
  210.         txtEmail.ReadOnly = false;  
  211.    
  212.         btnBKTrainTk.Visible = false;  
  213.         lnkEdit.Visible = false;  
  214.         lnkUpdate.Visible = true;  
  215.     }  
  216.     #endregion   
  217.     #region fill state  
  218.     protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)  
  219.     {  
  220.         if (ddlCountry.SelectedValue != "Select Country")  
  221.         {  
  222.             string sqlconn = connect.GetConnection();  
  223.             string qry = "select * from StateMaster where   
  224. CountryID=" + ddlCountry.SelectedValue;  
  225.             SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn);  
  226.             DataSet ds = new DataSet();  
  227.             sda.Fill(ds);  
  228.             ddlState.DataSource = ds;  
  229.             ddlState.DataTextField = "StateName";  
  230.             ddlState.DataValueField = "StateID";  
  231.             ddlState.DataBind();  
  232.             ddlState.Items.Insert(0, "Select State");  
  233.         }  
  234.     }  
  235.     #endregion  
  236.     #region Fill City  
  237.     protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)  
  238.     {  
  239.         if (ddlCountry.SelectedValue != "Select State")  
  240.         {  
  241.             string sqlconn = connect.GetConnection();  
  242.             string qry = "select * from CityMaster   
  243. where stateID=" + ddlState.SelectedValue + "and   
  244. CountryID=" + ddlCountry.SelectedValue;  
  245.             SqlDataAdapter sda = new SqlDataAdapter(qry, sqlconn);  
  246.             DataSet ds = new DataSet();  
  247.             sda.Fill(ds);  
  248.             ddlCity.DataSource = ds;  
  249.             ddlCity.DataTextField = "CityName";  
  250.             ddlCity.DataValueField = "CityID";  
  251.             ddlCity.DataBind();  
  252.             ddlCity.Items.Insert(0, "Select City");  
  253.         }  
  254.     }  
  255.     #endregion  
  256.     #region update UserInfo  
  257.     protected void lnkUpdate_Click(object sender, EventArgs e)  
  258.     {  
  259.       if (Request.QueryString["url1"] != "")  
  260.          {  
  261.            HttpRequest q = Request;  
  262.            NameValueCollection n = q.QueryString;  
  263.            if (n.HasKeys())  
  264.             {  
  265.              int uid = Convert.ToInt32(n.Get(0));  
  266.              string fnm = txtFName.Text;  
  267.              string lnm = txtLName.Text;  
  268.              string country = Convert.ToString(ddlCountry.SelectedItem);  
  269.              string state = Convert.ToString(ddlState.SelectedItem);  
  270.              string city = Convert.ToString(ddlCity.SelectedItem);  
  271.              int pin = Convert.ToInt32(txtPincode.Text);  
  272.              string mob = txtMobNo.Text;  
  273.              string email = txtEmail.Text;  
  274.   
  275.              string scon = connect.GetConnection();  
  276.              string qry="Update PassengerInfo Set FirstName='"+fnm+"',  
  277. LastName='"+lnm+"',  
  278.             Country='"+country+"',State='"+state+"',City='"+city+"',  
  279. Pincode="+pin+",MobileNo='"+mob+"',  
  280.               Email='"+email+"' where PassengerId="+uid+"";  
  281.              SqlDataAdapter sda = new SqlDataAdapter(qry, scon);  
  282.             DataSet ds = new DataSet();  
  283.             sda.Fill(ds);  
  284.             Response.Write("Updated....");  
  285.            }  
  286.            lnkEdit.Visible = true;  
  287.            btnBKTrainTk.Visible = true;  
  288.            lnkUpdate.Visible = false;  
  289.      }  
  290.     }  
  291.     #endregion  
  292.     protected void btnCancel_Click(object sender, EventArgs e)  
  293.     {  
  294.        // ClaearForm();  
  295.     }  
  296. }