|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.Areas.TruckMng.DAL.MsWlCk;
|
|
|
using DSWeb.Areas.TruckMng.Models.MsWlCk;
|
|
|
using DSWeb.TruckMng.Comm.Cookie;
|
|
|
using DSWeb.TruckMng.Helper;
|
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
|
|
|
namespace DSWeb.Areas.TruckMng.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 配件申领单
|
|
|
/// </summary>
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsWlCkController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET: /TruckMng/MsWlCk/
|
|
|
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
|
|
|
//
|
|
|
// GET: /TruckMng/MsWlCk/Edit
|
|
|
|
|
|
public ActionResult Edit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/TruckMng/MsWlCk/GetDataList
|
|
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = MsWlCkDAL.GetDataList(condition);
|
|
|
|
|
|
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/MsWlCk/GetData/
|
|
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
{
|
|
|
MsWlCkHead headData = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsWlCkDAL.GetDataList(condition);
|
|
|
if (list.Count > 0)
|
|
|
headData = list[0];
|
|
|
}
|
|
|
|
|
|
if (headData == null)
|
|
|
{
|
|
|
headData = new MsWlCkHead();
|
|
|
}
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = headData });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/TruckMng/MsWlCk/Save
|
|
|
|
|
|
public ContentResult Save(string opstatus, string data, string body, string delbody)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<MsWlCkHead>(data);
|
|
|
var bodyList = JsonConvert.Deserialize<List<MsWlCkBody>>(body);
|
|
|
var bodyDelList = JsonConvert.Deserialize<List<MsWlCkBody>>(delbody);
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
headData.ModelUIStatus = "I";
|
|
|
|
|
|
headData.BillNo = PubSysDAL.GetBillNo("0103");
|
|
|
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;
|
|
|
}
|
|
|
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<MsWlCkBody>.ToModelObjectList(bodyList),
|
|
|
ModelObjectConvert<MsWlCkBody>.ToModelObjectList(bodyDelList));
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = MsWlCkDAL.GetHeadDataByBillNo(headData.BillNo)
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/TruckMng/MsWlCk/Delete
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<MsWlCkHead>(data);
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
DBResult result = modb.Delete(headData, "delete from tMsWlCkBody where BillNo='" + headData.BillNo + "'");
|
|
|
|
|
|
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<MsWlCkBody> list = MsWlCkDAL.GetBodyList(condition);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|