|
|
|
@ -29,6 +29,7 @@ using System.Configuration;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsCompanysDAL;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsChFeeDAL;
|
|
|
|
|
using DSWeb.MvcShipping.DAL.MsInfoClient;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
{
|
|
|
|
@ -3868,7 +3869,23 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult GetRemarksData(List<Chfee_do_detail> bodyList, string companyid, string billno, string templatename = "",string invdate="")
|
|
|
|
|
public static string GetInvTempSubStr(string html, string startstr, string endstr)
|
|
|
|
|
{
|
|
|
|
|
var subhtml = html;
|
|
|
|
|
var htmllength = subhtml.Length;
|
|
|
|
|
var startindex = subhtml.IndexOf(startstr);
|
|
|
|
|
//if (startindex == -1 || startindex == 0) return "";
|
|
|
|
|
if (startindex == -1) return "";
|
|
|
|
|
subhtml = subhtml.Substring(startindex + startstr.Length - 1);
|
|
|
|
|
var endindex = subhtml.IndexOf(endstr);
|
|
|
|
|
if (endindex != -1 && endindex != 0)
|
|
|
|
|
subhtml = subhtml.Substring(0, endindex + 1);
|
|
|
|
|
|
|
|
|
|
return subhtml;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult GetRemarksData(List<Chfee_do_detail> bodyList, string companyid, string billno, string templatename = "", string invdate = "", bool isapp = false)
|
|
|
|
|
{
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
if (templatename == "" || templatename == null) { templatename = "发票备注"; };
|
|
|
|
@ -3903,7 +3920,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
var INVGETNOWEXCHANGE = MsSysParamSetDAL.GetData("PARAMNAME='INVGETNOWEXCHANGE'").PARAMVALUE;
|
|
|
|
|
if (INVGETNOWEXCHANGE == "1")
|
|
|
|
|
{
|
|
|
|
|
var invratelist = MsChFeeDAL.GetFeeNowInvCurrList(invdate);
|
|
|
|
|
var invratelist = MsChFeeDAL.GetFeeNowInvCurrList(invdate, companyid);
|
|
|
|
|
if (invratelist != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var invrate in invratelist)
|
|
|
|
@ -3922,21 +3939,60 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
if (dsUserOp != null)
|
|
|
|
|
exrate = dsUserOp.Tables[0].Rows[0]["EXCHANGERATE"].ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var CUSTBANK = "";
|
|
|
|
|
var ACCOUNT = "";
|
|
|
|
|
var CUSTNAME = "";
|
|
|
|
|
if (isapp)
|
|
|
|
|
{
|
|
|
|
|
var head2 = ChinvoiceapplicationDAL.GetData("BILLNO='" + billno + "'");
|
|
|
|
|
CUSTBANK = head2.CUSTBANK;
|
|
|
|
|
if (!string.IsNullOrEmpty(head2.ACTUALCUSTOMERNAME))
|
|
|
|
|
CUSTNAME = head2.ACTUALCUSTOMERNAME;
|
|
|
|
|
else
|
|
|
|
|
CUSTNAME = head2.CUSTOMERNAME;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var head = GetData("BILLNO='" + billno + "'");
|
|
|
|
|
CUSTBANK = head.CUSTBANK;
|
|
|
|
|
ACCOUNT = head.ACCOUNT;
|
|
|
|
|
if (!string.IsNullOrEmpty(head.ACTUALCUSTOMERNAME))
|
|
|
|
|
CUSTNAME = head.ACTUALCUSTOMERNAME;
|
|
|
|
|
else
|
|
|
|
|
CUSTNAME = head.CUSTOMERNAME;
|
|
|
|
|
}
|
|
|
|
|
decimal rmbttl = 0;
|
|
|
|
|
decimal usdttl = 0;
|
|
|
|
|
decimal Allrmbttl = 0;
|
|
|
|
|
decimal Allusdttl = 0;
|
|
|
|
|
var str = templatestr;
|
|
|
|
|
var str = GetInvTempSubStr(templatestr, "《", "》");
|
|
|
|
|
var strl = "";
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
|
|
{
|
|
|
|
|
templatestr = templatestr.Replace(str, "《明细数据》");
|
|
|
|
|
str = str.Replace("《", "");
|
|
|
|
|
str = str.Replace("》", "");
|
|
|
|
|
|
|
|
|
|
str = str.Replace("\r\n", "\\");
|
|
|
|
|
str = str.Replace("\n", "\\");
|
|
|
|
|
str = str.Replace("\r", " ");
|
|
|
|
|
|
|
|
|
|
str = str.Replace("\r\n", "\\");
|
|
|
|
|
str = str.Replace("\n", "\\");
|
|
|
|
|
str = str.Replace("\r", " ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string[] StrList = str.Split('\\');
|
|
|
|
|
|
|
|
|
|
var custbank = "";
|
|
|
|
|
var custaccount = "";
|
|
|
|
|
if (CUSTBANK != null)
|
|
|
|
|
{
|
|
|
|
|
string[] custbanklist = CUSTBANK.Trim().Split(' ');
|
|
|
|
|
if (custbanklist.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
custbank = custbanklist[0];
|
|
|
|
|
custaccount = custbanklist[1];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var conn = db.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
@ -3964,38 +4020,42 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
|
|
|
|
|
str = StrList[i];
|
|
|
|
|
|
|
|
|
|
if (str.IndexOf("[外币金额(总计)]") < 0 && str.IndexOf("[人民币金额(总计)]") < 0 && str.IndexOf("[折算汇率(总计)]") < 0)
|
|
|
|
|
{
|
|
|
|
|
str = str.Replace("[委托编号]", enumValue.CUSTNO);
|
|
|
|
|
str = str.Replace("[主提单号]", enumValue.MBLNO);
|
|
|
|
|
str = str.Replace("[分提单号]", enumValue.HBLNO);
|
|
|
|
|
str = str.Replace("[委托单位]", enumValue.CUSTOMERNAME);
|
|
|
|
|
str = str.Replace("[开船日期]", enumValue.ETD);
|
|
|
|
|
str = str.Replace("[揽货人]", enumValue.SALE);
|
|
|
|
|
str = str.Replace("[船名]", enumValue.VESSEL);
|
|
|
|
|
str = str.Replace("[航次]", enumValue.VOYNO);
|
|
|
|
|
str = str.Replace("[装货港]", enumValue.PORTLOAD);
|
|
|
|
|
str = str.Replace("[卸货港]", enumValue.PORTDISCHARGE);
|
|
|
|
|
str = str.Replace("[目的港]", enumValue.DESTINATION);
|
|
|
|
|
str = str.Replace("[集装箱]", enumValue.CNTRTOTAL);
|
|
|
|
|
str = str.Replace("[订舱编号]", enumValue.ORDERNO);
|
|
|
|
|
|
|
|
|
|
str = str.Replace("[外币金额]", usdttl.ToString("#0.00"));
|
|
|
|
|
str = str.Replace("[人民币金额]", rmbttl.ToString("#0.00"));
|
|
|
|
|
//if (dsUserOp != null)
|
|
|
|
|
str = str.Replace("[折算汇率]", exrate);
|
|
|
|
|
//else
|
|
|
|
|
// str = str.Replace("[折算汇率]", "");
|
|
|
|
|
str = str.Replace("[外币金额(总计)]", "");
|
|
|
|
|
str = str.Replace("[人民币金额(总计)]", "");
|
|
|
|
|
str = str.Replace("[折算汇率(总计)]", "");
|
|
|
|
|
str = str.Replace("[委托编号]", enumValue.CUSTNO);
|
|
|
|
|
str = str.Replace("[主提单号]", enumValue.MBLNO);
|
|
|
|
|
str = str.Replace("[分提单号]", enumValue.HBLNO);
|
|
|
|
|
str = str.Replace("[委托单位]", enumValue.CUSTOMERNAME);
|
|
|
|
|
str = str.Replace("[订舱编号]", enumValue.ORDERNO);
|
|
|
|
|
str = str.Replace("[开船日期]", enumValue.ETD);
|
|
|
|
|
str = str.Replace("[揽货人]", enumValue.SALE);
|
|
|
|
|
str = str.Replace("[船名]", enumValue.VESSEL);
|
|
|
|
|
str = str.Replace("[航次]", enumValue.VOYNO);
|
|
|
|
|
str = str.Replace("[装货港]", enumValue.PORTLOAD);
|
|
|
|
|
str = str.Replace("[卸货港]", enumValue.PORTDISCHARGE);
|
|
|
|
|
str = str.Replace("[目的港]", enumValue.DESTINATION);
|
|
|
|
|
str = str.Replace("[集装箱]", enumValue.CNTRTOTAL);
|
|
|
|
|
str = str.Replace("[订舱编号]", enumValue.ORDERNO);
|
|
|
|
|
str = str.Replace("[业务发票号]", enumValue.INVNO);
|
|
|
|
|
|
|
|
|
|
str = str.Replace("[购方银行]", "");
|
|
|
|
|
str = str.Replace("[购方账号]", "");
|
|
|
|
|
str = str.Replace("[销方银行]", "");
|
|
|
|
|
|
|
|
|
|
str = str.Replace("[外币金额]", usdttl.ToString("#0.00"));
|
|
|
|
|
str = str.Replace("[人民币金额]", rmbttl.ToString("#0.00"));
|
|
|
|
|
//if (dsUserOp != null)
|
|
|
|
|
str = str.Replace("[折算汇率]", exrate);
|
|
|
|
|
//else
|
|
|
|
|
// str = str.Replace("[折算汇率]", "");
|
|
|
|
|
str = str.Replace("[外币金额(总计)]", "");
|
|
|
|
|
str = str.Replace("[人民币金额(总计)]", "");
|
|
|
|
|
str = str.Replace("[折算汇率(总计)]", "");
|
|
|
|
|
|
|
|
|
|
//if (strl == "") strl = str + Environment.NewLine;
|
|
|
|
|
//else strl = strl + str + Environment.NewLine;
|
|
|
|
|
if (strl == "") strl = str + " ";
|
|
|
|
|
else strl = strl + str + " ";
|
|
|
|
|
|
|
|
|
|
//if (strl == "") strl = str + Environment.NewLine;
|
|
|
|
|
//else strl = strl + str + Environment.NewLine;
|
|
|
|
|
if (strl == "") strl = str +" ";
|
|
|
|
|
else strl = strl + str +" ";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//rmbttl = rmbttl + enumValue.AMOUNT;
|
|
|
|
|
//if (enumValue.ORIGCURRENCY != "RMB")
|
|
|
|
@ -4003,40 +4063,89 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i <= StrList.Length - 1; i++)
|
|
|
|
|
//for (var i = 0; i <= StrList.Length - 1; i++)
|
|
|
|
|
//{
|
|
|
|
|
// str = StrList[i];
|
|
|
|
|
// if (str.IndexOf("[购方银行]") >= 0 || str.IndexOf("[购方账号]") >= 0 || str.IndexOf("[销方银行]") >= 0 || str.IndexOf("[外币金额(总计)]") >=0|| str.IndexOf("[人民币金额(总计)]") >= 0 && str.IndexOf("[折算汇率(总计)]") >= 0)
|
|
|
|
|
// {
|
|
|
|
|
// str = str.Replace("[委托编号]", "");
|
|
|
|
|
// str = str.Replace("[主提单号]", "");
|
|
|
|
|
// str = str.Replace("[委托单位]", "");
|
|
|
|
|
// str = str.Replace("[开船日期]", "");
|
|
|
|
|
// str = str.Replace("[订舱编号]", "");
|
|
|
|
|
// str = str.Replace("[揽货人]", "");
|
|
|
|
|
// str = str.Replace("[船名]", "");
|
|
|
|
|
// str = str.Replace("[航次]", "");
|
|
|
|
|
// str = str.Replace("[装货港]", "");
|
|
|
|
|
// str = str.Replace("[卸货港]", "");
|
|
|
|
|
// str = str.Replace("[目的港]", "");
|
|
|
|
|
// str = str.Replace("[外币金额]", "");
|
|
|
|
|
// str = str.Replace("[人民币金额]", "");
|
|
|
|
|
// str = str.Replace("[折算汇率]", "");
|
|
|
|
|
// str = str.Replace("[购方银行]", custbank);
|
|
|
|
|
// str = str.Replace("[购方账号]", custaccount);
|
|
|
|
|
// str = str.Replace("[销方银行]", ACCOUNT);
|
|
|
|
|
// str = str.Replace("[外币金额(总计)]", Allusdttl.ToString("#0.00"));
|
|
|
|
|
// str = str.Replace("[人民币金额(总计)]", Allrmbttl.ToString("#0.00"));
|
|
|
|
|
// //if (dsUserOp != null)
|
|
|
|
|
// // str = str.Replace("[折算汇率(总计)]", dsUserOp.Tables[0].Rows[0]["EXCHANGERATE"].ToString().Trim());
|
|
|
|
|
// //else
|
|
|
|
|
// // str = str.Replace("[折算汇率(总计)]", "");
|
|
|
|
|
// str = str.Replace("[折算汇率(总计)]", exrate);
|
|
|
|
|
// if (str.Trim() != "")
|
|
|
|
|
// strl = strl + str + " ";
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
templatestr = templatestr.Replace("《明细数据》", strl);
|
|
|
|
|
templatestr = templatestr.Replace("[购方银行]", custbank);
|
|
|
|
|
templatestr = templatestr.Replace("[购方账号]", custaccount);
|
|
|
|
|
templatestr = templatestr.Replace("[销方银行]", ACCOUNT);
|
|
|
|
|
templatestr = templatestr.Replace("[外币金额(总计)]", Allusdttl.ToString("#0.00"));
|
|
|
|
|
templatestr = templatestr.Replace("[人民币金额(总计)]", Allrmbttl.ToString("#0.00"));
|
|
|
|
|
//if (dsUserOp != null)
|
|
|
|
|
// str = str.Replace("[折算汇率(总计)]", dsUserOp.Tables[0].Rows[0]["EXCHANGERATE"].ToString().Trim());
|
|
|
|
|
//else
|
|
|
|
|
// str = str.Replace("[折算汇率(总计)]", "");
|
|
|
|
|
templatestr = templatestr.Replace("[折算汇率(总计)]", exrate);
|
|
|
|
|
|
|
|
|
|
var BANKLIST = MsInfoClientDAL.GetBankList(" LINKID in (select GID FROM info_client where SHORTNAME='" + CUSTNAME + "')");
|
|
|
|
|
var isusd = false;
|
|
|
|
|
var isrmb = false;
|
|
|
|
|
if (BANKLIST != null && BANKLIST.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
str = StrList[i];
|
|
|
|
|
if (str.IndexOf("[外币金额(总计)]") >=0|| str.IndexOf("[人民币金额(总计)]") >= 0 && str.IndexOf("[折算汇率(总计)]") >= 0)
|
|
|
|
|
foreach (var bank in BANKLIST)
|
|
|
|
|
{
|
|
|
|
|
str = str.Replace("[委托编号]", "");
|
|
|
|
|
str = str.Replace("[主提单号]", "");
|
|
|
|
|
str = str.Replace("[委托单位]", "");
|
|
|
|
|
str = str.Replace("[开船日期]", "");
|
|
|
|
|
str = str.Replace("[揽货人]", "");
|
|
|
|
|
str = str.Replace("[船名]", "");
|
|
|
|
|
str = str.Replace("[航次]", "");
|
|
|
|
|
str = str.Replace("[装货港]", "");
|
|
|
|
|
str = str.Replace("[卸货港]", "");
|
|
|
|
|
str = str.Replace("[目的港]", "");
|
|
|
|
|
str = str.Replace("[外币金额]", "");
|
|
|
|
|
str = str.Replace("[人民币金额]", "");
|
|
|
|
|
str = str.Replace("[折算汇率]", "");
|
|
|
|
|
str = str.Replace("[外币金额(总计)]", Allusdttl.ToString("#0.00"));
|
|
|
|
|
str = str.Replace("[人民币金额(总计)]", Allrmbttl.ToString("#0.00"));
|
|
|
|
|
//if (dsUserOp != null)
|
|
|
|
|
// str = str.Replace("[折算汇率(总计)]", dsUserOp.Tables[0].Rows[0]["EXCHANGERATE"].ToString().Trim());
|
|
|
|
|
//else
|
|
|
|
|
// str = str.Replace("[折算汇率(总计)]", "");
|
|
|
|
|
str = str.Replace("[折算汇率(总计)]", exrate);
|
|
|
|
|
if (str.Trim() != "")
|
|
|
|
|
strl = strl + str + " ";
|
|
|
|
|
if (!isusd && bank.CURRENCY == "USD")
|
|
|
|
|
{
|
|
|
|
|
templatestr = templatestr.Replace("[购方USD银行]", bank.BANKNAME);
|
|
|
|
|
templatestr = templatestr.Replace("[购方USD账号]", bank.ACCOUNT);
|
|
|
|
|
isusd = true;
|
|
|
|
|
}
|
|
|
|
|
if (!isrmb && bank.CURRENCY == "RMB")
|
|
|
|
|
{
|
|
|
|
|
templatestr = templatestr.Replace("[购方RMB银行]", bank.BANKNAME);
|
|
|
|
|
templatestr = templatestr.Replace("[购方RMB账号]", bank.ACCOUNT);
|
|
|
|
|
isrmb = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isusd)
|
|
|
|
|
{
|
|
|
|
|
templatestr = templatestr.Replace("[购方USD银行]", "");
|
|
|
|
|
templatestr = templatestr.Replace("[购方USD账号]", "");
|
|
|
|
|
}
|
|
|
|
|
if (!isrmb)
|
|
|
|
|
{
|
|
|
|
|
templatestr = templatestr.Replace("[购方RMB银行]", "");
|
|
|
|
|
templatestr = templatestr.Replace("[购方RMB账号]", "");
|
|
|
|
|
isrmb = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.Data = result.Data + strl;
|
|
|
|
|
result.Data = result.Data + templatestr;
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
|
|
|
}
|
|
|
|
@ -4057,12 +4166,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 导出发票
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string CreateInvList(List<ChInvoice> headList, string path)
|
|
|
|
|
{
|
|
|
|
|