@ -34,8 +34,6 @@ using iTextSharp.text.pdf;
using DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet ;
using DSWeb.Common.Helper ;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL ;
using NuonuoSDK ;
using java.applet ;
namespace DSWeb.Areas.Account.Controllers
{
@ -109,7 +107,7 @@ namespace DSWeb.Areas.Account.Controllers
sort = sort . Replace ( "INVOICETYPEREF" , "INVOICETYPE" ) ;
sort = sort . Replace ( "APPLICANT" , "(select top 1 (select ShowName from [user] where GID=ap.applicant) APPLICANT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO)" ) ;
}
var dataList = ChinvoiceDAL . GetDataList ( start , limit , condition , Convert . ToString ( Session [ "USERID" ] ) , CookieConfig . GetCookie_UserCode ( Request ) , Convert . ToString ( Session [ "COMPANYID" ] ) , sort ) ;
var dataList = ChinvoiceDAL . GetDataList ( start , limit , condition , Convert . ToString ( Session [ "USERID" ] ) , CookieConfig . GetCookie_UserCode ( Request ) , Convert . ToString ( Session [ "COMPANYID" ] ) , sort ) ;
int count = ChinvoiceDAL . getTotalCount ( condition , CookieConfig . GetCookie_UserId ( Request ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "查询成功" , totalCount = count , data = dataList . ToList ( ) } ) ;
@ -123,7 +121,7 @@ namespace DSWeb.Areas.Account.Controllers
return new ContentResult ( ) { Content = json } ;
}
public ContentResult GetData ( string handle , string condition , bool isapp )
public ContentResult GetData ( string handle , string condition , bool isapp )
{
ChInvoice_HangXin head = null ;
@ -163,7 +161,8 @@ namespace DSWeb.Areas.Account.Controllers
head . INVOICETYPE = 2 ;
head . INVOICETYPEREF = "申请发票" ;
}
else {
else
{
head . INVOICETYPE = 1 ;
head . INVOICETYPEREF = "自由发票" ;
}
@ -189,7 +188,7 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult GetBillList ( string condition , string sort )
{
var dataList = ChinvoiceDAL . GetBodyList ( condition , sort ) ;
var dataList = ChinvoiceDAL . GetBodyList ( condition , sort ) ;
var json = JsonConvert . Serialize ( new { Success = true , Message = "查询成功" , totalCount = dataList . Count , data = dataList . ToList ( ) } ) ;
@ -225,7 +224,7 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult GetBillDataList ( int start , int limit , string sort , string condition )
{
var dataList = ChinvoiceDAL . GetAddBillList ( start , limit , condition , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , sort ) ;
var dataList = ChinvoiceDAL . GetAddBillList ( start , limit , condition , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) , sort ) ;
int count = ChinvoiceDAL . getAddBillTotalCount ( condition , Convert . ToString ( Session [ "USERID" ] ) , Convert . ToString ( Session [ "SHOWNAME" ] ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var json = JsonConvert . Serialize (
new { Success = true , Message = "查询成功" , totalCount = count , data = dataList . ToList ( ) } ) ;
@ -308,7 +307,8 @@ namespace DSWeb.Areas.Account.Controllers
headData . CUSTADDRTEL = dsHSCODE . Tables [ 0 ] . Rows [ 0 ] [ "INVADDRTEL" ] . ToString ( ) ;
else headData . CUSTADDRTEL = dsHSCODE . Tables [ 0 ] . Rows [ 0 ] [ "Addr" ] . ToString ( ) + " " + dsHSCODE . Tables [ 0 ] . Rows [ 0 ] [ "Tel" ] . ToString ( ) ;
}
if ( string . IsNullOrEmpty ( headData . CUSTTEL ) ) {
if ( string . IsNullOrEmpty ( headData . CUSTTEL ) )
{
if ( dsHSCODE . Tables [ 0 ] . Rows [ 0 ] [ "Tel" ] . ToString ( ) ! = "" )
headData . CUSTTEL = dsHSCODE . Tables [ 0 ] . Rows [ 0 ] [ "Tel" ] . ToString ( ) ;
}
@ -348,7 +348,8 @@ namespace DSWeb.Areas.Account.Controllers
else headData . INVITERFACE = "诺诺发票接口" ;
}
if ( ! string . IsNullOrEmpty ( headData . CUSTTEL ) & & ( headData . CUSTTEL . Trim ( ) . Length > 20 ) ) {
if ( ! string . IsNullOrEmpty ( headData . CUSTTEL ) & & ( headData . CUSTTEL . Trim ( ) . Length > 20 ) )
{
isPost = false ;
errorstr = "客户电话长度不允许超过20" ;
@ -359,10 +360,12 @@ namespace DSWeb.Areas.Account.Controllers
isPost = false ;
errorstr = "客户电话长度不允许超过80" ;
}
if ( ! string . IsNullOrEmpty ( headData . SALECORPID ) & & ! string . IsNullOrEmpty ( headData . ACCOUNT ) ) {
if ( ! string . IsNullOrEmpty ( headData . SALECORPID ) & & ! string . IsNullOrEmpty ( headData . ACCOUNT ) )
{
var banklist = MsBaseInfoDAL . GetAllBANKList ( "LINKID='" + headData . SALECORPID + "'" ) ;
if ( banklist . Find ( x = > ( x . CURRENCY = = headData . RECVCURR | | x . CURRENCY = = "" ) & & x . BANKACCOUNT = = headData . ACCOUNT ) = = null ) {
var banklist = MsBaseInfoDAL . GetAllBANKList ( "LINKID='" + headData . SALECORPID + "'" ) ;
if ( banklist . Find ( x = > ( x . CURRENCY = = headData . RECVCURR | | x . CURRENCY = = "" ) & & x . BANKACCOUNT = = headData . ACCOUNT ) = = null )
{
isPost = false ;
errorstr = "银行及账号于收款单位和币别不一致,请检查" ;
@ -405,7 +408,8 @@ namespace DSWeb.Areas.Account.Controllers
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else {
else
{
var jsonRespose = new JsonResponse { Success = false , Message = errorstr + "不允许保存!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
@ -413,7 +417,7 @@ namespace DSWeb.Areas.Account.Controllers
}
public ContentResult AddDetail ( string bill , string data , string curr , bool islist , string GID , string invoiceno )
public ContentResult AddDetail ( string bill , string data , string curr , bool islist , string GID , string invoiceno )
{
//首先判断是否有 modInvoiceImport发票引入费用 权限
@ -424,7 +428,7 @@ namespace DSWeb.Areas.Account.Controllers
var bodyList = JsonConvert . Deserialize < List < BillChfeeDetail > > ( data ) ;
var headdata = ChinvoiceDAL . GetData ( " BILLNO='" + bill + "'" , Convert . ToString ( Session [ "USERID" ] ) , CookieConfig . GetCookie_UserCode ( Request ) , Convert . ToString ( Session [ "COMPANYID" ] ) ) ;
var modb = new ModelObjectDB ( ) ;
DBResult result = ChinvoiceDAL . AddDetail ( bill , bodyList , curr , Convert . ToString ( Session [ "COMPANYID" ] ) , islist , GID , headdata ) ;
DBResult result = ChinvoiceDAL . AddDetail ( bill , bodyList , curr , Convert . ToString ( Session [ "COMPANYID" ] ) , islist , GID , headdata ) ;
if ( result . Success ) { ChinvoiceDAL . p_update_Amount ( bill , GID ) ; }
@ -477,13 +481,13 @@ namespace DSWeb.Areas.Account.Controllers
}
public ContentResult DelBill ( string data , string billno , string GID )
public ContentResult DelBill ( string data , string billno , string GID )
{
//首先判断是否有 modInvoiceImport发票引入费用 权限
var bodyList = JsonConvert . Deserialize < List < Chfee_do_detail > > ( data ) ;
DBResult result = ChinvoiceDAL . DelFeeDo ( bodyList , GID ) ;
DBResult result = ChinvoiceDAL . DelFeeDo ( bodyList , GID ) ;
if ( result . Success ) { ChinvoiceDAL . p_update_Amount ( billno , GID ) ; }
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
@ -496,13 +500,14 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult Delete ( string data )
{
var headData = JsonConvert . Deserialize < ChInvoice_HangXin > ( data ) ;
headData = ChinvoiceDAL . GetData ( " cm.BILLNO='" + headData . BILLNO + "'" ) ;
headData = ChinvoiceDAL . GetData ( " cm.BILLNO='" + headData . BILLNO + "'" ) ;
DBResult result ;
//首先判断是否有 modInvLock 发票开出锁定
//20191205 防止已经获得【流水号】的发票业务被删除
if ( ! string . IsNullOrWhiteSpace ( headData . INVOICESERIALNUM ) & & headData . INVAMOUNT > 0 ) {
if ( ! string . IsNullOrWhiteSpace ( headData . INVOICESERIALNUM ) & & headData . INVAMOUNT > 0 )
{
var jsonRespose1 = new JsonResponse { Success = false , Message = "已经获得流水号且仍包含费用的发票业务不能删除" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose1 ) } ;
}
@ -512,7 +517,8 @@ namespace DSWeb.Areas.Account.Controllers
var jsonRespose1 = new JsonResponse { Success = false , Message = "已经实际开出的发票业务不能删除" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose1 ) } ;
}
if ( headData . EINVOICESTATEREF = = "开票中" ) {
if ( headData . EINVOICESTATEREF = = "开票中" )
{
var jsonRespose1 = new JsonResponse { Success = false , Message = "当前发票状态不允许删除" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose1 ) } ;
@ -548,7 +554,7 @@ namespace DSWeb.Areas.Account.Controllers
var rangestr = BasicDataRefDAL . CanOperateStr_INVOICE ( ModName , Session [ "USERID" ] . ToString ( ) ) ;
var _L = ChinvoiceDAL . GetData ( "GID='" + head . GID + "' and " + rangestr ) ;
var _L = ChinvoiceDAL . GetData ( "GID='" + head . GID + "' and " + rangestr ) ;
if ( _L . GID = = head . GID )
{
@ -613,10 +619,10 @@ namespace DSWeb.Areas.Account.Controllers
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
//}
DBResult result ;
result = ChinvoiceDAL . UpdateDelete ( headData . BILLNO , Convert . ToString ( Session [ "USERID" ] ) , false ) ;
result = ChinvoiceDAL . UpdateDelete ( headData . BILLNO , Convert . ToString ( Session [ "USERID" ] ) , false ) ;
if ( result . Success = = true )
{
ChinvoiceDAL . UpdateInvNoDelete ( headData . INVOICENO , Convert . ToString ( Session [ "USERID" ] ) , false ) ;
ChinvoiceDAL . UpdateInvNoDelete ( headData . INVOICENO , Convert . ToString ( Session [ "USERID" ] ) , false ) ;
}
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
@ -638,15 +644,15 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult AddAppDetail ( string bill , string data , string invoiceno , string GID )
{
var bodyList = JsonConvert . Deserialize < List < ChInvoiceapplication > > ( data ) ;
var StrGid = "" ;
var StrGid = "" ;
if ( bodyList ! = null )
{
foreach ( var enumValue in bodyList )
{
if ( StrGid = = "" )
StrGid = "'" + enumValue . GID + "'" ;
if ( StrGid = = "" )
StrGid = "'" + enumValue . GID + "'" ;
else
StrGid = StrGid + ",'" + enumValue . GID + "'" ;
StrGid = StrGid + ",'" + enumValue . GID + "'" ;
}
}
@ -662,13 +668,15 @@ namespace DSWeb.Areas.Account.Controllers
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
else {
else
{
var jsonRespose = new JsonResponse { Success = false , Message = "发票申请已生成发票,请刷新!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
}
else {
var jsonRespose = new JsonResponse { Success = false , Message = "无需要添加的发票申请!" } ;
else
{
var jsonRespose = new JsonResponse { Success = false , Message = "无需要添加的发票申请!" } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
@ -680,13 +688,13 @@ namespace DSWeb.Areas.Account.Controllers
var bodyList = JsonConvert . Deserialize < List < ChInvoiceapplication > > ( data ) ;
DBResult result = ChinvoiceDAL . DelAppList ( bodyList , billno ) ;
DBResult result = ChinvoiceDAL . DelAppList ( bodyList , billno ) ;
if ( result . Success ) { ChinvoiceDAL . p_update_Amount ( billno , GID ) ; }
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult DelInvDetail ( string billno , string body , string GID )
public ContentResult DelInvDetail ( string billno , string body , string GID )
{
var bodyList = JsonConvert . Deserialize < List < ChInvoiceDetail > > ( body ) ;
@ -745,7 +753,8 @@ namespace DSWeb.Areas.Account.Controllers
#region 保存指定发票业务list的PDF文件 将其拼合成一个dpf后返回url
public ContentResult GetONEPDF ( string BILLNOS ) {
public ContentResult GetONEPDF ( string BILLNOS )
{
JsonResponse result = new JsonResponse ( ) ;
try
@ -777,7 +786,8 @@ namespace DSWeb.Areas.Account.Controllers
result . Message = "没有可以打印的发票文件" ;
return result . getContentReult ( ) ;
}
else {
else
{
//pdflist.OrderBy(o => o);
pdflist . Sort ( delegate ( string p1 , string p2 )
@ -796,7 +806,8 @@ namespace DSWeb.Areas.Account.Controllers
result . Data = "../../INVOICEPDF/" + Session [ "USERID" ] . ToString ( ) + ".pdf" ;
}
catch ( Exception e ) {
catch ( Exception e )
{
result . Success = false ;
result . Message = e . Message ;
}
@ -806,7 +817,8 @@ namespace DSWeb.Areas.Account.Controllers
}
private void SavePDF ( string [ ] pdfarray ) {
private void SavePDF ( string [ ] pdfarray )
{
string outputFileName = BasicDataRefDAL . getPath ( "INVOICEPDF" ) + Session [ "USERID" ] . ToString ( ) + ".pdf" ;
//PdfDocumentBase doc = PdfDocument.MergeFiles(pdfarray);
@ -865,7 +877,7 @@ namespace DSWeb.Areas.Account.Controllers
if ( filename ! = "" )
{
//result.Data = "../../EDIFiles/ExportInv/" + filename;
result . Data = filename ;
result . Data = filename ;
filename = Path . GetFileName ( filename ) ;
result . Success = true ;
result . Message = filename ;
@ -918,7 +930,8 @@ namespace DSWeb.Areas.Account.Controllers
#region 航信接口调用
public ContentResult test ( string str ) {
public ContentResult test ( string str )
{
var result = new KPResponse ( ) ;
@ -964,14 +977,15 @@ namespace DSWeb.Areas.Account.Controllers
// return View();
//}
private JsonResponse checkinfo ( string BILLNO , string redirecturl ) {
private JsonResponse checkinfo ( string BILLNO , string redirecturl )
{
var result = new DBResult ( ) ;
var head = new ChInvoice_HangXin ( ) ;
//var detail = new List<chinvoice_de>
var jsonRespose = new JsonResponse { Success = true , Message = result . Message , Data = result . Data } ;
//首先判断数据完整性与合法性
head = ChinvoiceDAL . GetData ( "cm.BILLNO='" + BILLNO + "'" ) ;
head = ChinvoiceDAL . GetData ( "cm.BILLNO='" + BILLNO + "'" ) ;
if ( string . IsNullOrEmpty ( head . INVOICELINE ) )
@ -981,7 +995,7 @@ namespace DSWeb.Areas.Account.Controllers
}
if ( head . BILLNO ! = "" )
if ( head . BILLNO ! = "" )
{
if ( string . IsNullOrEmpty ( head . INVITERFACE ) )
{
@ -1014,7 +1028,7 @@ namespace DSWeb.Areas.Account.Controllers
else
{
if ( head . INVITERFACE = = "诺诺发票接口" | | head . INVITERFACE = = "" )
if ( head . INVITERFACE = = "诺诺发票接口" | | head . INVITERFACE = = "" )
{
//如果该税号的token需要 返回认证窗口
var hx = HangXinRequestHelper . getHelper ( head . TAXCODE ) ;
@ -1025,21 +1039,17 @@ namespace DSWeb.Areas.Account.Controllers
jsonRespose . Message = hx . ERRORMSG ;
return jsonRespose ;
}
//20230109如无token则采用新的token获取方式
//HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl);
//if (hx.needStart)
//{
// //BasicDataRefDAL.SaveLog("checkinfo; BILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口");
// jsonRespose = TokenPage();
//
// var token= NNOpenSDK.getMerchantToken(HangXinRequestHelper.appKey, HangXinRequestHelper.appSecret);
// //public static string getMerchantToken(string appKey, string appSecret)
//}
HangXinRequestHelper . redirectUri = getRedirecturl ( redirecturl ) ;
if ( hx . needStart )
{
BasicDataRefDAL . SaveLog ( "checkinfo; BILLNO=" + BILLNO , "" , "诺诺平台" , "返回认证窗口" ) ;
jsonRespose = TokenPage ( ) ;
}
else {
jsonRespose . Success = true ;
jsonRespose . Message = "" ;
}
else
{
jsonRespose . Success = true ;
jsonRespose . Message = "" ;
return jsonRespose ;
}
}
@ -1047,7 +1057,8 @@ namespace DSWeb.Areas.Account.Controllers
}
private JsonResponse TokenPage ( ) {
private JsonResponse TokenPage ( )
{
var jsonRespose = new JsonResponse { Success = true , Message = "" , Data = "" } ;
@ -1063,7 +1074,7 @@ namespace DSWeb.Areas.Account.Controllers
/// </summary>
/// <param name="bill"></param>
/// <returns></returns>
public ContentResult NNMakeInv ( string bill , string redirecturl )
public ContentResult NNMakeInv ( string bill , string redirecturl )
{
//首先判断是否有 modInvLock 发票开出锁定
var result = new DBResult ( ) ;
@ -1075,13 +1086,15 @@ namespace DSWeb.Areas.Account.Controllers
//首先判断数据完整性与合法性
var checkresult = checkinfo ( bill , redirecturl ) ;
var checkresult = checkinfo ( bill , redirecturl ) ;
if ( ! checkresult . Success ) {
if ( ! checkresult . Success )
{
return new ContentResult ( ) { Content = JsonConvert . Serialize ( checkresult ) } ;
}
else {
var head = ( ChInvoice_HangXin ) checkresult . Data ;
else
{
var head = ( ChInvoice_HangXin ) checkresult . Data ;
decimal invamount = 0 ;
var invitems = ChinvoiceapplicationDAL . GetDetailList ( "PID='" + head . GID + "'" , "" ) ;
foreach ( var invitem in invitems )
@ -1096,7 +1109,7 @@ namespace DSWeb.Areas.Account.Controllers
ChInvoice_HangXin returndate = null ;
if ( head . INVITERFACE = = "诺诺发票接口" | | head . INVITERFACE = = "" )
if ( head . INVITERFACE = = "诺诺发票接口" | | head . INVITERFACE = = "" )
{
var hx = HangXinRequestHelper . getHelper ( head . TAXCODE ) ;
if ( ! hx . CanUse )
@ -1119,19 +1132,19 @@ namespace DSWeb.Areas.Account.Controllers
else
{
//HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl) ;
HangXinRequestHelper . redirectUri = getRedirecturl ( redirecturl ) ;
var detailList = ChinvoiceDAL . GetDetailList ( "PID='" + head . GID + "'" ) ;
//var CodeGoodInvList = MsCodeGoodInvDAL.GetDataList(" gid in (SELECT GOODSNAME FROM ch_fee_invoicedetail where PID = '"+ head.GID + "')");
if ( ! string . IsNullOrWhiteSpace ( hx . accessToken ) )
{
result = hx . PostInvoice ( head , detailList ) ;
}
//if (result.Message == "需要重新认证" || string.IsNullOrWhiteSpace(hx.accessToken) )
// {
// BasicDataRefDAL.SaveLog("PostInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口");
// var _r = TokenPage();
// return new ContentResult() { Content = JsonConvert.Serialize(_r) };
// }
if ( result . Message = = "需要重新认证" | | string . IsNullOrWhiteSpace ( hx . accessToken ) )
{
BasicDataRefDAL . SaveLog ( "PostInvoice 反回‘需要重新认证’" , "" , "诺诺平台" , "返回认证窗口" ) ;
var _r = TokenPage ( ) ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( _r ) } ;
}
//returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'");
}
@ -1142,7 +1155,7 @@ namespace DSWeb.Areas.Account.Controllers
string msg = null ;
if ( ! string . IsNullOrEmpty ( head . INVOICESERIALNUM ) )
{ //如果该发票流水号不为空
result . Success = ruihongHelper . QueryInvoiceRecord ( head . GID , head . INVOICESERIALNUM , out msg ) ;
result . Success = ruihongHelper . QueryInvoiceRecord ( head . GID , head . INVOICESERIALNUM , out msg ) ;
result . Message = msg ;
}
@ -1194,7 +1207,7 @@ namespace DSWeb.Areas.Account.Controllers
{
//如果已有pdf地址 则直接返回
var headdata = ChinvoiceDAL . GetData ( " cm.BILLNO='" + BILLNO + "'" ) ;
var headdata = ChinvoiceDAL . GetData ( " cm.BILLNO='" + BILLNO + "'" ) ;
@ -1207,7 +1220,7 @@ namespace DSWeb.Areas.Account.Controllers
}
else
{
if ( headdata . INVITERFACE = = "诺诺发票接口" | | headdata . INVITERFACE = = "" )
if ( headdata . INVITERFACE = = "诺诺发票接口" | | headdata . INVITERFACE = = "" )
{
result = Do_NNReadInv ( BILLNO , redirecturl ) ;
}
@ -1216,10 +1229,10 @@ namespace DSWeb.Areas.Account.Controllers
RuihongHelper ruihongHelper = new RuihongHelper ( ) ;
string msg = null ;
var succ = ruihongHelper . QueryInvoiceRecord ( headdata . GID , headdata . INVOICESERIALNUM , out msg ) ;
var succ = ruihongHelper . QueryInvoiceRecord ( headdata . GID , headdata . INVOICESERIALNUM , out msg ) ;
result . Success = succ ;
result . Message = msg ;
result . Data = ChinvoiceDAL . GetData ( " BILLNO='" + headdata . BILLNO + "'" ) ;
result . Data = ChinvoiceDAL . GetData ( " BILLNO='" + headdata . BILLNO + "'" ) ;
}
}
@ -1259,7 +1272,7 @@ namespace DSWeb.Areas.Account.Controllers
string msg = null ;
var succ = ruihongHelper . QueryInvoiceRecord ( headdata . GID , headdata . INVOICESERIALNUM , out msg ) ;
var invoice = ChinvoiceDAL . GetData ( " BILLNO='" + headdata . BILLNO + "'" ) ;
var invoice = ChinvoiceDAL . GetData ( " BILLNO='" + headdata . BILLNO + "'" ) ;
result . Success = succ ;
result . Message = msg ;
result . Data = invoice ;
@ -1276,7 +1289,8 @@ namespace DSWeb.Areas.Account.Controllers
return result . getContentReult ( ) ;
}
private JsonResponse Do_NNReadInv ( string BILLNO , string redirecturl ) {
private JsonResponse Do_NNReadInv ( string BILLNO , string redirecturl )
{
//var hx = HangXinRequestHelper.getHelper(taxnum);
//var result = new DBResult();
@ -1348,7 +1362,8 @@ namespace DSWeb.Areas.Account.Controllers
return jsonRespose ;
}
public static string getRedirecturl ( string redirecturl ) {
public static string getRedirecturl ( string redirecturl )
{
return redirecturl ;
}
@ -1407,7 +1422,8 @@ namespace DSWeb.Areas.Account.Controllers
return result . getContentReult ( ) ;
}
public JsonResponse Do_NNVoidInv ( string BILLNO , string redirecturl ) {
public JsonResponse Do_NNVoidInv ( string BILLNO , string redirecturl )
{
var jsonRespose = new JsonResponse { Success = false , Message = "" , Data = "" } ;
@ -1501,7 +1517,8 @@ namespace DSWeb.Areas.Account.Controllers
var head = ( ChInvoice_HangXin ) checkresult . Data ;
if ( string . IsNullOrEmpty ( head . INVOICENO ) | | string . IsNullOrEmpty ( head . INVOICECODE ) ) {
if ( string . IsNullOrEmpty ( head . INVOICENO ) | | string . IsNullOrEmpty ( head . INVOICECODE ) )
{
jsonRespose . Success = false ;
jsonRespose . Message = "该发票没有发票号和发票代码,无法进行冲红。" ;
@ -1518,7 +1535,7 @@ namespace DSWeb.Areas.Account.Controllers
var detailList = ChinvoiceDAL . GetDetailList ( "PID='" + head . GID + "'" ) ;
//如果已经存在一张相应的红票, 则将现在这个head变成那个红票
var _existRed = ChinvoiceDAL . GetData ( " REDNUM='" + head . INVOICENO + "' and REDCODE='" + head . INVOICECODE + "' " ) ;
var _existRed = ChinvoiceDAL . GetData ( " REDNUM='" + head . INVOICENO + "' and REDCODE='" + head . INVOICECODE + "' " ) ;
if ( _existRed . BILLNO ! = "*" )
{
head = _existRed ;
@ -1584,7 +1601,7 @@ namespace DSWeb.Areas.Account.Controllers
var returndate = ChinvoiceDAL . GetData ( " BILLNO='" + head . BILLNO + "'" ) ;
if ( head . INVITERFACE = = "诺诺发票接口" | | head . INVITERFACE = = "" )
if ( head . INVITERFACE = = "诺诺发票接口" | | head . INVITERFACE = = "" )
{
var hx = HangXinRequestHelper . getHelper ( head . TAXCODE ) ;
if ( ! hx . CanUse )
@ -1627,7 +1644,8 @@ namespace DSWeb.Areas.Account.Controllers
string msg = null ;
result . Success = ruihongHelper . RedInvoiceRecord ( returndate . GID , out msg ) ;
result . Message = msg ;
if ( result . Success ) {
if ( result . Success )
{
var needautolock = MsSysParamSetDAL . GetSysParam ( "INVOICEAUTOLOCK" ) . isnullortrue ( ) ;
if ( needautolock )
@ -1661,18 +1679,21 @@ namespace DSWeb.Areas.Account.Controllers
/// </summary>
/// <param name="REMARK"></param>
/// <returns></returns>
private string REDREMARK ( string REMARK ) {
private string REDREMARK ( string REMARK )
{
if ( REMARK . Length < = 88 ) return REMARK ;
else {
else
{
while ( ( REMARK . Length > 88 ) & & ( REMARK . IndexOf ( " " ) > = 0 ) )
while ( ( REMARK . Length > 88 ) & & ( REMARK . IndexOf ( " " ) > = 0 ) )
{
REMARK = REMARK . Replace ( " " , " " ) ;
REMARK = REMARK . Replace ( " " , " " ) ;
}
if ( REMARK . Length > 88 ) {
REMARK = REMARK . Replace ( "\n" , "" ) ;
if ( REMARK . Length > 88 )
{
REMARK = REMARK . Replace ( "\n" , "" ) ;
}
if ( REMARK . Length > 88 )
{
@ -1689,13 +1710,14 @@ namespace DSWeb.Areas.Account.Controllers
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
private DBResult checkCanPost ( ChInvoice_HangXin head ) {
var result = new DBResult ( true , "" , "" ) ;
private DBResult checkCanPost ( ChInvoice_HangXin head )
{
var result = new DBResult ( true , "" , "" ) ;
if ( string . IsNullOrEmpty ( head . INVOICECUSTNAME ) ) setErrorMessage ( ref result , "购方名称 不能为空" ) ;
if ( string . IsNullOrEmpty ( head . PUSHMOBILE ) ) setErrorMessage ( ref result , "推送的手机号码 不能为空" ) ;
var ErrorInfo = "销售方公司(我方公司)没有维护:" ;
var ErrorInfo = "销售方公司(我方公司)没有维护:" ;
var LocalErrorInfo = "销售方公司(我方公司)没有维护:" ;
if ( string . IsNullOrWhiteSpace ( head . TAXCODE ) )
{
@ -1787,7 +1809,8 @@ namespace DSWeb.Areas.Account.Controllers
private void setErrorMessage ( ref DBResult r , string message ) {
private void setErrorMessage ( ref DBResult r , string message )
{
r . setMessage ( false , message ) ;
}
@ -1807,11 +1830,11 @@ namespace DSWeb.Areas.Account.Controllers
{
DBResult result = ChinvoiceDAL . GetRemarksTemplate ( Convert . ToString ( Session [ "COMPANYID" ] ) , TemplateName ) ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message , Data = result . Data } ;
var jsonRespose = new JsonResponse { Success = result . Success , Message = result . Message , Data = result . Data } ;
return new ContentResult ( ) { Content = JsonConvert . Serialize ( jsonRespose ) } ;
}
public ContentResult SaveRemarksTemplate ( string Template , string TemplateName )
public ContentResult SaveRemarksTemplate ( string Template , string TemplateName )
{
DBResult result = ChinvoiceDAL . SaveRemarksTemplate ( Template , Convert . ToString ( Session [ "COMPANYID" ] ) , TemplateName ) ;
@ -1896,7 +1919,7 @@ namespace DSWeb.Areas.Account.Controllers
{
headData . DbOperationType = DbOperationType . DbotDel ;
}
if ( headData . TYPE = = "" ) headData . TYPE = "0" ;
if ( headData . TYPE = = "" ) headData . TYPE = "0" ;
var BILLNO = headData . GID ;
var modb = new ModelObjectDB ( ) ;
@ -2010,7 +2033,7 @@ namespace DSWeb.Areas.Account.Controllers
var _count = 0 ;
//(string TABLENAME,string _PKEY,string _sql,string DBNAME)
BaseTableMC fromdbbase = new BaseTableMC ( "M_INVOICE" , "INVOICE_ID" , "" , "P2DB" ) ;
BaseTableMC fromdbbase = new BaseTableMC ( "M_INVOICE" , "INVOICE_ID" , "" , "P2DB" ) ;
var dataList = DBTableConnDAL . getToList ( fromdbbase , "联力P2发票" , condition ) ;
@ -2048,8 +2071,10 @@ namespace DSWeb.Areas.Account.Controllers
var splitword = "\r\n" ;
if ( dataList . Count > 0 ) {
foreach ( var data in dataList ) {
if ( dataList . Count > 0 )
{
foreach ( var data in dataList )
{
var feenamearray = data . GetSplitField ( "FEENAME" , splitword ) ;
var amoutarray = data . GetSplitField ( "AMOUNT" , splitword ) ;
var PRICEarray = data . GetSplitField ( "PRICE" , splitword ) ;
@ -2058,7 +2083,8 @@ namespace DSWeb.Areas.Account.Controllers
if ( feenamearray . Length > 1 )
{
for ( var _i = 0 ; _i < feenamearray . Length ; _i + + ) {
for ( var _i = 0 ; _i < feenamearray . Length ; _i + + )
{
var resultdata = new BaseTableMC ( ) ;
resultdata . SetValue ( "CURRENCY" , data . GetValue ( "CURRENCY" ) ) ;
@ -2071,7 +2097,8 @@ namespace DSWeb.Areas.Account.Controllers
resultlist . Add ( resultdata ) ;
}
}
else {
else
{
resultlist . Add ( data ) ;
}
}
@ -2090,7 +2117,7 @@ namespace DSWeb.Areas.Account.Controllers
return new ContentResult ( ) { Content = json } ;
}
public ContentResult GetP2_CUST ( string condition = " isnull(invoice_no,'')='' " )
public ContentResult GetP2_CUST ( string condition = " isnull(invoice_no,'')='' " )
{
var canlogin = BasicDataRefDAL . CheckLogin ( Session ) ;
@ -2178,7 +2205,7 @@ namespace DSWeb.Areas.Account.Controllers
}
public ContentResult SaveNewP2 ( string opstatus , string data , string GID , string localdata )
public ContentResult SaveNewP2 ( string opstatus , string data , string GID , string localdata )
{
var headData = JsonConvert . Deserialize < ChInvoice_HangXin > ( data ) ;
@ -2186,7 +2213,7 @@ namespace DSWeb.Areas.Account.Controllers
BaseTableMC fromdbbase = new BaseTableMC ( "M_INVOICE" , "INVOICE_ID" , "" , "P2DB" ) ;
var P2DataList = DBTableConnDAL . getToList ( fromdbbase , "联力P2发票" , " INVOICE_ID='" + headData . BSNO + "'" ) ;
var P2DataList = DBTableConnDAL . getToList ( fromdbbase , "联力P2发票" , " INVOICE_ID='" + headData . BSNO + "'" ) ;
var bodyList = new List < ChInvoiceDetail > ( ) ;
@ -2194,7 +2221,8 @@ namespace DSWeb.Areas.Account.Controllers
var P2Data = new BaseTableMC ( ) ;
if ( P2DataList . Count ( ) > 0 ) {
if ( P2DataList . Count ( ) > 0 )
{
P2Data = P2DataList [ 0 ] ;
}
@ -2202,7 +2230,8 @@ namespace DSWeb.Areas.Account.Controllers
{
//查看是否已被使用 如是则返回错误并结束
var isexists = CheckExists ( " BSNO='" + headData . BSNO + "' " ) ;
if ( ! isexists . Success ) {
if ( ! isexists . Success )
{
return isexists . getContentReult ( ) ;
}
@ -2226,7 +2255,7 @@ namespace DSWeb.Areas.Account.Controllers
localData . DbOperationType = DbOperationType . DbotUpd ;
bodyList = ChinvoiceDAL . GetDetailList ( " PID='" + localData . GID + "' " ) ;
bodyList = ChinvoiceDAL . GetDetailList ( " PID='" + localData . GID + "' " ) ;
}
localData . SetP2Value ( P2Data ) ;
@ -2237,7 +2266,7 @@ namespace DSWeb.Areas.Account.Controllers
ChinvoiceDAL . DelInvDetail ( bodyList ) ;
}
SaveBodyList = ChInvoiceDetail . GetP2DetailList ( P2Data , ( localData . PTORRED = = "2" ) ) ;
SaveBodyList = ChInvoiceDetail . GetP2DetailList ( P2Data , ( localData . PTORRED = = "2" ) ) ;
var BILLNO = localData . BILLNO ;
var modb = new ModelObjectDB ( ) ;
@ -2262,10 +2291,11 @@ namespace DSWeb.Areas.Account.Controllers
Data = ChinvoiceDAL . GetData ( " BILLNO='" + BILLNO + "'" , Convert . ToString ( Session [ "USERID" ] ) , CookieConfig . GetCookie_UserCode ( Request ) , Convert . ToString ( Session [ "COMPANYID" ] ) )
} ;
return jsonRespose . getContentReult ( ) ;
return jsonRespose . getContentReult ( ) ;
}
private JsonResponse CheckExists ( string condition ) {
private JsonResponse CheckExists ( string condition )
{
var existsdata = ChinvoiceDAL . GetData ( condition ) ;
JsonResponse result = new JsonResponse ( ) ;
if ( ! string . IsNullOrWhiteSpace ( existsdata . GID ) )
@ -2273,7 +2303,8 @@ namespace DSWeb.Areas.Account.Controllers
result . Success = false ;
result . Message = "该发票已经被使用!" ;
}
else {
else
{
result . Success = true ;
}
return result ;