using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.PaymentManage; using EMIS.ViewModel.PaymentManage; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; namespace EMIS.Web.Controllers.PaymentManage { [Authorization] public class WorktimeAdjustmentController : Controller { public IWorktimeAdjustmentServices WorktimeAdjustmentServices { get; set; } public ActionResult List() { return View(); } public ActionResult Edit(Guid? WorktimeAdjustmentID) { WorktimeAdjustmentView worktimeAdjustmentView = new WorktimeAdjustmentView(); if (WorktimeAdjustmentID.HasValue) { worktimeAdjustmentView = WorktimeAdjustmentServices.GetWorktimeAdjustmentView(WorktimeAdjustmentID); } else { worktimeAdjustmentView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); } return View(worktimeAdjustmentView); } public ActionResult GenerateChargeAgainst() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var coursematerialID = pararms.getExtraGuid("cgbCourse"); var teacherUserID = pararms.getExtraGuid("cgbUser"); var worktimeAdjustmentTypeID = pararms.getExtraInt("ddlWorktimeAdjustmentType") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("ddlWorktimeAdjustmentType"); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; return base.Json(WorktimeAdjustmentServices.GetWorktimeAdjustmentViewList(configuretView, schoolyearID, coursematerialID, teacherUserID, worktimeAdjustmentTypeID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Edit(WorktimeAdjustmentView worktimeAdjustmentView) { try { WorktimeAdjustmentServices.Save(worktimeAdjustmentView); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult Delete(string worktimeAdjustmentIDs) { try { List list = worktimeAdjustmentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); WorktimeAdjustmentServices.Delete(list); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" }); } catch (Exception ex) { return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message }); } } [HttpPost] public ActionResult GetEducationMissionClass(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearID"); var userID = pararms.getExtraGuid("UserID"); var adjustDate = pararms.getExtraDateTime("AdjustDate"); var collegeID = pararms.getExtraGuid("CollegeID"); var gradeYearID = pararms.getExtraInt("GradeYearID") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("GradeYearID"); var standardID = pararms.getExtraInt("StandardID") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("StandardID"); var coursematerialID = pararms.getExtraGuid("CoursematerialID"); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; return base.Json(WorktimeAdjustmentServices.GetEducationMissionClassList(configuretView, schoolyearID, userID, adjustDate, collegeID, gradeYearID, standardID, coursematerialID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult GenerateChargeAgainst(Guid schoolyearID) { try { WorktimeAdjustmentServices.GenerateChargeAgainst(schoolyearID); return base.Json(new ReturnMessage { IsSuccess = true, Message = "生成成功" }); } catch (Exception ex) { return base.Json(new ReturnMessage { IsSuccess = false, Message = "生成失败:" + ex.Message }); } } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo(); var coursematerialID = Request.Form["cgbCourse"].ParseStrTo(); var teacherUserID = Request.Form["cgbUser"].ParseStrTo(); var worktimeAdjustmentTypeID = Request.Form["ddlWorktimeAdjustmentType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWorktimeAdjustmentType"].ParseStrTo(); var dt = WorktimeAdjustmentServices.GetWorktimeAdjustmentViewList(configuretView, schoolyearID, coursematerialID, teacherUserID, worktimeAdjustmentTypeID).Select(x => new { x.AdjustDate, x.SchoolyearCode, x.EducationMissionClassName, x.TeacherName, x.CourseCode, x.CourseName, x.WorktimeAdjustmentTypeDesc, x.Worktime, }).ToTable(); string[] liststring = { "记录时间", "学年学期", "任务班级", "教师", "课程编码", "课程名称", "登记类型", "课时数" }; neh.Export(dt, liststring, "工作量调整"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Action("List").AddMenuParameter() }); } } }