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/MsCodeTruckPortController.cs

156 lines
4.6 KiB
C#

2 years ago
using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.TruckMng.Models.CodeTruckPort;
using DSWeb.TruckMng.DAL.MsCodeTruckPort;
using DSWeb.TruckMng.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
8 months ago
using DSWeb.SoftMng.Filter;
2 years ago
namespace DSWeb.Areas.TruckMng.Controllers
{
[JsonRequestBehavior]
public class MsCodeTruckPortController : Controller
{
//
// GET:
public ActionResult Index()
{
return View();
}
//
// GET: /
public ActionResult Edit()
{
return View();
}
//
// GET
public ContentResult GetDataList(string condition,string sort)
{
var dataList = MsCodeTruckPortDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetDataListRm(string CODENAME="",string condition="")
{
if (CODENAME == "")
{
}
else
{
if (condition.Trim() == "")
condition = " PORTCODE like '" + CODENAME + "%' or PORT like '%" + CODENAME + "%' ";
else
condition = condition + " and (PORTCODE like '" + CODENAME + "%' or PORT like '%" + CODENAME + "%') ";
}
var dataList = MsCodeTruckPortDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]),"");
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/MsWlTyreAcc/GetData/
public ContentResult GetData(string handle, string condition)
{
CodeTruckPort head = null;
if (handle == "edit")
{
var list = MsCodeTruckPortDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeTruckPort();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<CodeTruckPort>(data);
if (opstatus == "add")
{
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
var modb = new ModelObjectDB();
var GID = headData.PORTID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodeTruckPortDAL.GetData("PORTID='" + GID + "'", Convert.ToString(Session["COMPANYID"]))
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<CodeTruckPort>(data);
var modb = new ModelObjectDB();
DBResult result = modb.Delete(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeTruckPort>>(body);
DBResult result = MsCodeTruckPortDAL.SaveDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#region 参照部分
#endregion
}
}