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