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.
154 lines
4.7 KiB
C#
154 lines
4.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using DSWeb.MvcShipping.Models.CodeAll;
|
|
using DSWeb.MvcShipping.DAL.MsCodeAll;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using System.Collections.Generic;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using DSWeb.TruckMng.Helper.Repository;
|
|
using DSWeb.Common.DB;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
[JsonRequestBehavior]
|
|
public class MsCodeAllController : Controller
|
|
{
|
|
public ActionResult Lanes()
|
|
{//
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Edit()
|
|
{//
|
|
return View();
|
|
}
|
|
|
|
#region 查询
|
|
public ContentResult GetLanesList ( string condition, string sort )
|
|
{
|
|
var dataList = MsCodeAllDAL.GetLanesList(condition, sort);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetLanesPortList(string LANEID)
|
|
{
|
|
var dataList = MsCodeAllDAL.GetLanesPortList(LANEID);
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
public ContentResult SaveLanesList ( string data )
|
|
{
|
|
var dataList = JsonConvert.Deserialize<List<Code_lanesmb>>(data);
|
|
foreach (var _d in dataList)
|
|
{
|
|
if (_d.GID == "" || _d.GID == "*")
|
|
{
|
|
_d.DbOperationType = DbOperationType.DbotIns;
|
|
_d.ModelUIStatus = "I";
|
|
|
|
_d.GID = System.Guid.NewGuid().ToString(); //获取合同号
|
|
}
|
|
else
|
|
{
|
|
_d.DbOperationType = DbOperationType.DbotUpd;
|
|
_d.ModelUIStatus = "E";
|
|
}
|
|
}
|
|
|
|
var result = new DBResult();
|
|
var _L = ModelObjectConvert<Code_lanesmb>.ToModelObjectList(dataList);
|
|
//var _DL = ModelObjectConvert<MsWlPcHead_ADLEdit>.ToModelObjectList(DeldataList);
|
|
|
|
var modb = new ModelObjectRepository();
|
|
result = modb.SaveHead(_L);
|
|
|
|
//刷新父窗口上的父节点
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = null
|
|
};
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
public ContentResult SaveLanesPort(string data,string body)
|
|
{
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = true,
|
|
Message = "保存成功",
|
|
Data = null
|
|
};
|
|
|
|
try
|
|
{
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
var headdata = JsonConvert.Deserialize<Code_lanesmb>(data);
|
|
|
|
var LANEID = headdata;
|
|
|
|
var bodylist = JsonConvert.Deserialize<List<code_lanes_port_md>>(body);
|
|
|
|
if (bodylist.Count > 0)
|
|
{
|
|
|
|
foreach (var item in bodylist)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(item.GID))
|
|
{
|
|
item.GID = System.Guid.NewGuid().ToString();
|
|
cdc.code_lanes_port.Add(item);
|
|
}
|
|
else
|
|
{
|
|
var updrec = cdc.code_lanes_port.FirstOrDefault(x => x.GID == item.GID);
|
|
updrec.SaveCopy(item);
|
|
}
|
|
}
|
|
cdc.SaveChanges();
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
jsonRespose.Success = false;
|
|
jsonRespose.Message = e.Message;
|
|
}
|
|
|
|
|
|
//刷新父窗口上的父节点
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 删除
|
|
public ContentResult DeleteLanes(string data)
|
|
{
|
|
var headData = JsonConvert.Deserialize<Code_lanesmb>(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) };
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|