using System ;
using System.Linq ;
using System.Text ;
using System.Web.Mvc ;
using DSWeb.MvcShipping.DAL.MsOpAiriDAL ;
using DSWeb.MvcShipping.Models.MsOpAiri ;
using DSWeb.MvcShipping.Helper ;
using DSWeb.MvcShipping.Comm.Cookie ;
using HcUtility.Comm ;
using HcUtility.Core ;
using System.Collections.Generic ;
using System.IO ;
using System.Data ;
using System.Data.OleDb ;
using DSWeb.EntityDA ;
using DSWeb.Areas.CommMng.DAL ;
using DSWeb.Areas.RptMng.Comm ;
using DSWeb.Areas.CommMng.Models ;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL ;
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.DAL.MsInfoClient ;
using DSWeb.Areas.SysMng.DAL.SysUser ;
using DSWeb.MvcShipping.DAL.MsCodeOpTemplate ;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL ;
using DSWeb.MvcShipping.DAL.MsChFeeDAL ;
namespace DSWeb.MvcShipping.Controllers
{
[JsonRequestBehavior]
public class MsOpAiriController : 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 AiriFeeView ( )
{
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 EditView ( )
{
return View ( ) ;
}
public ContentResult GetDataList ( int start , int limit , string sort , string condition , string load )
{
var dataList = MsOpAiriDAL . GetDataList ( 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 = list . ToList ( ) } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult GetSaleDataList ( int start , int limit , string sort , string condition , string load )
{
var dataList = MsOpAiriDAL . GetSaleDataList ( 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 = list . ToList ( ) } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult GetDataListStr ( string sort , string condition )
{
var dataListStr = MsOpAiriDAL . 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 GetSum ( string condition )
{
var rangstr = MsOpAiriDAL . 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 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(KGS) KGS,SUM(PKGS) PKGS,SUM(CBM) CBM,SUM(FEEKGS) FEEKGS from op_airi 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 json = RptHelper . GetRptJsonResult ( 0 , 1 , dbRptResult2 , "Result_Set" , true ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult GetData ( string handle , string condition )
{
MsOpAiri head = null ;
if ( handle = = "edit" )
{
head = MsOpAiriDAL . GetData ( condition ) ;
}
if ( head = = null )
{
head = new MsOpAiri ( ) ;
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 copyfee = "false" )
{
MsOpAiri head = null ;
var oldhead = MsOpAiriDAL . 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 = "topairi" + Guid . NewGuid ( ) . ToString ( ) ;
head . MASTERNO = "" ;
head . CUSTNO = "" ;
head . ORDERNO = "" ;
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 ( copyfee = = "true" )
{
//var feelist = MsChFeeDAL.GetAllDataList(condition);
var feelist = MsChFeeDAL . GetDataList ( condition , 1 , "op_airi" , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( feelist ! = null )
{
for ( int _i = 0 ; _i < feelist . Count ; _i + + )
{
feelist [ _i ] . BsNo = "*" ;
}
MsChFeeDAL . SaveFee ( feelist , head . BSNO , CookieConfig . GetCookie_UserId ( Request ) ) ;
}
}
//if (copybill == "true")
//{
// var billlist = MsOpAiriDAL.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);
// }
// }
//}
}
else
{
if ( head = = null )
{
head = new MsOpAiri ( ) ;
head . BSNO = "topairi" + 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 ( 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 ) ) ;
}
}
//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);
// }
// }
//}
}
}
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 aaa = "" ;
var dataall = data . Replace ( "}" , "," ) + data2 . Replace ( "{" , "" ) ;
var headData = JsonConvert . Deserialize < MsOpAiri > ( 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_airi" ) ;
}
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 ) ;
}
headData . CUSTNO = MsSysBillNoSetDAL . GetBillNo ( billnoset , headData . ETA . ToString ( ) . Trim ( ) , headData . ACCDATE . ToString ( ) . Trim ( ) , "" , headData . OP , headData . SALECORPID , CUSTOMHEAD ) ;
iscreatecustno = true ;
}
}
}
else {
//if (!isuse) {
// {
var ct = MsOpAiriDAL . GetRdCount ( "BSNO<>'" + headData . BSNO + "' 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 ! = "空运分票" )
{
var mblreapeat = MsSysParamSetDAL . GetData ( "PARAMNAME='AiriMblrepeat'" ) ;
if ( mblreapeat . PARAMVALUE ! = "1" )
{
var ct = MsOpAiriDAL . GetRdCount ( "MASTERNO<>'" + headData . BSNO + "' 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='AiriHblrepeat'" ) ;
if ( mblreapeat . PARAMVALUE ! = "1" )
{
var ct = MsOpAiriDAL . GetRdCount ( "BSNO<>'" + headData . BSNO + "' 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 . ETA . ToString ( ) . Trim ( ) , headData . ACCDATE . ToString ( ) . Trim ( ) , "" , headData . OP , headData . SALECORPID ) ;
headData . HBLNO = hblno ;
}
}
}
if ( headData . ORDERNO ! = "" & & headData . ORDERNO ! = null )
{
var ct = MsOpAiriDAL . GetRdCount ( "BSNO<>'" + headData . BSNO + "' AND ORDERNO='" + headData . ORDERNO + "' and CORPID='" + Convert . ToString ( Session [ "COMPANYID" ] ) + "'" ) ;
if ( ct ! = 0 )
{
isPost = false ;
errorstr = "订舱编号" ;
}
}
if ( headData . ETA ! = "" & & headData . CUSTOMERNAME ! = "" ) // headData.STLDATE == "" &&
{
//根据客户、开船日计算账期
var _dmb = MsInfoClientDAL . GetSTLDATE ( headData . CUSTOMERNAME , "海运出口" , headData . ETA , headData . SALE ) ;
headData . STLNAME = _dmb . STLNAME ;
headData . STLDATE = _dmb . STLDATE ;
if ( _dmb . STLNAME = = "" )
{
headData . STLNAME = "现结买单" ;
headData . STLDATE = 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 . INSPECTIONDATE = = "" ) headData . INSPECTIONDATE = null ;
if ( headData . CUSTOMDATE = = "" ) headData . CUSTOMDATE = null ;
if ( headData . CHANGEDOCDATE = = "" ) headData . CHANGEDOCDATE = null ;
if ( headData . DELIVERYDATE = = "" ) headData . DELIVERYDATE = null ;
headData . BSSOURCE = headData . BSSOURCE . Trim ( ) ;
headData . PORTLOAD = MsBaseInfoDAL . DelPortCn ( headData . PORTLOAD ) ;
headData . PORTDISCHARGE = MsBaseInfoDAL . DelPortCn ( headData . PORTDISCHARGE ) ;
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 = MsOpAiriDAL . 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 ) } ;
}
}
#region 拼箱操作
public ContentResult GetFenList ( int start , int limit , string sort , string condition )
{
var dataList = MsOpAiriDAL . 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 GetDataListSum ( int start , int limit , string sort , string condition )
{
var dataList = MsOpAiriDAL . GetDataListSum ( condition , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , sort ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "查询成功" , totalCount = dataList . Count , data = dataList . ToList ( ) } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SaveFen ( string bsno , string fenbody )
{
var bodyList = JsonConvert . Deserialize < List < MsOpAiri > > ( fenbody ) ;
var bodyList2 = new List < MsOpAiri > ( ) ;
var isPost = true ;
var errorstr = "" ;
if ( bodyList ! = null )
{
foreach ( var enumValue in bodyList )
{
if ( enumValue . CUSTNO = = "" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='空运进口'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var FENCUSTNOE = MsSysParamSetDAL . GetData ( "PARAMNAME='FENCUSTNOE'" ) ;
if ( FENCUSTNOE . PARAMVALUE ! = "1" & & enumValue . MASTERNO ! = "" & & enumValue . BSNO ! = enumValue . MASTERNO )
{
enumValue . CUSTNO = MsSysBillNoSetDAL . GetFenCustNo ( enumValue . MASTERNO , "op_airi" ) ;
}
else
{
enumValue . CUSTNO = MsSysBillNoSetDAL . GetBillNo ( billnoset , enumValue . ETA . ToString ( ) . Trim ( ) , enumValue . ACCDATE . ToString ( ) . Trim ( ) , "" , enumValue . OP , enumValue . SALECORPID ) ;
}
}
if ( enumValue . ETA = = "" ) enumValue . ETA = null ;
if ( enumValue . ETD = = "" ) enumValue . ETD = null ;
if ( enumValue . STLDATE = = "" ) enumValue . STLDATE = null ;
if ( enumValue . HBLNO ! = "" & & enumValue . HBLNO ! = null )
{
var ct = MsOpAiriDAL . GetRdCount ( "BSNO<>'" + enumValue . BSNO + "' AND HBLNO='" + enumValue . HBLNO + "'" ) ;
if ( ct ! = 0 )
{
isPost = false ;
errorstr = enumValue . HBLNO + "," + errorstr ;
}
else
{
bodyList2 . Add ( enumValue ) ;
}
}
else
{
bodyList2 . Add ( enumValue ) ;
}
}
}
DBResult result = null ;
if ( isPost = = false )
{
var jsonRespose = new JsonResponse { Success = false , Message = "分提单号:" + errorstr + "分提单号重复,请修改后重新保存!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
result = MsOpAiriDAL . SaveFenList ( bsno , bodyList2 , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
public ContentResult DeleteFen ( string fenbody )
{
var bodyList = JsonConvert . Deserialize < List < MsOpAiri > > ( fenbody ) ;
DBResult result = null ;
var isPost = true ;
var errorstr = "" ;
if ( bodyList ! = null )
{
foreach ( var enumValue in bodyList )
{
var isfee = MsOpAiriDAL . GetFeeCount ( enumValue . BSNO ) ;
if ( isfee )
{
isPost = false ;
errorstr = enumValue . HBLNO + "," + errorstr ;
}
else
{
result = MsOpAiriDAL . DeleteFen ( enumValue . BSNO ) ;
}
}
}
if ( isPost = = false )
{
result . Success = true ;
result . Message = "分提单号:" + errorstr + "存在费用信息,无法直接删除!" ;
} ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult CancelFenAdd ( string data )
{
var bodyList = JsonConvert . Deserialize < List < MsOpAiri > > ( data ) ;
DBResult result = null ;
var isPost = true ;
var errorstr = "" ;
if ( bodyList ! = null )
{
foreach ( var enumValue in bodyList )
{
result = MsOpAiriDAL . CancelFenAdd ( enumValue . BSNO ) ;
}
}
if ( isPost = = false )
{
result . Success = true ;
result . Message = "分提单号:" + errorstr + "存在费用信息,无法直接删除!" ;
} ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
# endregion
public ContentResult Delete ( string data )
{
var head = JsonConvert . Deserialize < MsOpAiri > ( data ) ;
var isfee = MsOpAiriDAL . 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_AIRI 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 blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + BSNO + "','删除空运进口','" + DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) + "','" + head . MBLNO + '(' + head . CUSTOMERNAME + ')' + "','" + Convert . ToString ( Session [ "USERID" ] ) + "')" ;
bool bl = T_ALL_DA . GetExecuteSqlCommand ( blUpSQL ) ;
}
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 SaveBG ( string data , string data2 )
{
var aaa = "" ;
var head = JsonConvert . Deserialize < MsOpAiri > ( 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 ;
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 = "4" ;
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
/ /
}
}