62,046
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 删除图书信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gdvPublishList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string strtmp = this.gdvPublishList.DataKeys[e.RowIndex].Value.ToString();
int intBookNum = Convert.ToInt32(this.gdvPublishList.DataKeys[e.RowIndex].Value.ToString());
string[] pathValues = new string[2] { "", "" };
pathValues = publish.getBookToPic(intBookNum);
string strCoverPicPath = pathValues[0].ToString().Trim(); //取得封面图片相对路径
string strOtherPicPath = pathValues[1].ToString().Trim(); //取得插图图片相对路径
if (strCoverPicPath != "")
{
strCoverPicPath = Server.MapPath(strCoverPicPath);
if (File.Exists(strCoverPicPath)) //使用File.Exists判断某文件是否存在
{
File.Delete(strCoverPicPath);//删除实际封面图片
}
}
if (strOtherPicPath != "")
{
strOtherPicPath = Server.MapPath(strOtherPicPath);
if (File.Exists(strOtherPicPath)) //使用File.Exists判断某文件是否存在
{
File.Delete(strOtherPicPath);//删除实际插图图片
}
}
string strFlag = publish.delBookInfo(Convert.ToInt32(Session["user_id"]), Convert.ToInt32(strtmp));
if (strFlag == "1")
{
lblMsg.Text = " 提示:图书信息删除成功";
}
else
lblMsg.Text = " 错误:图书信息删除失败!请稍后再试...";
BindPage(strCondition);
BindPublishList(strCondition);
}