Example #1
0
File: BBS.cs Project: blfsir/benzoa
    /// <summary>
    /// 将附件和回复绑定
    /// </summary>
    /// <param name="filenames">文件名,多个文件名用 , 分开</param>
    public void Attach(string filenames)
    {
        UDS.Components.Database data = new UDS.Components.Database();
        string[] arrfilename = filenames.Split(',');
        try
        {
            for (int i = 0; i < arrfilename.Length; i++)
            {
                if (arrfilename[i].Trim() != "")
                {
                    SqlParameter[] prams = {
                                           data.MakeInParam("@replayid",  SqlDbType.Int, 4,this.ReplayId),
                                           data.MakeInParam("@filename",  SqlDbType.VarChar, 500,arrfilename[i])
                                       };
                    data.RunProc("sp_BBS_AttachmentToReplay", prams);
                }

            }
        }
        finally
        {
            if (data != null)
            {
                data.Close();
                data.Dispose();
            }
        }
    }
Example #2
0
File: BBS.cs Project: blfsir/benzoa
    /// <summary>
    /// 删除附件
    /// </summary>
    public void DelAttachment(string attachmentmd)
    {
        UDS.Components.Database data = new UDS.Components.Database();
        SqlParameter[] prams = {
                                   data.MakeInParam("@replayid",  SqlDbType.Int, 4,this.ReplayId),
                               };

        SqlDataReader dr = null;
        try
        {

            data.RunProc("sp_BBS_GetReplayAttachment", prams, out dr);
            while (dr.Read())
            {
                System.IO.File.Delete(attachmentmd + "\\" + dr["filename"].ToString());
            }

            dr.Close();
            SqlParameter[] prams1 = {
                                        data.MakeInParam("@replayid",  SqlDbType.Int, 4,this.ReplayId),
                                    };
            data.RunProc("sp_BBS_DelAttachmentToReplay", prams1);
        }
        finally
        {
            if (dr != null)
            {
                dr.Close();
                dr.Dispose();
            }
            if (data != null)
            {
                data.Close();
                data.Dispose();
            }

        }
    }
Example #3
0
File: BBS.cs Project: blfsir/benzoa
    /// <summary>
    /// 删除附件
    /// </summary>
    public void DelAttachment(string attachmentmd)
    {
        UDS.Components.Database data = new UDS.Components.Database();
        try
        {
            //删除所有回复附件
            //得到所有回复
            UDS.Components.BBSClass bbs = new UDS.Components.BBSClass();
            SqlDataReader dr1 = null;
            dr1 = bbs.ReadBBSForumItemReplay(this);
            try
            {
                while (dr1.Read())
                {
                    BBSReplay replay = new BBSReplay();
                    replay.ReplayId = Int32.Parse(dr1["replay_id"].ToString());
                    replay.DelAttachment(attachmentmd);
                }
            }
            finally
            {
                dr1.Close();
                dr1.Dispose();
            }
            //删除贴子本身附件
            SqlParameter[] prams = {
                                   data.MakeInParam("@itemid",  SqlDbType.Int, 4,this.ItemID),
        };
            SqlDataReader dr = null;
            try
            {
                data.RunProc("sp_BBS_GetItemAttachment", prams, out dr);
                while (dr.Read())
                {
                    System.IO.File.Delete(attachmentmd + "\\" + dr["filename"].ToString());
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr.Dispose();
                }
            }

            SqlParameter[] prams1 = {
                                    data.MakeInParam("@itemid",  SqlDbType.Int, 4,this.ItemID),
        };
            data.RunProc("sp_BBS_DelAttachmentToItem", prams1);
        }
        finally
        {
            if (data != null)
            {
                data.Close();
                data.Dispose();
            }
        }
    }