Hidistro.SqlDal/Store/PhotoGalleryDao.cs

(开头部分) 9KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

namespace Hidistro.SqlDal.Store
{
    using Hidistro.Core;
    using Hidistro.Core.Entities;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using System.Text;

    public class PhotoGalleryDao
    {
        private Database database = DatabaseFactory.CreateDatabase();

        public bool AddPhote(int categoryId, string photoName, string photoPath, int fileSize)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_PhotoGallery(CategoryId, PhotoName, PhotoPath, FileSize, UploadTime, LastUpdateTime) VALUES (@CategoryId, @PhotoName, @PhotoPath, @FileSize, @UploadTime, @LastUpdateTime)");
            this.database.AddInParameter(sqlStringCommand, "CategoryId", DbType.Int32, categoryId);
            this.database.AddInParameter(sqlStringCommand, "PhotoName", DbType.String, photoName);
            this.database.AddInParameter(sqlStringCommand, "PhotoPath", DbType.String, photoPath);
            this.database.AddInParameter(sqlStringCommand, "FileSize", DbType.Int32, fileSize);
            this.database.AddInParameter(sqlStringCommand, "UploadTime", DbType.DateTime, DateTime.Now);
            this.database.AddInParameter(sqlStringCommand, "LastUpdateTime", DbType.DateTime, DateTime.Now);
            return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }

        public bool AddPhotoCategory(string name)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DECLARE @DisplaySequence INT; SELECT @DisplaySequence = ISNULL(MAX(DisplaySequence), 0) + 1 FROM Hishop_PhotoCategories; INSERT Hishop_PhotoCategories (CategoryName, DisplaySequence) VALUES (@CategoryName, @DisplaySequence)");
            this.database.AddInParameter(sqlStringCommand, "CategoryName", DbType.String, name);
            return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }

        public int AddPhotoCategory2(string name)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DECLARE @DisplaySequence INT; SELECT @DisplaySequence = ISNULL(MAX(DisplaySequence), 0) + 1 FROM Hishop_PhotoCategories; INSERT Hishop_PhotoCategories (CategoryName, DisplaySequence) VALUES (@CategoryName, @DisplaySequence);SELECT @@IDENTITY");
            this.database.AddInParameter(sqlStringCommand, "CategoryName", DbType.String, name);
            return Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand));
        }

        public bool DeletePhoto(int photoId)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Hishop_PhotoGallery WHERE PhotoId = @PhotoId");
            this.database.AddInParameter(sqlStringCommand, "PhotoId", DbType.Int32, photoId);
            return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }

        public bool DeletePhotoCategory(int categoryId)
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("DELETE FROM Hishop_PhotoCategories WHERE CategoryId = @CategoryId; UPDATE Hishop_PhotoGallery SET CategoryId = 0 WHERE CategoryId = @CategoryId");
            this.database.AddInParameter(sqlStringCommand, "CategoryId", DbType.Int32, categoryId);
            return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
        }

        public int GetDefaultPhotoCount()
        {
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT count(*) FROM Hishop_PhotoGallery where CategoryId=0");
            return Convert.ToInt32(this.database.ExecuteScalar(sqlStringCommand));
        }
后面还有 104 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。