/// <summary> /// 根据Id获取指定建筑信息 /// </summary> /// <param name="Id"></param> /// <returns></returns> public Model.T_Base_Architecture GetArchitecture(int Id) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from T_Base_Architecture where Id = " + Id; SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["Id"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); architecture.IsCollege = Convert.ToInt32(reader["IsCollege"]); reader.Close(); config.Close(); return(architecture); }
/// <summary> /// 保存添加的讲座信息 /// </summary> /// <param name="majorClass"></param> /// <returns></returns> public int AddSaveLecture(string AddNum, Model.T_Base_Lecture Lecture, int AddPlaceId) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); int result = -1; try { cmd.Transaction = config.getSqlConnection().BeginTransaction(); if (CheckDateTime(Lecture.Id, Lecture.LectureTime, Lecture.Span, AddPlaceId)) { cmd.CommandText = "insert into T_Base_Lecture " + "values('" + Lecture.Subject + "','" + Lecture.Summary + "',0,-1,'" + Lecture.DeathLine + "','" + Lecture.LectureTime + "'," + Lecture.Span + "," + Lecture.ExpectPeople + ",0," + Lecture.Score + ",0)"; try { cmd.ExecuteNonQuery(); } catch { cmd.Transaction.Rollback(); return(-3); //请确保按照格式填入全部信息 } cmd.CommandText = "select top 1 Id from T_Base_Lecture order by Id desc"; result = (int)cmd.ExecuteScalar(); cmd.CommandText = "insert into T_Base_Apply values('" + AddNum + "'," + result + "," + AddPlaceId + ",'" + DateTime.Now + "','')"; cmd.ExecuteNonQuery(); cmd.Transaction.Commit(); } else { cmd.Transaction.Rollback(); return(-2); //时间冲突 } } catch { result = -1; } config.Close(); return(result); }
public int SaveExcelUser(List <Model.T_Base_User> User) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.Transaction = config.getSqlConnection().BeginTransaction(); int result = 0; //添加的学生数 for (int i = 0; i < User.Count; i++) { //判断该生是否存在 cmd.CommandText = "select count(1) from T_Base_User where Num='" + User[i].Num + "'"; if ((int)cmd.ExecuteScalar() == 1) { continue; } //判断学院是否存在 cmd.CommandText = "select count(1) from T_Base_Architecture where ArchitectureName='" + User[i].MajorClass.Architecture.ArchitectureName + "'"; if ((int)cmd.ExecuteScalar() == 0) { cmd.CommandText = "insert into T_Base_Architecture values('" + User[i].MajorClass.Architecture.ArchitectureName + "',1)"; cmd.ExecuteNonQuery(); } cmd.CommandText = "select Id from T_Base_Architecture where ArchitectureName='" + User[i].MajorClass.Architecture.ArchitectureName + "'"; int architectureId = (int)cmd.ExecuteScalar(); //判断班级是否存在 cmd.CommandText = "select count(1) from T_Base_MajorClass where MajorClassName='" + User[i].MajorClass.MajorClassName + "'"; if ((int)cmd.ExecuteScalar() == 0) { cmd.CommandText = "insert into T_Base_MajorClass values('" + User[i].MajorClass.MajorClassName + "'," + architectureId + ")"; cmd.ExecuteNonQuery(); } cmd.CommandText = "select Id from T_Base_MajorClass where MajorClassName='" + User[i].MajorClass.MajorClassName + "'"; int majorClassId = (int)cmd.ExecuteScalar(); //添加用户 cmd.CommandText = "insert into T_Base_User values('" + User[i].Num + "','" + User[i].Name + "'," + User[i].Sex + "," + majorClassId + ",'" + User[i].PhoneNum + "','" + User[i].Num + "',0,0,3)"; result += cmd.ExecuteNonQuery(); } cmd.Transaction.Commit(); config.Close(); return(result); }
public List <Model.T_Base_Resource> GetAllResource(int LectureId) { List <Model.T_Base_Resource> list = new List <Model.T_Base_Resource>(); SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from T_Base_Resource where LectureId = " + LectureId; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Model.T_Base_Resource resource = new Model.T_Base_Resource(); resource.Id = Convert.ToInt32(reader["Id"]); resource.Num = Convert.ToString(reader["Num"]); resource.LectureId = Convert.ToInt32(reader["LectureId"]); resource.Content = Convert.ToString(reader["Content"]); if (reader["FilePosition1"].Equals(DBNull.Value)) { resource.FilePosition1 = Convert.ToString(DBNull.Value); } else { resource.FilePosition1 = Convert.ToString(reader["FilePosition1"]); } if (reader["ResourceDate"].Equals(DBNull.Value)) { resource.ResourceDate = Convert.ToDateTime(null); } else { resource.ResourceDate = Convert.ToDateTime(reader["ResourceDate"]); } resource.ReviewFlag = Convert.ToInt16(reader["ReviewFlag"]); list.Add(resource); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 获取指定Id的专业班级信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public Model.T_Base_MajorClass GetMajorClass(int id) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from T_Base_MajorClass where Id = " + id; SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Id = Convert.ToInt32(reader["Id"]); majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); majorClass.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); reader.Close(); config.Close(); return(majorClass); }
/// <summary> /// 获取指定Id的地点信息 /// </summary> /// <param name="Id"></param> /// <returns></returns> public Model.T_Base_Place GetPlace(int Id) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from V_Place_Architecture where Id = " + Id; SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); Model.T_Base_Place place = new Model.T_Base_Place(); place.Id = Convert.ToInt32(reader["Id"]); place.PlaceName = Convert.ToString(reader["PlaceName"]); place.PeopleNum = Convert.ToInt32(reader["PeopleNum"]); place.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["ArchitectureId"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); place.Architecture = architecture; config.Close(); return(place); }
/// <summary> /// 查询建筑内可举办讲座地点(Id,地点名称,容纳人数) /// </summary> /// <param name="ArchitectureId"></param> /// <returns></returns> public List <Model.T_Base_Place> GetAllPlace(int ArchitectureId) { List <Model.T_Base_Place> list = new List <Model.T_Base_Place>(); SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from T_Base_Place where ArchitectureId = " + ArchitectureId; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Model.T_Base_Place place = new Model.T_Base_Place(); place.Id = Convert.ToInt32(reader["Id"]); place.PlaceName = Convert.ToString(reader["PlaceName"]); place.PeopleNum = Convert.ToInt32(reader["PeopleNum"]); list.Add(place); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 根据指定建筑Id获取学院专业 /// </summary> /// <returns></returns> public List <Model.T_Base_MajorClass> GetMajorClass(int ArchitectureId) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from T_Base_MajorClass where ArchitectureId = " + ArchitectureId; SqlDataReader reader = cmd.ExecuteReader(); List <Model.T_Base_MajorClass> list = new List <Model.T_Base_MajorClass>(); while (reader.Read()) { Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Id = Convert.ToInt32(reader["Id"]); majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); majorClass.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); list.Add(majorClass); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 获取全部建筑 /// </summary> /// <param name="PageSize"></param> /// <param name="PageNumber"></param> /// <returns></returns> public List <Model.T_Base_Architecture> GetAllArchitecture() { List <Model.T_Base_Architecture> list = new List <Model.T_Base_Architecture>(); SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from T_Base_Architecture"; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["Id"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); architecture.IsCollege = Convert.ToInt32(reader["IsCollege"]); list.Add(architecture); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 查询出席的讲座 /// </summary> /// <param name="Num"></param> /// <returns></returns> public List <Model.T_Base_Statistic> GetAllAttendance(string Num, int State) { List <Model.T_Base_Statistic> list = new List <Model.T_Base_Statistic>(); SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); if (State == 0) { cmd.CommandText = "select * from V_Lecture_Statistic where Num = '" + Num + "'"; } else if (State == 1) { cmd.CommandText = "select * from V_Lecture_Statistic where Num = '" + Num + "' and EndTime <> '1900/1/1 0:00:00'"; } SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Model.T_Base_Statistic statistic = new Model.T_Base_Statistic(); Model.T_Base_Lecture lecture = new Model.T_Base_Lecture(); lecture.Id = Convert.ToInt32(reader["Id"]); lecture.Subject = Convert.ToString(reader["Subject"]); lecture.Score = Convert.ToDouble(reader["Score"]); lecture.RealPeople = Convert.ToInt32(reader["RealPeople"]); lecture.LectureTime = Convert.ToDateTime(reader["LectureTime"]); statistic.Id = Convert.ToInt32(reader["StatisticId"]); statistic.Num = Convert.ToString(reader["Num"]); statistic.StartTime = Convert.ToDateTime(reader["StartTime"]); statistic.EndTime = Convert.ToDateTime(reader["EndTime"]); statistic.Lecture = lecture; list.Add(statistic); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 查询参与讲座人员信息 /// </summary> /// <param name="LectureId"></param> /// <returns></returns> public List <Model.T_Base_Statistic> SavePeopleExcel(int LectureId) { List <Model.T_Base_Statistic> list = new List <Model.T_Base_Statistic>(); SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from V_Excel where LectureId = " + LectureId; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Model.T_Base_Statistic statistic = new Model.T_Base_Statistic(); Model.T_Base_User user = new Model.T_Base_User(); user.Num = Convert.ToString(reader["Num"]); user.Name = Convert.ToString(reader["Name"]); user.Sex = Convert.ToInt16(reader["Sex"]); user.PhoneNum = Convert.ToString(reader["PhoneNum"]); Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Architecture = architecture; majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); user.MajorClass = majorClass; statistic.StartTime = Convert.ToDateTime(reader["StartTime"]); statistic.EndTime = Convert.ToDateTime(reader["EndTime"]); statistic.User = user; list.Add(statistic); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 获取指定Num的用户信息 /// </summary> /// <param name="UserId"></param> /// <returns></returns> public Model.T_Base_User GetUser(string Num) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select * from V_User_MajorClass_Architecture where Num = '" + Num + "'"; SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); //所属学院信息 Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["ArchitectureId"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); //所属专业班级信息 Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Id = Convert.ToInt32(reader["MajorClassId"]); majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); majorClass.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); majorClass.Architecture = architecture; //用户信息 Model.T_Base_User user = new Model.T_Base_User(); user.Id = Convert.ToInt32(reader["Id"]); user.Num = Convert.ToString(reader["Num"]); user.Name = Convert.ToString(reader["Name"]); user.Sex = Convert.ToInt32(reader["Sex"]); user.MajorClassId = Convert.ToInt32(reader["MajorClassId"]); user.PhoneNum = Convert.ToString(reader["PhoneNum"]); user.PassWord = Convert.ToString(reader["PassWord"]); user.MajorClass = majorClass; user.Role = Convert.ToInt32(reader["Role"]); reader.Close(); config.Close(); return(user); }
/// <summary> /// 签到 /// </summary> /// <param name="Num"></param> /// <param name="LectureId"></param> /// <param name="Ip"></param> /// <returns></returns> public int AddSaveStatistic(string Num, int LectureId, string Ip) { int result = -1; SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select LectureTime,Span from T_Base_Lecture where Id = " + LectureId; SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); DateTime LectureTime = Convert.ToDateTime(reader["LectureTime"]); double Span = Convert.ToDouble(reader["Span"]); reader.Close(); if (DateTime.Now >= LectureTime.AddMinutes(-30) && DateTime.Now <= LectureTime.AddMinutes(5)) { //签到,提前三十分钟到开始五分钟区间内可签到 cmd.CommandText = "select count(1) from T_Base_Statistic where LectureId = " + LectureId + " and Ip = '" + Ip + "'"; result = (int)cmd.ExecuteScalar(); if (result == 0) { cmd.CommandText = "insert into T_Base_Statistic values('" + Num + "'," + LectureId + ",'" + DateTime.Now + "','" + DBNull.Value + "','" + Ip + "')"; try { result = cmd.ExecuteNonQuery(); config.Close(); return(1); //签到成功 } catch { return(-4); //学号输入不正确或不存在该学号 } } else { config.Close(); return(-3); //存在代签情况 } } else if (DateTime.Now >= LectureTime.AddMinutes(Span * 60 * 0.8) && DateTime.Now <= LectureTime.AddMinutes(Span * 60 + 30)) { //签退 cmd.CommandText = "select count(1) from T_Base_Statistic where LectureId = " + LectureId + " and Ip = '" + Ip + "'"; result = (int)cmd.ExecuteScalar(); if (result <= 1) { cmd.CommandText = "select count(1) from T_Base_Statistic where Num = '" + Num + "' and LectureId = " + LectureId; result = (int)cmd.ExecuteScalar(); if (result < 1) { config.Close(); return(-2); //未签到 } cmd.CommandText = "update T_Base_Statistic set EndTime = '" + DateTime.Now + "' where Num = '" + Num + "' and LectureId = " + LectureId; result = cmd.ExecuteNonQuery(); config.Close(); return(2); //签退成功 } else { config.Close(); return(-3); //存在代签情况 } } config.Close(); return(-1); //签到失败 }
/// <summary> /// 获取个人所申请的全部讲座信息 /// </summary> /// <param name="Num"></param> /// <returns></returns> public List <Model.T_Base_Apply> GetPersonalAllLecture(string Num, int Role) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); if (Role == 1 || Role == 2) { cmd.CommandText = "select * from V_User_Lecture_Place order by Id desc"; } else if (Role == 3) { cmd.CommandText = "select * from V_User_Lecture_Place where Num = '" + Num + "' order by Id desc"; } SqlDataReader reader = cmd.ExecuteReader(); List <Model.T_Base_Apply> list = new List <Model.T_Base_Apply>(); while (reader.Read()) { Model.T_Base_Apply apply = new Model.T_Base_Apply(); apply.Id = Convert.ToInt32(reader["Id"]); apply.Num = Convert.ToString(reader["Num"]); apply.LectureId = Convert.ToInt32(reader["LectureId"]); apply.PlaceId = Convert.ToInt32(reader["PlaceId"]); apply.ApplyTime = Convert.ToDateTime(reader["ApplyTime"]); Model.T_Base_User user = new Model.T_Base_User(); user.Id = Convert.ToInt32(reader["Id"]); user.Num = Convert.ToString(reader["Num"]); user.Name = Convert.ToString(reader["Name"]); user.Sex = Convert.ToInt32(reader["Sex"]); user.MajorClassId = Convert.ToInt32(reader["MajorClassId"]); Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Id = Convert.ToInt32(reader["MajorClassId"]); majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); user.MajorClass = majorClass; user.PhoneNum = Convert.ToString(reader["PhoneNum"]); apply.User = user; Model.T_Base_Lecture lecture = new Model.T_Base_Lecture(); lecture.Id = Convert.ToInt32(reader["LectureId"]); lecture.Subject = Convert.ToString(reader["Subject"]); lecture.Summary = Convert.ToString(reader["Summary"]); lecture.State = Convert.ToInt32(reader["State"]); lecture.QRCode = Convert.ToString(reader["QRCode"]); lecture.DeathLine = Convert.ToDateTime(reader["DeathLine"]); lecture.LectureTime = Convert.ToDateTime(reader["LectureTime"]); lecture.Span = Convert.ToDouble(reader["Span"]); lecture.ExpectPeople = Convert.ToInt32(reader["ExpectPeople"]); lecture.RealPeople = Convert.ToInt32(reader["RealPeople"]); lecture.Score = Convert.ToDouble(reader["Score"]); apply.Lecture = lecture; Model.T_Base_Place place = new Model.T_Base_Place(); place.Id = Convert.ToInt32(reader["PlaceId"]); place.PlaceName = Convert.ToString(reader["PlaceName"]); place.PeopleNum = Convert.ToInt32(reader["PeopleNum"]); place.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["ArchitectureId"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); place.Architecture = architecture; apply.Place = place; list.Add(apply); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 获取全部讲座信息 /// </summary> /// <param name="ArchitectureId"></param> /// <returns></returns> public List <Model.T_Base_Apply> GetAllLecture(string ParamLecture, int PageSize, int PageNumber, string State) { SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); cmd.CommandText = "select top " + PageSize + " * from V_User_Lecture_Place" + " where Id not in (select top " + (PageSize * (PageNumber - 1)) + " Id from V_User_Lecture_Place where (V_User_Lecture_Place.Subject" + " like '%" + ParamLecture + "%' or V_User_Lecture_Place.Name like '%" + ParamLecture + "%') and V_User_Lecture_Place.State " + State + ") and (V_User_Lecture_Place.Subject" + " like '%" + ParamLecture + "%' or V_User_Lecture_Place.Name like '%" + ParamLecture + "%') and State " + State; SqlDataReader reader = cmd.ExecuteReader(); List <Model.T_Base_Apply> list = new List <Model.T_Base_Apply>(); while (reader.Read()) { Model.T_Base_Apply apply = new Model.T_Base_Apply(); apply.Id = Convert.ToInt32(reader["Id"]); apply.Num = Convert.ToString(reader["Num"]); apply.LectureId = Convert.ToInt32(reader["LectureId"]); apply.PlaceId = Convert.ToInt32(reader["PlaceId"]); apply.ApplyTime = Convert.ToDateTime(reader["ApplyTime"]); Model.T_Base_User user = new Model.T_Base_User(); user.Id = Convert.ToInt32(reader["UserId"]); user.Num = Convert.ToString(reader["Num"]); user.Name = Convert.ToString(reader["Name"]); user.Sex = Convert.ToInt32(reader["Sex"]); user.MajorClassId = Convert.ToInt32(reader["MajorClassId"]); Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Id = Convert.ToInt32(reader["MajorClassId"]); majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); user.MajorClass = majorClass; user.PhoneNum = Convert.ToString(reader["PhoneNum"]); apply.User = user; Model.T_Base_Lecture lecture = new Model.T_Base_Lecture(); lecture.Id = Convert.ToInt32(reader["LectureId"]); lecture.Subject = Convert.ToString(reader["Subject"]); lecture.Summary = Convert.ToString(reader["Summary"]); lecture.State = Convert.ToInt32(reader["State"]); lecture.QRCode = Convert.ToString(reader["QRCode"]); lecture.DeathLine = Convert.ToDateTime(reader["DeathLine"]); lecture.LectureTime = Convert.ToDateTime(reader["LectureTime"]); lecture.Span = Convert.ToDouble(reader["Span"]); lecture.ExpectPeople = Convert.ToInt32(reader["ExpectPeople"]); lecture.RealPeople = Convert.ToInt32(reader["RealPeople"]); lecture.Score = Convert.ToDouble(reader["Score"]); apply.Lecture = lecture; Model.T_Base_Place place = new Model.T_Base_Place(); place.Id = Convert.ToInt32(reader["PlaceId"]); place.PlaceName = Convert.ToString(reader["PlaceName"]); place.PeopleNum = Convert.ToInt32(reader["PeopleNum"]); place.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["ArchitectureId"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); place.Architecture = architecture; apply.Place = place; list.Add(apply); } reader.Close(); config.Close(); return(list); }
/// <summary> /// 获取指定id的讲座 /// </summary> /// <param name="Id"></param> /// <returns></returns> public List <Model.T_Base_Apply> GetLecture(int LectureId, int State) { List <Model.T_Base_Apply> list = new List <Model.T_Base_Apply>(); SqlConfig config = new SqlConfig(); SqlCommand cmd = config.getSqlCommand(); if (State == 1) { cmd.CommandText = "select * from V_User_Lecture_Place where LectureId = " + LectureId; } else if (State == 2) { cmd.CommandText = "select * from V_User_Lecture_Place_Audit where LectureId = " + LectureId; } SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Model.T_Base_Apply apply = new Model.T_Base_Apply(); apply.Id = Convert.ToInt32(reader["Id"]); apply.Num = Convert.ToString(reader["Num"]); apply.LectureId = Convert.ToInt32(reader["LectureId"]); apply.PlaceId = Convert.ToInt32(reader["PlaceId"]); apply.ApplyTime = Convert.ToDateTime(reader["ApplyTime"]); Model.T_Base_User user = new Model.T_Base_User(); user.Id = Convert.ToInt32(reader["Id"]); user.Num = Convert.ToString(reader["Num"]); user.Name = Convert.ToString(reader["Name"]); user.Sex = Convert.ToInt32(reader["Sex"]); user.MajorClassId = Convert.ToInt32(reader["MajorClassId"]); Model.T_Base_MajorClass majorClass = new Model.T_Base_MajorClass(); majorClass.Id = Convert.ToInt32(reader["MajorClassId"]); majorClass.MajorClassName = Convert.ToString(reader["MajorClassName"]); user.MajorClass = majorClass; user.PhoneNum = Convert.ToString(reader["PhoneNum"]); apply.User = user; Model.T_Base_Lecture lecture = new Model.T_Base_Lecture(); lecture.Id = Convert.ToInt32(reader["LectureId"]); lecture.Subject = Convert.ToString(reader["Subject"]); lecture.Summary = Convert.ToString(reader["Summary"]); lecture.State = Convert.ToInt32(reader["State"]); lecture.QRCode = Convert.ToString(reader["QRCode"]); lecture.DeathLine = Convert.ToDateTime(reader["DeathLine"]); lecture.LectureTime = Convert.ToDateTime(reader["LectureTime"]); lecture.Span = Convert.ToDouble(reader["Span"]); lecture.ExpectPeople = Convert.ToInt32(reader["ExpectPeople"]); lecture.RealPeople = Convert.ToInt32(reader["RealPeople"]); lecture.Score = Convert.ToDouble(reader["Score"]); if (State == 2) { if (reader["Reason"].Equals(DBNull.Value)) { lecture.Reason = ""; } else { lecture.Reason = Convert.ToString(reader["Reason"]); } } apply.Lecture = lecture; Model.T_Base_Place place = new Model.T_Base_Place(); place.Id = Convert.ToInt32(reader["PlaceId"]); place.PlaceName = Convert.ToString(reader["PlaceName"]); place.PeopleNum = Convert.ToInt32(reader["PeopleNum"]); place.ArchitectureId = Convert.ToInt32(reader["ArchitectureId"]); Model.T_Base_Architecture architecture = new Model.T_Base_Architecture(); architecture.Id = Convert.ToInt32(reader["ArchitectureId"]); architecture.ArchitectureName = Convert.ToString(reader["ArchitectureName"]); place.Architecture = architecture; apply.Place = place; list.Add(apply); } reader.Close(); config.Close(); return(list); }