99 lines
3.1 KiB
C#
99 lines
3.1 KiB
C#
|
|
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 newsController : Controller
|
|||
|
|
{
|
|||
|
|
// GET: news
|
|||
|
|
public ActionResult Index()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 新闻
|
|||
|
|
public ActionResult newsinfo()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string newsinfoAll()
|
|||
|
|
{
|
|||
|
|
var dal = new newsinfoBll();
|
|||
|
|
string modelslistjson = JsonConvert.SerializeObject(dal.GetAllList(""));
|
|||
|
|
return "{\"Rows\":" + modelslistjson + "}";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult newsinfoMessage(string id)
|
|||
|
|
{
|
|||
|
|
var list = new List<Droplist>() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } };
|
|||
|
|
var bll = new newsinfoBll();
|
|||
|
|
if (!string.IsNullOrEmpty(id))
|
|||
|
|
{
|
|||
|
|
var model = bll.GetAllList(id).First();
|
|||
|
|
ViewData["ztD"] = new SelectList(list, "value", "title", model.zt);
|
|||
|
|
return View(model);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ViewData["ztD"] = new SelectList(list, "value", "title");
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[ValidateInput(false)]
|
|||
|
|
public JsonResult savenewsinfo(string id, string bt, string nr, string yd, string zt)
|
|||
|
|
{
|
|||
|
|
newsinfoModel model = new newsinfoModel();
|
|||
|
|
if (string.IsNullOrEmpty(id))
|
|||
|
|
id = "0";
|
|||
|
|
model.id = Convert.ToInt32(id);
|
|||
|
|
model.bt = bt;
|
|||
|
|
model.nr = nr;
|
|||
|
|
model.yd = Convert.ToByte(yd);
|
|||
|
|
model.zt = Convert.ToByte(zt);
|
|||
|
|
model.sj = DateTime.Now;
|
|||
|
|
//修改
|
|||
|
|
var f = false;
|
|||
|
|
newsinfoBll bll = new newsinfoBll();
|
|||
|
|
f = model.id != 0 ? bll.Update(model) : bll.Add(model);
|
|||
|
|
return Json(f ? new { State = 1, Message = "操作成功!" } : new { State = 0, Message = "操作失败!" });
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public JsonResult deletenewsinfo(string id)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(id))
|
|||
|
|
return Json(null);
|
|||
|
|
return Json(new BLL.newsinfoBll().delete(id));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ActionResult newsinfo2(string id)
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
public ActionResult newsinfoShow(string id)
|
|||
|
|
{
|
|||
|
|
var list = new List<Droplist>() { new Droplist { Value = "1", Title = "正常" }, new Droplist { Value = "2", Title = "禁用" } };
|
|||
|
|
var bll = new newsinfoBll();
|
|||
|
|
if (!string.IsNullOrEmpty(id))
|
|||
|
|
{
|
|||
|
|
var model = bll.GetAllList(id).First();
|
|||
|
|
ViewData["ztD"] = new SelectList(list, "value", "title", model.zt);
|
|||
|
|
return View(model);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ViewData["ztD"] = new SelectList(list, "value", "title");
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|