using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using Bowin.Common.Data;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.SupervisionManage;
using EMIS.ViewModel.SupervisionManage;
using EMIS.Utility;
using Bowin.Common.Utility;
using EMIS.CommonLogic.SystemServices;
namespace EMIS.Web.Controllers.SupervisionManage
{
[Authorization]
public class ProjectRecordController : Controller
{
public IProjectRecordServices projectRecordServices { get; set; }
public IRoleServices IRoleServices { get; set; }
public ActionResult List()
{
return View();
}
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
var collegeID = pararms.getExtraGuid("CollegeDropdown");
var ddCcollegeID = pararms.getExtraGuid("DDCollegeDropdown");
var supervisionType = pararms.getExtraInt("SupervisionType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SupervisionType");
var startDate = pararms.getExtraDateTime("StartDate");
var endDate = pararms.getExtraDateTime("EndDate");
var dataRange = IRoleServices.GetDataRange();
return base.Json(projectRecordServices.GetProjectRecordViewGrid(configuretView, schoolyearID, collegeID, supervisionType, ddCcollegeID, startDate, endDate,dataRange, (int)pararms.page, (int)pararms.rows));
}
[HttpGet]
public ActionResult Edit(Guid? projectRecordID, int? isShow)
{
ProjectRecordView projectRecordView = new ProjectRecordView();
var evaluation = (int)SUP_SupervisionType.Evaluation;
if (projectRecordID.HasValue && projectRecordID != Guid.Empty)
{
projectRecordView = projectRecordServices.GetProjectRecordView(projectRecordID);
}
ViewBag.Evaluation = evaluation;
return View(projectRecordView);
}
///
/// 编辑
///
///
///
[HttpPost]
public ActionResult Edit(ProjectRecordView projectRecordView)
{
try
{
var teacherList = DataGrid.GetTableData("dgTeacherList");
if (teacherList.Count <= 0)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:督导组成员不能为空。"
});
}
List filelist = new List();
var sessionName = FileUploadHelper.GetFileUploadSessionName(projectRecordView.ProjectRecordID);
var sessionfileList = (List)Session[sessionName];
if (sessionfileList != null)
{
foreach (var file in sessionfileList)
{
filelist.Add(file);
}
}
projectRecordServices.Save(projectRecordView, teacherList, filelist);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
[HttpPost]
public ActionResult Delete(string projectRecordIDs)
{
try
{
var projectRecordIDList = projectRecordIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
projectRecordServices.Delete(projectRecordIDList);
return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
}
catch (Exception ex)
{
return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
}
}
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null);
var schoolyearID = Request.Form["Schoolyear"].ParseStrTo();
var collegeID = Request.Form["College"].ParseStrTo();
var supervisionType = Request.Form["SupervisionType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SupervisionType"].ParseStrTo();
var supervisionCollegeID = Request.Form["SupervisionCollege"].ParseStrTo();
var startDate = Request.Form["StartDate"].ParseStrTo();
var endDate = Request.Form["EndDate"].ParseStrTo();
var projectRecordIDString = Request.Form["SelectedID"];
var projectRecordIDList = projectRecordIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
var dataRange = IRoleServices.GetDataRange();
List result;
result = projectRecordServices.GetProjectRecordViewList(conditionView, schoolyearID, collegeID, supervisionType, supervisionCollegeID,
startDate, endDate, projectRecordIDList, dataRange);
var dt = result.Select(x => new
{
x.SchoolyearCode,
x.SupervisionTypeDesc,
x.CollegeName,
x.SupervisionCollegeName,
x.SupervisionTarget,
x.DateWeekTimeDesc,
x.Location,
x.staffListDesc,
x.CreateUserName,
CreateTime = x.CreateTime.Value.ToShortDateString(),
}).ToTable();
string[] liststring = { "学年学期", "督导类型", "院系所", "督导院系", "督导对象", "督导时间","督导地点",
"督导组成员", "创建人", "创建时间" };
neh.Export(dt, liststring, "督导项目记录");
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功!"
});
}
[HttpGet]
public ActionResult TeacherSelect()
{
return View();
}
[HttpPost]
public ActionResult TeacherList(QueryParamsModel pararms, Guid? projectRecordID)
{
if (projectRecordID.HasValue && projectRecordID != Guid.Empty)
{
return base.Json(projectRecordServices.GetProjectRecordTeacherViewGridByID(projectRecordID, (int)pararms.page, (int)pararms.rows));
}
else
{
return base.Json(projectRecordServices.GetDefaultTeacherViewGrid((int)pararms.page, (int)pararms.rows)); ;
}
}
[HttpGet]
public ActionResult Upload(Guid? projectRecordID)
{
ProjectRecordView projectRecordView = new ProjectRecordView();
projectRecordView.ProjectRecordID = projectRecordID.Value;
return View(projectRecordView);
}
[HttpPost]
public ActionResult Upload()
{
return Json("上传成功");
}
[HttpPost]
public ActionResult GetFileListByProjectRecordID(Guid? projectRecordID)
{
//var convertByApplyID = scoreConvertByApplyID.ParseStrTo();
var sessionName = FileUploadHelper.GetFileUploadSessionName(projectRecordID ?? Guid.Empty);
var fileList = (List)Session[sessionName];
return Json(fileList);
}
[HttpGet]
public ActionResult SelectAdvise()
{
return View();
}
/////
///// 教师列表查询
/////
/////
/////
//[HttpPost]
//public ActionResult ALLTeacherList(QueryParamsModel pararms)
//{
// ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
// var userID = pararms.getExtraGuid("SaffDropdown");
// var campusID = pararms.getExtraGuid("CampusDropdown");
// var collegeID = pararms.getExtraGuid("CollegeDropdown");
// var departmentID = pararms.getExtraGuid("DepartmentDropdown");
// var isphotoUrl = pararms.getExtraInt("PhotoUrltmentDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PhotoUrltmentDropdown");
// return base.Json(staffServices.Value.GetStaffViewGrid(configuretView, campusID, collegeID, departmentID, isphotoUrl, userID, (int)pararms.page, (int)pararms.rows));
//}
//public ActionResult GetLoginUser()
//{
// var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
// return View(curUser);
//}
}
}