using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.TruckMng.DAL.MsWlPc; using DSWeb.Areas.TruckMng.Models.MsWlPc; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using HcUtility.Comm; using HcUtility.Core; namespace DSWeb.Areas.TruckMng.Controllers { [JsonRequestBehavior] public class MsWlPcHeadController : Controller { // // GET: /TruckMng/MsWlPcHead public ActionResult Index() { return View(); } // // GET: /TruckMng/MsWlPcHead/Edit public ActionResult Edit() { return View(); } // // GET:/TruckMng/MsWlPcHead/GetDataList public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = MsWlPcHeadDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request),sort); 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/MsWlPcHead/GetData/ public ContentResult GetData(string handle, string condition) { MsWlPcHead head = null; if (handle == "edit") { var list = MsWlPcHeadDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); if (list.Count > 0) head = list[0]; } if (head == null) { head = new MsWlPcHead(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsWlPcHead/Save public ContentResult Save(string opstatus, string data) { MsWlPcHead 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 = MsWlPcHeadDAL.GetData("BillNo='" + head.BillNo + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; 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 参照部分 public ContentResult GetTruckNoList(string condition) { var list = MsWlPcHeadDAL.GetTruckNoList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = list.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDrvNameList(string condition) { var list = MsWlPcHeadDAL.GetDrvNameList(Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = list.ToList() }); return new ContentResult() { Content = json }; } #endregion } }