|
|
using System;
|
|
|
using System.Linq;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.MvcShipping.Models.MsContainerSet;
|
|
|
using DSWeb.MvcShipping.DAL.MsContainerSet;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using System.Collections.Generic;
|
|
|
using DSWeb.MvcShipping.Models.FtpSet;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
using DSWeb.Common.DB;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsContainerSetController: Controller
|
|
|
{
|
|
|
//
|
|
|
// GET:
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET: /
|
|
|
public ActionResult Edit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
|
|
|
public ContentResult GetDataList(string condition, string sort)
|
|
|
{
|
|
|
var dataList = MsContainerSetDAL.GetDataList(condition, sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/TruckMng/MsWlTyreAcc/GetData/
|
|
|
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
{
|
|
|
MsContainerSetEntity head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsContainerSetDAL.GetDataList(condition);
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new MsContainerSetEntity();
|
|
|
}
|
|
|
|
|
|
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<MsContainerSetEntity>(data);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(headData.CTN) && !string.IsNullOrWhiteSpace(headData.CTNSIZE)) {
|
|
|
headData.CTNTYPE = headData.CTN.Replace(headData.CTNSIZE, "");
|
|
|
}
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(headData.EDICODE) && !string.IsNullOrWhiteSpace(headData.CTN))
|
|
|
{
|
|
|
headData.EDICODE = headData.CTN;
|
|
|
}
|
|
|
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
var cdc = new CommonDataContext();
|
|
|
var currCodeCtn = cdc.CODE_CTN.Where(x => 1 == 1).ToList();
|
|
|
|
|
|
headData.CTNID = (currCodeCtn.Count + 1).ToString();
|
|
|
|
|
|
while (currCodeCtn.Exists(x => x.CTNID == headData.CTNID))
|
|
|
{
|
|
|
headData.CTNID = (Convert.ToInt32(headData.CTNID) + 1).ToString();
|
|
|
}
|
|
|
|
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
|
//headData.CTNID = Convert.ToString(Session["COMPANYID"]);
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headData.ModelUIStatus = "E";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
var CTNID = headData.CTNID;
|
|
|
DBResult result = modb.Save(headData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = MsContainerSetDAL.GetData("CTNID='" + CTNID + "'")
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<MsContainerSetEntity>(data);
|
|
|
string cntUpdate = "update code_ctn_disp set CNT1=";
|
|
|
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) };
|
|
|
}
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
} |