public void PostEdit(int schoolTermID, string name, int gradeID) { int _code = 0; string _message = "修改班级名称失败"; if (!string.IsNullOrEmpty(name)) { SchoolTerm _schoolTerm = new SchoolTerm(); _schoolTerm.ID = schoolTermID; _schoolTerm.Name = name; _schoolTerm.GradeID = gradeID; _code = _schoolTermService.UpdateSchoolTerm(_schoolTerm); if (_code > 0) { _message = "修改班级名称"; } else { _message = "对不起,修改失败!"; } } else { _message = "班级名称不能为空!"; } RenderText("{\"code\":\"" + _code + "\",\"message\":\"" + _message + "\"}"); CancelLayout(); }
public ActionResult TermsContent(int year) { var viewmodel = new List <SchoolTermsViewModel>(); foreach (var entry in db.schools) { var school = entry; var schoolTerms = new List <SchoolTerm>(); var terms = repository.GetSchoolTerms().Where(x => x.schoolid == school.id); foreach (var term in terms) { var att = term.attendance_terms.SingleOrDefault(x => x.year == year); SchoolTerm row; if (att == null) { row = new SchoolTerm { term = term.name, termid = term.id, year = year }; } else { row = att.ToModel(); } schoolTerms.Add(row); } var model = new SchoolTermsViewModel { terms = schoolTerms, schoolid = school.id, schoolname = school.name }; viewmodel.Add(model); } return(View(viewmodel)); }
public void PostCreate(string name, int gradeID) { int _code = 0; string _message = "对不起,添加失败"; if (!string.IsNullOrEmpty(name)) { SchoolTerm _schoolTerm = new SchoolTerm(); _schoolTerm.Name = name; _schoolTerm.GradeID = gradeID; _code = _schoolTermService.InsertSchoolTerm(_schoolTerm); if (_code > 0) { _message = "添加成功"; } else { _message = "对不起,添加失败,班级名有可能重名了!"; } } else { _message = "对不起,班级名称不能为空"; } RenderText("{\"code\":\"" + _code + "\",\"message\":\"" + _message + "\"}"); CancelLayout(); }
/// <summary> /// 插入SchoolTerm /// </summary> /// <param name="SchoolTerm">SchoolTerm</param> public int InsertSchoolTerm(SchoolTerm schoolTerm) { Hashtable _map = new Hashtable(); _map.Add("GradeID", schoolTerm.GradeID); _map.Add("Name", schoolTerm.Name); _map.Add("id", schoolTerm.ID); schoolTerm.ID = (int)ExecuteInsert("JNyulu.InsertSchoolTerm", _map); return(schoolTerm.ID); }
public ActionResult Terms() { var year = DateTime.Now.Year; var viewmodel = new AdminSchoolTermsViewModel(); viewmodel.yearList = new[] { year }.Union(db.attendance_terms.Select(x => x.year)) .Distinct() .OrderByDescending(x => x) .Select(x => new SelectListItem() { Text = x.ToString(), Value = x.ToString() }); foreach (var entry in db.schools) { var school = entry; var schoolTerms = new List <SchoolTerm>(); var terms = repository.GetSchoolTerms().Where(x => x.schoolid == school.id); foreach (var term in terms) { var att = term.attendance_terms.SingleOrDefault(x => x.year == year); SchoolTerm row; if (att == null) { row = new SchoolTerm { term = term.name, termid = term.id, year = year }; } else { row = att.ToModel(); } schoolTerms.Add(row); } var model = new SchoolTermsViewModel { terms = schoolTerms, schoolid = school.id, schoolname = school.name }; viewmodel.terms.Add(model); } return(View(viewmodel)); }
/// <summary> /// 插入SchoolTerm /// </summary> /// <param name="schoolTerm">SchoolTerm</param> public int InsertSchoolTerm(SchoolTerm schoolTerm) { int _id = -1; try { //_daoManager.BeginTransaction(); _id = _schoolTermDao.InsertSchoolTerm(schoolTerm); //_daoManager.CommitTransaction(); } catch (Exception ex) { //_daoManager.RollBackTransaction(); throw ex; } return(_id); }
public List <SchoolTerm> GetAllSchoolTerm() //获取学年学期的方法 { SchoolTerm school; List <SchoolTerm> list = new List <SchoolTerm>(); string sql = "select * from SchoolTerm"; using (SqlDataReader sdr = DBHelpers.GetAllInfo(sql)) { while (sdr.Read()) { school = new SchoolTerm(); school.SchoolTermID = int.Parse(sdr["SchoolTermID"].ToString()); school.TermName = sdr["TermName"].ToString(); list.Add(school); } } return(list); }
public void Edit(int schoolTermID) { Employee _logonUser = Session["logonUser"] as Employee; SchoolTerm _schoolTerm = _schoolTermService.GetSchoolTermByID(schoolTermID); PropertyBag["schoolTerm"] = _schoolTerm; int _totalNums = 0, _pageSize = 12, pageIndex = 1; string _conAttr = "1 = 1"; if (_logonUser.UserType == 2 && _logonUser.GradeID > 0) { _conAttr = "Grade.ID = " + _logonUser.GradeID; } IList <Grade> _gradeList = _gradeService.PaginatedGrade(pageIndex, _pageSize, "ID", _conAttr, ref _totalNums); PropertyBag["gradeList"] = _gradeList; }
public void VideoList(int stID = 0, int pageIndex = 1) { PropertyBag["catalog"] = -1; int _totalNums = 0, _pageSize = 12; if (pageIndex < 1) { pageIndex = 1; } IList <SchoolTerm> _schoolTermList = _schoolTermService.PaginatedSchoolTerm(1, 120, "SchoolTerm.ID", "SchoolTerm.ID IN(SELECT [STID] FROM [JNyulu_db].[dbo].[Video](NOLOCK) WHERE Permit=0)", ref _totalNums); PropertyBag["schoolTermList"] = _schoolTermList; string _conAttr = "permit = 0"; if (stID > 0) { _conAttr += " AND STID = " + stID; } SchoolTerm _schoolTerm = _schoolTermService.GetBaseSchoolTermByID(stID); if (_schoolTerm == null) { _schoolTerm = new SchoolTerm(); _schoolTerm.Name = "雨露微课堂"; } PropertyBag["schoolTerm"] = _schoolTerm; IList <Video> _videoList = _videoService.PaginatedVideo(pageIndex, _pageSize, "SortNum", _conAttr, ref _totalNums); string uri = "VideoList.do?stID=" + stID + "&pageIndex={0}"; string ltlShowPager = Paginated.BuildPager(uri, _totalNums, pageIndex, _pageSize); PropertyBag["videoList"] = _videoList; PropertyBag["ltlShowPager"] = ltlShowPager; }
public void Video(int videoID) { int _totalNums = 0; IList <SchoolTerm> _schoolTermList = _schoolTermService.PaginatedSchoolTerm(1, 120, "SchoolTerm.ID", "SchoolTerm.ID IN(SELECT [STID] FROM [JNyulu_db].[dbo].[Video](NOLOCK) WHERE Permit=0)", ref _totalNums); PropertyBag["schoolTermList"] = _schoolTermList; Video _video = _videoService.GetVideoByID(videoID); if (_video != null) { SchoolTerm _schoolTerm = _schoolTermService.GetBaseSchoolTermByID(_video.STID); if (_schoolTerm == null) { _schoolTerm = new SchoolTerm(); _schoolTerm.Name = "雨露微课堂"; } PropertyBag["schoolTerm"] = _schoolTerm; } PropertyBag["video"] = _video; }
Term CreateTerm(SchoolTerm term, int year) => new Term() { Id = Guid.NewGuid(), SchoolTerm = term, Year = year };
/// <summary> /// 获取SchoolTerm列表(包含父对象) /// </summary> /// <param name="schoolTerm">SchoolTerm</param> /// <returns>SchoolTerm集合</returns> public IList <SchoolTerm> GetSchoolTerm(SchoolTerm schoolTerm) { return(ExecuteQueryForList <SchoolTerm>("JNyulu.GetSchoolTerm", schoolTerm)); }
/// <summary> /// 更新SchoolTerm /// </summary> /// <param name="SchoolTerm">SchoolTerm</param> public int UpdateSchoolTerm(SchoolTerm schoolTerm) { int i = ExecuteUpdate("JNyulu.UpdateSchoolTerm", schoolTerm); return(i); }
public void PostImportExcel() { string _fileExt = string.Empty; int _code = 0; string _message = string.Empty; try { HttpPostedFile _uploadFiles = Request.Files["uploadFile"] as HttpPostedFile; if (_uploadFiles == null || _uploadFiles.FileName.Length < 3) { _message = "您没有选择要上传的文件!"; _code = -4; } else { _fileExt = Path.GetExtension(_uploadFiles.FileName).ToLower(); //获取文件扩展名 String[] _allowedExt = { ".xls", ".xlsx" }; //允许上传的文件格式 if (!_allowedExt.Contains(_fileExt)) { _message = "您上传的格式为" + _fileExt + ", 本统只接受扩展名为" + string.Join("、", _allowedExt) + "格式文件"; _code = -3; } else if (_uploadFiles.ContentLength == 0) { _message = "上传的内容为空!"; _code = -2; } else if (_uploadFiles.ContentLength > 1024 * 1024 * 8) { _message = "您上传的文件超过了8M!"; _code = -1; } } if (_code == 0) { string _fileName = ShortFileNameUtil.ShortFileName(Guid.NewGuid().ToString()) + _fileExt; string _virtualPath = "/UploadFiles/registrationXls/"; string _physicalPath = HttpContext.Server.MapPath(_virtualPath); if (!Directory.Exists(_physicalPath)) { Directory.CreateDirectory(_physicalPath); } string _fullPath = _physicalPath + _fileName; _uploadFiles.SaveAs(_fullPath); DataTable _employeeData = JNyuluUtils.ImportExcel(_fullPath); int _i = 0; StringBuilder _result = new StringBuilder(); _result.AppendLine("上传路径为:" + _virtualPath + _fileName); _result.AppendLine("Excel解析日志记录:"); foreach (DataRow dr in _employeeData.Rows) { _i++; try { //["学籍号"] ["学生姓名"] dr["报名时间"] dr["班级"] dr["原校"] dr["原来年级"] dr["金额"] dr["备注"] string _name = dr["学籍号"].ToString() + ""; if (!string.IsNullOrEmpty(_name)) { Employee _employee = _employeeService.GetEmployeeByName(_name); if (_employee != null) { string _gradeName = dr["原来年级"].ToString() + ""; Grade _grade = _gradeService.GetGradeByName(_gradeName); if (_grade != null) { int _stID = 0; string _schoolTermName = dr["班级"].ToString(); SchoolTerm _schoolTerm = _schoolTermService.GetBaseSchoolTermByName(_schoolTermName); if (_schoolTerm != null) { _stID = _schoolTerm.ID; } int _schoolFee = 0; int.TryParse(dr["金额"].ToString(), out _schoolFee); Registration _registration = new Registration(); _registration.EmployeeID = _employee.ID; _registration.SchoolName = dr["原校"].ToString() + ""; _registration.GradeID = _grade.ID; _registration.GradeName = _grade.Name; _registration.STID = _stID; _registration.SchoolFee = _schoolFee; _registration.Remark = dr["备注"].ToString() + ""; DateTime _recordDate = DateTime.Today; if (DateTime.TryParse(dr["报名时间"].ToString() + "", out _recordDate)) { _registration.RecordDate = _recordDate; } else { LogHelper.Info("记录[" + _i + "]考试时间格式错误"); _result.AppendLine("记录[" + _i + "]考试时间格式错误"); continue; } _code = _registrationService.InsertRegistration(_registration); } else { LogHelper.Error("记录[" + _i + "]原来年级" + _gradeName + "不存在"); _result.AppendLine("记录[" + _i + "]原来年级" + _gradeName + "不存在"); } } else { LogHelper.Error("记录[" + _i + "]学籍号" + _name + "不存在,您必须选注册学籍号"); _result.AppendLine("记录[" + _i + "]学籍号" + _name + "不存在,您必须选注册学籍号"); } } else { LogHelper.Error("记录[" + _i + "] 中的学籍号不能为空"); _result.AppendLine("记录[" + _i + "] 中的学籍号不能为空"); } } catch (Exception ex) { LogHelper.Error("记录[" + _i + "]导入出错 " + ex.ToString()); _result.AppendLine("记录[" + _i + "]导入出错 " + ex.ToString()); continue; } _i++; } _message = _result.ToString(); } } catch (Exception ex) { _code = -1; _message = ex.Message; } finally { RenderText("{code: " + _code + ",message: '" + _message + "'}"); CancelLayout(); } }
public void PostImportExcel() { string _fileExt = string.Empty; int _code = 0; string _message = string.Empty; try { HttpPostedFile _uploadFiles = Request.Files["uploadFile"] as HttpPostedFile; if (_uploadFiles == null || _uploadFiles.FileName.Length < 3) { _message = "您没有选择要上传的文件!"; _code = -4; } else { _fileExt = Path.GetExtension(_uploadFiles.FileName).ToLower(); //获取文件扩展名 String[] _allowedExt = { ".xls", ".xlsx" }; //允许上传的文件格式 if (!_allowedExt.Contains(_fileExt)) { _message = "您上传的格式为" + _fileExt + ", 本统只接受扩展名为" + string.Join("、", _allowedExt) + "格式文件"; _code = -3; } else if (_uploadFiles.ContentLength == 0) { _message = "上传的内容为空!"; _code = -2; } else if (_uploadFiles.ContentLength > 1024 * 1024 * 8) { _message = "您上传的文件超过了8M!"; _code = -1; } } if (_code == 0) { string _fileName = ShortFileNameUtil.ShortFileName(Guid.NewGuid().ToString()) + _fileExt; string _virtualPath = "/UploadFiles/syllabusXls/"; string _physicalPath = HttpContext.Server.MapPath(_virtualPath); if (!Directory.Exists(_physicalPath)) { Directory.CreateDirectory(_physicalPath); } string _fullPath = _physicalPath + _fileName; _uploadFiles.SaveAs(_fullPath); DataTable _employeeData = JNyuluUtils.ImportExcel(_fullPath); int _i = 0; StringBuilder _result = new StringBuilder(); _result.AppendLine("上传路径为:" + _virtualPath + _fileName); _result.AppendLine("Excel解析日志记录:"); foreach (DataRow dr in _employeeData.Rows) { try { //dr["班级"] dr["学籍号"] dr["学生姓名"] dr["课程表路径"]; string _name = dr["学籍号"].ToString() + ""; Employee _employee = _employeeService.GetEmployeeByName(_name); if (_employee == null) { LogHelper.Info("记录[" + _i + "]学籍:" + _name + " 不存在"); _result.AppendLine("记录[" + _i + "]学籍:" + _name + " 不存在"); continue; } int _stID = 0; string _schoolTermName = dr["班级"].ToString() + ""; SchoolTerm _schoolTerm = _schoolTermService.GetBaseSchoolTermByName(_schoolTermName); if (_schoolTerm == null) { LogHelper.Info("记录[" + _i + "]班级:" + _schoolTermName + " 不存在"); _result.AppendLine("记录[" + _i + "]班级:" + _schoolTermName + " 不存在"); continue; } if (_employee.ID > 0 && _stID > 0) { Syllabus _syllabus = new Syllabus(); _syllabus.EmployeeID = _employee.ID; _syllabus.STID = _stID; _syllabus.SyllabusUrl = _virtualPath + dr["课程表路径"].ToString() + ""; IList <Syllabus> _syllabusList = _syllabusService.GetBaseSyllabus(_syllabus); if (_syllabusList.Count > 0) { _code = _syllabusList[0].ID; _syllabusService.UpdateSyllabus(_syllabus); } else { _code = _syllabusService.InsertSyllabus(_syllabus); } if (_code > 0) { LogHelper.Info("记录[" + _i + "]导入成功"); _result.AppendLine("记录[" + _i + "]导入成功"); } _code = _syllabus.ID; } } catch (Exception ex) { _result.AppendLine(ex.ToString()); LogHelper.Error(ex.ToString()); continue; } _i++; } _message = _result.ToString(); } } catch (Exception ex) { _code = -1; _message = ex.Message; } finally { RenderText("{code: " + _code + ",message: \"" + _message.Replace(@"\", @"\\") + "\"}"); CancelLayout(); } }
/// <summary> /// 获取SchoolTerm列表(包含父对象) /// </summary> /// <param name="schoolTerm">SchoolTerm</param> /// <returns>SchoolTerm集合</returns> public IList <SchoolTerm> GetSchoolTerm(SchoolTerm schoolTerm) { return(_schoolTermDao.GetSchoolTerm(schoolTerm)); }
/// <summary> /// 更新SchoolTerm /// </summary> /// <param name="schoolTerm">SchoolTerm</param> public int UpdateSchoolTerm(SchoolTerm schoolTerm) { return(_schoolTermDao.UpdateSchoolTerm(schoolTerm)); }
public void PostImportExcel() { string _fileExt = string.Empty; int _code = 0; string _message = string.Empty; try { HttpPostedFile _uploadFiles = Request.Files["uploadFile"] as HttpPostedFile; if (_uploadFiles == null || _uploadFiles.FileName.Length < 3) { _message = "您没有选择要上传的文件!"; _code = -4; } else { _fileExt = Path.GetExtension(_uploadFiles.FileName).ToLower(); //获取文件扩展名 String[] _allowedExt = { ".xls", ".xlsx" }; //允许上传的文件格式 if (!_allowedExt.Contains(_fileExt)) { _message = "您上传的格式为" + _fileExt + ", 本统只接受扩展名为" + string.Join("、", _allowedExt) + "格式文件"; _code = -3; } else if (_uploadFiles.ContentLength == 0) { _message = "上传的内容为空!"; _code = -2; } else if (_uploadFiles.ContentLength > 1024 * 1024 * 8) { _message = "您上传的文件超过了8M!"; _code = -1; } } if (_code == 0) { string _fileName = ShortFileNameUtil.ShortFileName(Guid.NewGuid().ToString()) + _fileExt; string _virtualPath = "/UploadFiles/reportCardXls/"; string _physicalPath = HttpContext.Server.MapPath(_virtualPath); if (!Directory.Exists(_physicalPath)) { Directory.CreateDirectory(_physicalPath); } string _fullPath = _physicalPath + _fileName; _uploadFiles.SaveAs(_fullPath); DataTable _employeeData = JNyuluUtils.ImportExcel(_fullPath); int _i = 0; StringBuilder _result = new StringBuilder(); _result.AppendLine("上传路径为:" + _virtualPath + _fileName); _result.AppendLine("导入记录数为:" + _employeeData.Rows.Count + " , Excel解析日志记录:"); foreach (DataRow dr in _employeeData.Rows) { _i++; try { //dr["班级"] dr["学籍号"] dr["学生姓名"] dr["考试时间"] dr["试卷路径"]; string _name = dr["学籍号"].ToString() + ""; Employee _employee = _employeeService.GetEmployeeByName(_name); if (_employee == null) { LogHelper.Info("记录[" + _i + "]学籍:" + _name + " 不存在"); _result.AppendLine("记录[" + _i + "]学籍:" + _name + " 不存在"); continue; } string _schoolTermName = dr["班级"].ToString() + ""; SchoolTerm _schoolTerm = _schoolTermService.GetBaseSchoolTermByName(_schoolTermName); if (_schoolTerm == null) { LogHelper.Info("记录[" + _i + "]班级:" + _schoolTermName + " 不存在"); _result.AppendLine("记录[" + _i + "]班级:" + _schoolTermName + " 不存在"); continue; } _result.AppendLine("记录[" + _i + "] employeeID:[" + _employee.ID + "] 班级ID:[" + _schoolTerm.ID + "]"); if (_employee.ID > 0 && _schoolTerm.ID > 0) { ReportCard _reportCard = new ReportCard(); _reportCard.EmployeeID = _employee.ID; _reportCard.STID = _schoolTerm.ID; DateTime _examDate = DateTime.Today; if (DateTime.TryParse(dr["考试时间"].ToString() + "", out _examDate)) { _reportCard.ExamDate = _examDate; } else { LogHelper.Info("记录[" + _i + "]考试时间格式错误"); _result.AppendLine("记录[" + _i + "]考试时间格式错误"); continue; } string _testPaper = dr["试卷路径"].ToString() + ""; if (!string.IsNullOrEmpty(_testPaper)) { _reportCard.TestPaperUrl = "/UploadFiles/testPaperFiles/" + _testPaper; } IDictionary _hash = new Hashtable(); _hash.Add("EmployeeID", _reportCard.EmployeeID); _hash.Add("STID", _reportCard.STID); _hash.Add("TestPaperUrl", _reportCard.TestPaperUrl); IList <ReportCard> _reportCardList = _reportCardService.GetReportCard(_hash); _result.AppendLine("记录[" + _i + "](" + _reportCard.TestPaperUrl + ") _reportCardList.Count:" + _reportCardList.Count); if (_reportCardList.Count > 0) { _reportCard.ID = _reportCardList[0].ID; _code = _reportCardService.UpdateReportCard(_reportCard); } else { _reportCard.ID = _reportCardService.InsertReportCard(_reportCard); } _result.AppendLine("记录[" + _i + "] _reportCard.ID:" + _reportCard.ID); _code = _reportCard.ID; } } catch (Exception ex) { _result.AppendLine(ex.ToString()); LogHelper.Error(ex.ToString()); continue; } } _message = _result.ToString(); } } catch (Exception ex) { _code = -1; _message = ex.Message; } finally { RenderText("{code: " + _code + ",message: \"" + _message.Replace(@"\", @"\\") + "\"}"); CancelLayout(); } }