Esempio n. 1
0
        public static FilmCategory GetFilmCategorySingle(SqlConnection dbcon, int id)
        {
            FilmCategory  obj    = new FilmCategory();
            string        strsql = "select * from FilmCategories where FikmID = " + id;
            SqlCommand    cmd    = new SqlCommand(strsql, dbcon);
            SqlDataReader myReader;

            myReader = cmd.ExecuteReader();
            while (myReader.Read())
            {
                obj.FilmID     = Convert.ToInt32(myReader["FilmID"].ToString());
                obj.CategoryID = Convert.ToInt32(myReader["CategoryID"].ToString());
            }
            myReader.Close();
            return(obj);
        }
Esempio n. 2
0
        public static List <FilmCategory> GetFilmCategoryList(SqlConnection dbcon)
        {
            List <FilmCategory> itemlist = new List <FilmCategory>();
            string        strsql         = "select * from FilmCategories";
            SqlCommand    cmd            = new SqlCommand(strsql, dbcon);
            SqlDataReader myReader;

            myReader = cmd.ExecuteReader();
            while (myReader.Read())
            {
                FilmCategory obj = new FilmCategory();
                obj.FilmID     = Convert.ToInt32(myReader["FilmID"].ToString());
                obj.CategoryID = Convert.ToInt32(myReader["CategoryID"].ToString());
                itemlist.Add(obj);
            }
            myReader.Close();
            return(itemlist);
        }
Esempio n. 3
0
        public static int CUDFilmCategory(SqlConnection dbcon, string CUDAction, FilmCategory obj)
        {
            SqlCommand cmd = new SqlCommand();

            if (CUDAction == "create")
            {
                cmd.CommandText = "insert into FilmCategories " +
                                  "Values (@FilmID,@CategoryID)";
                cmd.Parameters.AddWithValue("@FilmID", SqlDbType.Int).Value     = obj.FilmID;
                cmd.Parameters.AddWithValue("@CategoryID", SqlDbType.Int).Value = obj.CategoryID;
            }
            else if (CUDAction == "delete")
            {
                cmd.CommandText = "delete FilmCategories where FilmID = @FilmID";
                cmd.Parameters.AddWithValue("@FilmID", SqlDbType.Int).Value = obj.FilmID;
            }
            cmd.Connection = dbcon;
            int intResult = cmd.ExecuteNonQuery();

            cmd.Dispose();
            return(intResult);
        }