using System; using System.Linq; using System.Web.Mvc; using DSWeb.MvcShipping.DAL.MsCodeOpTemplate; using DSWeb.MvcShipping.Models.MsCodeOpTemplate; using DSWeb.MvcShipping.Helper; using DSWeb.MvcShipping.Comm.Cookie; using System.Collections.Generic; using HcUtility.Comm; using HcUtility.Core; using DSWeb.SoftMng.Filter; namespace DSWeb.MvcShipping.Controllers { [JsonRequestBehavior] public class MsCodeOpTemplateController : Controller { // // GET: public ActionResult Index() { return View(); } // // GET: / public ActionResult Edit() { return View(); } // // GET: [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = MsCodeOpTemplateDAL.GetDataList(condition,Convert.ToString(Session["COMPANYID"]), sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsWlTyreAcc/GetData/ [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetData(string handle, string condition) { CodeOpTemplate head = null; if (handle == "edit") { var list = MsCodeOpTemplateDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"])); if (list.Count > 0) head = list[0]; } if (head == null) { head = new CodeOpTemplate(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetBodyList(int start, int limit, string sort, string condition) { var dataList = MsCodeOpTemplateDAL.GetCodeOpTemplateDetail(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } public ContentResult Save(string opstatus, string data, string body) { var headData = JsonConvert.Deserialize(data); var bodyList = JsonConvert.Deserialize>(body); if (opstatus == "add") { headData.DbOperationType = DbOperationType.DbotIns; headData.INPUTBY = Convert.ToString(Session["USERID"]); headData.COMPANYID = Convert.ToString(Session["COMPANYID"]); 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 modb = new ModelObjectDB(); modb.Save(headData); var GID = headData.GID; DBResult result = MsCodeOpTemplateDAL.SaveCodeOpTemplateDetail(bodyList, headData.GID); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = MsCodeOpTemplateDAL.GetData("GID='" + GID + "'",Convert.ToString(Session["COMPANYID"])) }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize(data); DBResult result = MsCodeOpTemplateDAL.DeleteDetail(headData); if (result.Success == true) { var modb = new ModelObjectDB(); result = modb.Delete(headData); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } public ContentResult DeleteDetail(string data) { var bodyList = JsonConvert.Deserialize>(data); DBResult result = MsCodeOpTemplateDAL.DeleteCodeOpTemplateDetail(bodyList); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public ContentResult GetFieldList(string optable) { var dataList = MsCodeOpTemplateDAL.GetFieldList(optable); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); return new ContentResult() { Content = json }; } #region 参照部分 #endregion } }