Esempio n. 1
0
        protected void BtnCreateFlight1_Click(object sender, EventArgs e)
        {
            try
            {
                using (AirlineEntities1 cntx = new AirlineEntities1())
                {
                    FlightDetail addFlight = new FlightDetail();

                    addFlight.FlightNo = FlightNumber1TextBox.Text;
                    addFlight.FromCity = FromCity1DropDown.Text;
                    addFlight.ToCity   = ToCity1DropDown.Text;
                    if (DateOfDeparture1Textbox.Text != string.Empty)
                    {
                        addFlight.DateofDeparture = Convert.ToDateTime(DateOfDeparture1Textbox.Text);
                    }
                    if (DepartureTime1TextBox.Text != string.Empty)
                    {
                        addFlight.DepartureTime = TimeSpan.Parse(DepartureTime1TextBox.Text);
                    }
                    if (ArrivalTime1Texbox.Text != string.Empty)
                    {
                        addFlight.ArrivalTime = TimeSpan.Parse(ArrivalTime1Texbox.Text);
                    }
                    if (Seats1TextBox.Text != string.Empty)
                    {
                        addFlight.Seats = Convert.ToInt32(Seats1TextBox.Text);
                    }
                    if (StatusDropdown1.Text != string.Empty)
                    {
                        addFlight.Status = StatusDropdown1.Text;
                    }
                    if (Price1TextBox.Text != string.Empty)
                    {
                        addFlight.price = Convert.ToDecimal(Price1TextBox.Text);
                    }
                    //cntx.FlightDetail.AddObject(addFlight);
                    cntx.FlightDetails.Add(addFlight);
                    // cntx.AddToFlightDetails(addFlight);
                    cntx.SaveChanges();
                    ClearFields2();
                    // NewFlight.Text = "New Flight Added";
                    NewFlight.Visible = true;
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel();", true);
                    NewFlight.Text = "Form has been submitted successfully.";

                    //  flight.DateofDeparture = Convert.ToDateTime(DepartureDateTextbox.Text);
                    // flight.DepartureTime = TimeSpan.Parse(DepartureTimeTextbox.Text);
                }
            }
            catch (Exception ex)
            {
                // Log the exception
                ForInputError.Visible = true;
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel3();", true);

                ForInputError.Text = "Invalid Input Field Please Check your input field";
            }
            finally
            {
            }
        }
        protected void BtnCreateFlight1_Click(object sender, EventArgs e)
        {
            try
            {
                using (AirlineEntities1 cntx = new AirlineEntities1())
                {
                    FlightDetail addFlight = new FlightDetail();

                    addFlight.FlightNo = FlightNumber1TextBox.Text;
                    addFlight.FromCity = FromCity1DropDown.Text;
                    addFlight.ToCity = ToCity1DropDown.Text;
                    if (DateOfDeparture1Textbox.Text != string.Empty)
                    {
                        addFlight.DateofDeparture = Convert.ToDateTime(DateOfDeparture1Textbox.Text);
                    }
                    if (DepartureTime1TextBox.Text != string.Empty)
                    {
                        addFlight.DepartureTime = TimeSpan.Parse(DepartureTime1TextBox.Text);
                    }
                    if (ArrivalTime1Texbox.Text != string.Empty)
                    {
                        addFlight.ArrivalTime = TimeSpan.Parse(ArrivalTime1Texbox.Text);
                    }
                    if (Seats1TextBox.Text != string.Empty)
                    {
                        addFlight.Seats = Convert.ToInt32(Seats1TextBox.Text);
                    }
                    if (StatusDropdown1.Text != string.Empty)
                    {
                        addFlight.Status = StatusDropdown1.Text;
                    }
                    if (Price1TextBox.Text != string.Empty)
                    {
                        addFlight.price = Convert.ToDecimal(Price1TextBox.Text);
                    }
                    //cntx.FlightDetail.AddObject(addFlight);
                    cntx.FlightDetails.Add(addFlight);
                    // cntx.AddToFlightDetails(addFlight);
                    cntx.SaveChanges();
                    ClearFields2();
                   // NewFlight.Text = "New Flight Added";
                        NewFlight.Visible = true;
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel();", true);
                        NewFlight.Text = "Form has been submitted successfully.";

                    //  flight.DateofDeparture = Convert.ToDateTime(DepartureDateTextbox.Text);
                    // flight.DepartureTime = TimeSpan.Parse(DepartureTimeTextbox.Text);
                }
            }
            catch (Exception ex)
            {
                // Log the exception        
                ForInputError.Visible = true;
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel3();", true);

                ForInputError.Text = "Invalid Input Field Please Check your input field";
            }
            finally
            {
            }  
        }
Esempio n. 3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            AirlineEntities1 db     = new AirlineEntities1();
            FlightDetail     Flight = new FlightDetail();


            UpdateFlightLabel.Text = "";

            Flight.FlightNo = TextBox1.Text;
            //   Flight.FromCity = TextBox4.Text;
            //    Flight.ToCity = TextBox5.Text;
            //   Flight.Status = TextBox9.Text;

            Flight.FromCity = FromCityDropDown.Text;
            Flight.ToCity   = SearchToCityDropDown.Text;
            Flight.Status   = SearchStatusDropdown.Text;


            if (!string.IsNullOrEmpty(TextBox2.Text))
            {
                Flight.DateofDeparture = DateTime.Parse(TextBox2.Text);
            }

            if (!string.IsNullOrEmpty(TextBox3.Text))
            {
                Flight.DepartureTime = TimeSpan.Parse(TextBox3.Text);
            }

            if (!string.IsNullOrEmpty(TextBox6.Text))
            {
                Flight.ArrivalTime = TimeSpan.Parse(TextBox6.Text);
            }

            if (!string.IsNullOrEmpty(TextBox7.Text))
            {
                Flight.Seats = Int32.Parse(TextBox7.Text);
            }

            if (!string.IsNullOrEmpty(TextBox8.Text))
            {
                Flight.price = Decimal.Parse(TextBox8.Text);
            }

            var result = from S in db.FlightDetails
                         where (S.FlightNo == Flight.FlightNo || S.FromCity == Flight.FromCity || S.DateofDeparture == Flight.DateofDeparture || S.DepartureTime == Flight.DepartureTime || S.ToCity == Flight.ToCity || S.ArrivalTime == Flight.ArrivalTime || S.Seats == Flight.Seats || S.Status == Flight.Status || S.price == Flight.price)
                         select new { S.FlightNo, S.FromCity, S.ToCity, S.DateofDeparture, S.DepartureTime, S.ArrivalTime, S.Seats, S.Status, S.price };



            //Flight.FromCity = TextBox1.Text;
            //var result1 = from S in db.FlightDetails
            //              where S.FromCity == Flight.FromCity
            //             select new { S.FlightNo, S.FromCity, S.ToCity, S.DateofDeparture, S.DepartureTime };

            //Flight.DateofDeparture = DateTime.Parse(TextBox1.Text);
            //var result2 = from S in db.FlightDetails
            //              where S.DateofDeparture == Flight.DateofDeparture
            //              select new { S.FlightNo, S.FromCity, S.ToCity, S.DateofDeparture, S.DepartureTime };



            GridView1.DataSource = result.ToList();
            //GridView1.DataSource = result1.ToList();
            //     GridView1.DataSource = result2.ToList();

            GridView1.DataBind();
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            AirlineEntities1 db = new AirlineEntities1();
            FlightDetail Flight = new FlightDetail();


            UpdateFlightLabel.Text = "";

            Flight.FlightNo =TextBox1.Text;
         //   Flight.FromCity = TextBox4.Text;
        //    Flight.ToCity = TextBox5.Text;
         //   Flight.Status = TextBox9.Text;

            Flight.FromCity = FromCityDropDown.Text;
            Flight.ToCity = SearchToCityDropDown.Text;
            Flight.Status = SearchStatusDropdown.Text;


            if (!string.IsNullOrEmpty(TextBox2.Text))
            {
                Flight.DateofDeparture = DateTime.Parse(TextBox2.Text);
            }

            if (!string.IsNullOrEmpty(TextBox3.Text))
            {
                Flight.DepartureTime = TimeSpan.Parse(TextBox3.Text);
            }

            if (!string.IsNullOrEmpty(TextBox6.Text))
            {
                Flight.ArrivalTime = TimeSpan.Parse(TextBox6.Text);
            }

            if (!string.IsNullOrEmpty(TextBox7.Text))
            {
                Flight.Seats = Int32.Parse(TextBox7.Text);
            }

            if (!string.IsNullOrEmpty(TextBox8.Text))
            {
                Flight.price = Decimal.Parse(TextBox8.Text);
            }

            var result = from S in db.FlightDetails
                         where (S.FlightNo == Flight.FlightNo || S.FromCity == Flight.FromCity || S.DateofDeparture == Flight.DateofDeparture || S.DepartureTime==Flight.DepartureTime || S.ToCity==Flight.ToCity || S.ArrivalTime==Flight.ArrivalTime || S.Seats==Flight.Seats || S.Status==Flight.Status || S.price==Flight.price )
                         select new { S.FlightNo, S.FromCity, S.ToCity, S.DateofDeparture, S.DepartureTime,S.ArrivalTime,S.Seats,S.Status,S.price};






            //Flight.FromCity = TextBox1.Text;
            //var result1 = from S in db.FlightDetails
            //              where S.FromCity == Flight.FromCity
            //             select new { S.FlightNo, S.FromCity, S.ToCity, S.DateofDeparture, S.DepartureTime };

            //Flight.DateofDeparture = DateTime.Parse(TextBox1.Text);
            //var result2 = from S in db.FlightDetails
            //              where S.DateofDeparture == Flight.DateofDeparture
            //              select new { S.FlightNo, S.FromCity, S.ToCity, S.DateofDeparture, S.DepartureTime };



            GridView1.DataSource = result.ToList();
            //GridView1.DataSource = result1.ToList();
       //     GridView1.DataSource = result2.ToList();

            GridView1.DataBind();


        }