using System; using System.Linq; using System.Collections.Generic; using System.Web.Mvc; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.TruckMng.DAL; using DSWeb.Areas.TruckMng.Models.MsWlBulk; 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 MsWlBulkController : Controller { // // GET: /TruckMng/MsWlBulk public ActionResult Index() { return View(); } // // GET: /TruckMng/MsWlBulk/Edit public ActionResult Edit() { return View(); } // // GET:/TruckMng/MsWlBulk/GetDataList public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = MsWlBulkDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); 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/MsWlBulk/GetData/ public ContentResult GetData(string handle, string condition) { MsWlBulkHead head = null; if (handle == "edit") { var list = MsWlBulkDAL.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 MsWlBulkHead(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public JsonResult GetBodyList(string billno) { var condition = " l.BulkBillNo='" + billno + "'"; var list = MsWlBulkDAL.GetBodyList(condition); return Json(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); } // // GET:/TruckMng/MsWlBulk/Save public ContentResult Save(string opstatus, string data, string body, string delbody) { MsWlBulkHead head = JsonConvert.Deserialize(data); var bodyList = JsonConvert.Deserialize>(body); var bodyDelList = JsonConvert.Deserialize>(delbody); if (opstatus == "add") { head.BillNo = PubSysDAL.GetBillNo("0113"); head.DbOperationType = DbOperationType.DbotIns; head.ModelUIStatus = "I"; head.UserCode = CookieConfig.GetCookie_UserCode(Request); head.UserName = CookieConfig.GetCookie_UserName(Request); head.OrgCode = CookieConfig.GetCookie_OrgCode(Request); head.OrgName = CookieConfig.GetCookie_OrgName(Request); head.LrDate = DateTime.Now; } else if (opstatus == "edit") { head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; } else { head.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(head, ModelObjectConvert.ToModelObjectList(bodyList), ModelObjectConvert.ToModelObjectList(bodyDelList)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsWlBulkDAL.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 ModelObjectDBBill(); DBResult result = modb.Delete(head); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 参照部分 #endregion } }