using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bowin.Common.JSON;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using EMIS.CommonLogic.TeachingMaterial;
using Bowin.Web.Controls.Mvc;
using EMIS.ViewModel.TeachingMaterial;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.Utility;
using EMIS.CommonLogic.CalendarManage;
namespace EMIS.Web.Controllers.TeachingMaterial
{
[Authorization]
public class TeachersConfirmOrderController : Controller
{
public ITeachersConfirmOrderServices TeachersConfirmOrderServices { get; set; }
public ISchoolYearServices schoolYearServices { get; set; }
///
/// 页面列表查询
///
///
[HttpGet]
public ActionResult List()
{
//默认加载当前校历下学年学期的下一个学期
var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true);
var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
ViewBag.SchoolYearID = schoolyear.SchoolYearID;
return View();
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
//避开全选值
Guid? publishID = pararms.getExtraGuid("PublishDropdown");
Guid? coursematerialID = pararms.getExtraGuid("CourseDropdown");
var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown");
Guid? teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
var approvalStatus = pararms.getExtraInt("StatusDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
return base.Json(TeachersConfirmOrderServices.GetTeachersOrderViewGrid(configuretView, schoolYearID, teachingMaterialID, coursematerialID, publishID, approvalStatus, (int)pararms.page, (int)pararms.rows));
}
#region 2.0 加载清单明细列表
///
/// 明细页面
///
///
[HttpGet]
public ActionResult Detail(string teachersOrderID)
{
string yearIds = Request.QueryString["schoolYearID"];
if (yearIds != null)
{
ViewData["schoolYearID"] = yearIds;
ViewData["teachingMaterialPoolID"] = Request.QueryString["teachingMaterialPoolID"];
}
return View();
}
///
/// 清单征订明细查看
///
///
///
[HttpPost]
public ActionResult Detail(QueryParamsModel pararms)
{
var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
//避开全选值
var schoolYearID = Request.Params["schoolYearID"] == null ? Guid.Empty.ToString() : Request.Params["schoolYearID"].ToString();
var teachingMaterialID = Request.Params["teachingMaterialPoolID"] == null ? Guid.Empty.ToString() : Request.Params["teachingMaterialPoolID"].ToString();
Guid? collegeID = user.CollegeID;
Guid? teachingMaterialPoolIDs = new Guid(teachingMaterialID);
Guid? schoolYearIDs = new Guid(schoolYearID);
return base.Json(TeachersConfirmOrderServices.GetTeachersOrderDetailViewGrid(schoolYearIDs, collegeID, teachingMaterialPoolIDs, (int)pararms.page, (int)pararms.rows));
}
#endregion
#region 3.0 获取预加窗口
///
/// 获取下一步动作
///
///
///
[HttpGet]
public ActionResult BatchSetPreAddedValue()
{
TeachersConfirmOrderView teachersConfirmOrderView;
teachersConfirmOrderView = new TeachersConfirmOrderView()
{
PreAddedValue = 5
};
return View(teachersConfirmOrderView);
}
#endregion
#region 4.0 待定
#endregion
#region 5.0 批量设置值
///
/// 批量设置预加值
///
///
[HttpPost]
public ActionResult BatchSetPreAddedValue(string orderJsonStr)
{
try
{
orderJsonStr = Request.Form["hid_JsonStr"];
string PreAddedValue = Request.Form["PreAddedValue"];
if (orderJsonStr != null)
{
var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
var addTeacherList = orderJsonStr.JsonToObject>();
TeachersConfirmOrderServices.BatchUpdatePreAddedValue(addTeacherList, Convert.ToInt32(PreAddedValue), user.UserID);
}
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功!"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存失败,原因:" + ex.Message + "!"
});
}
}
#endregion
#region 6.0 页面Excel表格导出
[HttpPost]
public ActionResult Excel(QueryParamsModel pararms)
{
//避开全选值
bool? isLate = null;
Guid? publishID = Request.Form["PublishDropdown"].ParseStrTo();
Guid? coursematerialID = Request.Form["CourseDropdown"].ParseStrTo();
var schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo();
var teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo();
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var dt = TeachersConfirmOrderServices.GetTeachersConfirmOrderViewExcel(configuretView, schoolYearID, teachingMaterialID, coursematerialID, publishID).Select(x => new
{
x.SchoolyearName,
x.TeachingMaterialCode,
x.CoursematerialName,
x.ISBN,
x.TeachingMaterialName,
x.Price,
x.PublishTime,
x.PublishName,
x.Author,
x.OrderQty,
x.PreAddedValue,
x.CountNumber
}).ToTable();
string[] liststring = { "学年学期","教材编号","课程名称","ISBN","教材名称","单价"
,"版本时间","出版单位","作者","征订数量","增加数量","总数量"};
neh.Export(dt, liststring, "征订统计信息");
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功!",
url = Url.Content("~/TeachersConfirmOrder/List").AddMenuParameter()
});
}
#endregion
#region 6.0 明细Excel表格导出
[HttpPost]
public ActionResult DetailExcel(QueryParamsModel pararms)
{
//避开全选值
Guid? schoolyearID = Request.Params["schoolyearID"].ParseStrTo();
Guid? teachingMaterialPoolID = Request.Params["teachingMaterialPoolID"].ParseStrTo();
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var dt = TeachersConfirmOrderServices.GetTeachersConfirmOrderViewDetailExcel(schoolyearID, teachingMaterialPoolID).Select(x => new
{
x.SchoolyearName,
x.CollegeName,
x.TeachingMaterialCode,
x.CoursematerialName,
x.ISBN,
x.TeachingMaterialName,
x.PublishTime,
x.PublishName,
x.Author,
x.OrderQty,
x.OrderUserName,
x.OrderDate,
x.OrderDesc,
x.Desc
}).ToTable();
string[] liststring = { "学年学期",RSL.Get("College"),"教材编号","课程名称","ISBN","教材名称"
,"版本时间","出版单位","作者","征订数量","征订人","征订日期","征订说明","备注"};
neh.Export(dt, liststring, "教师征订清单明细信息");
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功!",
url = Url.Content("~/TeachersConfirmOrder/List").AddMenuParameter()
});
}
#endregion
}
}