using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Text ;
using System.Web ;
using System.Web.Mvc ;
using DSWeb.Areas.CommMng.DAL ;
using DSWeb.Areas.TruckMng.DAL ;
using DSWeb.Areas.TruckMng.DAL.MsRptPcHeadEdit ;
using DSWeb.Areas.TruckMng.Models.MsWlBs ;
using DSWeb.TruckMng.Helper ;
using HcUtility.Comm ;
using DSWeb.Areas.CommMng.Models ;
using Microsoft.Practices.EnterpriseLibrary.Data ;
using HcUtility.Core ;
using DSWeb.TruckMng.Comm.Cookie ;
using DSWeb.EntityDA ;
using DSWeb.TruckMng.Helper.Repository ;
using DSWeb.MvcShipping.DAL.MsSysBillNoSet ;
using DSWeb.MvcShipping.Models.MsSysBillNoSet ;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL ;
using DSWeb.MvcShipping.Models.MsOpLetter ;
using DSWeb.Areas.MvcShipping.DAL ;
using DSWeb.MvcShipping.DAL.ChMonthCloseDAL ;
using DSWeb.Areas.TruckMng.DAL.MsWlBs ;
using DSWeb.Areas.RptMng.Comm ;
using DSWeb.Common.DB ;
using DSWeb.SoftMng.Filter ;
using DSWeb.MvcShipping.Models.MsOpSeae ;
using DSWeb.MvcShipping.DAL.MsOpAireDAL ;
using DSWeb.MvcShipping.Models.MsOpAire ;
using DSWeb.MvcShipping.DAL.MsSysParamSet ;
using Ivony.Fluent ;
using DSWeb.MvcShipping.Models.MsChFee ;
using DSWeb.Areas.MvcShipping.Models.Message.VGM ;
namespace DSWeb.Areas.TruckMng.Controllers
{
/// <summary>
/// 路单查询
/// </summary>
[JsonRequestBehavior]
public class PcHeadEdit_WFSDController : Controller
//20160217 应对潍坊松达需求
//在MSRPTPcHead(烟台爱德林需求)基础上修改
{
/ /
// GET: /RptMng/MsRptPcHeadQry
public ActionResult Index ( )
{
return View ( ) ;
}
public ActionResult Edit ( )
{
return View ( ) ;
}
public ActionResult FeeEdit ( )
{
return View ( ) ;
}
public ActionResult FeeAmendEdit ( )
{
return View ( ) ;
}
public ActionResult RptTruckIndex ( )
{
return View ( ) ;
}
public ActionResult TaskView ( )
{
return View ( ) ;
}
public ActionResult HYRDIndex ( )
{
return View ( ) ;
}
public ActionResult HYRDEdit ( )
{
return View ( ) ;
}
public ActionResult QDLHIndex ( )
{
return View ( ) ;
}
public ActionResult QDLHEdit ( )
{
return View ( ) ;
}
public ActionResult ZXIndex ( )
{
return View ( ) ;
}
public ActionResult ZXEdit ( )
{
return View ( ) ;
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult GetDataList ( int start , int limit , string sort , string condition )
{
var dataList = MsRptPcHeadEditDAL . GetWFSDList ( condition , CookieConfig . GetCookie_UserId ( Request ) , CookieConfig . GetCookie_UserCode ( Request ) , CookieConfig . GetCookie_UserName ( Request ) , CookieConfig . GetCookie_CompanyId ( Request ) , 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 } ;
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult GetHYRDDataList ( int start , int limit , string sort , string condition , string ismaster )
{
var dataList = MsRptPcHeadEditDAL . GetHYRDList ( condition , CookieConfig . GetCookie_UserId ( Request ) , CookieConfig . GetCookie_UserCode ( Request ) , CookieConfig . GetCookie_UserName ( Request ) , CookieConfig . GetCookie_CompanyId ( Request ) , sort , ismaster ) ;
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 } ;
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult GetDataFenList ( int start , int limit , string sort , string condition )
{
var dataList = MsRptPcHeadEditDAL . GetWFSDFenList ( 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 } ;
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult GetData ( string handle , string condition )
{
MsWlPcHead_WFSDEdit head = null ;
if ( handle = = "edit" | | handle = = "copyadd" )
{
head = MsRptPcHeadEditDAL . GetWFSDData ( condition ) ;
}
if ( head = = null )
{
head = new MsWlPcHead_WFSDEdit ( ) ;
head . gId = "PC_" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
head . PGid = head . gId ;
head . UserCode = CookieConfig . GetCookie_UserCode ( Request ) ;
head . UserName = Convert . ToString ( Session [ "SHOWNAME" ] ) ;
head . BLTYPE = "派车单票" ;
var period = ChMonthCloseDAL . GetData ( "" , CookieConfig . GetCookie_CompanyId ( Request ) ) ;
if ( Convert . ToDateTime ( period . FDAY ) > DateTime . Now )
{
head . ACCDATE = period . PERIOD ;
} else head . ACCDATE = DateTime . Now . ToString ( "yyyy-MM" ) ;
}
var json = JsonConvert . Serialize (
new { Success = true , Message = "查询成功" , data = head } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult GetHYRDData ( string handle , string condition )
{
MsWlPcHead_WFSDEdit head = null ;
if ( handle = = "edit" | | handle = = "copyadd" )
{
head = MsRptPcHeadEditDAL . GetHYRDData ( condition ) ;
}
if ( head = = null )
{
head = new MsWlPcHead_WFSDEdit ( ) ;
head . gId = "PC_" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
head . PGid = head . gId ;
head . UserCode = CookieConfig . GetCookie_UserCode ( Request ) ;
head . UserName = Convert . ToString ( Session [ "SHOWNAME" ] ) ;
head . BLTYPE = "派车单票" ;
var period = ChMonthCloseDAL . GetData ( "" , CookieConfig . GetCookie_CompanyId ( Request ) ) ;
if ( Convert . ToDateTime ( period . FDAY ) > DateTime . Now )
{
head . ACCDATE = period . PERIOD ;
}
else head . ACCDATE = DateTime . Now . ToString ( "yyyy-MM" ) ;
}
var json = JsonConvert . Serialize (
new { Success = true , Message = "查询成功" , data = head } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult CreateDriverFee ( string FeeValue , string data )
{
var headData = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
CostModel cm = new CostModel
{
BSNO = headData . gId ,
CustomerName = headData . F_CustomerName ,
FeeName = "陆运费" ,
FeeType = "2" ,
FeeValue = Convert . ToSingle ( FeeValue ) ,
CustomerType = "车队" ,
Remark = "利润自动生成司机费用" ,
} ;
DBResult resultCost = new DBResult { Success = false , Message = "" } ;
resultCost = MsOpLetterDAL . CreateCost ( cm , CookieConfig . GetCookie_UserId ( Request ) ) ;
var jsonRespose = new JsonResponse
{
Success = resultCost . Success ,
Message = resultCost . Message ,
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult GetQDLHDataList ( int start , int limit , string sort , string condition )
{
var dataList = MsRptPcHeadEditDAL . GetQDLHList ( condition , CookieConfig . GetCookie_UserId ( Request ) , CookieConfig . GetCookie_UserCode ( Request ) , CookieConfig . GetCookie_UserName ( Request ) , CookieConfig . GetCookie_CompanyId ( Request ) , 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 } ;
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult GetQDLHData ( string handle , string condition )
{
MsWlPcHead_QDLHEdit head = null ;
if ( handle = = "edit" | | handle = = "copyadd" )
{
head = MsRptPcHeadEditDAL . GetQDLHData ( condition ) ;
}
if ( head = = null )
{
head = new MsWlPcHead_QDLHEdit ( ) ;
head . gId = "PC_" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
head . PGid = head . gId ;
head . UserCode = CookieConfig . GetCookie_UserCode ( Request ) ;
head . UserName = Convert . ToString ( Session [ "SHOWNAME" ] ) ;
head . BLTYPE = "派车单票" ;
var period = ChMonthCloseDAL . GetData ( "" , CookieConfig . GetCookie_CompanyId ( Request ) ) ;
if ( Convert . ToDateTime ( period . FDAY ) > DateTime . Now )
{
head . ACCDATE = period . PERIOD ;
}
else head . ACCDATE = DateTime . Now . ToString ( "yyyy-MM" ) ;
}
var json = JsonConvert . Serialize (
new { Success = true , Message = "查询成功" , data = head } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult SaveWFSD ( string opstatus , string data , string ctnbody )
{
var headData = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var bodyctnData = JsonConvert . Deserialize < List < MsOpLetterTruckCtn > > ( ctnbody ) ;
//var fixBodyDelList = JsonConvert.Deserialize<List<MsWlPcFixed>>(fixdelbody);
var isPost = true ;
var errorstr = "" ;
var custno = "" ;
if ( opstatus = = "add" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . TRANSSTATUS = "新建" ;
}
else if ( opstatus = = "edit" )
{
headData . DbOperationType = DbOperationType . DbotUpd ;
headData . ModelUIStatus = "E" ;
}
else
{
headData . DbOperationType = DbOperationType . DbotDel ;
}
if ( ! string . IsNullOrEmpty ( headData . LrDate ) )
{
headData . LrDate = headData . LrDate . Substring ( 0 , 10 ) ;
}
else
{
var currentTime = System . DateTime . Now ;
headData . LrDate = currentTime . ToString ( "d" ) ;
}
var BSNO = headData . gId ;
if ( isPost )
{
var modb = new ModelObjectDB ( ) ;
DBResult result = modb . Save ( headData ) ;
if ( result . Success = = true ) {
MsOpLetterDAL . SaveTruckCtn ( headData . gId , bodyctnData ) ; // MsWlPcDAL.SaveDetail(BSNO, fixBodyList, CookieConfig.GetCookie_UserId(Request));
}
else
{
MsSysBillNoSetDAL . DeleteBsNo ( custno ) ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
Data = MsRptPcHeadEditDAL . GetWFSDData ( "GID='" + BSNO + "'" )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var jsonRespose = new JsonResponse { Success = false , Message = errorstr + "重复,不允许保存!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
public ContentResult SaveHYRD ( string opstatus , string data , string ctnbody ,
string fixbody , string fixdelbody , string createpc = "0" )
{
var headData = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var bodyctnData = JsonConvert . Deserialize < List < MsOpSeaeDetail > > ( ctnbody ) ;
var fixBodyList = JsonConvert . Deserialize < List < MsWlPcFixed > > ( fixbody ) ;
var fixBodyDelList = JsonConvert . Deserialize < List < MsWlPcFixed > > ( fixdelbody ) ;
if ( ( createpc = = "1" ) & & ( ! string . IsNullOrEmpty ( headData . Property ) ) )
{
var jsonRespose2 = new JsonResponse { Success = false , Message = "已生成派车,不允许重复生成!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose2 ) } ;
}
//var fixBodyDelList = JsonConvert.Deserialize<List<MsWlPcFixed>>(fixdelbody);
var isPost = true ;
var errorstr = "" ;
var custno = "" ;
if ( string . IsNullOrEmpty ( headData . ACCDATE ) ) {
headData . ACCDATE = DateTime . Now . ToString ( "yyyy-MM" ) ;
}
if ( opstatus = = "add" )
{
if ( string . IsNullOrEmpty ( headData . BillNo ) )
{
if ( headData . BsType = = "装箱" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运装箱' " , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( billnoset . BILLTYPE ! = "" )
{
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
}
}
else
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
}
}
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . TRANSSTATUS = "新建" ;
headData . Property = "" ;
headData . LrDate = DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ;
}
else if ( opstatus = = "edit" )
{
headData . DbOperationType = DbOperationType . DbotUpd ;
headData . ModelUIStatus = "E" ;
}
else
{
headData . DbOperationType = DbOperationType . DbotDel ;
}
//if (!string.IsNullOrEmpty(headData.LrDate))
//{
// headData.LrDate = headData.LrDate.Substring(0, 10);
//}
//else
//{
// var currentTime = System.DateTime.Now;
// headData.LrDate = currentTime.ToString("d");
//}
if ( ! string . IsNullOrEmpty ( headData . UserName ) )
headData . UserName = Convert . ToString ( Session [ "SHOWNAME" ] ) ;
var BSNO = headData . gId ;
var BILLNO = headData . BillNo ;
var GId = "" ;
if ( createpc = = "1" ) {
GId = "PC" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
headData . Property = GId ;
}
if ( isPost )
{
var modb = new ModelObjectDB ( ) ;
DBResult result = modb . Save ( headData ) ;
if ( result . Success = = true )
{
if ( fixBodyList ! = null ) {
foreach ( var fixBody in fixBodyList ) {
if ( string . IsNullOrEmpty ( fixBody . ENTEROPERATOR ) ) fixBody . ENTEROPERATOR = Convert . ToString ( Session [ "USERID" ] ) ;
}
}
if ( headData . BLTYPE = = "派车主票" & & ! string . IsNullOrEmpty ( headData . ArriveDate ) ) {
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var blUpBL = "update tMsWlPcHead set ArriveDate='" + headData . ArriveDate + "' where PGID='" + headData . gId + "'" ;
bool blBL = T_ALL_DA . GetExecuteSqlCommand ( blUpBL ) ;
}
MsRptPcHeadEditDAL . SaveFixFee ( headData . gId , fixBodyList ) ;
MsRptPcHeadEditDAL . SaveCtnDetail ( headData . gId , bodyctnData , Convert . ToString ( Session [ "USERID" ] ) ) ;
if ( createpc = = "1" )
{
if ( headData . BsType = = "装箱" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运装箱' " , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( billnoset . BILLTYPE ! = "" )
{
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
}
}
if ( string . IsNullOrEmpty ( headData . BillNo ) | | headData . BillNo = = "*" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
}
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . TRANSSTATUS = "新建" ;
headData . BsType = "" ;
headData . gId = GId ;
headData . PGid = headData . gId ;
headData . RefBillNo = BILLNO ;
headData . ACCDATE = DateTime . Now . ToString ( "yyyy-MM" ) ;
headData . LrDate = DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ;
//if (!string.IsNullOrEmpty(headData.LrDate))
//{
// headData.LrDate = headData.LrDate.Substring(0, 10);
//}
//else
//{
// var currentTime = System.DateTime.Now;
// headData.LrDate = currentTime.ToString("d");
//}
headData . LoadFactory = headData . FactoryAddrSe ;
headData . FactoryAddrSe = "" ;
var modb2 = new ModelObjectDB ( ) ;
result = modb2 . Save ( headData ) ;
if ( result . Success )
{
result . Message = "生成成功!" ;
}
else
{
result . Message = "生成失败" ;
}
}
if ( ! string . IsNullOrEmpty ( headData . Property ) ) {
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var blUpBL = "update tMsWlPcHead set VoyVeg='" + headData . VoyVeg + "',VoyVegSe='" + headData . VoyVegSe + "',EtDateSe='" + headData . EtDateSe + "' where GID='" + headData . Property + "'" ;
bool blBL = T_ALL_DA . GetExecuteSqlCommand ( blUpBL ) ;
} else if ( ! string . IsNullOrEmpty ( headData . RefBillNo ) )
{
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
var blUpBL = "update tMsWlPcHead set VoyVeg='" + headData . VoyVeg + "',VoyVegSe='" + headData . VoyVegSe + "',EtDateSe='" + headData . EtDateSe + "' where Property='" + headData . gId + "'" ;
bool blBL = T_ALL_DA . GetExecuteSqlCommand ( blUpBL ) ;
}
}
else
{
MsSysBillNoSetDAL . DeleteBsNo ( custno ) ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
Data = MsRptPcHeadEditDAL . GetHYRDData ( "GID='" + BSNO + "'" )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var jsonRespose = new JsonResponse { Success = false , Message = errorstr + "重复,不允许保存!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
public ContentResult SaveHYRDList ( string data )
{
var dataList = JsonConvert . Deserialize < List < MsWlPcHead_WFSDEdit > > ( data ) ;
foreach ( var _d in dataList )
{
if ( ! string . IsNullOrEmpty ( _d . ExpDate ) )
{
_d . ExpDate = _d . ExpDate . Replace ( "T" , " " ) ;
}
if ( ! string . IsNullOrEmpty ( _d . ExpDate ) )
{
_d . ExpDate = _d . ExpDate . Substring ( 0 , 10 ) ;
}
if ( ! string . IsNullOrEmpty ( _d . ArriveDate ) )
{
_d . ArriveDate = _d . ArriveDate . Substring ( 0 , 10 ) ;
}
if ( ! string . IsNullOrEmpty ( _d . ReturnDate ) )
{
_d . ReturnDate = _d . ReturnDate . Substring ( 0 , 10 ) ;
}
if ( ! string . IsNullOrEmpty ( _d . LrDate ) )
{
_d . LrDate = _d . LrDate . Substring ( 0 , 10 ) ;
}
else
{
var currentTime = System . DateTime . Now ;
_d . LrDate = currentTime . ToString ( "d" ) ;
}
if ( _d . BillNo = = "" | | _d . BillNo = = "*" )
{
_d . DbOperationType = DbOperationType . DbotIns ;
_d . ModelUIStatus = "I" ;
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
_d . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , DateTime . Now . ToString ( "yyyy-MM-dd" ) , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
_d . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
_d . gId = "PC_" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
_d . PGid = _d . gId ;
}
else
{
_d . DbOperationType = DbOperationType . DbotUpd ;
_d . ModelUIStatus = "E" ;
}
}
var result = new DBResult ( ) ;
var _L = ModelObjectConvert < MsWlPcHead_WFSDEdit > . ToModelObjectList ( dataList ) ;
//var _DL = ModelObjectConvert<MsWlPcHead_ADLEdit>.ToModelObjectList(DeldataList);
var modb = new ModelObjectRepository ( ) ;
result = modb . SaveHead ( _L ) ;
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult GetFeeFixBodyList ( string billno )
{
var condition = " BillNo='" + billno + "'" ;
List < MsWlPcFixed > list = MsRptPcHeadEditDAL . GetBodyList ( condition , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "查询成功" , totalCount = list . Count , data = list . ToList ( ) } ) ;
return new ContentResult ( ) { Content = json } ;
}
public ContentResult DeleteFixBodyList ( string data )
{
var BodyList = JsonConvert . Deserialize < List < MsWlPcFixed > > ( data ) ;
if ( BodyList ! = null & & BodyList . Count ! = 0 ) {
T_ALL_DA T_ALL_DA = new EntityDA . T_ALL_DA ( ) ;
foreach ( var body in BodyList ) {
var blUpBL = " delete from tMsWlPcFixed where GId='" + body . GId + "'" ;
bool blBL = T_ALL_DA . GetExecuteSqlCommand ( blUpBL ) ;
}
}
var jsonRespose = new JsonResponse { Success = true } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
//var isfee = MsWlPcDAL.GetFeeCount(head.GId);
//if (isfee)
//{
// var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在费用,请先删除费用才能删除此票业务!" };
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
//var isfen = MsWlPcDAL.GetFenCount(head.GId);
//if (isfen)
//{
// var jsonRespose = new JsonResponse { Success = false, Message = "此票业务存在分票,请先删除分票才能删除此票业务!" };
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
//else
//{
// var modb = new ModelObjectDBBill();
// DBResult result = modb.Delete(head,
// "delete from tMsWlBsFixed where BillNo='" + head.BillNo + "'",
// "delete from ch_fee where BsNo='" + head.GId + "'",
// "delete from tcard_use where BillNo='" + head.BillNo + "'");
// MsSysBillNoSetDAL.DeleteBsNo(head.BillNo);
// var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
//}
}
public ContentResult CreateHYRDPc ( string bsno )
{
var headData = MsRptPcHeadEditDAL . GetHYRDData ( "GID='" + bsno + "'" ) ;
if ( ! string . IsNullOrEmpty ( headData . Property ) ) {
var jsonRespose2 = new JsonResponse { Success = false , Message = "已生成派车,不允许重复生成!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose2 ) } ;
}
var refbillno = headData . BillNo ;
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . TRANSSTATUS = "新建" ;
headData . BsType = "" ;
headData . gId = "PC" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
headData . PGid = headData . gId ;
headData . RefBillNo = refbillno ;
headData . LrDate = DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ;
//if (!string.IsNullOrEmpty(headData.LrDate))
//{
// headData.LrDate = headData.LrDate.Substring(0, 10);
//}
//else
//{
// var currentTime = System.DateTime.Now;
// headData.LrDate = currentTime.ToString("d");
//}
var BSNO = headData . gId ;
var modb = new ModelObjectDB ( ) ;
DBResult result = modb . Save ( headData ) ;
if ( result . Success )
{
result . Message = "生成成功!" ;
}
else {
result . Message = "生成失败" ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult CreateHYRDFen ( string bsno , string ctnbody )
{
var headData = MsRptPcHeadEditDAL . GetHYRDData ( "GID='" + bsno + "'" ) ;
var bodyctnData = JsonConvert . Deserialize < List < MsOpSeaeDetail > > ( ctnbody ) ;
var Fenlist = MsRptPcHeadEditDAL . GetHYRDList ( "t.PGID='" + headData . gId + "' AND t.GID<>'" + headData . gId + "'" , "" , "" , "" , "" , null ) ;
if ( bodyctnData ! = null & & bodyctnData . Count = = 1 )
{
var jsonRespose2 = new JsonResponse { Success = true , Message = "不需要生成分票!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose2 ) } ;
}
if ( Fenlist ! = null & & Fenlist . Count ! = 0 )
{
var jsonRespose2 = new JsonResponse { Success = false , Message = "已生成分票,不允许引入生成!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose2 ) } ;
}
if ( bodyctnData = = null | | bodyctnData . Count = = 0 )
{
var jsonRespose2 = new JsonResponse { Success = false , Message = "不存在要生成分票的数据!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose2 ) } ;
}
var PGID = headData . gId ;
DBResult result = new DBResult ( ) ;
foreach ( var ctn in bodyctnData ) {
if ( headData . BsType = = "装箱" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运装箱' " , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
if ( billnoset . BILLTYPE ! = "" )
{
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
}
}
else
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
}
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . TRANSSTATUS = "新建" ;
headData . gId = "PC" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
headData . PGid = PGID ;
headData . SealNo = ctn . SEALNO ;
headData . ContainerNo = ctn . CNTRNO ;
headData . ContainerType = ctn . CTNALL ;
headData . ContainerQty = "1" ;
headData . BLTYPE = "派车分票" ;
headData . ACCDATE = DateTime . Now . ToString ( "yyyy-MM" ) ;
headData . LrDate = DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ;
//if (!string.IsNullOrEmpty(headData.LrDate))
//{
// headData.LrDate = headData.LrDate.Substring(0, 10);
//}
//else
//{
// var currentTime = System.DateTime.Now;
// headData.LrDate = currentTime.ToString("d");
//}
var BSNO = headData . gId ;
var modb = new ModelObjectDB ( ) ;
result = modb . Save ( headData ) ;
}
if ( result . Success )
{
result . Message = "生成成功!" ;
}
else
{
result . Message = "生成失败" ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult SaveQDLH ( string opstatus , string data , string ctnbody )
{
var headData = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var bodyctnData = JsonConvert . Deserialize < List < MsOpLetterTruckCtn > > ( ctnbody ) ;
//var fixBodyDelList = JsonConvert.Deserialize<List<MsWlPcFixed>>(fixdelbody);
var isPost = true ;
var errorstr = "" ;
var custno = "" ;
if ( opstatus = = "add" )
{
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . TRANSSTATUS = "新建" ;
}
else if ( opstatus = = "edit" )
{
headData . DbOperationType = DbOperationType . DbotUpd ;
headData . ModelUIStatus = "E" ;
}
else
{
headData . DbOperationType = DbOperationType . DbotDel ;
}
//if ( !string.IsNullOrEmpty(headData.ExpDate)){
// headData.ExpDate = headData.ExpDate.Replace("T", " ");
//}
//if ( !string.IsNullOrEmpty(headData.ExpDate))
//{
// headData.ExpDate = headData.ExpDate.Substring(0, 10);
//}
//if ( !string.IsNullOrEmpty(headData.ArriveDate))
//{
// headData.ArriveDate = headData.ArriveDate.Substring(0, 10);
//}
//if (!string.IsNullOrEmpty(headData.ReturnDate))
//{
// headData.ReturnDate = headData.ReturnDate.Substring(0, 10);
//}
if ( ! string . IsNullOrEmpty ( headData . LrDate ) )
{
headData . LrDate = headData . LrDate . Substring ( 0 , 10 ) ;
}
else
{
var currentTime = System . DateTime . Now ;
headData . LrDate = currentTime . ToString ( "d" ) ;
}
var BSNO = headData . gId ;
if ( isPost )
{
var modb = new ModelObjectDB ( ) ;
DBResult result = modb . Save ( headData ) ;
if ( result . Success = = true )
{
MsOpLetterDAL . SaveTruckCtn ( headData . gId , bodyctnData ) ; // MsWlPcDAL.SaveDetail(BSNO, fixBodyList, CookieConfig.GetCookie_UserId(Request));
}
else
{
MsSysBillNoSetDAL . DeleteBsNo ( custno ) ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
Data = MsRptPcHeadEditDAL . GetQDLHData ( "GID='" + BSNO + "'" )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var jsonRespose = new JsonResponse { Success = false , Message = errorstr + "重复,不允许保存!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
public ContentResult SaveWFSDList ( string data )
{
var dataList = JsonConvert . Deserialize < List < MsWlPcHead_WFSDEdit > > ( data ) ;
foreach ( var _d in dataList ) {
if ( ! string . IsNullOrEmpty ( _d . ExpDate ) ) {
_d . ExpDate = _d . ExpDate . Replace ( "T" , " " ) ;
}
if ( ! string . IsNullOrEmpty ( _d . ExpDate ) )
{
_d . ExpDate = _d . ExpDate . Substring ( 0 , 10 ) ;
}
if ( ! string . IsNullOrEmpty ( _d . ArriveDate ) )
{
_d . ArriveDate = _d . ArriveDate . Substring ( 0 , 10 ) ;
}
if ( ! string . IsNullOrEmpty ( _d . ReturnDate ) )
{
_d . ReturnDate = _d . ReturnDate . Substring ( 0 , 10 ) ;
}
if ( ! string . IsNullOrEmpty ( _d . LrDate ) )
{
_d . LrDate = _d . LrDate . Substring ( 0 , 10 ) ;
}
else
{
var currentTime = System . DateTime . Now ;
_d . LrDate = currentTime . ToString ( "d" ) ;
}
if ( _d . BillNo = = "" | | _d . BillNo = = "*" )
{
_d . DbOperationType = DbOperationType . DbotIns ;
_d . ModelUIStatus = "I" ;
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
_d . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , DateTime . Now . ToString ( "yyyy-MM-dd" ) , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
_d . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
_d . gId = "PC_" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
_d . PGid = _d . gId ;
}
else
{
_d . DbOperationType = DbOperationType . DbotUpd ;
_d . ModelUIStatus = "E" ;
}
}
var result = new DBResult ( ) ;
var _L = ModelObjectConvert < MsWlPcHead_WFSDEdit > . ToModelObjectList ( dataList ) ;
//var _DL = ModelObjectConvert<MsWlPcHead_ADLEdit>.ToModelObjectList(DeldataList);
var modb = new ModelObjectRepository ( ) ;
result = modb . SaveHead ( _L ) ;
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult IsDelete ( string data )
{
var head = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var isfee = MsWlPcDAL . GetPcCount ( head . Property ) ;
if ( isfee )
{
var jsonRespose = new JsonResponse { Success = false , Message = "此票业务存派车信息!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var jsonRespose = new JsonResponse { Success = true } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
public ContentResult DeleteHYRD ( string data )
{
var head = JsonConvert . Deserialize < MsWlPcHead > ( data ) ;
var isfee = MsWlPcDAL . GetFeeCount ( head . GId ) ;
if ( isfee )
{
var jsonRespose = new JsonResponse { Success = false , Message = "此票业务存在费用,请先删除费用才能删除此票业务!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
var isfen = MsWlPcDAL . GetFenCount ( head . GId ) ;
if ( isfen )
{
var jsonRespose = new JsonResponse { Success = false , Message = "此票业务存在分票,请先删除分票才能删除此票业务!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var modb = new ModelObjectDBBill ( ) ;
DBResult result = modb . Delete ( head ,
"delete from tMsWlBsFixed where BillNo='" + head . BillNo + "'" ,
"delete from ch_fee where BsNo='" + head . GId + "'" ,
"delete from tcard_use where BillNo='" + head . BillNo + "'" ) ;
MsSysBillNoSetDAL . DeleteBsNo ( head . BillNo ) ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
public ContentResult HuiDan ( string data , string jsonBody )
{
var headData = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var bodylist = JsonConvert . Deserialize < List < MsWlPcHead_WFSDEdit > > ( jsonBody ) ;
var result = MsRptPcHeadEditDAL . HuiDan ( headData , bodylist ) ;
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult CreatePC ( string MblNo , string CustomerName , string ContainerQty , string Ton , string LoadCount )
{
var result = new DBResult ( ) ;
var _D = new MsWlPcHead_WFSDEdit ( ) ;
_D . MblNo = MblNo ;
_D . CustomerName = CustomerName ;
_D . ContainerQty = ContainerQty ; //件数
_D . Ton = Ton ; //重量
_D . LoadCount = LoadCount ; //体积
//////////////
_D . DbOperationType = DbOperationType . DbotIns ;
_D . ModelUIStatus = "I" ;
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='拼箱运输'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0121" ;
_D . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , DateTime . Now . ToString ( ) , DateTime . Now . ToString ( ) ) ; //获取合同号
_D . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
_D . gId = "PC_" + Guid . NewGuid ( ) . ToString ( "N" ) . ToUpper ( ) ;
var modb = new ModelObjectRepository ( ) ;
result = modb . Save ( _D ) ;
//刷新父窗口上的父节点
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
//Data = XXHDAL.GetData("M.ContractNo='" + head.ContractNo + "'")
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult AddBillAuto ( string data )
{
var head = JsonConvert . Deserialize < MsWlBsHead > ( data ) ;
var headData = new MsWlPcHead_WFSDEdit ( ) ;
var isPost = true ;
var errorstr = "" ;
var custno = "" ;
var billnoset = MsSysBillNoSetDAL . GetData ( "OPLBNAME='陆运'" , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
billnoset . BILLTYPE = "0111" ;
billnoset . RULEDATETYPE = "业务日期" ;
var bsdate = headData . ExpDate ;
if ( bsdate = = "" | | bsdate = = null )
bsdate = DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
headData . BillNo = MsSysBillNoSetDAL . GetBillNo ( billnoset , bsdate , DateTime . Now . ToString ( "yyyy-MM" ) ) ; //获取合同号
headData . OrgCode = CookieConfig . GetCookie_OrgCode ( Request ) ;
headData . DbOperationType = DbOperationType . DbotIns ;
headData . RefBillNo = head . BillNo ;
headData . CustName = head . CustName ;
headData . CustomerName = head . CustName ;
headData . VoyVeg = head . VoyVeg ;
headData . EtDate = head . EtDate ;
headData . DstArea = head . DstArea ;
headData . EndPortDate = head . EndPortDate ;
headData . MblNo = head . MblNo ;
headData . DispatchName = head . DispatchName ;
headData . DetiNation = head . DetiNation ;
if ( ! string . IsNullOrEmpty ( headData . LrDate ) )
{
headData . LrDate = headData . LrDate . Substring ( 0 , 10 ) ;
}
else
{
var currentTime = System . DateTime . Now ;
headData . LrDate = currentTime . ToString ( "d" ) ;
}
var BSNO = headData . gId ;
if ( isPost )
{
var modb = new ModelObjectDB ( ) ;
DBResult result = modb . Save ( headData ) ;
if ( result . Success = = true ) { }
else
{
MsSysBillNoSetDAL . DeleteBsNo ( custno ) ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
Data = MsRptPcHeadEditDAL . GetWFSDData ( "GID='" + BSNO + "'" )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var jsonRespose = new JsonResponse { Success = false , Message = errorstr + "重复,不允许保存!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
[SqlKeyWordsFilter(Type = "Action")] //sql 防注入过滤器
public ContentResult RptTruckListData ( int start , int limit , string condition , string sort , string printstr , string sortstr )
{
var strSql = new StringBuilder ( ) ;
strSql . Append ( " select CargoID,LoadFactory,PcBillType,PGid,BLTYPE,TRANSSTATUS " ) ;
strSql . Append ( " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99046 and EnumValueID=t.PcBillType) PcBillTypeREF " ) ;
strSql . Append ( " ,convert(bigint ,t.TimeMark) as timeMark,gId,UserName " ) ;
strSql . Append ( " ,BillNo,dbo.trimtime(ExpDate) ExpDate,ArriveDate,ReturnDate " ) ;
strSql . Append ( " ,CustomerName,F_CustomerName,t.DrvName,t.TruckNo,MblNo,LinkMan,DstArea,DetiNation,ContainerQty,GOODSCOUNT,CBM " ) ;
strSql . Append ( " ,Ton,t.LoadCount,LoadPlace,TruckSpec,IsDouble,Property,RefBillNo,RefBillNose,MblNoSe,dbo.trimdate(EndPortDate) EndPortDate,VoyVeg,dbo.trimdate(EtDate) EtDate " ) ;
strSql . Append ( " ,t.Remark,t.FeeStatus,dbo.trimdate(LrDate) LrDate" ) ;
strSql . Append ( " ,case when t.TruckNo='' then '接单' else case when isnull(isend,0)=0 then '派车' else '完成' end end PCSTATUSREF " ) ;
strSql . Append ( " ,ContainerType,LinkTel,YardName,LinkManSe,LinkTelSe,RtnYardName,BsType,CustName,CustLikeManName,CustTel,ChangedReson,DispatchName,RoadFee,FactoryAddr,ContainerNo,SealNo" ) ;
strSql . Append ( ",t.SALECORPID,(select [NAME] from [company] where GID=t.SALECORPID) as SALECORP,DCLASS,DUNNO" ) ;
strSql . Append ( " ,INVOICENO,KINDPKGS,CUSTNO,SalesName,GoodsName,PORTLOAD,DESTINATION,RtnDocStatus,RtnDocTime,ACCDATE,(CASE FEESTATUS WHEN 1 THEN '锁定' else '未锁定' end) as FEESTATUSREF " ) ;
strSql . Append ( " ,g.TRUCKYFCR,g.TRUCKJDJYCR,g.TRUCKJQCR,g.TRUCKDXJQCR,g.TRUCKGSFCR,g.TRUCKXJYQCR,g.TRUCKXJGSCR,g.TRUCKXJNSCR,g.TRUCKXJTLXCR,g.TRUCKXJWXCR,g.TRUCKXJQTCR " ) ;
strSql . Append ( ",g.TRUCKLQFCR,g.TTLTRUCKCR,g.TTLTRUCKSTLCR,g.TTLTRUCKBLCCR,g.TTLYFCR,g.TTLDSFCR,g.TTLGSFCR,g.TTLQTFCR,g.TTLOTCR,g.TTLOTSTLCR,g.TTLOTBLCCR,g.TTLDR,g.TTLCR " ) ;
strSql . Append ( ",g.TTLDR-g.TTLCR TTLPROFIT,g.TTLOTCR-g.TTLTRUCKSTLCR TTLTRUCKPROFIT " ) ;
strSql . Append ( " from tMsWlPcHead t left join v_op_gain_sum_truck g on (g.BSNO=t.gId) " ) ;
if ( ! string . IsNullOrEmpty ( condition ) )
{
//strSql.Append(" where 1=1 AND " + strCondition);
strSql . Append ( " where " + condition ) ;
}
else
{
}
if ( ( ! string . IsNullOrEmpty ( printstr ) ) & & ( printstr = = "true" ) )
{
if ( ! string . IsNullOrEmpty ( sortstr ) )
{
strSql . Append ( " order by " + sortstr ) ;
}
else
{
strSql . Append ( " order by ExpDate " ) ;
}
var jsonRespose = new JsonResponse
{
Success = true ,
Message = "完成" ,
Data = strSql . ToString ( )
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else
{
var sortstring = DatasetSort . Getsortstring ( sort ) ;
if ( ! string . IsNullOrEmpty ( sortstring ) )
{
strSql . Append ( " order by " + sortstring ) ;
}
else
{
strSql . Append ( " order by ExpDate" ) ;
}
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 ( start , limit , dbRptResult , "Result_Set" , true ) ;
return new ContentResult ( ) { Content = json } ;
}
}
/// <summary>
/// 用于optask模块调用 生成费用
/// 费用记录在 ch_fee_order模块 如果
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public ContentResult MakeFee ( string data )
{
var head = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var USERID = Convert . ToString ( Session [ "USERID" ] ) ;
var result = MsRptPcHeadEditDAL . MakeFee ( head , USERID ) ;
return BasicDataRefDAL . GetContentResult ( result ) ;
}
public ContentResult UnMakeFee ( string data )
{
var head = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( data ) ;
var result = MsRptPcHeadEditDAL . UnMakeFee ( head ) ;
return BasicDataRefDAL . GetContentResult ( result ) ;
}
#region 参照部分
# endregion
public ContentResult GetTruckFuelList ( string BSNO )
{
var cdc = new CommonDataContext ( ) ;
var resultList = cdc . t_Truck_FHApp_Fuel . Where ( x = > x . BSNO = = BSNO ) . ToList ( ) ;
var result = new DBResult ( ) ;
result . Success = true ;
result . Data = resultList ;
return BasicDataRefDAL . GetDataListContentResult ( result ) ;
}
public ContentResult SelectionCopy ( string GIDList )
{
var canlogin = BasicDataRefDAL . CheckLogin ( Session ) ;
if ( ! canlogin . Success )
{
return ( ContentResult ) canlogin . Data ;
}
var result = MsRptPcHeadEditDAL . SelectionCopy ( GIDList , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
return BasicDataRefDAL . GetDataListContentResult ( result ) ;
}
public ContentResult modify ( string data , string modifydata )
{
var bodyList = JsonConvert . Deserialize < List < MsWlPcHead_WFSDEdit > > ( data ) ;
var amodifydata = JsonConvert . Deserialize < MsWlPcHead_WFSDEdit > ( modifydata ) ;
var result = new DBResult ( ) ;
if ( bodyList ! = null )
{
result = MsRptPcHeadEditDAL . Modify ( bodyList , amodifydata , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
}
var jsonRespose = new JsonResponse
{
Success = result . Success ,
Message = result . Message ,
} ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult CancelShippingOrderList ( string data , string type )
{
var headData = JsonConvert . Deserialize < List < MsWlPcHead_WFSDEdit > > ( data ) ;
var errstr = "" ;
if ( headData ! = null )
{
foreach ( var enumValue in headData )
{
var BSNO = enumValue . gId ;
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 )
MsRptPcHeadEditDAL . CancelShippingOrder ( BSNO , type , Convert . ToString ( Session [ "SHOWNAME" ] ) ) ;
}
else
{
var iscancel = true ;
if ( ! string . IsNullOrEmpty ( enumValue . ACCDATE ) )
{
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 = MsWlPcDAL . GetFeeCount ( enumValue . gId ) ;
if ( isfee )
{
if ( errstr = = "" )
errstr = enumValue . CUSTNO + "存在费用" ;
else
errstr = errstr + "," + enumValue . CUSTNO + "存在费用" ;
iscancel = false ;
}
isfee = MsWlPcDAL . GetFenCount ( enumValue . gId ) ;
if ( isfee )
{
if ( errstr = = "" )
errstr = enumValue . CUSTNO + "存在分票" ;
else
errstr = errstr + "," + enumValue . CUSTNO + "存在分票" ;
iscancel = false ;
}
if ( enumValue . BSSTATUSREF = = "锁定" )
{
errstr = errstr + "," + enumValue . CUSTNO + "已业务锁定" ;
iscancel = false ;
}
if ( iscancel )
MsRptPcHeadEditDAL . CancelShippingOrder ( 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 ) } ;
}
}
}