📄 user_actiondal.cs
字号:
//------------------------------------
//版权所有:杭州商易信息技术有限公司
//功能描述:数据访问类
// 作者:沈伟
// 日期:2008/08/21
//------------------------------------
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using SystemFrameworks;
namespace Itsv.DAL.SystemManage
{
/// <summary>
/// 数据访问类user_action。
/// </summary>
public class user_actionDAL
{
public user_actionDAL()
{ }
#region 成员方法
/// <summary>
/// 是否存在该记录
/// </summary>
public bool Exists(int id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) from user_action where id=" + id + "");
object obj = DbHelperSQL.GetSingle(strSql.ToString());
int cmdresult;
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
cmdresult = 0;
}
else
{
cmdresult = int.Parse(obj.ToString());
}
if (cmdresult == 0)
{
return false;
}
else
{
return true;
}
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(Itsv.Model.user_action model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into user_action(");
strSql.Append("account,user_id,action,date_time,dept_name");
strSql.Append(")");
strSql.Append(" values (");
strSql.Append("'" + model.account + "',");
strSql.Append("" + model.user_id + ",");
strSql.Append("'" + model.action + "',");
strSql.Append("'" + model.date_time + "',");
strSql.Append("'" + model.dept_name + "'");
strSql.Append(")");
int QueryNum = DbHelperSQL.ExecuteSql(strSql.ToString());
return QueryNum;
}
/// <summary>
/// 更新一条数据
/// </summary>
public void Update(Itsv.Model.user_action model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update user_action set ");
strSql.Append("account='" + model.account + "',");
strSql.Append("user_id=" + model.user_id + ",");
strSql.Append("action='" + model.action + "',");
strSql.Append("date_time='" + model.date_time + "',");
strSql.Append("dept_name='" + model.dept_name + "'");
strSql.Append(" where id=" + model.id + "");
DbHelperSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 删除一条数据
/// </summary>
public void Delete(int id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete user_action ");
strSql.Append(" where id=" + id);
DbHelperSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 删除一组数据
/// </summary>
/// <param name="beginTime">开始时间</param>
/// <param name="endTime">结束时间</param>
/// <returns>影响的行数</returns>
public int Delete(DateTime beginTime,DateTime endTime)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete user_action ");
strSql.Append(" where dateTime between '"+beginTime.AddDays(-1).ToShortDateString()+"' and '"+(endTime.AddDays(1)).ToShortDateString()+"'");
int QueryNum = DbHelperSQL.ExecuteSql(strSql.ToString());
return QueryNum;
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Itsv.Model.user_action GetModel(int id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from user_action ");
strSql.Append(" where id=" + id);
Itsv.Model.user_action model = new Itsv.Model.user_action();
DataSet ds = DbHelperSQL.Query(strSql.ToString());
model.id = id;
if (ds.Tables[0].Rows.Count > 0)
{
model.account = ds.Tables[0].Rows[0]["account"].ToString();
if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
{
model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
}
model.action = ds.Tables[0].Rows[0]["action"].ToString();
if (ds.Tables[0].Rows[0]["date_time"].ToString() != "")
{
model.date_time = DateTime.Parse(ds.Tables[0].Rows[0]["date_time"].ToString());
}
model.dept_name = ds.Tables[0].Rows[0]["dept_name"].ToString();
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from user_action ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by id ");
return DbHelperSQL.Query(strSql.ToString());
}
/// <summary>
/// 格式化日志表
/// </summary>
public bool TruncateTable()
{
StringBuilder strSql = new StringBuilder();
strSql.Append("truncate table user_action ");
DbHelperSQL.ExecuteSql(strSql.ToString());
return true;
}
#endregion 成员方法
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -