using YLErp.Modules.ClientCashModule; namespace YLErp.Web.Controllers { public class variety_pfe_deductController : BaseController { public ActionResult variety_pfe_deductEdit(string enid) { if (string.IsNullOrEmpty(enid)) { return View(new variety_pfe_deduct()); } var intid = DecryptInt(enid); var varietyPFEDeduct = yldb.variety_pfe_deduct.Find(intid); varietyPFEDeduct.Rate *= 100; return View(varietyPFEDeduct); } [HttpPost] public JsonResult varietyPFEDeductEditJson(variety_pfe_deduct req) { if (req == null) { return JsonError("数据不能为空"); } try { req.Rate /= 100; var r = new VarietyPFEDeductService(CurUser).SaveVarietyPFEConfig(req); return JsonSuccess("更新成功", r); } catch (Exception e) { LogFactory.GetLogger("交易保存").Error(e); return JsonError("保存失败:" + e.GetBaseException().Message, e.ToJson()); } } [HttpPost] public JsonResult deleteVarietyPFEDeduct(string enid) { var intid = DecryptInt(enid); var r = yldb.variety_pfe_deduct.Find(intid); if (r == null) { return JsonError("该数据已不存在"); } yldb.variety_pfe_deduct.Remove(r); yldb.SaveChanges(); return JsonSuccess("删除成功"); } public ActionResult variety_pfe_deductList() { return View(); } public ActionResult variety_pfe_deductUpload() { return View(); } public ActionResult Uploadvariety_pfe_deduct() { if (Request.Form.Files.Count == 0) { return JsonError("上传文件不存在"); } var file = Request.Form.Files[0]; if (!Path.GetExtension(file.FileName).Equals(".xlsx", StringComparison.OrdinalIgnoreCase)) { return JsonError("请上传Excel(.xlsx)格式文件"); } using var stream = file.OpenReadStream(); new VarietyPFEDeductService(CurUser).ImportVarietyPFEDeductFromExcel(stream, out var TotalNum, out var SuccessNum); return Json(new { success = true, totalNum = TotalNum, successNum = SuccessNum, }); } [HttpPost] public JsonResult variety_pfe_deductQuery(VarietyMappingDeductReq req) { var service = new VarietyPFEDeductService(CurUser); var sList = service.SearchVarietyPFEDeductList(req); return Json(sList); } } }