using System.Linq; using System.Web.Mvc; using DSWeb.Areas.TruckMng.DAL.MsLsKcPc; using DSWeb.Areas.TruckMng.Models.MsLsKcPc; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using HcUtility.Comm; using HcUtility.Core; namespace DSWeb.Areas.TruckMng.Controllers { [JsonRequestBehavior] public class MsLsKcPcController : Controller { // // GET: /TruckMng/MsLsKcPc public ActionResult Index() { return View(); } // // GET: /TruckMng/MsLsKcPc/Edit public ActionResult Edit() { return View(); } // // GET:/TruckMng/MsLsKcPc/GetDataList public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = MsLsKcPcDAL.GetDataList(condition); var list = dataList.Skip(start).Take(limit); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsLsKcPc/GetData/ public ContentResult GetData(string handle, string condition) { MsLsKcPc head = null; if (handle == "edit") { var list = MsLsKcPcDAL.GetDataList(condition); if (list.Count > 0) head = list[0]; } if (head == null) { head = new MsLsKcPc(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsLsKcPc/Save public ContentResult Save(string opstatus, string data) { MsLsKcPc head = JsonConvert.Deserialize(data); if (opstatus == "add") { head.DbOperationType = DbOperationType.DbotIns; head.OrgCode = CookieConfig.GetCookie_OrgCode(Request); } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectDB(); DBResult result = modb.Save(head); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsLsKcPcDAL.GetData("SerialNo=" + head.SerialNo + "") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Delete(string data) { var head = JsonConvert.Deserialize(data); var modb = new ModelObjectDB(); DBResult result = modb.Delete(head); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 参照部分 #endregion } }