using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.TruckMng.DAL.MsWlBulkPc;
using DSWeb.Areas.TruckMng.Models.MsWlBulkPc;
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 MsWlBulkPcController : Controller
{
//
// GET: /TruckMng/MsWlBulkPc/
public ActionResult Index()
{
return View();
}
//
// GET: /TruckMng/MsWlBulkPc/Edit
public ActionResult Edit()
{
return View();
}
public ActionResult IndexChache()
{
return View();
}
public ActionResult IndexQuery()
{
return View();
}
//
// GET: /TruckMng/MsWlBulkPc/EditChache
public ActionResult EditChache()
{
return View();
}
//
// GET:/TruckMng/MsWlBulkPc/GetDataList
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var sqlwhere = condition;
if (!string.IsNullOrEmpty(condition))
sqlwhere += " and ";
sqlwhere += " PcBillType='1'";
var dataList = MsWlBulkPcDAL.GetDataList(sqlwhere, 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 };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetDataQueryList(int start, int limit, string sort, string condition)
{
var sqlwhere = condition;
if (!string.IsNullOrEmpty(condition))
sqlwhere += " and ";
sqlwhere += " p.PcBillType='1'";
var dataList = MsWlBulkPcDAL.GetDataQueryList(sqlwhere, 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 = dataList.ToList() });
return new ContentResult() { Content = json };
}
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetChacheDataList(int start, int limit, string sort, string condition)
{
var sqlwhere = condition;
if (!string.IsNullOrEmpty(condition))
sqlwhere += " and ";
sqlwhere += " PcBillType='3'";
var dataList = MsWlBulkPcDAL.GetDataList(sqlwhere, 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/MsWlBulkPc/GetData/
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
public ContentResult GetData(string handle, string condition)
{
MsWlPcHead headData = null;
if (handle == "edit")
{
var list = MsWlBulkPcDAL.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 MsWlPcHead();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = headData });
return new ContentResult() { Content = json };
}
//
// GET:/TruckMng/MsWlBulkPc/Save
public ContentResult Save(string opstatus, string data, string body, string delbody,bool chache=false)
{
var headData = JsonConvert.Deserialize(data);
var bodyList = JsonConvert.Deserialize>(body);
var bodyDelList = JsonConvert.Deserialize>(delbody);
if (bodyList != null)
{
foreach (var bulkPound in bodyList)
{
if (!string.IsNullOrEmpty(bulkPound.DepartureDate))
{
bulkPound.DepartureDate = bulkPound.DepartureDate.Substring(0, 10);
}
}
}
if (opstatus == "add")
{
headData.BillNo = PubSysDAL.GetBillNo("0111");
headData.OilticketNO = PubSysDAL.GetBillNo("0118");
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
headData.UserCode = CookieConfig.GetCookie_UserCode(Request);
headData.UserName = CookieConfig.GetCookie_UserName(Request);
headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
headData.OrgName = CookieConfig.GetCookie_OrgName(Request);
headData.LrDate = DateTime.Now;
if (chache) headData.PcBillType ="3" ;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectRepository();
DBResult result = modb.Save(headData,
ModelObjectConvert.ToModelObjectList(bodyList),
ModelObjectConvert.ToModelObjectList(bodyDelList));
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsWlBulkPcDAL.GetHeadDataByBillNo(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
// GET:/TruckMng/MsWlBulkPc/Delete
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize(data);
var modb = new ModelObjectDBBill();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult GetBodyList(string billno)
{
var condition = " BillNo='" + billno + "' ";
List list = MsWlBulkPcDAL.GetBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
#region 参照部分
public ContentResult GetTruckNoList(string condition)
{
var list = MsWlBulkPcDAL.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 };
}
public ContentResult GetDrvNameList(string condition)
{
var list = MsWlBulkPcDAL.GetDrvNameList(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 };
}
public ContentResult GetBulkBillNoList(string condition)
{
var list = MsWlBulkPcDAL.GetBulkBillNoList(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 };
}
public ContentResult GetTruckFuel(string truckNo, decimal overmil, decimal ton, decimal mil, decimal unloadcount)
{
var fuel = MsWlBulkPcDAL.GetTruckFuel(truckNo, overmil, ton, mil,unloadcount);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = fuel });
return new ContentResult() { Content = json };
}
#endregion
}
}