You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.6 KiB
C#

10 months ago
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;
namespace DSWeb.Areas.TruckMng.Controllers
{
/// <summary>
/// 配件申领单
/// </summary>
[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
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/
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<KfCgHead>(data);
var bodyList = JsonConvert.Deserialize<List<KfCgBody>>(body);
var bodyDelList = JsonConvert.Deserialize<List<KfCgBody>>(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<KfCgBody>.ToModelObjectList(bodyList),
ModelObjectConvert<KfCgBody>.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<KfCgHead>(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<KfCgBody> list = KfCgDAL.GetBodyList(condition);
return Json(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
}
}
}