using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.ScoreManage;
using EMIS.ViewModel.ScoreManage;
using Bowin.Common.Exceptions;
using Bowin.Common.Utility;
using Bowin.Common.Data;
namespace EMIS.Web.Controllers.ScoreManage
{
public partial class ScoreConvertController
{
public IScoreConvertByLevelServices ScoreConvertByLevelServices { get; set; }
public ActionResult ByLevelList()
{
return View();
}
///
/// 列表查询
///
[HttpPost]
public ActionResult ByLevelList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
//避开全选值
var schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
var collegeID = pararms.getExtraGuid("CollegeDropdown");
var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
var coursematerialID = pararms.getExtraGuid("CourseDropdown");
var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
return base.Json(ScoreConvertByLevelServices.GetUniteMaintainViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, coursematerialID, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
///
public ActionResult ByLevelEdit()
{
ScoreConvertByLevelView scoreConvertByLevelView = new ScoreConvertByLevelView();
return View(scoreConvertByLevelView);
}
[HttpPost]
public ActionResult ByLevelEdit(ScoreConvertByLevelView scoreConvertByLevelView)
{
try
{
var success= ScoreConvertByLevelServices.Save(scoreConvertByLevelView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = success
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败:" + ex.Message
});
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult ByLevelDelete(string ScoreConvertByLevelScoreIDs)
{
try
{
List list = new List();
for (int i = 0; i < ScoreConvertByLevelScoreIDs.Split(',').Length; i++)
{
if (!string.IsNullOrEmpty(ScoreConvertByLevelScoreIDs.Split(',')[i]))
{
Guid ScoreConvertByLevelScoreID = new Guid(ScoreConvertByLevelScoreIDs.Split(',')[i]);
list.Add(ScoreConvertByLevelScoreID);
}
}
ScoreConvertByLevelServices.Delete(list);
return this.Json("删除成功!");
}
catch (Exception ex)
{
string mge = ex.Message;
System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
if (num != null)
{
if (num.Number == 547)
mge = "请先删除所有关联的数据!";
}
return this.Json("删除失败,原因:" + mge);
}
}
///
/// 导出Excel
///
///
[HttpPost]
public ActionResult ByLevelExcel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var ScoreConvertByLevelScoreIDs = Request.Form["ScoreConvertByLevelScoreIDs"];
var schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo();
var collegeID = Request.Form["CollegeDropdown"].ParseStrTo();
var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo();
var coursematerialID = Request.Form["CourseDropdown"].ParseStrTo();
var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo();
var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo();
List ScoreConvertByLevelScoreIDList = new List();
if (ScoreConvertByLevelScoreIDs != "")
{
ScoreConvertByLevelScoreIDList = ScoreConvertByLevelScoreIDs.SplitIDString();
}
else
{
ScoreConvertByLevelScoreIDList = null;
}
var dt = ScoreConvertByLevelServices.GetScoreConvertByLevelView_Excel(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, coursematerialID, ScoreConvertByLevelScoreIDList).Select(x => new
{
x.SchoolyearCode,
x.CollegeName,
x.Year,
x.StandardStr,
x.ClassmajorName,
x.LoginID,
x.UserName,
x.CourseCode,
x.CourseName,
x.ExaminationSubjectName,
x.Score
}).ToTable();
string[] liststring = { "学年学期", EMIS.Utility.RSL.Get("College"),"年级", "专业", "班级名称", "学号","姓名","课程代码", "课程名称","科目名称", "成绩" };
neh.Export(dt, liststring, "统一认定信息");
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功!",
url = Url.Action("List").AddMenuParameter()
});
}
}
}