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.Web.Controls; using EMIS.ViewModel; using Bowin.Common.Data; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using EMIS.Utility; namespace EMIS.Web.Controllers.PaymentManage { [Authorization] public class WorktimeAdditionController : Controller { public IWorktimeAdditionServices WorktimeAdditionServices { get; set; } public ActionResult List() { return View(); } public ActionResult Edit(Guid? WorktimeAdditionID) { WorktimeAdditionView worktimeAdditionView = new WorktimeAdditionView(); if (WorktimeAdditionID.HasValue) { worktimeAdditionView = WorktimeAdditionServices.GetWorktimeAdditionView(WorktimeAdditionID); } else { worktimeAdditionView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); } return View(worktimeAdditionView); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var collegeID = pararms.getExtraGuid("cgbCollege"); var teacherUserID = pararms.getExtraGuid("cgbTeacherUser"); var studentCollegeID = pararms.getExtraGuid("cgbStudentCollege"); var courseCollegeID = pararms.getExtraGuid("cgbCourseCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("ddlYear"); var standardID = pararms.getExtraInt("cgbStandard") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("cgbStandard"); var teachingModeID = pararms.getExtraInt("ddlTeachingMode") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("ddlTeachingMode"); var month = pararms.getExtraInt("ddlMonth") == DropdownList.PLEASE_SELECT ? null : pararms.getExtraInt("ddlMonth"); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; return base.Json(WorktimeAdditionServices.GetWorktimeAdditionViewList(configuretView, schoolyearID, collegeID, teacherUserID, studentCollegeID, courseCollegeID, year, standardID, teachingModeID,month, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Edit(WorktimeAdditionView worktimeAdditionView) { try { WorktimeAdditionServices.Save(worktimeAdditionView); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult Delete(string worktimeAdditionIDs) { try { List list = worktimeAdditionIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); WorktimeAdditionServices.Delete(list); 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 collegeID = Request.Form["cgbCollege"].ParseStrTo(); var teacherUserID = Request.Form["cgbTeacherUser"].ParseStrTo(); var studentCollegeID = Request.Form["cgbStudentCollege"].ParseStrTo(); var courseCollegeID = Request.Form["cgbCourseCollege"].ParseStrTo(); var year = Request.Form["ddlYear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo(); var standardID = Request.Form["cgbStandard"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["cgbStandard"].ParseStrTo(); var teachingModeID = Request.Form["ddlTeachingMode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlTeachingMode"].ParseStrTo(); var month = Request.Form["ddlMonth"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlMonth"].ParseStrTo(); var dt = WorktimeAdditionServices.GetWorktimeAdditionViewList(configuretView, schoolyearID, collegeID, teacherUserID, studentCollegeID, courseCollegeID, year, standardID, teachingModeID, month).Select(x => new { x.SchoolyearCode, x.CollegeName, x.TeacherName, x.GradeYearID, x.StandardDesc, x.CourseCode, x.CourseName, x.CourseCollegeName, x.EducationMissionClassName, x.TeachingModeDesc, x.TeachTypeDesc, x.StudentCount, x.CourseTime, x.Remark }).ToTable(); string[] liststring = { "学年学期", "教师单位", "教师姓名", "年级", "专业", "课程代码", "课程名称", RSL.Get("CourseCollege"), "任务班名", "授课方式", "任课方式", "学生人数", "课时数", "备注" }; neh.Export(dt, liststring, "课时补登"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Action("List").AddMenuParameter() }); } } }