using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.TruckMng.DAL.KfCg; using DSWeb.Areas.TruckMng.Models.KfCg; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using DSWeb.TruckMng.Helper.Repository; using HcUtility.Comm; using HcUtility.Core; using DSWeb.SoftMng.Filter; namespace DSWeb.Areas.TruckMng.Controllers { /// /// 配件申领单 /// [JsonRequestBehavior] public class KfCgController : Controller { // // GET: /TruckMng/KfCg/ public ActionResult Index() { return View(); } // // GET: /TruckMng/KfCg/Edit public ActionResult Edit() { return View(); } // // GET:/TruckMng/KfCg/GetDataList [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public JsonResult GetDataList(int start, int limit, string sort, string condition) { var dataList = KfCgDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request),sort); var list = dataList.Skip(start).Take(limit); return Json(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() }); } // // GET:/TruckMng/KfCg/GetData/ [SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器 public JsonResult GetData(string handle, string condition) { KfCgHead headData = null; if (handle == "edit") { var list = KfCgDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)); if (list.Count > 0) headData = list[0]; } if (headData == null) { headData = new KfCgHead(); } return Json(new { Success = true, Message = "查询成功", data = headData }); } // // GET:/TruckMng/KfCg/Save public JsonResult Save(string opstatus, string data, string body, string delbody) { var cardHead = JsonConvert.Deserialize(data); var bodyList = JsonConvert.Deserialize>(body); var bodyDelList = JsonConvert.Deserialize>(delbody); if (opstatus == "add") { cardHead.DbOperationType = DbOperationType.DbotIns; cardHead.ModelUIStatus = "I"; cardHead.BillNo = PubSysDAL.GetBillNo("0105"); cardHead.UserCode = CookieConfig.GetCookie_UserCode(Request); cardHead.UserName = CookieConfig.GetCookie_UserName(Request); cardHead.OrgCode = CookieConfig.GetCookie_OrgCode(Request); cardHead.OrgName = CookieConfig.GetCookie_OrgName(Request); } else if (opstatus == "edit") { cardHead.DbOperationType = DbOperationType.DbotUpd; cardHead.ModelUIStatus = "E"; } else { cardHead.DbOperationType = DbOperationType.DbotDel; } var modb = new ModelObjectRepository(); DBResult result = modb.Save(cardHead, ModelObjectConvert.ToModelObjectList(bodyList), ModelObjectConvert.ToModelObjectList(bodyDelList)); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = KfCgDAL.GetHeadDataByBillNo(cardHead.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request)) }; return Json(jsonRespose); } // // GET:/TruckMng/KfCg/Delete public JsonResult Delete(string data) { var headData = JsonConvert.Deserialize(data); var modb = new ModelObjectDB(); DBResult result = modb.Delete(headData, "delete from tKfCgBody where BillNo='" + headData.BillNo + "'"); var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return Json(jsonRespose); } public JsonResult GetBodyList(string billno) { var condition = " BillNo='" + billno + "' "; List list = KfCgDAL.GetBodyList(condition); return Json(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() }); } } }