private DataTable GetTable(string SQL) { DataSet ds = AccessAdo.ExecuteDataSet(SQL); DataTable dt = ds.Tables[0]; return(dt); }
private DocumentForm OpenFile(string nodeId) { //获取文章信息 string SQL = "select Title,Content from TContent inner join TTree on TContent.NodeId=Ttree.NodeId where TContent.NodeId=" + nodeId; DataTable temp = AccessAdo.ExecuteDataSet(SQL, null).Tables[0]; if (temp.Rows.Count == 0) { return(null); } string Title = temp.Rows[0]["Title"].ToString(); string Content = temp.Rows[0]["Content"].ToString(); DocumentForm doc = new DocumentForm(); SetScintillaToCurrentOptions(doc); doc.Scintilla.Text = Content; doc.Scintilla.UndoRedo.EmptyUndoBuffer(); doc.Scintilla.Modified = false; doc.Text = Title; doc.NodeId = nodeId; doc.Show(dockPanel1); return(doc); }
//刷新附件 public void ReFreshAttachGrid() { DataView dv = new DataView(AccessAdo.ExecuteDataSet("select affixid,nodeid,'' as 序号,[title] as 标题,[size] as 大小,[time] as 加入日期 from tattachment where nodeid=" + Attachment.ActiveNodeId).Tables[0]); dataGridView1.DataSource = dv; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Visible = false; int count = dv.Count; for (int i = 0; i < count; i++) { dataGridView1.Rows[i].Cells[2].Value = i + 1; } }
//删除数据库记录,同时关闭已打开的文章 public void DelNodeData(string NodeId) { string SQL = string.Format("select NodeId from Ttree where parentId={0}", NodeId); DataTable temp = AccessAdo.ExecuteDataSet(SQL).Tables[0]; DataView dv = new DataView(temp); foreach (DataRowView drv in dv) { DelNodeData(drv["NodeId"].ToString()); } //关闭打开的文章 formParent.CloseDoc(NodeId); string DelSQL = string.Format("Delete from TAttachment where NodeId={0}", NodeId); AccessAdo.ExecuteNonQuery(DelSQL); DelSQL = string.Format("Delete from Tcontent where NodeId={0}", NodeId); AccessAdo.ExecuteNonQuery(DelSQL); DelSQL = string.Format("Delete from Ttree where NodeId={0}", NodeId); AccessAdo.ExecuteNonQuery(DelSQL); }
private void FormAttachment_Load(object sender, EventArgs e) { dataGridView1.DataSource = AccessAdo.ExecuteDataSet("select '' as 序号,[title] as 标题,[size] as 大小,[time] as 加入日期 from tattachment where nodeid=" + Attachment.ActiveNodeId).Tables[0]; }