📄 vdbaaaaa.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 ReadCommonMessageService:IReadCommonMessageService
{
#region IBaseService<ReadCommonMessage> 成员
private static List<ReadCommonMessage> GetModelsFromDataSet(DataSet ds)
{
List<ReadCommonMessage> ls = new List<ReadCommonMessage>();
foreach (DataRow row in ds.Tables[0].Rows)
{
ReadCommonMessage model = new ReadCommonMessage();
model.ReadId = Convert.ToInt32(row[0]);
model.MessageId = Convert.ToInt32(row[1]);
model.UserId = Convert.ToString(row[2]);
ls.Add(model);
}
return ls;
}
public int AddModel(ReadCommonMessage model)
{
string sql = string.Format("insert into ReadCommonMessage values('{0}','{1}','{2}')",
model.MessageId,
model.UserId );
return DBOperate.UpdateModel(sql);
}
public int DeleteModelById(int id)
{
string where = " ReadId=" + id;
return DeleteModelByWhere(where);
}
public int DeleteModelByWhere(string where)
{
string sql = string.Format("delete ReadCommonMessage");
if (!string.IsNullOrEmpty(where))
{
sql = sql + " where " + where;
}
return DBOperate.UpdateModel(sql);
}
public int UpdateModel(ReadCommonMessage model)
{
string something = string.Format(" MessageId='{0}',UserId='{1}' ",
model.MessageId,
model.UserId);
string where = string.Format(" ReadId={0} ", model.ReadId);
return UpdateSomethingByWhere(something, where);
}
public int UpdateSomethingByWhere(string something, string where)
{
string sql = "update ReadCommonMessage set " + something;
if (!string.IsNullOrEmpty(where))
{
sql = sql + " where " + where;
}
return DBOperate.UpdateModel(sql);
}
public List<ReadCommonMessage> GetAllModels()
{
DataSet ds = DBOperate.GetModels("ReadCommonMessage", "");
return GetModelsFromDataSet(ds);
}
public ReadCommonMessage GetModelById(int id)
{
DataSet ds = DBOperate.GetModels("ReadCommonMessage", "ReadId=" + id);
return GetModelsFromDataSet(ds)[0];
}
public List<ReadCommonMessage> GetModelByForeignKey(int ForeignKeyID)
{
throw new Exception("The method or operation is not implemented.");
}
public List<ReadCommonMessage> GetModels(string strWhere)
{
DataSet ds = DBOperate.GetModels("ReadCommonMessage", strWhere);
return GetModelsFromDataSet(ds);
}
public List<ReadCommonMessage> GetModels(int pageIndex, int pageSize, string orderColumnsName, string strWhere)
{
DataSet ds = DBOperate.GetModels("ReadCommonMessage", pageIndex, pageSize, orderColumnsName, strWhere);
return GetModelsFromDataSet(ds);
}
public List<ReadCommonMessage> GetModels(int pageIndex, int pageSize, string orderColumnsName)
{
return GetModels(pageIndex, pageSize, orderColumnsName, "");
}
public List<ReadCommonMessage> GetModels(int pageIndex, string orderColumnsName)
{
return GetModels(pageIndex, 10, orderColumnsName, "");
}
public List<ReadCommonMessage> GetModels(int pageIndex, int pageSize)
{
return GetModels(pageIndex, pageSize, "ReadId", "");
}
public List<ReadCommonMessage> GetModels(int pageIndex)
{
return GetModels(pageIndex, 10, "ReadId", "");
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -