//protected void Button1_Click(object sender, EventArgs e)
        //{

        //    using (AirlineEntities1 cntx = new AirlineEntities1())
        //    {
        //        var flight = cntx.FlightDetails.FirstOrDefault(m => m.FlightNo == FlightNOTextbox.Text);
        //        if(flight !=null)
        //        {
        //            //FromTextbox.Text = flight.FromCity;
        //            //ToTextbox.Text = flight.ToCity;
        //            DepartureDateTextbox.Text = flight.DateofDeparture.ToString();
        //            DepartureTimeTextbox.Text = flight.DepartureTime.ToString();
        //            SeatTextbox.Text = flight.Seats.ToString();
        //            FlightNOTextbox.Text = flight.FlightNo;
        //            //StatusTextbox.Text = flight.Seats.ToString();
        //            PriceTextbox.Text = flight.price.ToString();
        //        }


        //    }

        //}

        protected void Update_Click(object sender, EventArgs e)
        {
            

            try
            {

                using (AirlineEntities1 cntx = new AirlineEntities1())
                {
                    var flight = cntx.FlightDetails.FirstOrDefault(m => m.FlightNo == FlightNOTextbox.Text);
                    if (flight != null)
                    {
                        //flight.FromCity = FromTextbox.Text;
                        //flight.ToCity =ToTextbox.Text  ;
                        flight.DateofDeparture = Convert.ToDateTime(DepartureDateTextbox.Text);
                        flight.ArrivalTime = TimeSpan.Parse(ArrivalTimeTextbox.Text);

                        flight.DepartureTime = TimeSpan.Parse(DepartureTimeTextbox.Text);
                        flight.Seats = Convert.ToInt32(SeatTextbox.Text);
                        // flight.Status = StatusTextbox.Text;
                        flight.price = Convert.ToDecimal(PriceTextbox.Text);
                        FlightNOTextbox.Text = flight.FlightNo;

                        flight.FromCity = UpdateFromCity.Text;
                        flight.ToCity = UpdateToCityDropDown.Text;
                        flight.Status = UpdateStatusDrop.Text;

                        cntx.SaveChanges();
                        UpdateFlightLabel.Visible = true;
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel2();", true);
                        UpdateFlightLabel.Text = "Form has been submitted successfully.";
                        ClearFields();
                    }
                }

            }

              catch (Exception ex)
            {
                // Log the exception    
                UpdateFlightError.Visible = true;
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel4();", true);
                UpdateFlightError.Text = "Invalid Input Field Please Check your input field";
            }
            finally
            {
            }  


        }
Exemple #2
0
        protected void UpdateDelete_Click(object sender, EventArgs e)
        {
            using (AirlineEntities1 cntx = new AirlineEntities1())
            {
                var flight = cntx.FlightDetails.FirstOrDefault(m => m.FlightNo == FlightNOTextbox.Text);
                if (flight != null)
                {
                    // cntx.Delete(data);
                    cntx.FlightDetails.Remove(flight);

                    cntx.SaveChanges();
                    ClearFields();
                }
            }
        }
Exemple #3
0
        //protected void Button1_Click(object sender, EventArgs e)
        //{

        //    using (AirlineEntities1 cntx = new AirlineEntities1())
        //    {
        //        var flight = cntx.FlightDetails.FirstOrDefault(m => m.FlightNo == FlightNOTextbox.Text);
        //        if(flight !=null)
        //        {
        //            //FromTextbox.Text = flight.FromCity;
        //            //ToTextbox.Text = flight.ToCity;
        //            DepartureDateTextbox.Text = flight.DateofDeparture.ToString();
        //            DepartureTimeTextbox.Text = flight.DepartureTime.ToString();
        //            SeatTextbox.Text = flight.Seats.ToString();
        //            FlightNOTextbox.Text = flight.FlightNo;
        //            //StatusTextbox.Text = flight.Seats.ToString();
        //            PriceTextbox.Text = flight.price.ToString();
        //        }


        //    }

        //}

        protected void Update_Click(object sender, EventArgs e)
        {
            try
            {
                using (AirlineEntities1 cntx = new AirlineEntities1())
                {
                    var flight = cntx.FlightDetails.FirstOrDefault(m => m.FlightNo == FlightNOTextbox.Text);
                    if (flight != null)
                    {
                        //flight.FromCity = FromTextbox.Text;
                        //flight.ToCity =ToTextbox.Text  ;
                        flight.DateofDeparture = Convert.ToDateTime(DepartureDateTextbox.Text);
                        flight.ArrivalTime     = TimeSpan.Parse(ArrivalTimeTextbox.Text);

                        flight.DepartureTime = TimeSpan.Parse(DepartureTimeTextbox.Text);
                        flight.Seats         = Convert.ToInt32(SeatTextbox.Text);
                        // flight.Status = StatusTextbox.Text;
                        flight.price         = Convert.ToDecimal(PriceTextbox.Text);
                        FlightNOTextbox.Text = flight.FlightNo;

                        flight.FromCity = UpdateFromCity.Text;
                        flight.ToCity   = UpdateToCityDropDown.Text;
                        flight.Status   = UpdateStatusDrop.Text;

                        cntx.SaveChanges();
                        UpdateFlightLabel.Visible = true;
                        ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel2();", true);
                        UpdateFlightLabel.Text = "Form has been submitted successfully.";
                        ClearFields();
                    }
                }
            }

            catch (Exception ex)
            {
                // Log the exception
                UpdateFlightError.Visible = true;
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "HideLabel4();", true);
                UpdateFlightError.Text = "Invalid Input Field Please Check your input field";
            }
            finally
            {
            }
        }
Exemple #4
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 UpdateDelete_Click(object sender, EventArgs e)
        {
                        using (AirlineEntities1 cntx = new AirlineEntities1())
            {
                var flight = cntx.FlightDetails.FirstOrDefault(m => m.FlightNo == FlightNOTextbox.Text);
                if (flight != null)
                {
                   // cntx.Delete(data);
                    cntx.FlightDetails.Remove(flight);

                    cntx.SaveChanges();
                    ClearFields();
                }

                }
        }
        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
            {
            }  
        }