コード例 #1
0
        public bool UpdateItemById(PortfolioItem b)
        {
            try
            {
                MySqlConnection cnn    = ReturnMYSQLConnection();
                var             query  = "UPDATE PortfolioItem SET Name=@Name, Description=@Description, FrontpageImg=@FrontpageImg, Thumbnail=@Thumbnail, CategoryName=@CategoryName, ItemTitle=@ItemTitle, CreatedDate=@CreatedDate, UrlTitle=@UrlTitle, UrlLink=@UrlLink WHERE ID = @Id";
                MySqlCommand    newCmd = CreateMYSQLCommandText(query, cnn);

                newCmd.Parameters.AddWithValue("@Id", b.RetrieveId());
                newCmd.Parameters.AddWithValue("@Name", b.RetrieveTitle());
                newCmd.Parameters.AddWithValue("@Description", b.RetrieveDescription());
                newCmd.Parameters.AddWithValue("@FrontpageImg", b.FrontpageImg);
                newCmd.Parameters.AddWithValue("@Thumbnail", b.Thumbnail);
                newCmd.Parameters.AddWithValue("@CategoryName", b.categoryName);
                newCmd.Parameters.AddWithValue("@ItemTitle", b.RetrieveTitle());
                newCmd.Parameters.AddWithValue("@CreatedDate", b.createdDate);
                newCmd.Parameters.AddWithValue("@UrlTitle", b.urlTitle);
                newCmd.Parameters.AddWithValue("@UrlLink", b.urlLink);

                newCmd.ExecuteNonQuery();
                cnn.Close();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(false);
        }
コード例 #2
0
        public bool CreateNewItem(PortfolioItem b)
        {
            MySqlConnection cnn    = ReturnMYSQLConnection();
            string          query  = "INSERT INTO PortfolioItem (Name, Description, FrontpageImg, CategoryName, ItemTitle, CreatedDate, UrlTitle, UrlLink) VALUES (@Name, @Description, @FrontpageImg, @CategoryName, @ItemTitle, @CreatedDate, @UrlTitle, @UrlLink)";
            MySqlCommand    newCmd = CreateMYSQLCommandText(query, cnn);

            newCmd.Parameters.AddWithValue("@Name", b.RetrieveTitle());
            newCmd.Parameters.AddWithValue("@Description", b.RetrieveDescription());
            newCmd.Parameters.AddWithValue("@FrontpageImg", b.FrontpageImg);
            newCmd.Parameters.AddWithValue("@CategoryName", b.categoryName);
            newCmd.Parameters.AddWithValue("@ItemTitle", b.RetrieveTitle());
            newCmd.Parameters.AddWithValue("@CreatedDate", b.createdDate);
            newCmd.Parameters.AddWithValue("@UrlTitle", b.urlTitle);
            newCmd.Parameters.AddWithValue("@UrlLink", b.urlLink);
            newCmd.ExecuteNonQuery();
            cnn.Close();
            return(true);
        }