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/MvcShipping/Controllers/MsCodeCtnEdiController.cs

577 lines
25 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Linq;
using System.Web.Mvc;
using DSWeb.MvcShipping.Models.CodeCtnEdi;
using DSWeb.MvcShipping.DAL.MsCodeCtnEdi;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using System.Collections.Generic;
using HcUtility.Comm;
using HcUtility.Core;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsCodeCtnEdiController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
#region 查询
public ContentResult GetDataList(string condition,string sort)
{
var dataList = MsCodeCtnEdiDAL.GetDataList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
CodeCtnEdi head = null;
if (handle == "edit")
{
var list = MsCodeCtnEdiDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
if (list.Count > 0)
head = list[0];
}
if (head == null)
{
head = new CodeCtnEdi();
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetCustList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetCustList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetPkgsList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetPkgsList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetVesselList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetVesselList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetSERVICEList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetSERVICEList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetPORTDISCHARGEList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetPORTDISCHARGEList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetISSUETYPEList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetISSUETYPEList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAFRList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetAFRList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetFeeNameList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetFeeNameList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetReeferfList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetReeferfList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetCarrierList(string condition, string sort)
{
var dataList = MsCodeCtnEdiDAL.GetCarrierList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
#region 保存
public ContentResult Save(string opstatus, string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(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.GID;
DBResult result = modb.Save(headData);
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsCodeCtnEdiDAL.GetData("GID='" + GID + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME&&x.CTN==PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveCustDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveCustDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SavePkgsDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SavePkgsDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveSERVICEDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复,不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveSERVICEDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SavePORTDISCHARGEDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
DBResult result = MsCodeCtnEdiDAL.SavePORTDISCHARGEDetail(bodyList, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]).ToString().Trim());
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveVesselDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveVesselDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveISSUETYPEDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveISSUETYPEDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveFeeName(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveFeeName(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveReeferf(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveReeferf(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveCarrierDetail(string body)
{
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
var copybodylist = new List<CodeCtnEdi>();
var ismost = false;
if (bodyList != null && bodyList.Count != 0)
{
foreach (var PORTEDI in bodyList)
{
var addbody = copybodylist.Find(x => x.EDINAME == PORTEDI.EDINAME && x.CTN == PORTEDI.CTN);
if (addbody != null)
{
ismost = true;
}
else
{
var newbody = new CodeCtnEdi();
newbody.EDINAME = PORTEDI.EDINAME;
newbody.CTN = PORTEDI.CTN;
copybodylist.Add(newbody);
}
}
}
if (ismost)
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "EDI代码设置不允许重复" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
DBResult result = MsCodeCtnEdiDAL.SaveCarrierDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 删除
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(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 DeleteCust(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteCust(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeletePkgs(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeletePkgs(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteSERVICE(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteSERVICE(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeletePORTDISCHARGE(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeletePORTDISCHARGE(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteVessel(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteVessel(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteISSUETYPE(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteISSUETYPE(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteFeeName(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteFeeName(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteReeferf(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteReeferf(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult DeleteCarrier(string data)
{
var headData = JsonConvert.Deserialize<CodeCtnEdi>(data);
var modb = new ModelObjectDB();
DBResult result = MsCodeCtnEdiDAL.DeleteCarrier(headData);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
}
}