using System; using System.Linq; using System.Web.Mvc; using DSWeb.SoftMng.Models.MsSysTable; using DSWeb.SoftMng.DAL.SoftSysTable; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using System.IO; using System.Data; using System.Data.OleDb; using DSWeb.EntityDA; using DSWeb.DataAccess; using DSWeb.TruckMng.Helper.Repository; namespace DSWeb.SoftMng.Controllers { [JsonRequestBehavior] public class MsSoftSysTableController : Controller { // // GET: public ActionResult Index() { return View(); } // // GET: / public ActionResult Edit() { return View(); } // // GET: public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = MsSoftSysTableDAL.GetDataList(condition, 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/MsWlTyreAcc/GetData/ public ContentResult GetData(string handle, string condition) { sys_table head = null; if (handle == "edit") { var list = MsSoftSysTableDAL.GetDataList(condition); if (list.Count > 0) head = list[0]; } if (head == null) { head = new sys_table(); head.INPUTBY = Convert.ToString(Session["USERID"]); head.INPUTBYREF = Convert.ToString(Session["SHOWNAME"]); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string body) { var headData = JsonConvert.Deserialize(data); var bodyList = JsonConvert.Deserialize>(body); var bodyListdel = JsonConvert.Deserialize>(""); var errorstr = ""; var isPost = true; if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.INPUTBY = Convert.ToString(Session["USERID"]); headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } else if (opstatus == "edit") { headData.DbOperationType = DbOperationType.DbotUpd; headData.ModelUIStatus = "E"; } else { headData.DbOperationType = DbOperationType.DbotDel; } var GID = headData.GID; if (isPost) { var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); if (result.Success == true) { result = MsSoftSysTableDAL.SaveTableDetail(bodyList, GID,Convert.ToString(Session["USERID"])); } //var modb = new ModelObjectRepository(); //var result = modb.Save(headData //, ModelObjectConvert.ToModelObjectList(bodyList) //, ModelObjectConvert.ToModelObjectList(bodyListdel)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsSoftSysTableDAL.GetData("GID='" + GID + "'") }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } else { var jsonRespose = new JsonResponse { Success = false, Message = errorstr }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } } public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsSoftSysTableDAL.DeleteSysTable(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #region 相关表 public ContentResult GetTableDetailList(string condition, string sort) { var dataList = MsSoftSysTableDAL.GetTableDetailList(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult GetDefTableDetailList(string tablename) { var dataList = MsSoftSysTableDAL.GetDefTableDetailList(tablename); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult SaveTableDetail(string body, string PID) { // var bodyList = JsonConvert.Deserialize>(body); DBResult result = MsSoftSysTableDAL.SaveTableDetail(bodyList, PID, Convert.ToString(Session["USERID"])); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteTableDetail(string data) { var headData = JsonConvert.Deserialize>(data); DBResult result = MsSoftSysTableDAL.DeleteTableDetail(headData); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } #endregion #region 参照部分 #endregion } }