//删除选中的文章 protected void btnDeleteArt_Click(object sender, EventArgs e) { for (int i = 0; i < gvArtManager.Rows.Count; i++) { //获取GridView中每一行的CheckBox引用 CheckBox chk = (CheckBox)gvArtManager.Rows[i].FindControl("chkCheck"); if (chk.Checked) { Guid artID = (Guid)gvArtManager.DataKeys[i].Value; string sqlQuery = string.Format("select * from T_ARTICLE where ID='{0}'", artID); DataTable dtQuery = SqlServerHooker.GetDataTable(sqlQuery); //删除文章中的图片 string imageNames = dtQuery.Rows[0][7].ToString(); string[] imageArr = imageNames.Split(';'); foreach (string imageName in imageArr) { string imgFtpPath = "ueditor/net/upload/image/" + imageName; _ftpManager.DeleteFile(imgFtpPath); } //删除ftp里面对应的html文件 string htmlName = dtQuery.Rows[0][6].ToString(); bool isSuc = _ftpManager.DeleteFile(string.Format("article/{0}.html", htmlName)); //if (isSuc) //{ //删除数据库信息 string sqlDelete = string.Format("delete from T_ARTICLE where ID='{0}'", artID); SqlServerHooker.DeleteDataFromTable(sqlDelete); //} } } //刷新GridView gvArtManager.DataBind(); }
public void Reset() { Invoke( new Action( () => loadingLabel.Text = "Resetting data...")); if (_projectFileCreated) { try { string localPath = null; Invoke(new Action(() => localPath = localPathTextBox.Text)); File.Delete(localPath); _projectFileCreated = false; } catch (Exception ex) { Invoke( new Action( () => Popup.ShowPopup(this, SystemIcons.Error, "Error while deleting the project file.", ex, PopupButtons.Ok))); } } if (_projectConfigurationEdited) { string name = null; Invoke( new Action( () => name = nameTextBox.Text)); _projectConfiguration.RemoveAt(_projectConfiguration.FindIndex(item => item.Name == name)); try { File.WriteAllText(Program.ProjectsConfigFilePath, Serializer.Serialize(_projectConfiguration)); _projectConfigurationEdited = false; } catch (Exception ex) { Invoke( new Action( () => Popup.ShowPopup(this, SystemIcons.Error, "Error while deleting the project file.", ex, PopupButtons.Ok))); } } if (_phpFileCreated) { var phpFilePath = Path.Combine(Program.Path, "Projects", nameTextBox.Text, "statistics.php"); try { File.Delete(phpFilePath); _phpFileCreated = false; } catch (Exception ex) { Invoke( new Action( () => Popup.ShowPopup(this, SystemIcons.Error, "Error while deleting \"statistics.php\" again.", ex, PopupButtons.Ok))); } } if (_phpFileUploaded) { try { _ftp.DeleteFile("statistics.php"); _phpFileUploaded = false; } catch (Exception ex) { Invoke( new Action( () => Popup.ShowPopup(this, SystemIcons.Error, "Error while deleting \"statistics.php\" on the server again.", ex, PopupButtons.Ok))); } } bool useStatistics = false; Invoke(new Action(() => useStatistics = useStatisticsServerRadioButton.Checked)); if (useStatistics) { Settings.Default.ApplicationID -= 1; Settings.Default.Save(); } SetUiState(true); if (_mustClose) { Invoke(new Action(Close)); } }