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.ViewModel.TeachingMaterial; using EMIS.CommonLogic.TeachingMaterial; using Bowin.Common.Utility; using Bowin.Common.Data; namespace EMIS.Web.Controllers.TeachingMaterial { [Authorization] public class StockInSetController : Controller { public ISupplierDiscountSetServices supplierDiscountSetServices { get; set; } /// /// 供应商折扣率设置 /// /// [HttpGet] public ActionResult List() { return View(); } /// /// 列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); bool? isDefault = null; if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; return base.Json(supplierDiscountSetServices.GetSupplierDiscountSetViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid supplierDiscountSetID) { SupplierDiscountSetView supplierDiscountSetView = new SupplierDiscountSetView(); supplierDiscountSetView = supplierDiscountSetServices.GetSupplierDiscountSetView(supplierDiscountSetID); return View("Edit", supplierDiscountSetView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(SupplierDiscountSetView supplierDiscountSetView) { supplierDiscountSetView.SupplierDiscountSetID = Guid.Empty; return this.Edit(supplierDiscountSetView); } /// /// 新增、修改 /// /// /// [HttpGet] public ActionResult Edit(Guid? supplierDiscountSetID) { SupplierDiscountSetView supplierDiscountSetView = new SupplierDiscountSetView(); if (supplierDiscountSetID.HasValue && supplierDiscountSetID != Guid.Empty) { supplierDiscountSetView = supplierDiscountSetServices.GetSupplierDiscountSetView((Guid)supplierDiscountSetID); } return View(supplierDiscountSetView); } /// /// 新增、修改 /// /// /// [HttpPost] public ActionResult Edit(SupplierDiscountSetView supplierDiscountSetView) { try { supplierDiscountSetServices.SupplierDiscountSetViewEdit(supplierDiscountSetView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "。" }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string supplierDiscountSetIDs) { try { List list = supplierDiscountSetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); supplierDiscountSetServices.SupplierDiscountSetDelete(list); return base.Json("删除成功。"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message); } } /// /// 导出 /// /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var supplierDiscountSetID = Request.Form["SupplierDiscountSetID"]; List supplierDiscountSetIDList = new List(); bool? isDefault = null; if (supplierDiscountSetID != "") { supplierDiscountSetIDList = supplierDiscountSetID.SplitIDString(); } else { supplierDiscountSetIDList = null; } //var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo(); //var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo(); //var yearID = Request.Form["DictionaryGrade"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo(); //var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo(); //var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo(); //var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo(); //var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo(); //var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo(); //var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo(); //var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo(); //var education = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); //var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString(); var dt = supplierDiscountSetServices.GetSupplierDiscountSetViewList(configuretView, isDefault, supplierDiscountSetIDList).Select(x => new { x.UnitName, x.IsDefaultName, x.Discount }).ToTable(); string[] liststring = { "供应商名称","是否默认","折扣率" }; neh.Export(dt, liststring, "供应商折扣率设置信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Action("List").AddMenuParameter() }); } [HttpPost] public ActionResult GetDiscountByID(Guid supplierID) { decimal? discount = supplierDiscountSetServices.GetDiscountByPublishID(supplierID); return base.Json(discount.ToString()); } } }