Пример #1
0
        //To show data in popup for editing
        public AirportEntity GetAirport(Int32 M_Airport_Slno)
        {
            String selectQuery = @"select *from [M_Airport] where [M_Airport_Slno]=@M_Airport_Slno";

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = _ConnStr;
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = selectQuery;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@M_Airport_Slno", M_Airport_Slno);

                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                SqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                DataTable     dataTable  = new DataTable();
                dataTable.Load(dataReader);
                AirportEntity existingairport = new AirportEntity();
                foreach (DataRow row in dataTable.Rows)
                {
                    existingairport.M_Airport_Slno    = Convert.ToInt32(row["M_Airport_Slno"]);
                    existingairport.M_Airport_Name    = Convert.ToString(row["M_Airport_Name"]);
                    existingairport.M_Airport_Sname   = Convert.ToString(row["M_Airport_Sname"]);
                    existingairport.M_Airport_Country = Convert.ToInt32(row["M_Airport_Country"]);
                }
                conn.Close();

                return(existingairport);
            }
        }
Пример #2
0
        // Update airport data in database
        public bool UpdateAirport(AirportEntity airport)
        {
            String updateQuery = @"UPDATE [M_Airport] SET [M_Airport_Name]=@M_Airport_Name , [M_Airport_Sname] = @M_Airport_Sname, [M_Airport_Country] = @M_Airport_Country  Where [M_Airport_Slno]=@M_Airport_Slno";

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = _ConnStr;
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = updateQuery;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@M_Airport_Slno", airport.M_Airport_Slno);
                cmd.Parameters.AddWithValue("@M_Airport_Name", airport.M_Airport_Name);
                cmd.Parameters.AddWithValue("@M_Airport_Sname", airport.M_Airport_Sname);
                cmd.Parameters.AddWithValue("@M_Airport_Country", countrydropdownlistEditpopup.SelectedItem.Value);


                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                cmd.ExecuteNonQuery();
                conn.Close();

                return(true);
            }
        }
Пример #3
0
        //Adding airport data to database
        public bool AddNewAirport(AirportEntity airport)
        {
            String insertQuery = @"INSERT INTO [M_Airport]([M_Airport_Name],[M_Airport_Sname],[M_Airport_Country]) VALUES(@M_Airport_Name,@M_Airport_Sname,@M_Airport_Country)";

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = _ConnStr;
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = insertQuery;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@M_Airport_Name", airport.M_Airport_Name);
                cmd.Parameters.AddWithValue("@M_Airport_Sname", airport.M_Airport_Sname);
                cmd.Parameters.AddWithValue("@M_Airport_Country", countrydropdownlistAddpopup.SelectedItem.Value);


                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                cmd.ExecuteNonQuery();
                conn.Close();

                return(true);
            }
        }
Пример #4
0
        //View button click event
        protected void ibtnView_Click(object sender, ImageClickEventArgs e)
        {
            GridViewRow   gvRow          = (GridViewRow)((ImageButton)sender).NamingContainer;
            Int32         M_Airport_Slno = Convert.ToInt32(gvAirport.DataKeys[gvRow.RowIndex].Value);
            AirportEntity airport        = GetAirport(M_Airport_Slno);

            airportidAddpopup.Value           = airport.M_Airport_Slno.ToString();
            txtairportnameViewpopup.Text      = airport.M_Airport_Name;
            txtairportshortnameViewpopup.Text = airport.M_Airport_Sname;

            mpeAirportView.Show();
        }
Пример #5
0
        protected void EditpopupSaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                AirportEntity airport = new AirportEntity();
                airport.M_Airport_Slno    = Convert.ToInt32(airportidEditpopup.Value);
                airport.M_Airport_Name    = txtairportnameEditpopup.Text.Trim();
                airport.M_Airport_Sname   = txtairportshortnameEditpopup.Text.Trim();
                airport.M_Airport_Country = Convert.ToInt32(countrydropdownlistEditpopup.SelectedItem.Value);



                if (airport.M_Airport_Slno != 0)
                {
                    UpdateAirport(airport);
                }


                LoadData();
            }
        }
Пример #6
0
        protected void AddpopupSaveButton_Click(object sender, EventArgs e)
        {
            //  ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Sorry there are no attachments');", true);

            if (Page.IsValid)
            {
                AirportEntity airport = new AirportEntity();
                airport.M_Airport_Slno    = Convert.ToInt32(airportidAddpopup.Value);
                airport.M_Airport_Name    = txtairportnameAddpopup.Text.Trim();
                airport.M_Airport_Sname   = txtairportshortnameAddpopup.Text.Trim();
                airport.M_Airport_Country = Convert.ToInt32(countrydropdownlistAddpopup.SelectedItem.Value);



                if (airport.M_Airport_Slno == 0)
                {
                    AddNewAirport(airport);
                }


                LoadData();
            }
        }