|
|
using System;
|
|
|
using System.Linq;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.MvcShipping.DAL.MsChDui;
|
|
|
using DSWeb.MvcShipping.Models.MsChDui;
|
|
|
using DSWeb.MvcShipping.Models.MsChDuiView;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using System.Collections.Generic;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
|
|
|
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
|
|
|
using DSWeb.Areas.MvcShipping.DAL.Disports;
|
|
|
using DSWeb.MvcShipping.Models.MsCodeGoods;
|
|
|
using DSWeb.MvcShipping.DAL.MsCodeGoods;
|
|
|
using DSWeb.Areas.MvcShipping.Models.Disport;
|
|
|
using DSWeb.Areas.MvcShipping.DAL.code_vesselModelDal;
|
|
|
using DSWeb.Areas.MvcShipping.Models.MsCodeVesselSetModel;
|
|
|
using DSWeb.MvcShipping.Models.CodeCtnEdi;
|
|
|
using DSWeb.MvcShipping.DAL.MsCodeCtnEdi;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsCodeVesselSetController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET:
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET: /
|
|
|
public ActionResult Edit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
public ActionResult FootEdit()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = code_vessel.GetVesselList(condition);
|
|
|
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 };
|
|
|
}
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
{
|
|
|
|
|
|
code_vesselModel head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = code_vessel.GetVesselByID(condition);
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new code_vesselModel();
|
|
|
}
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
|
|
|
public ContentResult GetFootList(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = code_vessel.GetVoynoList(condition);
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
public ContentResult GetFootData(string handle, string condition)
|
|
|
{
|
|
|
|
|
|
code_voynoModel head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = code_vessel.GetVoynoList(condition);
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new code_voynoModel();
|
|
|
}
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
public ContentResult UpdateBsVesselVoy(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<code_voynoModel>(data);
|
|
|
|
|
|
DBResult result = code_vessel.UpdateBsVesselVoy(headData);
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
#region 获取航次列表
|
|
|
public ContentResult GetCountryType(int start, int limit, string sort, string condition)
|
|
|
{
|
|
|
var dataList = code_vessel.GetVoynotList();
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
#endregion
|
|
|
public ContentResult Save(string opstatus, string data, string body)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<code_vesselModel>(data);
|
|
|
var bodyList = JsonConvert.Deserialize<List<CodeCtnEdi>>(body);
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
DBResult re = code_vessel.InsertDetail(headData);
|
|
|
if (re.Success==false)
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse { Success = re.Success, Message =re.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headData.ModelUIStatus = "E";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
|
|
|
var copybodylist = new List<CodeCtnEdi>();
|
|
|
var ismost = false;
|
|
|
if (bodyList != null && bodyList.Count != 0)
|
|
|
{
|
|
|
foreach (var PORTEDI in bodyList)
|
|
|
{
|
|
|
PORTEDI.CTN = headData.vessel;
|
|
|
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) };
|
|
|
}
|
|
|
|
|
|
|
|
|
var modb = new ModelObjectDB();
|
|
|
modb.Save(headData);
|
|
|
var GID = headData.DM_ID;
|
|
|
DBResult result = code_vessel.SDetail(headData);
|
|
|
if (result.Success)
|
|
|
{
|
|
|
MsCodeCtnEdiDAL.SaveVesselDetail(bodyList, Convert.ToString(Session["COMPANYID"]));
|
|
|
|
|
|
}
|
|
|
var jRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = code_vessel.GetVesselByID(GID)
|
|
|
//
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jRespose) };
|
|
|
}
|
|
|
public ContentResult SaveFoot(string opstatus, string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<code_voynoModel>(data);
|
|
|
if (Session["COMPANYID"] != null)
|
|
|
{
|
|
|
headData.CORPID = Session["COMPANYID"].ToString();
|
|
|
}
|
|
|
if (opstatus == "add")
|
|
|
{
|
|
|
DBResult re = code_vessel.InsertVessel(headData);
|
|
|
if (re.Success == false)
|
|
|
{
|
|
|
var jsonRespose = new JsonResponse { Success = re.Success, Message = re.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
}
|
|
|
else if (opstatus == "edit")
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
|
headData.ModelUIStatus = "E";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
|
}
|
|
|
var modb = new ModelObjectDB();
|
|
|
modb.Save(headData);
|
|
|
var GID = headData.DM_ID;
|
|
|
DBResult result = code_vessel.InsertVoyno(headData);
|
|
|
var jRespose = new JsonResponse
|
|
|
{
|
|
|
Success = result.Success,
|
|
|
Message = result.Message,
|
|
|
Data = code_vessel.GetVoynoListById(GID)
|
|
|
//
|
|
|
};
|
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jRespose) };
|
|
|
}
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<code_vesselModel>(data);
|
|
|
|
|
|
DBResult result = code_vessel.DeleteDetail(headData);
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#region 删除foot
|
|
|
public ContentResult DeleteFoot(string data)
|
|
|
{
|
|
|
var headData = JsonConvert.Deserialize<code_voynoModel>(data);
|
|
|
|
|
|
DBResult result = code_vessel.DeleteDetailFoot(headData);
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
#endregion
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|