using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web.Mvc; using DSWeb.Areas.CommMng.DAL; using DSWeb.Areas.RptMng.Comm; using DSWeb.Areas.TruckMng.DAL.MsWlTyreWx; using DSWeb.Areas.TruckMng.Models.MsWlTyreWx; using DSWeb.TruckMng.Comm.Cookie; using DSWeb.TruckMng.Helper; using HcUtility.Comm; using HcUtility.Core; namespace DSWeb.Areas.TruckMng.Controllers { [JsonRequestBehavior] public class MsWlTyreWxController : Controller { // // GET: /TruckMng/MsWlTyreWx public ActionResult Index() { return View(); } // // GET: /TruckMng/MsWlTyreWx/Edit public ActionResult Edit() { return View(); } // // GET:/TruckMng/MsWlTyreWx/GetDataList public ContentResult GetDataList(int start, int limit, string sort, string condition) { var dataList = MsWlTyreWxDAL.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/MsWlTyreWx/GetData/ public ContentResult GetData(string handle, string condition) { MsWlTyreWx head = null; if (handle == "edit") { var list = MsWlTyreWxDAL.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 MsWlTyreWx(); } var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", data = head }); return new ContentResult() { Content = json }; } // // GET:/TruckMng/MsWlTyreWx/Save public ContentResult Save(string opstatus, string data) { MsWlTyreWx 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 = MsWlTyreWxDAL.GetData("SerialNo=" + head.SerialNo + "", 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) }; } public ContentResult TyreJhGd(string data) { var head = JsonConvert.Deserialize(data); var dbparams = new List(); var paramps_SerialNo = new CustomDbParamter(); paramps_SerialNo.ParameterName = "@ps_SerialNo"; paramps_SerialNo.DbType = DbType.Decimal; paramps_SerialNo.Direction = ParameterDirection.Input; paramps_SerialNo.Value = head.SerialNo; dbparams.Add(paramps_SerialNo); var paramps_UserCode = new CustomDbParamter(); paramps_UserCode.ParameterName = "@ps_UserCode"; paramps_UserCode.DbType = DbType.String; paramps_UserCode.Direction = ParameterDirection.Input; paramps_UserCode.Value = CookieConfig.GetCookie_UserCode(Request); dbparams.Add(paramps_UserCode); var paramps_UserName = new CustomDbParamter(); paramps_UserName.ParameterName = "@ps_UserName"; paramps_UserName.DbType = DbType.String; paramps_UserName.Direction = ParameterDirection.Input; paramps_UserName.Value = CookieConfig.GetCookie_UserName(Request); dbparams.Add(paramps_UserName); var dbResult = PubSysDAL.GetMsSqlPrcDataSet("sMsTyreJhGd", dbparams, "Result_Set"); var json = RptHelper.GetRptJsonResult(dbResult, "Result_Set"); return new ContentResult() { Content = json }; } #region 参照部分 public ContentResult GetTruckNoList(string condition) { var list = MsWlTyreWxDAL.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 }; } #endregion } }