/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { //取得相册MODEL List<Model.article_albums> albumsList = new DAL.article_albums(databaseprefix).GetList(id); //取得附件MODEL List<Model.article_attach> attachList = new DAL.article_attach(databaseprefix).GetList(id); //删除扩展字段表 StringBuilder strSql1 = new StringBuilder(); strSql1.Append("delete from " + databaseprefix + "article_attribute_value "); strSql1.Append(" where article_id=@article_id "); SqlParameter[] parameters1 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters1[0].Value = id; List<CommandInfo> sqllist = new List<CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql1.ToString(), parameters1); sqllist.Add(cmd); //删除图片相册 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "article_albums "); strSql2.Append(" where article_id=@article_id "); SqlParameter[] parameters2 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters2[0].Value = id; cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(cmd); //删除附件 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "article_attach "); strSql3.Append(" where article_id=@article_id "); SqlParameter[] parameters3 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters3[0].Value = id; cmd = new CommandInfo(strSql3.ToString(), parameters3); sqllist.Add(cmd); //删除用户组价格 StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_group_price "); strSql4.Append(" where article_id=@article_id "); SqlParameter[] parameters4 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters4[0].Value = id; cmd = new CommandInfo(strSql4.ToString(), parameters4); sqllist.Add(cmd); //删除商品价格 StringBuilder strSql5 = new StringBuilder(); strSql5.Append("delete from " + databaseprefix + "article_goods"); strSql5.Append(" where article_id=@article_id"); SqlParameter[] parameters5 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters5[0].Value = id; cmd = new CommandInfo(strSql5.ToString(), parameters5); sqllist.Add(cmd); //删除商品规格 StringBuilder strSql6 = new StringBuilder(); strSql6.Append("delete from " + databaseprefix + "article_goods_spec"); strSql6.Append(" where article_id=@article_id"); SqlParameter[] parameters6 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters6[0].Value = id; cmd = new CommandInfo(strSql6.ToString(), parameters6); sqllist.Add(cmd); //删除Tags标签关系 StringBuilder strSql7 = new StringBuilder(); strSql7.Append("delete from " + databaseprefix + "article_tags_relation"); strSql7.Append(" where article_id=@article_id"); SqlParameter[] parameters7 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters7[0].Value = id; cmd = new CommandInfo(strSql7.ToString(), parameters7); sqllist.Add(cmd); //删除评论 StringBuilder strSql8 = new StringBuilder(); strSql8.Append("delete from " + databaseprefix + "article_comment "); strSql8.Append(" where article_id=@article_id "); SqlParameter[] parameters8 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters8[0].Value = id; cmd = new CommandInfo(strSql8.ToString(), parameters8); sqllist.Add(cmd); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "article "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist); if (rowsAffected > 0) { new DAL.article_albums(databaseprefix).DeleteFile(albumsList); //删除图片 new DAL.article_attach(databaseprefix).DeleteFile(attachList); //删除附件 return true; } else { return false; } }
public article_albums() { dal = new DAL.article_albums(siteConfig.sysdatabaseprefix); }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(string channel_name, int channel_id, int article_id) { //取得相册MODEL List <Model.article_albums> albumsList = new DAL.article_albums(databaseprefix).GetList(channel_id, article_id); //取得附件MODEL List <Model.article_attach> attachList = new DAL.article_attach(databaseprefix).GetList(channel_id, article_id); //删除图片相册 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "article_albums"); strSql2.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters2 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters2[0].Value = channel_id; parameters2[1].Value = article_id; List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(cmd); //删除附件 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "article_attach"); strSql3.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters3 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters3[0].Value = channel_id; parameters3[1].Value = article_id; cmd = new CommandInfo(strSql3.ToString(), parameters3); sqllist.Add(cmd); //删除用户组价格 StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_group_price"); strSql4.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters4 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters4[0].Value = channel_id; parameters4[1].Value = article_id; cmd = new CommandInfo(strSql4.ToString(), parameters4); sqllist.Add(cmd); //删除商品价格 StringBuilder strSql5 = new StringBuilder(); strSql5.Append("delete from " + databaseprefix + "article_goods"); strSql5.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters5 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters5[0].Value = channel_id; parameters5[1].Value = article_id; cmd = new CommandInfo(strSql5.ToString(), parameters5); sqllist.Add(cmd); //删除商品规格 StringBuilder strSql6 = new StringBuilder(); strSql6.Append("delete from " + databaseprefix + "article_goods_spec"); strSql6.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters6 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters6[0].Value = channel_id; parameters6[1].Value = article_id; cmd = new CommandInfo(strSql6.ToString(), parameters6); sqllist.Add(cmd); //删除Tags标签关系 StringBuilder strSql7 = new StringBuilder(); strSql7.Append("delete from " + databaseprefix + "article_tags_relation"); strSql7.Append(" where channel_id=@channel_id and article_id=@article_id"); SqlParameter[] parameters7 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters7[0].Value = channel_id; parameters7[1].Value = article_id; cmd = new CommandInfo(strSql7.ToString(), parameters7); sqllist.Add(cmd); //删除评论 StringBuilder strSql8 = new StringBuilder(); strSql8.Append("delete from " + databaseprefix + "article_comment"); strSql8.Append(" where channel_id=@channel_id and article_id=@article_id "); SqlParameter[] parameters8 = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@article_id", SqlDbType.Int, 4) }; parameters8[0].Value = channel_id; parameters8[1].Value = article_id; cmd = new CommandInfo(strSql8.ToString(), parameters8); sqllist.Add(cmd); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + DTKeys.TABLE_CHANNEL_ARTICLE + channel_name); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = article_id; cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist); if (rowsAffected > 0) { new DAL.article_albums(databaseprefix).DeleteFile(albumsList); //删除图片 new DAL.article_attach(databaseprefix).DeleteFile(attachList); //删除附件 return(true); } else { return(false); } }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(int id) { //取得相册MODEL List<Model.article_albums> albumsList = new DAL.article_albums(databaseprefix).GetList(id); //取得附件MODEL List<Model.article_attach> attachList = new DAL.article_attach(databaseprefix).GetList(id); Hashtable sqllist = new Hashtable(); //删除扩展字段表 StringBuilder strSql1 = new StringBuilder(); strSql1.Append("delete from " + databaseprefix + "article_attribute_value "); strSql1.Append(" where article_id=@article_id "); OleDbParameter[] parameters1 = { new OleDbParameter("@article_id", OleDbType.Integer,4)}; parameters1[0].Value = id; sqllist.Add(strSql1.ToString(), parameters1); //删除图片相册 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "article_albums "); strSql2.Append(" where article_id=@article_id "); OleDbParameter[] parameters2 = { new OleDbParameter("@article_id", OleDbType.Integer,4)}; parameters2[0].Value = id; sqllist.Add(strSql2.ToString(), parameters2); //删除附件 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "article_attach "); strSql3.Append(" where article_id=@article_id "); OleDbParameter[] parameters3 = { new OleDbParameter("@article_id", OleDbType.Integer,4)}; parameters3[0].Value = id; sqllist.Add(strSql3.ToString(), parameters3); //删除用户组价格 StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_group_price "); strSql4.Append(" where article_id=@article_id "); OleDbParameter[] parameters4 = { new OleDbParameter("@article_id", OleDbType.Integer,4)}; parameters4[0].Value = id; sqllist.Add(strSql4.ToString(), parameters4); //删除评论 StringBuilder strSql8 = new StringBuilder(); strSql8.Append("delete from " + databaseprefix + "article_comment "); strSql8.Append(" where article_id=@article_id "); OleDbParameter[] parameters8 = { new OleDbParameter("@article_id", OleDbType.Integer,4)}; parameters8[0].Value = id; sqllist.Add(strSql8.ToString(), parameters8); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "article "); strSql.Append(" where id=@id"); OleDbParameter[] parameters = { new OleDbParameter("@id", OleDbType.Integer,4)}; parameters[0].Value = id; sqllist.Add(strSql.ToString(), parameters); bool result = DbHelperOleDb.ExecuteSqlTran(sqllist); if (result) { new DAL.article_albums(databaseprefix).DeleteFile(albumsList); //删除图片 new DAL.article_attach(databaseprefix).DeleteFile(attachList); //删除附件 return true; } else { return false; } }
/// <summary> /// ɾ��һ������ /// </summary> public bool Delete(int id) { //ȡ�����MODEL List<Model.article_albums> albumsList = new DAL.article_albums(databaseprefix).GetList(id); //ȡ�ø���MODEL List<Model.article_attach> attachList = new DAL.article_attach(databaseprefix).GetList(id); //ɾ����չ�ֶα� StringBuilder strSql1 = new StringBuilder(); strSql1.Append("delete from " + databaseprefix + "article_attribute_value "); strSql1.Append(" where article_id=@article_id "); SqlParameter[] parameters1 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters1[0].Value = id; List<CommandInfo> sqllist = new List<CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql1.ToString(), parameters1); sqllist.Add(cmd); //ɾ��ͼƬ��� StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "article_albums "); strSql2.Append(" where article_id=@article_id "); SqlParameter[] parameters2 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters2[0].Value = id; cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(cmd); //ɾ������ StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "article_attach "); strSql3.Append(" where article_id=@article_id "); SqlParameter[] parameters3 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters3[0].Value = id; cmd = new CommandInfo(strSql3.ToString(), parameters3); sqllist.Add(cmd); //ɾ����Ա��۸� StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_group_price "); strSql4.Append(" where article_id=@article_id "); SqlParameter[] parameters4 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters4[0].Value = id; cmd = new CommandInfo(strSql4.ToString(), parameters4); sqllist.Add(cmd); //ɾ������ StringBuilder strSql5 = new StringBuilder(); strSql5.Append("delete from " + databaseprefix + "article_comment "); strSql5.Append(" where article_id=@article_id "); SqlParameter[] parameters5 = { new SqlParameter("@article_id", SqlDbType.Int,4)}; parameters5[0].Value = id; cmd = new CommandInfo(strSql5.ToString(), parameters5); sqllist.Add(cmd); //ɾ������ StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + "article "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist); if (rowsAffected > 0) { new DAL.article_albums(databaseprefix).DeleteFile(albumsList); //ɾ��ͼƬ new DAL.article_attach(databaseprefix).DeleteFile(attachList); //ɾ������ return true; } else { return false; } }
/// <summary> /// 删除一条数据 /// </summary> public bool Delete(string channel_name, int channel_id, int article_id) { //取得相册MODEL List <Model.article_albums> albumsList = new DAL.article_albums(databaseprefix).GetList(channel_id, article_id); //取得附件MODEL List <Model.article_attach> attachList = new DAL.article_attach(databaseprefix).GetList(channel_id, article_id); //删除图片相册 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("delete from " + databaseprefix + "article_albums"); strSql2.Append(" where channel_id=@0 and article_id=@1"); WriteDataBase.Execute(strSql2.ToString(), channel_id, article_id); //删除附件 StringBuilder strSql3 = new StringBuilder(); strSql3.Append("delete from " + databaseprefix + "article_attach"); strSql3.Append(" where channel_id=@0 and article_id=@1"); WriteDataBase.Execute(strSql3.ToString(), channel_id, article_id); //删除用户组价格 StringBuilder strSql4 = new StringBuilder(); strSql4.Append("delete from " + databaseprefix + "user_group_price"); strSql4.Append(" where channel_id=@0 and article_id=@1"); WriteDataBase.Execute(strSql4.ToString(), channel_id, article_id); //删除商品价格 StringBuilder strSql5 = new StringBuilder(); strSql5.Append("delete from " + databaseprefix + "article_goods"); strSql5.Append(" where channel_id=@0 and article_id=@1"); WriteDataBase.Execute(strSql5.ToString(), channel_id, article_id); //删除商品规格 StringBuilder strSql6 = new StringBuilder(); strSql6.Append("delete from " + databaseprefix + "article_goods_spec"); strSql6.Append(" where channel_id=@0 and article_id=@1"); WriteDataBase.Execute(strSql6.ToString(), channel_id, article_id); //删除Tags标签关系 StringBuilder strSql7 = new StringBuilder(); strSql7.Append("delete from " + databaseprefix + "article_tags_relation"); strSql7.Append(" where channel_id=@0 and article_id=@1"); WriteDataBase.Execute(strSql7.ToString(), channel_id, article_id); //删除评论 StringBuilder strSql8 = new StringBuilder(); strSql8.Append("delete from " + databaseprefix + "article_comment"); strSql8.Append(" where channel_id=@0 and article_id=@1 "); WriteDataBase.Execute(strSql8.ToString(), channel_id, article_id); //删除主表 StringBuilder strSql = new StringBuilder(); strSql.Append("delete from " + databaseprefix + DTKeys.TABLE_CHANNEL_ARTICLE + channel_name); strSql.Append(" where id=@0"); int rowsAffected = WriteDataBase.Execute(strSql.ToString(), article_id); if (rowsAffected > 0) { new DAL.article_albums(databaseprefix).DeleteFile(albumsList); //删除图片 new DAL.article_attach(databaseprefix).DeleteFile(attachList); //删除附件 return(true); } else { return(false); } }