using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.CommonLogic.SelectCourse.SelectCourseResult;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using Bowin.Common.Utility;
using Bowin.Common.Data;
namespace EMIS.Web.Controllers.SelectCourseManage.SelectCourseResult
{
[Authorization]
public class SelectCourseListController : Controller
{
public ISelectCourseListServices SelectCourseListServices { get; set; }
///
/// 选课结果学生名单页面
///
///
public ActionResult List()
{
return View();
}
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var schoolyearID = pararms.getExtraGuid("SchoolYear");
var collegeID = pararms.getExtraGuid("CollegeComboGrid");
var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == -1 ? null : pararms.getExtraInt("DictionaryCourseType");
var selectCourseTypeID = pararms.getExtraInt("DictionarySelectCourseType") == -1 ? null : pararms.getExtraInt("DictionarySelectCourseType");
var isCreated = pararms.getExtraInt("DictionaryIsCreated") == -1 ? null : pararms.getExtraInt("DictionaryIsCreated");
var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
var result = SelectCourseListServices.GetSelectCourseViewList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID, isCreated, isOpen, (int)pararms.page, (int)pararms.rows);
return Json(result);
}
[HttpPost]
public ActionResult Excel()
{
//return View();
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
//避开全选值
if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
var schoolyearID = Request.Form["SchoolYear"].ParseStrTo();
var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo();
var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo();
var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo();
var selectCourseTypeID = Request.Form["DictionarySelectCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySelectCourseType"].ParseStrTo();
var isCreated = Request.Form["DictionaryIsCreated"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsCreated"].ParseStrTo();
var isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo();
var dt = SelectCourseListServices.GetSelectCourseList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID, isCreated, isOpen)
.Select(x => new
{
x.SchoolYearCode,
x.DefaultClassName,
x.CourseCode,
//x.CourseName,
x.CourseTypeName,
//x.CourseCategoryName,
//x.CourseQualityName,
//x.Credit,
//x.Totalhours,
//x.PeopleNumlower,
//x.PeopleNumlimit,
//x.StudentTotalNum,
//x.SelectCourseTypeName,
x.LoginID,
x.UserName,
x.ClassMajorName,
//x.TeachingModeName,
//x.SchoolcodeName,
//x.TeacherName,
//x.IsOpenedDesc
x.RecordStatusName
}).ToTable();
string[] liststring = { "学年学期",
"选修任务班名称",
"课程代码",
//"课程名称",
"课程类型",
"选修类型",
//"课程性质",
//"学分",
//"总学时", "人数下限", "人数上限",
//"已选人数",
"学号","姓名","学籍班",
//"教研室", RSL.Get("College"),
//"授课方式",
//"开课学期",
//"教师姓名",
//"是否开放"
"状态"
};
neh.Export(dt, liststring, "选课结果学生名单");
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功!",
url = Url.Content("~/SelectCourseList/List").AddMenuParameter()
});
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string IDs, string Types, string UserIDs)
{
try
{
List list = new List();
for (int i = 0; i < IDs.Split(',').Length; i++)
{
string id = IDs.Split(',')[i];
if (!string.IsNullOrEmpty(id))
{
Guid ID = new Guid(id);
list.Add(ID);
}
}
List list1 = new List();
for (int i = 0; i < Types.Split(',').Length; i++)
{
string type = Types.Split(',')[i];
if (!string.IsNullOrEmpty(type))
{
int Type = Convert.ToInt32(type);
list1.Add(Type);
}
}
List list2 = new List();
for (int i = 0; i < UserIDs.Split(',').Length; i++)
{
string id = UserIDs.Split(',')[i];
if (!string.IsNullOrEmpty(id))
{
Guid ID = new Guid(id);
list2.Add(ID);
}
}
SelectCourseListServices.SelectCourseListDelete(list, list1, list2);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "删除成功!"
});
}
catch (Exception ex)
{
string mge = ex.Message;
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "删除失败,原因:" + mge
});
}
}
}
}