Beispiel #1
0
        public static void Update(TourModel tour)

        {
            string        cnnstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection cnn       = new SqlConnection(cnnstring);

            cnn.Open();

            string sql = "UPDATE tours SET tour_ten = @tentour, tour_mota = @mota, loai_id = @loaiid, gia_id = @giaid WHERE tour_id = @id";


            SqlCommand cmd = new SqlCommand(sql, cnn);

            cmd.Parameters.AddWithValue("@id", tour.tour_id);
            cmd.Parameters.AddWithValue("@tentour", tour.tour_ten);
            cmd.Parameters.AddWithValue("@mota", tour.tour_mota);
            cmd.Parameters.AddWithValue("@loaiid", tour.loai_id);
            cmd.Parameters.AddWithValue("@giaid", tour.gia_id);
            cmd.ExecuteNonQuery();
        }
Beispiel #2
0
        public static void Insert(TourModel tour)

        {
            string        cnnstring = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection cnn       = new SqlConnection(cnnstring);

            cnn.Open();

            string sql = "INSERT INTO tours (tour_ten, tour_mota, loai_id, gia_id) " +
                         " VALUES(@tentour, @mota, @loaiid, @giaid)";


            SqlCommand cmd = new SqlCommand(sql, cnn);

            cmd.Parameters.AddWithValue("@tentour", tour.tour_ten);
            cmd.Parameters.AddWithValue("@mota", tour.tour_mota);
            cmd.Parameters.AddWithValue("@loaiid", tour.loai_id);
            cmd.Parameters.AddWithValue("@giaid", tour.gia_id);
            cmd.ExecuteNonQuery();
        }