📄 mdbaaaaa.a
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MODEL;
using DBManage;
using IDAL;
namespace SQLServerDAL
{
public class LoginLogService:ILoginLogService
{
#region IBaseService<LoginLog> 成员
private static List<LoginLog> GetModelsFromDataSet(DataSet ds)
{
List<LoginLog> ls = new List<LoginLog>();
foreach (DataRow row in ds.Tables[0].Rows)
{
LoginLog model = new LoginLog();
model.LoginId= Convert.ToInt32(row[0]);
model.UserId = Convert.ToString(row[1]);
model.LoginTime = Convert.ToString(row[2]);
model.IfSuccess = Convert.ToInt32(row[3]);
model.LoginUserIp= Convert.ToString(row[4]);
model.LoginDesc = Convert.ToString(row[5]);
ls.Add(model);
}
return ls;
}
public int AddModel(LoginLog model)
{
string sql = string.Format("insert into LoginLog values('{0}','{1}','{2}','{3}','{4}'", model.UserId,
model.LoginTime,
model.IfSuccess,
model.LoginUserIp,
model.LoginDesc);
return DBOperate.UpdateModel(sql);
}
public int DeleteModelById(int id)
{
string where = " LoginId=" + id;
return DeleteModelByWhere(where);
}
public int DeleteModelByWhere(string where)
{
string sql = string.Format("delete LoginLog");
if (!string.IsNullOrEmpty(where))
{
sql = sql + " where " + where;
}
return DBOperate.UpdateModel(sql);
}
public int UpdateModel(LoginLog model)
{
string something = string.Format(" UserId='{0}',LoginTime='{1}',IfSuccess='{2}',LoginUserIp='{3}',LoginDesc='{4}'", model.UserId,
model.LoginTime,
model.IfSuccess,
model.LoginUserIp,
model.LoginDesc);
string where = string.Format(" LoginId={0} ", model.LoginId);
return UpdateSomethingByWhere(something, where);
}
public int UpdateSomethingByWhere(string something, string where)
{
string sql = "update LoginLog set " + something;
if (!string.IsNullOrEmpty(where))
{
sql = sql + " where " + where;
}
return DBOperate.UpdateModel(sql);
}
public List<LoginLog> GetAllModels()
{
DataSet ds = DBOperate.GetModels("LoginLog", "");
return GetModelsFromDataSet(ds);
}
public LoginLog GetModelById(int id)
{
DataSet ds = DBOperate.GetModels("LoginLog", "LoginId=" + id);
return GetModelsFromDataSet(ds)[0];
}
public List<LoginLog> GetModelByForeignKey(int ForeignKeyID)
{
throw new Exception("The method or operation is not implemented.");
}
public List<LoginLog> GetModels(string strWhere)
{
DataSet ds = DBOperate.GetModels("LoginLog", strWhere);
return GetModelsFromDataSet(ds);
}
public List<LoginLog> GetModels(int pageIndex, int pageSize, string orderColumnsName, string strWhere)
{
DataSet ds = DBOperate.GetModels("LoginLog", pageIndex, pageSize, orderColumnsName, strWhere);
return GetModelsFromDataSet(ds);
}
public List<LoginLog> GetModels(int pageIndex, int pageSize, string orderColumnsName)
{
return GetModels(pageIndex, pageSize, orderColumnsName, "");
}
public List<LoginLog> GetModels(int pageIndex, string orderColumnsName)
{
return GetModels(pageIndex, 10, orderColumnsName, "");
}
public List<LoginLog> GetModels(int pageIndex, int pageSize)
{
return GetModels(pageIndex, pageSize, "LoginId", "");
}
public List<LoginLog> GetModels(int pageIndex)
{
return GetModels(pageIndex, 10, "LoginId", "");
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -