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.
DS7/DSWeb/Areas/TruckMng/Controllers/MsKfWxController.cs

187 lines
7.1 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.TruckMng.DAL.MsKfWx;
using DSWeb.Areas.TruckMng.Models.MsKfWx;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using HcUtility.Comm;
using HcUtility.Core;
8 months ago
using DSWeb.SoftMng.Filter;
2 years ago
namespace DSWeb.Areas.TruckMng.Controllers
{
/// <summary>
/// 配件申领单
/// </summary>
[JsonRequestBehavior]
public class MsKfWxController : Controller
{
//
// GET: /TruckMng/MsKfWx/
public ActionResult Index()
{
return View();
}
//
// GET: /TruckMng/MsKfWx/Edit
public ActionResult Edit()
{
return View();
}
//
// GET/TruckMng/MsKfWx/GetDataList
8 months ago
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
2 years ago
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = MsKfWxDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request),sort);
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/MsKfWx/GetData/
8 months ago
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
2 years ago
public ContentResult GetData(string handle, string condition)
{
MsKfWxHead headData = null;
if (handle == "edit")
{
var list = MsKfWxDAL.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 MsKfWxHead();
headData.OrgCode = CookieConfig.GetCookie_OrgCode(Request);
headData.REPAIRDAYS="0";
headData.REPAIRAMOUNT="0";
headData.MATERIALAMOUNT="0";
headData.WORKAMOUNT="0";
headData.TYREAMOUNT = "0";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = headData });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsKfWx/Save
public ContentResult Save(string opstatus, string data, string body, string delbody,
string bodyplu, string delbodyplu)
{
var headData = JsonConvert.Deserialize<MsKfWxHead>(data);
var bodyList = JsonConvert.Deserialize<List<MsKfWxBody>>(body);
var bodyDelList = JsonConvert.Deserialize<List<MsKfWxBody>>(delbody);
var wxPluList = JsonConvert.Deserialize<List<MsKfWxPlu>>(bodyplu);
var wxPluDelList = JsonConvert.Deserialize<List<MsKfWxPlu>>(delbodyplu);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
headData.ModelUIStatus = "I";
headData.BillNo = PubSysDAL.GetBillNo("0101");
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<MsKfWxBody>.ToModelObjectList(bodyList),
ModelObjectConvert<MsKfWxBody>.ToModelObjectList(bodyDelList),
ModelObjectConvert<MsKfWxPlu>.ToModelObjectList(wxPluList),
ModelObjectConvert<MsKfWxPlu>.ToModelObjectList(wxPluDelList) );
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsKfWxDAL.GetHeadDataByBillNo(headData.BillNo, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), CookieConfig.GetCookie_OrgCode(Request))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
//
// GET/TruckMng/MsKfWx/Delete
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<MsKfWxHead>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData, "delete from tMsKfWxBody where BillNo='" + headData.BillNo + "'",
"delete from tMsKfWxPlu 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<MsKfWxBody> list = MsKfWxDAL.GetBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetWxPluList(string billno)
{
var condition = " BillNo='" + billno + "' ";
List<MsKfWxPlu> list = MsKfWxDAL.GetWxPluList(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 = MsKfWxDAL.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 GetWxLxCodeList(string condition)
{
var list = MsKfWxDAL.GetWxLxCodeList();
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = list.ToList() });
return new ContentResult() { Content = json };
}
#endregion
}
}