using dccdc.BLL; using dccdc.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using static dccdc.Controllers.DictionariesController; namespace dccdc.Controllers { public class ChargeController : Controller { // GET: Charge public ActionResult Index() { return View(); } public JsonResult getChargeAll(int page, int pagesize) { var bll = new charge_maintBll(); int count = bll.getCount(); var result = bll.getList(page, pagesize); return Json(new { Total = count, Rows = result }); } public ActionResult ChargeMessage(string id) { ViewData["fplx"] = new SelectList(new List { new Droplist { Value = "非税发票", Title = "非税发票" }, new Droplist { Value = "门诊发票", Title = "门诊发票" } }, "Value", "Title"); var bll = new charge_maintBll(); if (!string.IsNullOrEmpty(id)) { var model = bll.GetAllList(id).First(); ViewData["cwry"] = new SelectList(new ERPUserBll().GetAllList(""), "TrueName", "TrueName", ""); return View(model); } else { var model = new charge_maintModel(); model.provide_person = (Session["loginUser"] as Models.ERPUser).TrueName; model.invoice_type = "非税发票"; ViewData["cwry"] = new SelectList(new ERPUserBll().GetAllList(""), "TrueName", "TrueName", ""); return View(model); } } [HttpPost] public ActionResult ChargeMessage(charge_maintModel model) { ModelState.Remove("id"); if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(v => v.Errors); ViewData["fplx"] = new SelectList(new List { new Droplist { Value = "非税发票", Title = "非税发票" }, new Droplist { Value = "门诊发票", Title = "门诊发票" } }, "Value", "Title"); ViewData["cwry"] = new SelectList(new ERPUserBll().GetAllList(""), "TrueName", "TrueName", ""); return View(model); } if (string.IsNullOrEmpty(model.status)) model.status = "在用"; if (string.IsNullOrEmpty(model.curr_time)) model.curr_time = DateTime.Now.ToString("yyyy-MM-dd"); charge_maintBll bll = new charge_maintBll(); return Json(bll.save(model)); } //打印用 public JsonResult getOne(string id) { if (string.IsNullOrEmpty(id)) return Json(null); var bll = new charge_maintBll(); var result = bll.GetAllList(id); return Json(result, JsonRequestBehavior.AllowGet); } [AllowAnonymous] public string getsfxx(string id) { var bll = new BLL.chargeBll(); var m = bll.getsfxx(id); return Newtonsoft.Json.JsonConvert.SerializeObject(m); } [AllowAnonymous] public string getsfmx(string id) { var bll = new BLL.chargeBll(); var list = bll.getsfmx(id); return Newtonsoft.Json.JsonConvert.SerializeObject(list); } } }