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.
1043 lines
43 KiB
C#
1043 lines
43 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.Mvc;
|
|
using System.Data;
|
|
using DSWeb.MvcShipping.DAL.MsOpAireDAL;
|
|
using DSWeb.MvcShipping.Models.MsOpAire;
|
|
using DSWeb.MvcShipping.Models.MsOpAireBill;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
using DSWeb.MvcShipping.DAL.MsSysBillNoSet;
|
|
using DSWeb.MvcShipping.Models.MsOpApply;
|
|
using DSWeb.MvcShipping.DAL.MsOpApplyDAL;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.MvcShipping.DAL.MsInfoClient;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using System.Collections.Generic;
|
|
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL;
|
|
using DSWeb.MvcShipping.DAL.MsCodeOpTemplate;
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
using DSWeb.Areas.SysMng.DAL.SysUser;
|
|
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
|
|
using System.Web;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
[JsonRequestBehavior]
|
|
public class MsOpAireController : Controller
|
|
{
|
|
//
|
|
// GET:
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Edit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult SaleEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult SaleIndex()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FeeEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FenList()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult SeaeFeeView()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult FeeAmendEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult ReceiptEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult BillEdit()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult FenEdit()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult PiLiangFeeEdit()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult HistryFeeIndex()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult HistryBillIndex()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult FenBillList()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult PiLiangFenFee()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult PiLiangOpBill()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult EditView()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ContentResult GetDataList(int start, int limit, string sort, string condition,string load)
|
|
{
|
|
var OPLISTNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='OPLISTNOCANCEL'").PARAMVALUE;
|
|
if (OPLISTNOCANCEL == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and isnull(B.ISCANCEL,'')<>'1' ";
|
|
}
|
|
else
|
|
{
|
|
condition = " isnull(B.ISCANCEL,'')<>'1' ";
|
|
}
|
|
|
|
}
|
|
var dataList = MsOpAireDAL.GetDataList(start, limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort,load);
|
|
//var list = dataList.Skip(start).Take(limit);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult GetSaleDataList(int start, int limit, string sort, string condition, string load)
|
|
{
|
|
var dataList = MsOpAireDAL.GetSaleDataList(start, limit,condition, Convert.ToString(Session["SHOWNAME"]), sort, load, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
|
|
//var list = dataList.Skip(start).Take(limit);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetSaleDataListStr(string condition)
|
|
{
|
|
var strbuilder = MsOpAireDAL.GetSaleDataListStringBuilder( condition, Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", data = strbuilder.ToString() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetDataListStr( string sort, string condition)
|
|
{
|
|
var OPLISTNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='OPLISTNOCANCEL'").PARAMVALUE;
|
|
if (OPLISTNOCANCEL == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and isnull(B.ISCANCEL,'')<>'1' ";
|
|
}
|
|
else
|
|
{
|
|
condition = " isnull(B.ISCANCEL,'')<>'1' ";
|
|
}
|
|
|
|
}
|
|
var dataListStr = MsOpAireDAL.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 GetFenList(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = MsOpAireDAL.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 GetSum(string condition)
|
|
{
|
|
var rangstr = MsOpAireDAL.GetRangDAStr("index", CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
condition = rangstr;
|
|
}
|
|
}
|
|
var OPLISTNOCANCEL = MsSysParamSetDAL.GetData("PARAMNAME='OPLISTNOCANCEL'").PARAMVALUE;
|
|
if (OPLISTNOCANCEL == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and B.ISCANCEL<>'1' ";
|
|
}
|
|
else
|
|
{
|
|
condition = " B.ISCANCEL<>'1' ";
|
|
}
|
|
|
|
}
|
|
|
|
var condition1 = condition.Replace("'", "''");
|
|
|
|
|
|
|
|
var strSql2 = new StringBuilder();
|
|
strSql2.Append(" SELECT SUM(CASE WHEN B.MASTERNO=B.BSNO THEN 1 ELSE 0 END) AS NOBILL,SUM(CASE WHEN B.BLTYPE<>'空运主票' THEN 1 ELSE 0 END) TTLBILL," +
|
|
"SUM(CASE WHEN B.BLTYPE<>'空运主票' AND B.ISCANCEL='1' THEN 1 ELSE 0 END) AMENDBILL,SUM(KGS) KGS,SUM(PKGS) PKGS,SUM(CBM) CBM,SUM(FEEKGS) FEEKGS from op_aire B ");
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql2.Append(" Where 1=1 AND " + condition);
|
|
}
|
|
else
|
|
{
|
|
strSql2.Append(" Where 1=1 ");
|
|
}
|
|
|
|
|
|
var dbparams2 = new List<CustomDbParamter>();
|
|
|
|
var paramps_sSQL2 = new CustomDbParamter();
|
|
paramps_sSQL2.ParameterName = "@sSQL";
|
|
paramps_sSQL2.DbType = DbType.String;
|
|
paramps_sSQL2.Direction = ParameterDirection.Input;
|
|
paramps_sSQL2.Value = strSql2.ToString();
|
|
dbparams2.Add(paramps_sSQL2);
|
|
|
|
var dbRptResult2 = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams2, "Result_Set");
|
|
|
|
|
|
|
|
//var strSql3 = new StringBuilder();
|
|
//strSql3.Append(" SELECT COUNT(1) AS TTLBILL,SUM(CASE WHEN B.ISCANCEL='1' THEN 1 ELSE 0 END) AMENDBILL from op_aire B ");
|
|
//if (!string.IsNullOrEmpty(condition))
|
|
//{
|
|
// strSql3.Append(" Where B.BLTYPE<>'空运主票' AND " + condition);
|
|
//}
|
|
//else
|
|
//{
|
|
// strSql3.Append(" Where B.BSNO IS NOT NULL AND B.MASTERNO=B.BSNO ");
|
|
//}
|
|
|
|
|
|
//var dbparams3 = new List<CustomDbParamter>();
|
|
|
|
//var paramps_sSQL3 = new CustomDbParamter();
|
|
//paramps_sSQL3.ParameterName = "@sSQL";
|
|
//paramps_sSQL3.DbType = DbType.String;
|
|
//paramps_sSQL3.Direction = ParameterDirection.Input;
|
|
//paramps_sSQL3.Value = strSql3.ToString();
|
|
//dbparams3.Add(paramps_sSQL3);
|
|
|
|
//var dbRptResult3 = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams3, "Result_Set");
|
|
//dbRptResult2.DataSet.Tables["Result_Set"].Rows[0]["TTLBILL"] = dbRptResult3.DataSet.Tables["Result_Set"].Rows[0]["TTLBILL"];
|
|
//dbRptResult2.DataSet.Tables["Result_Set"].Rows[0]["AMENDBILL"] = dbRptResult3.DataSet.Tables["Result_Set"].Rows[0]["AMENDBILL"];
|
|
|
|
|
|
var json = RptHelper.GetRptJsonResult(0, 1, dbRptResult2, "Result_Set", true);
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
{
|
|
MsOpAire head = null;
|
|
if (handle == "edit")
|
|
{
|
|
head = MsOpAireDAL.GetData(condition);
|
|
}
|
|
if (head == null)
|
|
{
|
|
head = new MsOpAire();
|
|
head.OP = Convert.ToString(Session["SHOWNAME"]);
|
|
head.INPUTBY= Convert.ToString(Session["SHOWNAME"]);
|
|
head.CUSTSERVICE = Convert.ToString(Session["SHOWNAME"]);
|
|
var SALEORDERDEPTBYOP = MsSysParamSetDAL.GetData("PARAMNAME='SALEORDERDEPTBYOP'");
|
|
if (SALEORDERDEPTBYOP.PARAMVALUE == "1")
|
|
{
|
|
head.SALEDEPT = Convert.ToString(Session["DEPTNAME"]);
|
|
}
|
|
}
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult GetCopyData(string handle, string condition, string copybill, string copyfee = "false")
|
|
{
|
|
MsOpAire head = null;
|
|
|
|
var oldhead = MsOpAireDAL.GetData(condition);
|
|
|
|
var copyfieldlist = MsCodeOpTemplateDAL.GetCodeOpTemplateDetail(" LINKGID in (select top 1 GID from CODE_OP_TEMPLATE where BSTYPE='空运出口' and (op='" + CookieConfig.GetCookie_UserId(Request) + "' or ISPUBLIC='是') order by ISPUBLIC)");
|
|
if (copyfieldlist.Count == 0)
|
|
{
|
|
head = oldhead;
|
|
head.BSNO = "topaire" + Guid.NewGuid().ToString();
|
|
head.MASTERNO = "";
|
|
head.CUSTNO = "";
|
|
head.ORDERNO = "";
|
|
head.ISCANCEL = "";
|
|
head.ORDERTYPE = "操作录入";
|
|
head.OP = Convert.ToString(Session["SHOWNAME"]);
|
|
head.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
|
|
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
|
|
{
|
|
head.ACCDATE = period.PERIOD;
|
|
}
|
|
else
|
|
{
|
|
head.ACCDATE = DateTime.Now.ToString("yyyy-MM");
|
|
}
|
|
head.BSSTATUS = false;
|
|
head.FEESTATUS = false;
|
|
head.BSSTATUSREF = "未锁定";
|
|
head.FEESTATUSREF = "未锁定";
|
|
|
|
if (copybill == "true")
|
|
{
|
|
var billlist = MsOpAireDAL.GetBillList(condition);
|
|
if (billlist != null)
|
|
{
|
|
foreach (var enumValue in billlist)
|
|
{
|
|
enumValue.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
enumValue.BSNO = head.BSNO;
|
|
enumValue.AS_ID = Guid.NewGuid().ToString();
|
|
enumValue.MBLNO = "";
|
|
enumValue.HBLNO = "";
|
|
enumValue.DbOperationType = DbOperationType.DbotIns;
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Save(enumValue);
|
|
}
|
|
}
|
|
}
|
|
if (copyfee == "true")
|
|
{
|
|
var feelist = MsChFeeDAL.GetAllDataList(condition);
|
|
if (feelist != null)
|
|
{
|
|
for (int _i = 0; _i < feelist.Count; _i++)
|
|
{
|
|
feelist[_i].BsNo = "*";
|
|
}
|
|
MsChFeeDAL.SaveFee(feelist, head.BSNO, CookieConfig.GetCookie_UserId(Request));
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
if (head == null)
|
|
{
|
|
head = new MsOpAire();
|
|
head.BSNO = "topaire" + Guid.NewGuid().ToString();
|
|
head.ORDERTYPE = "操作录入";
|
|
head.OP = Convert.ToString(Session["SHOWNAME"]);
|
|
// head.DOC = Convert.ToString(Session["SHOWNAME"]);
|
|
head.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
// head.CUSTSERVICE = Convert.ToString(Session["SHOWNAME"]);
|
|
var period = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
|
|
if (Convert.ToDateTime(period.FDAY) > DateTime.Now)
|
|
{
|
|
head.ACCDATE = period.PERIOD;
|
|
}
|
|
else
|
|
{
|
|
head.ACCDATE = DateTime.Now.ToString("yyyy-MM");
|
|
|
|
}
|
|
var propArr = head.GetType().GetProperties();
|
|
|
|
foreach (var enumValue in copyfieldlist)
|
|
{
|
|
var prop = propArr.FirstOrDefault(p => p.Name.ToLower() == enumValue.FIELDNAME.ToLower());
|
|
if (prop != null) {
|
|
prop.SetValue(head, oldhead.GetPropertyValue(enumValue.FIELDNAME));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (copybill == "true")
|
|
{
|
|
var billlist = MsOpAireDAL.GetBillList(condition);
|
|
if (billlist != null)
|
|
{
|
|
foreach (var enumValue in billlist)
|
|
{
|
|
enumValue.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
enumValue.BSNO = head.BSNO;
|
|
enumValue.AS_ID = Guid.NewGuid().ToString();
|
|
enumValue.MBLNO = "";
|
|
enumValue.HBLNO = "";
|
|
enumValue.DbOperationType = DbOperationType.DbotIns;
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Save(enumValue);
|
|
}
|
|
}
|
|
}
|
|
if (copyfee == "true")
|
|
{
|
|
var feelist = MsChFeeDAL.GetAllDataList(condition);
|
|
if (feelist != null)
|
|
{
|
|
for (int _i = 0; _i < feelist.Count; _i++)
|
|
{
|
|
feelist[_i].BsNo = "*";
|
|
}
|
|
MsChFeeDAL.SaveFee(feelist, head.BSNO, CookieConfig.GetCookie_UserId(Request));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
|
|
public ContentResult Save(string opstatus, string data, string data2)
|
|
{
|
|
|
|
var dataall = data.Replace("}", ",") + data2.Replace("{", "");
|
|
var headData = JsonConvert.Deserialize<MsOpAire>(dataall);
|
|
return DoSave(opstatus, headData, Session);
|
|
}
|
|
|
|
public ContentResult DoSave(string opstatus, MsOpAire headData, HttpSessionStateBase Session)
|
|
{
|
|
|
|
//var dataall = data.Replace("}", ",") + data2.Replace("{", "");
|
|
//var headData = JsonConvert.Deserialize<MsOpAire>(dataall);
|
|
|
|
|
|
var isPost = true;
|
|
var errorstr = "";
|
|
var isuse = false;
|
|
var iscreatecustno = false;
|
|
var billnoset = MsSysBillNoSetDAL.GetData("OPLBNAME='空运出口' AND RULEBLNO='委托编号' ", Convert.ToString(Session["COMPANYID"]));
|
|
if (billnoset.BILLTYPE != "")
|
|
isuse = true;
|
|
if (headData.CUSTNO == "")
|
|
{
|
|
if (isuse)
|
|
{
|
|
var FENCUSTNOE = MsSysParamSetDAL.GetData("PARAMNAME='FENCUSTNOE'");
|
|
if (FENCUSTNOE.PARAMVALUE == "1" && headData.MASTERNO != "" && headData.BSNO != headData.MASTERNO)
|
|
{
|
|
headData.CUSTNO = MsSysBillNoSetDAL.GetFenCustNo(headData.MASTERNO, "op_aire");
|
|
|
|
}
|
|
else
|
|
{
|
|
var CUSTOMHEAD = "";
|
|
if (billnoset.CUSTOMHEAD != "")
|
|
{
|
|
var HBLCUSTOMHEAD = billnoset.CUSTOMHEAD;
|
|
if ((HBLCUSTOMHEAD.IndexOf("[SALE]") >= 0) && !string.IsNullOrEmpty(headData.SALE))
|
|
{
|
|
var user = SysUserDAL.GetData("u.SHOWNAME='" + headData.SALE + "'");
|
|
if (!string.IsNullOrEmpty(user.NOCODE))
|
|
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[SALE]", user.NOCODE);
|
|
|
|
}
|
|
if ((HBLCUSTOMHEAD.IndexOf("[OP]") >= 0) && !string.IsNullOrEmpty(headData.OP))
|
|
{
|
|
var user = SysUserDAL.GetData("u.SHOWNAME='" + headData.OP + "'");
|
|
if (!string.IsNullOrEmpty(user.NOCODE))
|
|
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[OP]", user.NOCODE);
|
|
}
|
|
CUSTOMHEAD = HBLCUSTOMHEAD;
|
|
var CUST = MsInfoClientDAL.GetData("SHORTNAME='" + headData.CUSTOMERNAME + "'");
|
|
CUSTOMHEAD = CUSTOMHEAD.Replace("[CUSTCODE]", CUST.CODENAME);
|
|
}
|
|
|
|
var _etdstr = Convert.ToDateTime(headData.ETD).ToString("yyyy-MM-dd");
|
|
|
|
headData.CUSTNO = MsSysBillNoSetDAL.GetBillNo(billnoset, _etdstr, headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID, CUSTOMHEAD);
|
|
iscreatecustno = true;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
//if (!isuse) {
|
|
// {
|
|
var ct = MsOpAireDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND isnull(ISCANCEL,'')<>'1' AND CUSTNO='" + headData.CUSTNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "委托编号";
|
|
}
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
if (headData.CORPID == "" || headData.CORPID == null)
|
|
{
|
|
headData.CORPID = Convert.ToString(Session["COMPANYID"]);
|
|
}
|
|
|
|
if (headData.MBLNO != "" && headData.MBLNO != null && headData.BLTYPE != "拼箱分票" && headData.BLTYPE != "空运分票")
|
|
{
|
|
var mblreapeat = MsSysParamSetDAL.GetData("PARAMNAME='AireMblrepeat'");
|
|
if (mblreapeat.PARAMVALUE != "1")
|
|
{
|
|
var ct = MsOpAireDAL.GetRdCount("MASTERNO<>'" + headData.BSNO + "' AND isnull(ISCANCEL,'')<>'1' AND MBLNO='" + headData.MBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "主提单号";
|
|
}
|
|
}
|
|
}
|
|
|
|
if (headData.HBLNO != "" && headData.HBLNO != null)
|
|
{
|
|
var mblreapeat = MsSysParamSetDAL.GetData("PARAMNAME='AireHblrepeat'");
|
|
if (mblreapeat.PARAMVALUE != "1")
|
|
{
|
|
var ct = MsOpAireDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND isnull(ISCANCEL,'')<>'1' AND HBLNO='" + headData.HBLNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "分提单号";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
var billnosethblno = MsSysBillNoSetDAL.GetData("OPLBNAME='空运出口' AND RULEBLNO='分提单号' ", Convert.ToString(Session["COMPANYID"]));
|
|
if (billnosethblno.BILLTYPE != "" && billnosethblno.ISAUTO == "1")
|
|
{
|
|
if (billnosethblno.CUSTOMHEAD != "")
|
|
{
|
|
var HBLCUSTOMHEAD = billnosethblno.CUSTOMHEAD;
|
|
var bssource = BasicDataRefDAL.GetSourceData("SOURCENAME='" + headData.BSSOURCE + "'");
|
|
var lanelist = BasicDataRefDAL.GetCodeLaneList();
|
|
var lane = lanelist.Find(x => x.LANE == headData.LANE);
|
|
var bstypelist = PubSysDAL.GetEnumValueList(97042, "");
|
|
var bstype = bstypelist.Find(x => x.EnumValueName == headData.BLTYPE);
|
|
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[BS]", bssource.SOURCECODE);
|
|
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[LN]", lane.LANEID);
|
|
HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[BT]", bstype.EnumValueName_2);
|
|
// HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[BS]", bssource.SOURCECODE);
|
|
// HBLCUSTOMHEAD = HBLCUSTOMHEAD.Replace("[BS]", bssource.SOURCECODE);
|
|
|
|
var hblno = MsSysBillNoSetDAL.GetBillNoHblno(billnosethblno, headData.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim(), HBLCUSTOMHEAD);
|
|
headData.HBLNO = hblno;
|
|
}
|
|
else
|
|
{
|
|
var hblno = MsSysBillNoSetDAL.GetBillNo(billnosethblno, headData.ETD.ToString().Trim(), headData.ACCDATE.ToString().Trim(), "", headData.OP, headData.SALECORPID);
|
|
headData.HBLNO = hblno;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
if (headData.ORDERNO != "" && headData.ORDERNO != null)
|
|
{
|
|
var ct = MsOpAireDAL.GetRdCount("BSNO<>'" + headData.BSNO + "' AND isnull(ISCANCEL,'')<>'1' AND ORDERNO='" + headData.ORDERNO + "' and CORPID='" + Convert.ToString(Session["COMPANYID"]) + "'");
|
|
if (ct != 0)
|
|
{
|
|
isPost = false;
|
|
errorstr = "订舱编号";
|
|
}
|
|
}
|
|
|
|
|
|
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 = BasicDataRefDAL.现结买单结算日期_空运(headData.ETD); ;
|
|
}
|
|
if (_dmb.BSSOURCE != "") headData.BSSOURCE = _dmb.BSSOURCE;
|
|
}
|
|
|
|
if (opstatus == "add")
|
|
{
|
|
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
headData.BSDATE = DateTime.Now;
|
|
headData.BSSTATUS = false;
|
|
headData.FEESTATUS = false;
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
headData.ModelUIStatus = "E";
|
|
}
|
|
else
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
if (headData.MASTERNO == null || headData.MASTERNO == "") { headData.MASTERNO = headData.BSNO; }
|
|
|
|
if (headData.ETA == "") headData.ETA = null;
|
|
if (headData.ETD == "") headData.ETD = null;
|
|
if (headData.STLDATE == "") headData.STLDATE = null;
|
|
if (headData.DELIVERYDATE == "") headData.DELIVERYDATE = null;
|
|
|
|
if (headData.INSPECTIONDATE == "") headData.INSPECTIONDATE = null;
|
|
if (headData.CUSTOMDATE == "") headData.CUSTOMDATE = null;
|
|
headData.CREATETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
headData.PORTLOAD = MsBaseInfoDAL.DelPortCn(headData.PORTLOAD);
|
|
headData.PORTDISCHARGE = MsBaseInfoDAL.DelPortCn(headData.PORTDISCHARGE);
|
|
if (headData.KGS == "") headData.KGS = "0";
|
|
if (headData.PKGS == "") headData.PKGS = "0";
|
|
if (headData.CBM == "") headData.CBM = "0";
|
|
if (headData.FEEKGS == "") headData.FEEKGS = "0";
|
|
if (headData.PRICE == "") headData.PRICE = "0";
|
|
if (headData.TTLFREIGHT == "") headData.TTLFREIGHT = "0";
|
|
headData.BSSOURCE = headData.BSSOURCE.Trim();
|
|
|
|
if (headData.OTFEE1AMOUNT == "") headData.OTFEE1AMOUNT = "0";
|
|
if (headData.OTFEE2AMOUNT == "") headData.OTFEE2AMOUNT = "0";
|
|
if (headData.OTFEE3AMOUNT == "") headData.OTFEE3AMOUNT = "0";
|
|
if (headData.OTFEE4AMOUNT == "") headData.OTFEE4AMOUNT = "0";
|
|
if (headData.OTFEE5AMOUNT == "") headData.OTFEE5AMOUNT = "0";
|
|
if (headData.OTFEE6AMOUNT == "") headData.OTFEE6AMOUNT = "0";
|
|
if (headData.OTFEE7AMOUNT == "") headData.OTFEE7AMOUNT = "0";
|
|
if (headData.OTFEE8AMOUNT == "") headData.OTFEE8AMOUNT = "0";
|
|
|
|
var BSNO = headData.BSNO;
|
|
|
|
if (isPost)
|
|
{
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Save(headData);
|
|
if (result.Success == true) { }
|
|
else
|
|
{
|
|
MsSysBillNoSetDAL.DeleteBsNo(headData.CUSTNO);
|
|
}
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = MsOpAireDAL.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 Delete(string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<MsOpAire>(data);
|
|
var isfee = MsOpAireDAL.GetFeeCount(head.BSNO);
|
|
if (isfee)
|
|
{
|
|
var jsonRespose = new JsonResponse { Success = false, Message ="此票业务存在费用,请先删除费用才能删除此票业务!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
else {
|
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from OP_AIRE WHERE MASTERNO='" + head.BSNO + "' AND BSNO<>'" + head.BSNO + "'");
|
|
if (BLCOUNT == "0")
|
|
{
|
|
var BSNO = head.BSNO;
|
|
var modb = new ModelObjectDB();
|
|
DBResult result = modb.Delete(head);
|
|
if (result.Success == true) { MsSysBillNoSetDAL.DeleteBsNo(head.CUSTNO); }
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
else
|
|
{
|
|
var jsonRespose = new JsonResponse { Success = false, Message = "此票空运主票存在分票业务,请先删除分票信息!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
#region 尺码明细信息
|
|
public ContentResult GetAirCbmDetail(string condition)
|
|
{
|
|
var dataList = MsOpAireDAL.GetAirCbmDetail(condition);
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
public ContentResult SaveOpAirCbmDetail(string body, string bsno)
|
|
{
|
|
var bodyList = JsonConvert.Deserialize<List<MsOpAirCbmDetail>>(body);
|
|
|
|
DBResult result = MsOpAireDAL.SaveOpAirCbmDetail(bodyList, bsno, Convert.ToString(Session["USERID"]), Convert.ToString(Session["COMPANYID"]));
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
public ContentResult DeleteCbmDetail(string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<MsOpAirCbmDetail>(data);
|
|
DBResult result = MsOpAireDAL.DeleteOpAirCbmDetail(head);
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 提单信息
|
|
public ContentResult GetBillList(int start, int limit, string sort, string condition)
|
|
{
|
|
var dataList = MsOpAireDAL.GetBillList(condition, 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 GetBillData(string handle, string condition)
|
|
{
|
|
MsOpAireBill head = null;
|
|
if (handle == "edit")
|
|
{
|
|
head = MsOpAireDAL.GetBillData(condition);
|
|
}
|
|
if (head == null)
|
|
{
|
|
head = new MsOpAireBill();
|
|
head.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
}
|
|
var json = JsonConvert.Serialize(
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
public ContentResult BillSave(string opstatus, string data,string body)
|
|
{
|
|
var headData = JsonConvert.Deserialize<MsOpAireBill>(data);
|
|
|
|
if (opstatus == "add")
|
|
{
|
|
headData.INPUTBY = Convert.ToString(Session["SHOWNAME"]);
|
|
headData.INPUTTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
headData.AS_ID = Guid.NewGuid().ToString();
|
|
headData.DbOperationType = DbOperationType.DbotIns;
|
|
}
|
|
else if (opstatus == "edit")
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotUpd;
|
|
headData.ModelUIStatus = "E";
|
|
}
|
|
else
|
|
{
|
|
headData.DbOperationType = DbOperationType.DbotDel;
|
|
}
|
|
|
|
if (headData.ETA == "") headData.ETA = null;
|
|
if (headData.ETD == "") headData.ETD = null;
|
|
|
|
if (headData.ISSUEDATE == "") headData.ISSUEDATE = null;
|
|
|
|
if (headData.KGS == "") headData.KGS = "0";
|
|
if (headData.PKGS == "") headData.PKGS = "0";
|
|
if (headData.CBM == "") headData.CBM = "0";
|
|
if (headData.FEEKGS == "") headData.FEEKGS = "0";
|
|
if (headData.PRICE == "") headData.PRICE = "0";
|
|
if (headData.TTLFREIGHT == "") headData.TTLFREIGHT = "0";
|
|
if (headData.TOTALAMOUNT == "") headData.TOTALAMOUNT = "0";
|
|
|
|
if (headData.OTFEE1AMOUNT == "") headData.OTFEE1AMOUNT = "0";
|
|
if (headData.OTFEE2AMOUNT == "") headData.OTFEE2AMOUNT = "0";
|
|
if (headData.OTFEE3AMOUNT == "") headData.OTFEE3AMOUNT = "0";
|
|
if (headData.OTFEE4AMOUNT == "") headData.OTFEE4AMOUNT = "0";
|
|
if (headData.OTFEE5AMOUNT == "") headData.OTFEE5AMOUNT = "0";
|
|
if (headData.OTFEE6AMOUNT == "") headData.OTFEE6AMOUNT = "0";
|
|
if (headData.OTFEE7AMOUNT == "") headData.OTFEE7AMOUNT = "0";
|
|
if (headData.OTFEE8AMOUNT == "") headData.OTFEE8AMOUNT = "0";
|
|
|
|
headData.MODIFYUSER = Convert.ToString(Session["USERID"]);
|
|
headData.MODIFYTIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
var modb = new ModelObjectDB();
|
|
var AS_ID = headData.AS_ID;
|
|
|
|
DBResult result = modb.Save(headData);
|
|
//if (result.Success == true)
|
|
//{
|
|
// result = MsOpSeaeDAL.SaveBillDetail(AS_ID, bodyList, Convert.ToString(Session["USERID"]));
|
|
//}
|
|
|
|
|
|
var jsonRespose = new JsonResponse
|
|
{
|
|
Success = result.Success,
|
|
Message = result.Message,
|
|
Data = MsOpAireDAL.GetBillData("AS_ID='" + AS_ID + "'")
|
|
};
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
public ContentResult BillDelete(string data)
|
|
{
|
|
var head = JsonConvert.Deserialize<MsOpAireBill>(data);
|
|
var modb = new ModelObjectDB();
|
|
var AS_ID = head.AS_ID;
|
|
DBResult result = modb.Delete(head);
|
|
//if (result.Success == true) { MsOpSeaeDAL.DeleteDetail(AS_ID); }
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
}
|
|
|
|
#endregion
|
|
|
|
public ContentResult CancelOrderList(string data, string type)
|
|
{
|
|
var headData = JsonConvert.Deserialize<List<MsOpAire>>(data);
|
|
var errstr = "";
|
|
|
|
|
|
if (headData != null)
|
|
{
|
|
foreach (var enumValue in headData)
|
|
{
|
|
var BSNO = enumValue.BSNO;
|
|
|
|
if (type == "0")
|
|
{
|
|
var iscancel = true;
|
|
var head = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
|
|
if (Convert.ToDateTime(head.PERIOD + "-01") > Convert.ToDateTime(enumValue.ACCDATE + "-01"))
|
|
{
|
|
if (errstr == "")
|
|
errstr = enumValue.CUSTNO + "此票所在业务已月末结账";
|
|
else
|
|
errstr = errstr + "," + enumValue.CUSTNO + "此票所在业务已月末结账";
|
|
iscancel = false;
|
|
}
|
|
if (iscancel)
|
|
MsOpAireDAL.CancelOrder(BSNO, type, Convert.ToString(Session["SHOWNAME"]));
|
|
}
|
|
else
|
|
{
|
|
var iscancel = true;
|
|
var head = ChMonthCloseDAL.GetData("", Convert.ToString(Session["COMPANYID"]));
|
|
if (Convert.ToDateTime(head.PERIOD + "-01") > Convert.ToDateTime(enumValue.ACCDATE + "-01"))
|
|
{
|
|
if (errstr == "")
|
|
errstr = enumValue.CUSTNO + "此票所在业务已月末结账";
|
|
else
|
|
errstr = errstr + "," + enumValue.CUSTNO + "此票所在业务已月末结账";
|
|
iscancel = false;
|
|
}
|
|
|
|
|
|
var isfee = MsOpAireDAL.GetFeeCount(enumValue.BSNO);
|
|
if (isfee)
|
|
{
|
|
if (errstr == "")
|
|
errstr = enumValue.CUSTNO + "存在费用";
|
|
else
|
|
errstr = errstr + "," + enumValue.CUSTNO + "存在费用";
|
|
iscancel = false;
|
|
}
|
|
isfee = MsOpAireDAL.GetAmendCount(enumValue.BSNO);
|
|
if (isfee)
|
|
{
|
|
if (errstr == "")
|
|
errstr = enumValue.CUSTNO + "存在更改单";
|
|
else
|
|
errstr = errstr + "," + enumValue.CUSTNO + "存在更改单";
|
|
iscancel = false;
|
|
}
|
|
isfee = MsOpAireDAL.GetFenCount(enumValue.BSNO);
|
|
if (isfee)
|
|
{
|
|
if (errstr == "")
|
|
errstr = enumValue.CUSTNO + "存在分票";
|
|
else
|
|
errstr = errstr + "," + enumValue.CUSTNO + "存在分票";
|
|
iscancel = false;
|
|
}
|
|
if (enumValue.BLISSUESTATUS == "提单签出")
|
|
{
|
|
errstr = errstr + "," + enumValue.CUSTNO + "已提单签出";
|
|
iscancel = false;
|
|
|
|
}
|
|
if (enumValue.BSSTATUS)
|
|
{
|
|
errstr = errstr + "," + enumValue.CUSTNO + "已业务锁定";
|
|
iscancel = false;
|
|
|
|
}
|
|
|
|
if (iscancel)
|
|
MsOpAireDAL.CancelOrder(BSNO, type, Convert.ToString(Session["SHOWNAME"]));
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
if (type == "1")
|
|
{
|
|
if (errstr != "") errstr = errstr + "不允许退舱!";
|
|
}
|
|
else if (errstr != "") errstr = errstr + "不允许取消退舱!";
|
|
if (type == "1")
|
|
{
|
|
if (errstr == "") errstr = "退舱成功!";
|
|
}
|
|
else
|
|
{
|
|
if (errstr == "") errstr = "取消退舱成功!";
|
|
|
|
}
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = true, Message = errstr };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
}
|
|
|
|
|
|
|
|
#region 生成报关信息
|
|
public ContentResult SaveBG(string data, string data2)
|
|
{
|
|
var aaa = "";
|
|
|
|
var head = JsonConvert.Deserialize<MsOpAire>(data.Replace("}", ",") + data2.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.BSSOURCE = head.BSSOURCE;
|
|
headData.BSSOURCEDETAIL = head.BSSOURCEDETAIL;
|
|
headData.ETD = head.ETD;
|
|
headData.ETA = head.ETA;
|
|
if (head.PKGS == "")
|
|
headData.PKGS = 0;
|
|
else
|
|
headData.PKGS =Convert.ToInt32(head.PKGS);
|
|
if (head.KGS=="")
|
|
headData.KGS =0;
|
|
else
|
|
headData.KGS = Convert.ToDecimal(head.KGS);
|
|
if (head.CBM == "")
|
|
headData.CBM = 0;
|
|
else
|
|
headData.CBM = Convert.ToDecimal(head.CBM);
|
|
headData.PORTLOAD = head.PORTLOAD;
|
|
headData.PORTDISCHARGE = head.PORTDISCHARGE;
|
|
headData.SALE = head.SALE;
|
|
headData.SALEDEPT = head.SALEDEPT;
|
|
headData.BSTYPE = "3";
|
|
headData.CUSTOMNO = head.CUSTOMNO;
|
|
headData.CUSTOMDATE = head.CUSTOMDATE;
|
|
headData.INSPECTIONNO = head.INSPECTIONNO;
|
|
headData.INSPECTIONDATE = head.INSPECTIONDATE;
|
|
headData.ENTERP = head.ENTERP;
|
|
headData.ENTERPID = head.ENTERPID;
|
|
|
|
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
|
|
//
|
|
}
|
|
}
|
|
|