You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/TruckMng/Controllers/WlTruckController.cs

109 lines
2.9 KiB
C#

3 years ago
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.TruckMng.DAL;
using DSWeb.Areas.TruckMng.Models.WlTruck;
using DSWeb.TruckMng.Helper;
using HcUtility.Comm;
using HcUtility.Core;
namespace DSWeb.Areas.TruckMng.Controllers
{
[JsonRequestBehavior]
public class WlTruckController : Controller
{
//
// GET: /WlTruck
public ActionResult Index()
{
return View();
}
//
// GET: /TruckMng/WlTruck/Edit
public ActionResult Edit()
{
return View();
}
//
// GET/TruckMng/WlTruck/GetDataList
public JsonResult GetDataList(int start, int limit, string sort, string condition)
{
var ordYhList = WlTruckDAL.GetDataList(condition);
var list = ordYhList.Skip(start).Take(limit);
return Json(new { Success = true, Message = "查询成功", totalCount = ordYhList.Count, data = list.ToList() });
}
//
// GET/TruckMng/WlTruck/GetData/
public JsonResult GetData(string handle, string condition)
{
WlTruck wlTruck = null;
if (handle == "edit")
{
var list = WlTruckDAL.GetDataList(condition);
if (list.Count > 0)
wlTruck = list[0];
}
if (wlTruck == null)
{
wlTruck = new WlTruck();
}
return Json(new {Success = true, Message = "查询成功", data = wlTruck});
}
//
// GET/TruckMng/WlTruck/Save
public JsonResult Save(string opstatus,string data)
{
WlTruck wlTruck = JsonConvert.Deserialize<WlTruck>(data);
if (opstatus == "add")
{
wlTruck.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
wlTruck.DbOperationType = DbOperationType.DbotUpd;
}
else
{
wlTruck.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
DBResult result =modb.Save(wlTruck);
var jsonRespose = new JsonResponse {Success = result.Success, Message = result.Message};
return Json(jsonRespose);
}
public JsonResult Delete(string data)
{
var wlTruck = JsonConvert.Deserialize<WlTruck>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(wlTruck);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return Json(jsonRespose);
}
#region 参照部分
public JsonResult GetDrvCodeList()
{
var list = WlTruckDAL.GetDrvCodeList();
return Json(new { Success = true, Message = "查询成功",data = list.ToList() });
}
#endregion
}
}