1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.Students;
- using EMIS.ViewModel.Cultureplan;
- using EMIS.CommonLogic.SystemSetting;
- using EMIS.ViewModel.Students;
- using EMIS.ViewModel;
- using EMIS.Utility;
- using EMIS.Web.Controls;
- using System.IO;
- namespace EMIS.Web.Controllers.StudentSystem.StudentRecord
- {
- [Authorization]
- public class StudentRecordController : Controller
- {
- public IStudentsServices StudentsServices { get; set; }
- public IStudentRecordServices StudentRecordService { get; set; }
- public Lazy<IDictionaryServices> DictionaryServices { get; set; }
- /// <summary>
- /// 我的信息(学生平台,列表形式-暂时无效,有误)
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 我的信息
- /// </summary>
- /// <returns></returns>
- public ActionResult Record()
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var Student = StudentRecordService.GetStudentByStudentNo(user.UserID);
- return View(Student);
- }
- [HttpPost]
- public ActionResult Record(StudentRecordView studentRecordView)
- {
- try
- {
- var accepts = new List<string> { ".jpg" };
- var postedFile = Request.Files["PhotoUrl"];
- if (postedFile != null && !string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower()))
- {
- throw new Exception("只允许上传.jpg格式的文件。");
- }
- if (postedFile != null && !string.IsNullOrEmpty(postedFile.FileName) && (postedFile.ContentLength > (200 * 1024) || postedFile.ContentLength < (50 * 1024)))
- {
- throw new Exception("只允许上传50-200k大小的照片。");
- }
- string photoUrl = FileUploadHelper.UploadFile(postedFile);
- if (photoUrl != null)
- {
- studentRecordView.PhotoUrl = photoUrl;
- }
- StudentRecordService.RecordSave(studentRecordView);
- string UrlStr = Url.Action("Record").AddMenuParameter();
- return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "保存成功!",
- url = UrlStr
- });
- }
- catch (Exception ex)
- {
- string UrlStr = Url.Action("Record").AddMenuParameter();
- return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
- {
- WindowID = Request["WindowID"],
- msg = "保存失败,原因:" + ex.Message,
- url = UrlStr
- });
- }
- }
- }
- }
|