namespace dal
{
public class oledo
{
private olehelp olehelpex;
public oledo()
{
olehelpex = new olehelp();
}
/// <summary>
/// 选择所有数据
/// </summary>
/// <returns></returns>
public DataTable selectall()
{
DataTable dt = new DataTable();
//dt = olehelpex.execquery("selectall", CommandType.StoredProcedure);
dt = olehelpex.execquery("SELECT i.id, i.filetitle, i.filecontent, i.filename, i.filedate, c.catename FROM category AS c INNER JOIN info AS i ON c.id=i.caid order by i.filedate desc", CommandType.Text);
return dt;
}
/// <summary>
/// 插入
/// </summary>
/// <param name="filetitle"></param>
/// <param name="filecontent"></param>
/// <param name="filename"></param>
/// <param name="caid"></param>
/// <returns></returns>
public bool insertinfo(string filetitle, string filecontent, string filename, string caid)
{
bool flag = false;
OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@filetitle", filetitle), new OleDbParameter("@filecontent", filecontent), new OleDbParameter("@filename", filename), new OleDbParameter("@caid", caid) };
int res = olehelpex.execnonquery("insert into info(filetitle,filecontent,filename,caid) values(@filetitle,@filecontent,@filename,@caid)", paras, CommandType.Text);
if (res > 0)
{
flag = true;
}
return flag;
}
/// <summary>
/// 删除
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool deleinfo(string id)
{
bool flag = false;
OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@id", id) };
int res = olehelpex.execnonquery("delete from info where id=@id", paras, CommandType.Text);
if (res > 0)
{
flag = true;
}
return flag;
}
/// <summary>
/// 更新
/// </summary>
/// <param name="filetitle"></param>
/// <param name="filecontent"></param>
/// <param name="caid"></param>
/// <param name="id"></param>
/// <returns></returns>
public bool fixinfo(string filetitle, string filecontent,string caid,string id)
{
bool flag = false;
OleDbParameter[] paras = new OleDbParameter[] { new OleDbParameter("@filetitle", filetitle), new OleDbParameter("@filecontent", filecontent), new OleDbParameter("@caid",caid), new OleDbParameter("@id", id) };
int res = olehelpex.execnonquery("update info set filetitle=@filetitle,filecontent=@filecontent,caid=@caid where id=@id", paras, CommandType.Text);
if (res > 0)
{
flag = true;
}
return flag;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;