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.

1446 lines
72 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.DAL.MsOpSeaiDAL;
using DSWeb.MvcShipping.Models.MsOpSeai;
using DSWeb.MvcShipping.Helper;
using DSWeb.MvcShipping.Comm.Cookie;
using HcUtility.Comm;
using HcUtility.Core;
using System.Collections.Generic;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using DSWeb.EntityDA;
using System.IO;
using System.Text;
using System.Data;
using DSWeb.Areas.CommMng.DAL;
using DSWeb.Areas.RptMng.Comm;
using DSWeb.MvcShipping.DAL.MsCodeFtpSet;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsSysBillNoSet;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.MvcShipping.DAL.MsOpApplyDAL;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.MvcShipping.Models.MsOpSeaeToSeai;
using DSWeb.SoftMng.DAL.SoftSysTable;
using DSWeb.MvcShipping.Models.MsChFee;
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
using DSWeb.MvcShipping.DAL.MsInfoClient;
using Terminal_CDMA;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpSeaiController : Controller
{
#region 窗口页面
public ActionResult Index()
{
return View();
}
public ActionResult HistryFeeIndex()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public ActionResult FeeEdit()
{
return View();
}
public ActionResult SeaiFeeView()
{
return View();
}
public ActionResult FeeAmendEdit()
{
return View();
}
public ActionResult ReceiptEdit()
{
return View();
}
public ActionResult WMSIN()
{
return View();
}
public ActionResult WMSINEdit()
{
return View();
}
public ActionResult WMSOUT()
{
return View();
}
public ActionResult WMSOUTEdit()
{
return View();
}
public ActionResult PiLiangFeeEdit()
{
return View();
}
public ActionResult EditView()
{
return View();
}
public ActionResult SaleIndex()
{
return View();
}
public ActionResult Seae2SeaiIndex()
{
return View();
}
public ActionResult SaleEdit()
{
return View();
}
public ActionResult AmendIndex()
{
return View();
}
public ActionResult AmendFeeEdit()
{
return View();
}
#endregion
#region 基本函数
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var dataList = MsOpSeaiDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = MsOpSeaiDAL.getTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetSaleDataList(int start, int limit, string sort, string condition)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var dataList = MsOpSeaiDAL.GetSaleDataList(condition, Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
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 GetAmendDataList(int start, int limit, string sort, string condition, string load)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
var dataList = MsOpSeaiDAL.GetAmendDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = MsOpSeaiDAL.getAmendTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult GetAmendDataListStr(string sort, string condition)
{
var dataListStr = MsOpSeaiDAL.GetAmendDataStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = dataListStr.Message, data = dataListStr.Data });
return new ContentResult() { Content = json };
}
public ContentResult GetFenList(int start, int limit, string sort, string condition)
{
var dataList = MsOpSeaiDAL.GetFenList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
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 GetDataListStr(string sort, string condition)
{
var dataListStr = MsOpSeaiDAL.GetDataListStr(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = dataListStr });
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition)
{
MsOpSeai head = null;
if (handle == "edit" || handle == "copyadd")
{
head = MsOpSeaiDAL.GetData(condition);
}
if (head == null)
{
head = new MsOpSeai();
head.OP = Convert.ToString(Session["SHOWNAME"]);
head.BSTYPE = "2";
}
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetAmendData(string condition)
{
MsOpSeai head = null;
var headlist = MsOpSeaiDAL.GetAmendDataList(0, 1, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (headlist.Count > 0)
head = headlist[0];
else
head = new MsOpSeai();
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", data = head });
return new ContentResult() { Content = json };
}
public ContentResult GetBodyList(string condition)
{
var dataList = MsOpSeaiDAL.GetBodyList(condition);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
public ContentResult Save(string opstatus, string data, string data2, string data3, string body)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var headData = JsonConvert.Deserialize<MsOpSeai>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
var bodyList = JsonConvert.Deserialize<List<MsOpSeaiDetail>>(body);
var isPost = true;
var errorstr = "";
var iscreatecustno = false;
#region 默认值
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq");
if (headData.INPUTBY.ToString().Trim() == "")
{
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
}
if (headData.CORPID == "" || headData.CORPID ==null)
{
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
}
var isuse = false;
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='海运进口'", Convert.ToString(Session["COMPANYID"]));
if (billnoset.BILLTYPE != "")
isuse = true;
else
isuse = MsBaseInfoDAL.GetRuleUse("委托编号", "2");
if (headData.CUSTNO.Trim() == "" || headData.CUSTNO ==null)
{
if (isuse)
{
if (billnoset.BILLTYPE != "")
{
var FENCUSTNOE = MsSysParamSetDAL.GetData("PARAMNAME='FENCUSTNOE'");
if (FENCUSTNOE.PARAMVALUE == "1" && headData.MASTERNO != "" && headData.BSNO != headData.MASTERNO)
{
headData.CUSTNO = MsSysBillNoSetDAL.GetFenCustNo(headData.MASTERNO, "op_seai");
}
else
{
headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, headData.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim());
iscreatecustno = true;
}
}
else
headData.CUSTNO = MsOpSeaiDAL.getCodeRule("委托编号", "CUSTNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
}
else
{
var ct = MsOpSeaiDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND CUSTNO='" + headData.CUSTNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "委托编号重复";
}
}
if (headData.CUSTNO == "")
{
isPost = false;
errorstr = "委托编号为空";
}
//
if (headData.MBLNO != "" && headData.MBLNO != null && headData.BLTYPE != "拼箱分票")
{
var ct = MsOpSeaiDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "主提单号重复";
}
}
else
{
isuse = MsBaseInfoDAL.GetRuleUse("主提单号", "2");
if (isuse)
{
headData.CUSTNO = MsOpSeaiDAL.getCodeRule("主提单号", "MBLNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
}
//
if (headData.HBLNO != "" && headData.HBLNO != null)
{
var ct = MsOpSeaiDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
if (ct != 0)
{
isPost = false;
errorstr = "分提单号重复";
}
}
else
{
isuse = MsBaseInfoDAL.GetRuleUse("分提单号", "2");
if (isuse)
{
headData.HBLNO = MsOpSeaiDAL.getCodeRule("分提单号", "HBLNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
}
if (headData.ORDERNO != "" && headData.ORDERNO != null)
{
var ct = MsOpSeaiDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND ORDERNO='" + headData.ORDERNO + "'");
if (ct != 0)
{
isPost = false;
errorstr = "订舱编号重复";
}
}
//
if (headData.ACCDATE.ToString().Trim() == "")
{
headData.ACCDATE = DateTime.Parse(rq).ToString("yyyy-MM");
}
if (headData.BSDATE.ToString().Trim() == "")
{
headData.BSDATE = rq;
}
//
if (headData.ETD != null)
{
if (headData.ETD.ToString().Trim() == "")
{
headData.ETD = null;
}
}
if (headData.CUSTOMDATE != null)
{
if (headData.CUSTOMDATE.ToString().Trim() == "")
{
headData.CUSTOMDATE = null;
}
}
if (headData.INSPECTIONDATE != null)
{
if (headData.INSPECTIONDATE.ToString().Trim() == "")
{
headData.INSPECTIONDATE = null;
}
}
if (headData.BMDDATE != null)
{
if (headData.BMDDATE.ToString().Trim() == "")
{
headData.BMDDATE = null;
}
}
if (headData.MDTDATE != null)
{
if (headData.MDTDATE.ToString().Trim() == "")
{
headData.MDTDATE = null;
}
}
if (headData.UPDATETIME != null)
{
if (headData.UPDATETIME.ToString().Trim() == "")
{
headData.UPDATETIME = null;
}
}
if (headData.CLOSINGDATE != null)
{
if (headData.CLOSINGDATE.ToString().Trim() == "")
{
headData.CLOSINGDATE = null;
}
}
if (headData.ISSUEDATE != null)
{
if (headData.ISSUEDATE.ToString().Trim() == "")
{
headData.ISSUEDATE = null;
}
}
if (headData.CLOSEDOCDATE != null)
{
if (headData.CLOSEDOCDATE.ToString().Trim() == "")
{
headData.CLOSEDOCDATE = null;
}
}
if (headData.INTOPORTDATE != null)
{
if (headData.INTOPORTDATE.ToString().Trim() == "")
{
headData.INTOPORTDATE = null;
}
}
if (headData.TARRIFSPAIEDTIEM != null)
{
if (headData.TARRIFSPAIEDTIEM.ToString().Trim() == "")
{
headData.TARRIFSPAIEDTIEM = null;
}
}
if (headData.NOR != null)
{
if (headData.NOR.ToString().Trim() == "")
{
headData.NOR = null;
}
}
if (headData.STLDATE != null)
{
if (headData.STLDATE.ToString().Trim() == "")
{
headData.STLDATE = null;
}
}
if (headData.PORTLOAD == null)
{
headData.PORTLOAD = "";
}
if (headData.PORTDISCHARGE == null)
{
headData.PORTDISCHARGE = "";
}
if (headData.GOODSNAME == null)
{
headData.GOODSNAME = "";
}
if (headData.CUSTOMSER == null)
{
headData.CUSTOMSER = "";
}
if (headData.INSPECTION == null)
{
headData.INSPECTION = "";
}
if (headData.KINDPKGS == null)
{
headData.KINDPKGS = "";
}
if (headData.CARRIER == null)
{
headData.CARRIER = "";
}
if (headData.TRUCKER == null)
{
headData.TRUCKER = "";
}
if (headData.GOODSTYPENAME == null)
{
headData.GOODSTYPENAME = "";
}
if (headData.CURRENCY == null)
{
headData.CURRENCY = "";
}
if (headData.WMSTYPE == null)
{
headData.WMSTYPE = "";
}
if (headData.CHANGEDOCDATE == "") headData.CHANGEDOCDATE = null;
//需求编号SR2017071700004
if (headData.SJYHDATE != null)
{
if (headData.SJYHDATE.ToString().Trim() == "")
{
headData.SJYHDATE = null;
}
}
if (headData.YaXiangDate != null)
{
if (headData.YaXiangDate.ToString().Trim() == "")
{
headData.YaXiangDate = null;
}
}
#endregion
//
if (opstatus == "add")
{
#region 默认值
headData.ORDERTYPE = "操作录入";
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
if (headData.BSTYPE == null)
{
headData.BSTYPE = "普通货";
}
else
{
if (headData.BSTYPE.ToString().Trim() == "")
{
headData.BSTYPE = "普通货";
}
}
//
if (headData.BLTYPE == null)
{
headData.BLTYPE = "整箱";
}
else
{
if (headData.BLTYPE.ToString().Trim() == "")
{
headData.BLTYPE = "整箱";
}
}
//
if (headData.MASTERNO == null)
{
headData.MASTERNO = headData.BSNO;
}
else
{
if (headData.MASTERNO.ToString().Trim() == "")
{
headData.MASTERNO = headData.BSNO;
}
}
#endregion
//
headData.DbOperationType = DbOperationType.DbotIns;
}
else if (opstatus == "edit")
{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
}
else
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.ETD != "" && headData.CUSTOMERNAME != "")// headData.STLDATE == "" &&
{
//根据客户、开船日计算账期
var _dmb = MsInfoClientDAL.GetSTLDATE(headData.CUSTOMERNAME, "海运出口", headData.ETD, headData.SALE);
headData.STLNAME = _dmb.STLNAME;
headData.STLDATE = _dmb.STLDATE;
if (_dmb.STLNAME == "")
{
headData.STLNAME = "现结买单";
headData.STLDATE = headData.ETD;
}
}
if (headData.MASTERNO == null) { headData.MASTERNO = headData.BSNO; }
if (headData.ETA == "") headData.ETA = null;
if (headData.ETD == "") headData.ETD = null;
if (headData.STLDATE == "") headData.STLDATE = null;
if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null;
if (headData.ISSUEDATE == "") headData.ISSUEDATE = null;
if (headData.CLOSEDOCDATE == "") headData.CLOSEDOCDATE = null;
if (headData.INTOPORTDATE == "") headData.INTOPORTDATE = null;
if (headData.BMDDATE == "") headData.BMDDATE = null;
if (headData.MDTDATE == "") headData.MDTDATE = null;
if (headData.TARRIFSPAIEDTIEM == "") headData.TARRIFSPAIEDTIEM = null;
if (headData.NOR == "") headData.NOR = null;
if (headData.UPDATETIME == "") headData.UPDATETIME = null;
//需求编号SR2017071700004
if (headData.SJYHDATE == "") headData.SJYHDATE = null;
if (headData.YaXiangDate == "") headData.YaXiangDate = null;
#region 判断字段长度
if (isPost)
{
var seaefield = MsSoftSysTableDAL.GetDefTableDetailList("OP_SEAI");
foreach (var enumValue in seaefield)
{
if (enumValue.FIELDNAME == "MBLNO" && headData.MBLNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "主提单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "HBLNO" && headData.HBLNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "分提单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CUSTNO" && headData.CUSTNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "委托编号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ORDERNO" && headData.ORDERNO != null && headData.ORDERNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "订舱编号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "SHIPPERID" && headData.SHIPPERID != null && headData.SHIPPERID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发货人代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CONSIGNEEID" && headData.CONSIGNEEID != null && headData.CONSIGNEEID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "收货人代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "NOTIFYPARTYID" && headData.NOTIFYPARTYID != null && headData.NOTIFYPARTYID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "通知人代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "SHIPPER" && headData.SHIPPER != null && headData.SHIPPER.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发货人超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CONSIGNEE" && headData.CONSIGNEE != null && headData.CONSIGNEE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "收货人超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "NOTIFYPARTY" && headData.NOTIFYPARTY != null && headData.NOTIFYPARTY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "通知人超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "AGENTID" && headData.AGENTID != null && headData.AGENTID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "代理名称超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "AGENT" && headData.AGENT != null && headData.AGENT.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "代理超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "VESSEL" && headData.VESSEL != null && headData.VESSEL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "船名超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "VOYNO" && headData.VOYNO != null && headData.VOYNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "航次超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PORTLOADID" && headData.PORTLOADID != null && headData.PORTLOADID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "装货港代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PORTLOAD" && headData.PORTLOAD != null && headData.PORTLOAD.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "装货港超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PORTDISCHARGEID" && headData.PORTDISCHARGEID != null && headData.PORTDISCHARGEID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "卸货港代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PORTDISCHARGE" && headData.PORTDISCHARGE != null && headData.PORTDISCHARGE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "卸货港超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PLACEDELIVERYID" && headData.PLACEDELIVERYID != null && headData.PLACEDELIVERYID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "交货地代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PLACEDELIVERY" && headData.PLACEDELIVERY != null && headData.PLACEDELIVERY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "交货地超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DESTINATIONID" && headData.DESTINATIONID != null && headData.DESTINATIONID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "目的地代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DESTINATION" && headData.DESTINATION != null && headData.DESTINATION.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "目的地超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ISSUEPLACE" && headData.ISSUEPLACE != null && headData.ISSUEPLACE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "签单地点超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "BLFRT" && headData.BLFRT != null && headData.BLFRT.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "付费方式超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PREPARDAT" && headData.PREPARDAT != null && headData.PREPARDAT.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "预付地点超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PAYABLEAT" && headData.PAYABLEAT != null && headData.PAYABLEAT.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "到付地点超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "SERVICE" && headData.SERVICE != null && headData.SERVICE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "运输条款超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "MARKS" && headData.MARKS != null && headData.MARKS.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "唛头超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "NOPKGS" && headData.NOPKGS != null && headData.NOPKGS.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "件数包装超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DESCRIPTION" && headData.DESCRIPTION != null && headData.DESCRIPTION.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "货物描述超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "GOODSNAME" && headData.GOODSNAME != null && headData.GOODSNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "品名超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "KINDPKGS" && headData.KINDPKGS != null && headData.KINDPKGS.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "包装超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "LANE" && headData.LANE != null && headData.LANE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "航线超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "INVNO" && headData.INVNO != null && headData.INVNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "发票号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DCLASS" && headData.DCLASS != null && headData.DCLASS.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "危险品类别超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DUNNO" && headData.DUNNO != null && headData.DUNNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "危险品编号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "REEFERF" && headData.REEFERF != null && headData.REEFERF.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "冷藏通风量超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TEMPID" && headData.TEMPID != null && headData.TEMPID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "温度单位超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TEMPSET" && headData.TEMPSET != null && headData.TEMPSET.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "设置温度超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TEMPMAX" && headData.TEMPMAX != null && headData.TEMPMAX.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "最高温度超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TEMPMIN" && headData.TEMPMIN != null && headData.TEMPMIN.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "最低温度超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CONTRACTNO" && headData.CONTRACTNO != null && headData.CONTRACTNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "运费协议号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "INSURANCEER" && headData.INSURANCEER != null && headData.INSURANCEER.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "保险人超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "INSURANCENO" && headData.INSURANCENO != null && headData.INSURANCENO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "保险单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "REMARK" && headData.REMARK != null && headData.REMARK.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "备注超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "STLNAME" && headData.STLNAME != null && headData.STLNAME.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "结算方式超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "ENTERP" && headData.ENTERP != null && headData.ENTERP.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "经营单位超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "LINKMAN" && headData.LINKMAN != null && headData.LINKMAN.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "客户联系人超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "INSPECTSERVICE" && headData.INSPECTSERVICE != null && headData.INSPECTSERVICE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "报检项目超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "APPLYNO" && headData.APPLYNO != null && headData.APPLYNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "申请放箱号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "CUSTOMNO" && headData.CUSTOMNO != null && headData.CUSTOMNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "报关单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "INSPECTIONNO" && headData.INSPECTIONNO != null && headData.INSPECTIONNO.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "商检单号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "PLACERECEIPTID" && headData.PLACERECEIPTID != null && headData.PLACERECEIPTID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "收货地代码超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TRADETERM" && headData.TRADETERM != null && headData.TRADETERM.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "贸易条款超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "VESSELID" && headData.VESSELID != null && headData.VESSELID.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "船舶呼号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DPAGE" && headData.DPAGE != null && headData.DPAGE.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "危险品页号超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "TERMSDELIVERY" && headData.TERMSDELIVERY != null && headData.TERMSDELIVERY.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "贸易方式超长,字段长度限制" + enumValue.FIELDLEN; }
if (enumValue.FIELDNAME == "DLABEL" && headData.DLABEL != null && headData.DLABEL.Length > Convert.ToInt32(enumValue.FIELDLEN)) { isPost = false; errorstr = "危险品标签超长,字段长度限制" + enumValue.FIELDLEN; }
}
}
#endregion
if (isPost)
{
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
var BSNO = headData.BSNO;
if (result.Success == true)
{
result = MsOpSeaiDAL.SaveDetail(headData, bodyList, Convert.ToString(Session["USERID"]));
//if (headData.APPLYNO != "" && headData.ETA != null)
//{
// var blUpSQL1 = " update op_ctnbscard set I_ETD='" + headData.ETA + "' where IS_RETURE_EMPTY=1 and APPLYNO='" + headData.APPLYNO + "' ";
// bool bl1 = T_ALL_DA.GetExecuteSqlCommand(blUpSQL1);
//}
}
else {
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = MsOpSeaiDAL.GetData("BSNO='" + BSNO + "'")
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
if (iscreatecustno == true)
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
var jsonRespose = new JsonResponse { Success = false, Message =errorstr+",不允许保存!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult DeleteDetail(string data)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var head = JsonConvert.Deserialize<MsOpSeaiDetail>(data);
DBResult result = MsOpSeaiDAL.DeleteDetail2(head);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult Delete(string data)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var head = JsonConvert.Deserialize<MsOpSeai>(data);
var isfee = MsOpSeaiDAL.GetFeeCount(head.BSNO);
if (isfee)
{
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
DBResult result=null;
if (head.ORDERTYPE != "网上订舱")
{
if (head.BLTYPE == "拼箱主票")
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from OP_SEAI WHERE MASTERNO='" + head.BSNO + "' AND BSNO<>'" + head.BSNO + "'");
if (BLCOUNT == "0")
{
var BSNO = head.BSNO;
var modb = new ModelObjectDB();
result = modb.Delete(head);
if (result.Success == true) { MsOpSeaiDAL.DeleteDetail(head); MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
var jsonRespose3 = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose3) };
}
else
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "此票拼箱主票存在分票业务,请先删除分票信息!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
}
else
{
var BSNO = head.BSNO;
var modb = new ModelObjectDB();
result = modb.Delete(head);
if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
if (result.Success == true) { MsOpSeaiDAL.DeleteDetail(head); }
}
}
else {
result.Success = false;
result.Message = "网上订舱不能删除";
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
public ContentResult GetCtnSum(string condition)
{
var rangstr = MsOpSeaiDAL.GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(condition))
{
condition = condition + " and " + rangstr;
}
else
{
condition = rangstr;
}
}
condition = condition.Replace("'", "''");
var strSql = new StringBuilder();
strSql.Append(" declare @sql NVARCHAR(max) ");
strSql.Append(" set @sql='select S.NOBILL,S.PKGS,S.KGS,S.CBM,S.NETKGS,S.WMSCTNNUM ' ");
strSql.Append(" select @sql=@sql+',sum(case C.CTNALL when '''+t.CTN+''' then C.CTNNUM else 0 end) as C'+t.CTN ");
strSql.Append(" from (select CTN from code_ctn ) as t");
strSql.Append(" set @sql=@sql+',sum(C.TEU) TEU from op_ctn C left join op_seai B on (B.bsno=C.bsno) ");
strSql.Append(" left join (SELECT COUNT(BSNO) AS NOBILL,SUM(KGS) KGS,SUM(PKGS) PKGS,SUM(CBM) CBM,SUM(NETWEIGHT) NETKGS,SUM(ISNULL(W.WMSCTNNUM,0)) WMSCTNNUM");
strSql.Append(" from op_seai B LEFT JOIN (SELECT ASSOCIATEDNO,COUNT(DISTINCT CNTRNO) WMSCTNNUM FROM WMS_IN WHERE ISNULL(CNTRNO,'''')<>'''' GROUP BY ASSOCIATEDNO) W ON W.ASSOCIATEDNO=B.BSNO ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" ) S ON (1=1) ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where B.BSNO IS NOT NULL AND " + condition);
}
else {
strSql.Append(" Where B.BSNO IS NOT NULL ");
}
strSql.Append(" GROUP BY S.NOBILL,S.KGS,S.PKGS,S.CBM,S.NETKGS,S.WMSCTNNUM ' ");
strSql.Append(" exec(@sql) ");
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 1, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult GetSaleCtnSum(string condition)
{
condition = condition.Replace("'", "''");
var strSql = new StringBuilder();
strSql.Append(" declare @sql NVARCHAR(max) ");
strSql.Append(" set @sql='select S.NOBILL,S.PKGS,S.KGS,S.CBM' ");
strSql.Append(" select @sql=@sql+',sum(case C.CTNALL when '''+t.CTN+''' then C.CTNNUM else 0 end) as C'+t.CTN ");
strSql.Append(" from (select CTN from code_ctn ) as t");
strSql.Append(" set @sql=@sql+',sum(C.TEU) TEU from op_ctn C left join op_seai B on (B.bsno=C.bsno) ");
strSql.Append(" left join (SELECT COUNT(BSNO) AS NOBILL,SUM(KGS) KGS,SUM(PKGS) PKGS,SUM(CBM) CBM from op_seai B ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" ) S ON (1=1) ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
strSql.Append(" GROUP BY S.NOBILL,S.KGS,S.PKGS,S.CBM ' ");
strSql.Append(" exec(@sql) ");
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 1, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult GetCtnList(string condition)
{
var rangstr = MsOpSeaiDAL.GetRangDAStr("index", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(condition))
{
condition = condition + " and " + rangstr;
}
else
{
condition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append(" SELECT DISTINCT C.CTNALL from op_ctn C left join op_seai B on (B.bsno=C.bsno) ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" Where " + condition);
}
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(0, 20, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
}
public ContentResult CreateCtnFee(string bsno, string body)
{
var iResult = 0;
var headList = new List<MsChFee>();
var bodyList = JsonConvert.Deserialize<List<MsOpSeaiDetail>>(body);
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (enumValue.TRUCKFEE != "0" && enumValue.TRUCKFEE != "")
{
MsChFee data = new MsChFee();
data.BsNo = "*";
data.GId = Guid.NewGuid().ToString();
data.FeeType = 2;
data.FeeName = "陆运费";
data.CustomerType = "车队";
data.CustomerName = enumValue.TRUCKER;
data.Unit = enumValue.CTNALL;
data.UnitPrice = Convert.ToDecimal(enumValue.TRUCKFEE);
data.Quantity = 1;
data.Amount = Convert.ToDecimal(enumValue.TRUCKFEE);
data.Currency = "RMB";
data.ExChangerate = 1;
data.EnteroPerator = Convert.ToString(Session["USERID"]);
data.IsOpen = "0";
data.IsAdvancedpay = "0";
data.FeeStatus = 1;
data.TaxRate = 0;
data.NoTaxAmount = Convert.ToDecimal(enumValue.TRUCKFEE);
data.TaxUnitPrice = Convert.ToDecimal(enumValue.TRUCKFEE);
data.AccTaxRate = 0;
data.IsInvoice = "0";
data.LOCALCURR = "RMB";
headList.Add(data);
}
if (enumValue.CTNFEE != "0" && enumValue.CTNFEE != "")
{
MsChFee data = new MsChFee();
data.BsNo = "*";
data.GId = Guid.NewGuid().ToString();
data.FeeType = 2;
data.FeeName = "箱使费";
data.CustomerType = "车队";
data.CustomerName = enumValue.TRUCKER;
data.Unit = "天";
data.UnitPrice = Convert.ToDecimal(enumValue.CTNPRICE);
data.Quantity = Convert.ToInt16(enumValue.CTNDAY) - Convert.ToInt16(enumValue.FREECTNDAY);
data.Amount = Convert.ToDecimal(enumValue.CTNFEE);
data.Currency = "RMB";
data.ExChangerate = 1;
data.EnteroPerator = Convert.ToString(Session["USERID"]);
data.IsOpen = "0";
data.IsAdvancedpay = "0";
data.FeeStatus = 1;
data.TaxRate = 0;
data.NoTaxAmount = Convert.ToDecimal(enumValue.CTNFEE);
data.TaxUnitPrice = Convert.ToDecimal(enumValue.CTNPRICE);
data.AccTaxRate = 0;
data.IsInvoice = "0";
data.LOCALCURR = "RMB";
headList.Add(data);
}
}
if (headList != null)
{
iResult = MsChFeeDAL.SaveUpdateFee(headList, bsno, CookieConfig.GetCookie_UserId(Request));
}
}
if (iResult == 0 || iResult == 1)
{
var jsonRespose = new JsonResponse { Success = true, Message = "已生成费用!", Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "生成费用时出错!", Data = "" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region EDI引入
[HttpPost]
public ContentResult ImportEdi()
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var jsonRespose = new JsonResponse { Success = false, Message = "" };
if (Request.Files.Count != 1)
{
jsonRespose.Success = false;
jsonRespose.Message = "请选择上传的文件";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var file = Request.Files["file"];
if (file == null)
{
jsonRespose.Success = false;
jsonRespose.Message = "上传文件发生未知错误,请重新上传";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
var path = Server.MapPath("../../UploadFiles/Edi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var size = file.ContentLength;
var name = Path.GetFileName(file.FileName);
var usercode = CookieConfig.GetCookie_UserCode(Request);
string filename = path + "\\" + usercode + DateTime.Now.ToString("yyyyMMddHHmmssfff") + name;
if (System.IO.File.Exists(filename))
{
System.IO.File.Delete(filename);
}
file.SaveAs(filename);
try
{
var headList = MsOpSeaiDAL.ImportEdiList(filename, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
//var headList = new List<MsOpSeai>();
if (headList.Count != 0)
{
var json = JsonConvert.Serialize(new { Success = true, Message = "导入成功" + headList.Count.ToString()+"票", data = headList.ToList() });
return new ContentResult() { Content = json };
}
else {
var json = JsonConvert.Serialize(new { Success =false, Message = "未导入数据,请确认是否已经有此业务!" });
return new ContentResult() { Content = json };
}
}
catch (Exception)
{
jsonRespose.Success = false;
jsonRespose.Message = "读取EDI文件出错请确认文件正确性";
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
#endregion
#region EDI导出
public ContentResult CreateEDIList(string headData, string mblno, string type, string filetype, string filerole, int isbill, int isnoctn)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var headList = JsonConvert.Deserialize<List<MsOpSeai>>(headData);
var path = Server.MapPath("../../EDIFiles/SeaiEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var error = MsOpSeaiDAL.IsCreateEdi(headList, type, filetype, filerole,"");
if (error == "")
{
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='" + type + "'", Convert.ToString(Session["COMPANYID"]));
var filename = MsOpSeaiDAL.CreateEdi(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, type, isbill, isnoctn, "", "");
if (ftpset.SERVERIP != "" && ftpset.SERVERIP != null)
result = MsOpSeaiDAL.FtpFile(filename, ftpset);
else
{
result.Success = false;
result.Message = "FTP参数没有设置,请先设置FTP参数!";
}
}
else
{
result.Success = false;
result.Message = error;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveEDIList(string headData, string mblno, string type, string filetype, string filerole, int isbill, int isnoctn)
{
var headList = JsonConvert.Deserialize<List<MsOpSeai>>(headData);
var path = Server.MapPath("../../EDIFiles/SeaiEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var error = MsOpSeaiDAL.IsCreateEdi(headList, type, filetype, filerole,"");
if (error == "")
{
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='" + type + "'", Convert.ToString(Session["COMPANYID"]));
var filename = MsOpSeaiDAL.CreateEdi(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, type, isbill, isnoctn, "", "");
filename = Path.GetFileName(filename);
result.Success = true;
result.Data = "../../EDIFiles/SeaiEdi/" + filename;
result.Message = filename;
}
else
{
result.Success = false;
result.Message = error;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message,Data=result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region DHL EDI
public ContentResult CreateDHLList(string bsnos, string mblno, string filerole)
{
bsnos = bsnos.Replace(",", "','");
var headList = MsOpSeaiDAL.GetDataList("BSNO IN ('" + bsnos + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var path = Server.MapPath("../../EDIFiles/SeaiEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var error = MsOpSeaiDAL.IsCreateEdiDHL(headList,filerole);
if (error == "")
{
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='DHL' ", Convert.ToString(Session["COMPANYID"]));
var filename = "";
if (ftpset.SERVERIP != "" && ftpset.SERVERIP != null)
{
foreach (var bill in headList)
{
filename = MsOpSeaiDAL.CreateEdiDHL(bill, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset);
result = MsOpSeaiDAL.SFtpFile(filename, ftpset);
}
}
else
{
result.Success = false;
result.Message = "FTP参数没有设置,请先设置FTP参数!";
}
}
else
{
result.Success = false;
result.Message = error;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveDHLList(string bsnos, string mblno, string filerole)
{
bsnos = bsnos.Replace(",", "','");
var headList = MsOpSeaiDAL.GetDataList("BSNO IN ('" + bsnos + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var path = Server.MapPath("../../EDIFiles/SeaiEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var error = MsOpSeaiDAL.IsCreateEdiDHL(headList, filerole);
if (error == "")
{
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='DHL' ", Convert.ToString(Session["COMPANYID"]));
var filename = "";
if (ftpset.SENDCODE == "")
{
result.Success = false;
result.Message = "EDI参数没有设置,请先设置EDI参数!";
}
else
{
filename = MsOpSeaiDAL.CreateEdiDHL(headList[0], Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset);
filename = Path.GetFileName(filename);
result.Data = "../../EDIFiles/SeaiEdi/" + filename;
result.Success = true;
result.Message = filename;
}
}
else
{
result.Success = false;
result.Message = error;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message,Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 舱单申报
public ContentResult CreateCustomList(string bsnos, string type)
{
bsnos = bsnos.Replace(",", "','");
var billList = MsOpSeaiDAL.GetDataList("BSNO IN ('" + bsnos + "')", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var result = new DBResult();
var error = "";
if (error == "")
{
result = MsOpSeaiDAL.CreateCustomList(billList, type, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
}
else
{
result.Success = false;
result.Message = error;
}
var json = JsonConvert.Serialize(result);
return new ContentResult() { Content = json };
}
#endregion
#region 交通部2.0 EDI导出
public ContentResult CreateIFTMBFList(string bsnos, string mblno, string filerole, string carrier)
{
bsnos = bsnos.Replace(",", "','");
var headList = MsOpSeaiDAL.GetDataList("BSNO IN ('" + bsnos + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var path = Server.MapPath("../../EDIFiles/SeaiEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var error = MsOpSeaiDAL.IsCreateEdi(headList, "IFTMBF", "", filerole, carrier);
if (error == "")
{
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='IFTMBF' AND CARRIERID='" + carrier + "'", Convert.ToString(Session["COMPANYID"]));
var filename = "";
filename = MsOpSeaiDAL.CreateEdi(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "IFTMBF", 0, 0, carrier, "");
if (ftpset.SERVERIP != "" && ftpset.SERVERIP != null)
result = MsOpSeaiDAL.FtpFile(filename, ftpset);
else
{
result.Success = false;
result.Message = "FTP参数没有设置,请先设置FTP参数!";
}
}
else
{
result.Success = false;
result.Message = error;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveIFTMBFList(string bsnos, string mblno, string filerole, string carrier)
{
bsnos = bsnos.Replace(",", "','");
var headList = MsOpSeaiDAL.GetDataList("BSNO IN ('" + bsnos + "')", Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var path = Server.MapPath("../../EDIFiles/SeaiEdi");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var result = new DBResult();
var error = MsOpSeaiDAL.IsCreateEdi(headList, "IFTMBF", "", filerole, carrier);
if (error == "")
{
var ftpset = MsCodeFtpSetDAL.GetData("EDINAME='IFTMBF' AND CARRIERID='" + carrier + "'", Convert.ToString(Session["COMPANYID"]));
if (ftpset.SENDCODE == "" || ftpset.RECEIVECODE == "")
{
result.Success = false;
result.Message = "EDI参数没有设置,请先设置EDI参数!";
}
else
{
var filename = "";
//filename = MsOpSeaiDAL.CreateEdi(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "IFTMBF", isbill, 0, carrier, "", "", filetype);
filename = MsOpSeaiDAL.CreateEdi(headList, Convert.ToString(Session["USERCODE"]), path, mblno, filerole, ftpset, "IFTMBF", 0, 0, carrier, "");
filename = Path.GetFileName(filename);
result.Data = "../../EDIFiles/SeaiEdi/" + filename;
result.Success = true;
result.Message = filename;
}
}
else
{
result.Success = false;
result.Message = error;
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 生成报关信息
public ContentResult SaveBG(string data, string data2, string data3)
{
if (Convert.ToString(Session["COMPANYID"]).ToString().Trim() == "" || Convert.ToString(Session["USERID"]).ToString().Trim() == "" || Convert.ToString(Session["CODENAME"]).ToString().Trim() == "" || Convert.ToString(Session["SHOWNAME"]).ToString().Trim() == "" || Convert.ToString(Session["DEPTNAME"]).ToString().Trim() == "")
{
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
}
//
var aaa = "";
var head = JsonConvert.Deserialize<MsOpSeai>(data.Replace("}", ",") + data2.Replace("{", "").Replace("}", ",") + data3.Replace("{", ""));
var headData = new MsOpApply();
var isuse = MsBaseInfoDAL.GetRuleUse("委托编号", "4");
if (isuse)
{
headData.CUSTNO = MsOpApplyDAL.getCodeRule("委托编号", "CUSTNO", headData.BSDATE.ToString().Trim(), headData.ACCDATE.ToString().Trim(), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
}
if (headData.CORPID == "" || headData.CORPID == null)
{
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
}
headData.MASTERNO = head.BSNO;
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
headData.BSDATE = DateTime.Now;
headData.DbOperationType = DbOperationType.DbotIns;
headData.CUSTOMERNAME = head.CUSTOMERNAME;
headData.MBLNO = head.MBLNO;
headData.VESSEL = head.VESSEL;
headData.VOYNO = head.VOYNO;
headData.BSSOURCE = head.BSSOURCE;
headData.BSSOURCEDETAIL = head.BSSOURCEDETAIL;
headData.ETD = head.ETD;
headData.ETA = head.ETA;
headData.PKGS = head.PKGS;
headData.KGS = head.KGS;
headData.CBM = head.CBM;
headData.PORTLOAD = head.PORTLOAD;
headData.PORTDISCHARGE = head.PORTDISCHARGE;
headData.SALE = head.SALE;
headData.SALEDEPT = head.SALEDEPT;
headData.BSTYPE = "2";
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
if (result.Success == true)
{
result.Success = true;
result.Message = "生成成功";
}
else
{
result.Success = false;
result.Message = "生成过程发生错误";
}
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message
};
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
#endregion
#region 集团委托引入
public ContentResult GetImpDataList(int start, int limit, string sort, string condition)
{
//var dataList = MsOpSeaiDAL.GetDataList(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
//var list = dataList.Skip(start).Take(limit);
var dataList = MsOpSeaiDAL.GetImpDataList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = MsOpSeaiDAL.getImpTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
return new ContentResult() { Content = json };
}
#endregion
//
}
}