Exemple #1
0
 /// <summary>
 /// ɾ������
 /// </summary>
 public void DelAttachment(string attachmentmd)
 {
     UDS.Components.Database data = new UDS.Components.Database ();
     //ɾ�����лظ�����
     //�õ����лظ�
     UDS.Components.BBSClass bbs = new UDS.Components.BBSClass();
     SqlDataReader dr1 = null;
     dr1 = bbs.ReadBBSForumItemReplay(this);
     while(dr1.Read())
     {
         BBSReplay replay = new BBSReplay();
         replay.ReplayId = Int32.Parse(dr1["replay_id"].ToString());
         replay.DelAttachment(attachmentmd);
     }
     //ɾ�����ӱ������
     SqlParameter[] prams = {
                                data.MakeInParam("@itemid",  SqlDbType.Int, 4,this.ItemID),
     };
     SqlDataReader dr = null;
     data.RunProc ("sp_BBS_GetItemAttachment",prams,out dr);
     while(dr.Read())
     {
         System.IO.File.Delete(attachmentmd+"\\"+dr["filename"].ToString());
     }
     data.Close();
     SqlParameter[] prams1 = {
                                 data.MakeInParam("@itemid",  SqlDbType.Int, 4,this.ItemID),
     };
     data.RunProc("sp_BBS_DelAttachmentToItem",prams1);
 }
Exemple #2
0
    /// <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();
            }
        }
    }