|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Security;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.HtmlControls;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.Web.UI.WebControls.WebParts;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Settlements
|
|
|
|
|
{
|
|
|
|
|
public partial class DoReceiveAmountVerify : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
private string strBillNO;
|
|
|
|
|
private string strUserID;
|
|
|
|
|
private string strCompanyID;//公司GID
|
|
|
|
|
private string strShowName;//用户显示名
|
|
|
|
|
private string strDeptName;//部门名称
|
|
|
|
|
private string strFeeCache;
|
|
|
|
|
private string strCacheName;
|
|
|
|
|
private string strSettleCurrency;
|
|
|
|
|
private decimal usdToRmb;
|
|
|
|
|
private decimal rmbToUsd;
|
|
|
|
|
private string strVerifyCacheName;
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session["USERID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strUserID = Session["USERID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["SHOWNAME"] != null)
|
|
|
|
|
{
|
|
|
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["COMPANYID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["DEPTNAME"] != null)
|
|
|
|
|
{
|
|
|
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["verifycachename"] != null)
|
|
|
|
|
{
|
|
|
|
|
strVerifyCacheName = Request.QueryString["verifycachename"].ToString().Trim();
|
|
|
|
|
h_verifycache.Value = strVerifyCacheName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
if (this.txt_settleTime.Value.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq");//convert(char(10),getdate(),20)
|
|
|
|
|
this.txt_settleTime.Value = rq;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!h_enter.Value.Trim().Equals("1"))
|
|
|
|
|
{
|
|
|
|
|
if (Request.QueryString["obj"] != null)
|
|
|
|
|
{
|
|
|
|
|
strCacheName = Request.QueryString["obj"].ToString();
|
|
|
|
|
|
|
|
|
|
if (strCacheName != null)
|
|
|
|
|
{
|
|
|
|
|
if (Session[strCacheName] != null)
|
|
|
|
|
{
|
|
|
|
|
strFeeCache = Session[strCacheName].ToString();
|
|
|
|
|
Session.Remove(strCacheName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h_feecache.Value = strFeeCache;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InitDoSettlement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["currency"] != null)
|
|
|
|
|
{
|
|
|
|
|
strSettleCurrency = Request.QueryString["currency"].ToString();
|
|
|
|
|
h_settlecurrency.Value = strSettleCurrency;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["uex"] != null)
|
|
|
|
|
{
|
|
|
|
|
rmbToUsd = decimal.Parse(Request.QueryString["uex"].ToString());
|
|
|
|
|
h_rmbtousd.Value = rmbToUsd.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["rex"] != null)
|
|
|
|
|
{
|
|
|
|
|
usdToRmb = decimal.Parse(Request.QueryString["rex"].ToString());
|
|
|
|
|
h_usdtormb.Value = usdToRmb.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RecordSettleFee();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitDoSettlement()
|
|
|
|
|
{
|
|
|
|
|
txt_settleUser.Value = strShowName;
|
|
|
|
|
if (this.txt_settleTime.Value.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
string rq = T_ALL_DA.GetStrSQL("rq", "select getdate() as rq");//convert(char(10),getdate(),20)
|
|
|
|
|
this.txt_settleTime.Value = rq;
|
|
|
|
|
}
|
|
|
|
|
txt_billStatus.Value = "锁定";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int RecordSettleFee()
|
|
|
|
|
{
|
|
|
|
|
int billtype = 0;//结算类别:1收款,2付款。
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
string settleFee = "";
|
|
|
|
|
string settleTotal = "";
|
|
|
|
|
string customerName = "";
|
|
|
|
|
string recvAmountCache = "";
|
|
|
|
|
string strVerificationBillNO = "";
|
|
|
|
|
|
|
|
|
|
settleTotal = h_settleinfo.Value;
|
|
|
|
|
strFeeCache = h_feecache.Value;
|
|
|
|
|
recvAmountCache = h_recvamount.Value;
|
|
|
|
|
strVerificationBillNO = CreateVerifyInvoiceCode();
|
|
|
|
|
if (strFeeCache.IndexOf("[") >= 0 && strFeeCache.IndexOf("]") > 0)
|
|
|
|
|
{
|
|
|
|
|
strBillNO = CreateSettleCode();
|
|
|
|
|
settleFee = strFeeCache.Substring(strFeeCache.IndexOf("[") + 1, strFeeCache.IndexOf("]") - strFeeCache.IndexOf("[") - 1);
|
|
|
|
|
|
|
|
|
|
IList<FeeDoEntity> feeDoEntities = new List<FeeDoEntity>();
|
|
|
|
|
|
|
|
|
|
//settleFee = settleFee.Replace(, "#");
|
|
|
|
|
string[] strFees = settleFee.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
if (strFees.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < strFees.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("{", "");
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("}", "");
|
|
|
|
|
string[] strCell = strFees[i].Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (strCell.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
FeeDoEntity feeDoEntity = new FeeDoEntity();
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "id":
|
|
|
|
|
feeDoEntity.FeeID = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "type":
|
|
|
|
|
feeDoEntity.FeeType = int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
billtype = feeDoEntity.FeeType;
|
|
|
|
|
break;
|
|
|
|
|
case "cur":
|
|
|
|
|
feeDoEntity.Currency = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "stl":
|
|
|
|
|
feeDoEntity.Amount = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "cstl":
|
|
|
|
|
feeDoEntity.DoAmount = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "ustl":
|
|
|
|
|
break;
|
|
|
|
|
case "cus":
|
|
|
|
|
if (customerName.Equals(""))
|
|
|
|
|
{
|
|
|
|
|
customerName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
this.txt_customerName.Value = customerName;
|
|
|
|
|
}
|
|
|
|
|
feeDoEntity.CustomerName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "fname":
|
|
|
|
|
feeDoEntity.FeeName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "bsno":
|
|
|
|
|
feeDoEntity.BSNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "orig":
|
|
|
|
|
if (!strArg[1].ToString().Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
feeDoEntity.Orig = int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "oname":
|
|
|
|
|
if (!strArg[1].ToString().Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
feeDoEntity.OriginalFeeName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "ocstl":
|
|
|
|
|
if (!strArg[1].ToString().Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
feeDoEntity.OriginalFeeCSTL = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//feeDoEntity.BSNO = "";
|
|
|
|
|
feeDoEntity.MBLNO = "";
|
|
|
|
|
feeDoEntity.HBLNO = "";
|
|
|
|
|
//feeDoEntity.CustomerName = "";
|
|
|
|
|
//feeDoEntity.FeeName = "";
|
|
|
|
|
feeDoEntity.BillNO = strBillNO;
|
|
|
|
|
feeDoEntity.GID = Guid.NewGuid().ToString();
|
|
|
|
|
feeDoEntity.Category = 2;
|
|
|
|
|
feeDoEntity.BSType = 1;
|
|
|
|
|
feeDoEntity.BillStatus = 1;
|
|
|
|
|
feeDoEntity.Remark = "";
|
|
|
|
|
|
|
|
|
|
feeDoEntities.Add(feeDoEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (feeDoEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
IList<FeeSettlementEntity> feeSettlementEntities = new List<FeeSettlementEntity>();
|
|
|
|
|
|
|
|
|
|
FeeSettlementEntity feeSettlementEntity = new FeeSettlementEntity();
|
|
|
|
|
feeSettlementEntity.GID = Guid.NewGuid().ToString();
|
|
|
|
|
|
|
|
|
|
if (settleTotal != "")
|
|
|
|
|
{
|
|
|
|
|
string tempSettle = settleTotal.Substring(settleTotal.IndexOf("[") + 1, settleTotal.IndexOf("]") - settleTotal.IndexOf("[") - 1);
|
|
|
|
|
string[] tempSettleFees = tempSettle.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
if (tempSettleFees.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < tempSettleFees.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
tempSettleFees[i] = tempSettleFees[i].ToString().Replace("{", "");
|
|
|
|
|
tempSettleFees[i] = tempSettleFees[i].ToString().Replace("}", "");
|
|
|
|
|
string[] strCell = tempSettleFees[i].Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (strCell.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
string strCurrency = "";
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "id":
|
|
|
|
|
//feeSettlementEntity.GID = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "cur":
|
|
|
|
|
strCurrency = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "amount":
|
|
|
|
|
if (strCurrency.Equals("RMB"))
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.AmountRMB = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
}
|
|
|
|
|
else if (strCurrency.Equals("USD"))
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.AmountUSD = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "account":
|
|
|
|
|
if (strCurrency.Equals("RMB"))
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.AccountRMB = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
}
|
|
|
|
|
else if (strCurrency.Equals("USD"))
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.AccountUSD = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "bank":
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (tempSettleFees.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.Rate = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (feeSettlementEntity.AmountRMB > 0)
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.Rate = decimal.Parse(h_usdtormb.Value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.Rate = decimal.Parse(h_rmbtousd.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IList<VerificationEntity> verificationEntities = new List<VerificationEntity>();
|
|
|
|
|
IList<ReceiveAmountEntity> receiveAmountEntities = new List<ReceiveAmountEntity>();
|
|
|
|
|
|
|
|
|
|
if (recvAmountCache != "")
|
|
|
|
|
{
|
|
|
|
|
string tempSettle = recvAmountCache.Substring(recvAmountCache.IndexOf("[") + 1, recvAmountCache.IndexOf("]") - recvAmountCache.IndexOf("[") - 1);
|
|
|
|
|
string[] tempSettleFees = tempSettle.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
if (tempSettleFees.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < tempSettleFees.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ReceiveAmountEntity receiveAmountEntity = new ReceiveAmountEntity();
|
|
|
|
|
VerificationEntity verificationEntity = new VerificationEntity();
|
|
|
|
|
tempSettleFees[i] = tempSettleFees[i].ToString().Replace("{", "");
|
|
|
|
|
tempSettleFees[i] = tempSettleFees[i].ToString().Replace("}", "");
|
|
|
|
|
string[] strCell = tempSettleFees[i].Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (strCell.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "id":
|
|
|
|
|
receiveAmountEntity.GID = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
verificationEntity.RecvAmountGID = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "cur":
|
|
|
|
|
receiveAmountEntity.Currency = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "cstl":
|
|
|
|
|
receiveAmountEntity.DoAmount = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "ustl":
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
receiveAmountEntity.SettleUser = strUserID;
|
|
|
|
|
receiveAmountEntities.Add(receiveAmountEntity);
|
|
|
|
|
|
|
|
|
|
verificationEntity.GID = Guid.NewGuid().ToString();
|
|
|
|
|
verificationEntity.SettleUser = strUserID;
|
|
|
|
|
verificationEntity.BillNO = strVerificationBillNO;
|
|
|
|
|
verificationEntities.Add(verificationEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (feeSettlementEntity.AccountUSD == null)
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.AccountUSD = "";
|
|
|
|
|
}
|
|
|
|
|
if (feeSettlementEntity.AccountRMB == null)
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.AccountRMB = "";
|
|
|
|
|
}
|
|
|
|
|
//预收预付自由结算时,赋值
|
|
|
|
|
feeSettlementEntity.ACCOUNTS_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//记账资料_币别
|
|
|
|
|
feeSettlementEntity.ACCOUNTS_RATE = feeSettlementEntity.Rate;//记账资料_汇率
|
|
|
|
|
feeSettlementEntity.ACCOUNTS_MONEY = (feeSettlementEntity.AmountUSD == 0) ? feeSettlementEntity.AmountRMB : feeSettlementEntity.AmountUSD;//记账资料_金额
|
|
|
|
|
feeSettlementEntity.PREPAY_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//预付支资料_币别
|
|
|
|
|
feeSettlementEntity.PREPAY_RATE = feeSettlementEntity.Rate;//预付支资料_汇率
|
|
|
|
|
feeSettlementEntity.PREPAY_MONEY = 0;//预付支资料_金额
|
|
|
|
|
feeSettlementEntity.AHSR_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//实付支资料_币别
|
|
|
|
|
feeSettlementEntity.AHSR_RATE = feeSettlementEntity.Rate;//实付支资料_汇率
|
|
|
|
|
feeSettlementEntity.AHSR_MONEY = (feeSettlementEntity.AmountUSD == 0) ? feeSettlementEntity.AmountRMB : feeSettlementEntity.AmountUSD;//实付支资料_金额
|
|
|
|
|
feeSettlementEntity.FINANCIAL_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//财务费用_币别
|
|
|
|
|
feeSettlementEntity.FINANCIAL_RATE = feeSettlementEntity.Rate;//财务费用_汇率
|
|
|
|
|
feeSettlementEntity.FINANCIAL_MONEY = 0;//财务费用_金额
|
|
|
|
|
feeSettlementEntity.ADVANCE_CURRENCY = (feeSettlementEntity.AmountUSD == 0) ? "RMB" : "USD";//预付支取用资料_币别
|
|
|
|
|
feeSettlementEntity.ADVANCE_RATE = feeSettlementEntity.Rate;//预付支取用资料_汇率
|
|
|
|
|
feeSettlementEntity.ADVANCE_MONEY = 0;//预付支取用资料_金额
|
|
|
|
|
//
|
|
|
|
|
feeSettlementEntity.BillNO = strBillNO;
|
|
|
|
|
feeSettlementEntity.BillType = billtype;//由feeDoEntity.FeeType决定
|
|
|
|
|
feeSettlementEntity.VoucherNO = txt_voucherNO.Value.Trim();
|
|
|
|
|
feeSettlementEntity.SettleUser = strUserID;//txt_settleUser.Value.Trim();
|
|
|
|
|
if (this.txt_settleTime.Value.Trim() != "" && this.txt_settleTime.Value.Trim().IndexOf("0001") < 0)
|
|
|
|
|
{
|
|
|
|
|
feeSettlementEntity.SettleTime = DateTime.Parse(this.txt_settleTime.Value.Trim());
|
|
|
|
|
}
|
|
|
|
|
feeSettlementEntity.BillStatus = 1;
|
|
|
|
|
feeSettlementEntity.SettleMode = 2;//自由结算
|
|
|
|
|
feeSettlementEntity.FinancialVoucher = "";
|
|
|
|
|
feeSettlementEntity.CustomerName = customerName;//结算单位
|
|
|
|
|
feeSettlementEntity.SettleType = int.Parse(this.sel_settlemode.Value);
|
|
|
|
|
feeSettlementEntity.Remark = txt_remark.Value.Trim();
|
|
|
|
|
feeSettlementEntity.ChequeNo = "";
|
|
|
|
|
feeSettlementEntity.ChequeNoUsd = "";
|
|
|
|
|
feeSettlementEntity.CompanyID = strCompanyID;
|
|
|
|
|
feeSettlementEntities.Add(feeSettlementEntity);
|
|
|
|
|
|
|
|
|
|
FeeDoDA feeDoDA = new FeeDoDA();
|
|
|
|
|
iResult = feeDoDA.DoVerifyRecvAmountByRecvSettle(feeDoEntities, feeSettlementEntities, receiveAmountEntities, verificationEntities);
|
|
|
|
|
if (iResult == 1)
|
|
|
|
|
{
|
|
|
|
|
txt_billNO.Value = feeSettlementEntities[0].BillNO;
|
|
|
|
|
h_billno.Value = feeSettlementEntities[0].BillNO;
|
|
|
|
|
this.btn_enter.Disabled = true;
|
|
|
|
|
h_enter.Value = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string CreateSettleCode()
|
|
|
|
|
{
|
|
|
|
|
int CodeLength = 4;
|
|
|
|
|
string strSettleCode = "";
|
|
|
|
|
|
|
|
|
|
//获取分公司的票号头字符
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
|
|
string strFeeType = tempBANKSHEAD+"DR";
|
|
|
|
|
FeeDoDA feeDoDA = new FeeDoDA();
|
|
|
|
|
DateTime nowDateTime = feeDoDA.getServerDateTime();
|
|
|
|
|
|
|
|
|
|
string strYear = nowDateTime.Year.ToString();
|
|
|
|
|
string strMonth = nowDateTime.Month.ToString().Length < 2 ? "0" + nowDateTime.Month.ToString() : nowDateTime.Month.ToString();
|
|
|
|
|
//string strDay = nowDateTime.Day.ToString();
|
|
|
|
|
string strDateTime = strYear + strMonth;
|
|
|
|
|
string strCodePrefix = strFeeType + strDateTime;
|
|
|
|
|
|
|
|
|
|
string strSql = "SELECT TOP 1 BILLNO FROM ch_fee_do WHERE BILLNO LIKE '" + strFeeType + strDateTime + "%' ORDER BY BILLNO DESC";
|
|
|
|
|
DataTable billTable = feeDoDA.GetExcuteSql(strSql).Tables[0];
|
|
|
|
|
|
|
|
|
|
ArrayList codeArg = new ArrayList();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < CodeLength; i++)
|
|
|
|
|
{
|
|
|
|
|
codeArg.Add(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string strCode = "";//编号
|
|
|
|
|
|
|
|
|
|
if (billTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string oldCode = billTable.Rows[0][0].ToString();
|
|
|
|
|
|
|
|
|
|
if (oldCode.IndexOf(strCodePrefix) >= 0)
|
|
|
|
|
{
|
|
|
|
|
oldCode = oldCode.Substring(strCodePrefix.Length, oldCode.Length - strCodePrefix.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (oldCode.Length == CodeLength)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < oldCode.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (oldCode[i].ToString().IndexOf("0") == 0)
|
|
|
|
|
{
|
|
|
|
|
oldCode = oldCode.Remove(i, 1);
|
|
|
|
|
i = -1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int newNum = int.Parse(oldCode);
|
|
|
|
|
|
|
|
|
|
newNum = newNum + 1;
|
|
|
|
|
|
|
|
|
|
string strNewNum = newNum.ToString();
|
|
|
|
|
|
|
|
|
|
int codeArgCount = codeArg.Count - 1;
|
|
|
|
|
for (int i = strNewNum.Length - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
codeArg[codeArgCount] = strNewNum[i];
|
|
|
|
|
codeArgCount--;
|
|
|
|
|
}
|
|
|
|
|
//for (int i = 0; i < strNewNum.Length; i++)
|
|
|
|
|
//{
|
|
|
|
|
// codeArg[i] = strNewNum[i];
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int iOld = int.Parse(codeArg[codeArg.Count - 1].ToString());
|
|
|
|
|
codeArg[codeArg.Count - 1] = (iOld + 1).ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < codeArg.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
strCode += codeArg[i].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strSettleCode = strFeeType + strDateTime + strCode;
|
|
|
|
|
return strSettleCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string CreateVerifyInvoiceCode()
|
|
|
|
|
{
|
|
|
|
|
int CodeLength = 4;
|
|
|
|
|
string strSettleCode = "";
|
|
|
|
|
|
|
|
|
|
//获取分公司的票号头字符
|
|
|
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
|
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
|
|
string strFeeType = tempBANKSHEAD+"CV";
|
|
|
|
|
FeeDoDA feeDoDA = new FeeDoDA();
|
|
|
|
|
DateTime nowDateTime = feeDoDA.getServerDateTime();
|
|
|
|
|
|
|
|
|
|
string strYear = nowDateTime.Year.ToString();
|
|
|
|
|
string strMonth = nowDateTime.Month.ToString().Length < 2 ? "0" + nowDateTime.Month.ToString() : nowDateTime.Month.ToString();
|
|
|
|
|
//string strDay = nowDateTime.Day.ToString();
|
|
|
|
|
string strDateTime = strYear + strMonth;
|
|
|
|
|
string strCodePrefix = strFeeType + strDateTime;
|
|
|
|
|
|
|
|
|
|
string strSql = "SELECT TOP 1 BILLNO FROM ch_fee_do WHERE BILLNO LIKE '" + strFeeType + strDateTime + "%' ORDER BY BILLNO DESC";
|
|
|
|
|
DataTable billTable = feeDoDA.GetExcuteSql(strSql).Tables[0];
|
|
|
|
|
|
|
|
|
|
ArrayList codeArg = new ArrayList();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < CodeLength; i++)
|
|
|
|
|
{
|
|
|
|
|
codeArg.Add(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string strCode = "";//编号
|
|
|
|
|
|
|
|
|
|
if (billTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string oldCode = billTable.Rows[0][0].ToString();
|
|
|
|
|
|
|
|
|
|
if (oldCode.IndexOf(strCodePrefix) >= 0)
|
|
|
|
|
{
|
|
|
|
|
oldCode = oldCode.Substring(strCodePrefix.Length, oldCode.Length - strCodePrefix.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (oldCode.Length == CodeLength)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < oldCode.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (oldCode[i].ToString().IndexOf("0") == 0)
|
|
|
|
|
{
|
|
|
|
|
oldCode = oldCode.Remove(i, 1);
|
|
|
|
|
i = -1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int newNum = int.Parse(oldCode);
|
|
|
|
|
|
|
|
|
|
newNum = newNum + 1;
|
|
|
|
|
|
|
|
|
|
string strNewNum = newNum.ToString();
|
|
|
|
|
|
|
|
|
|
int codeArgCount = codeArg.Count - 1;
|
|
|
|
|
for (int i = strNewNum.Length - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
codeArg[codeArgCount] = strNewNum[i];
|
|
|
|
|
codeArgCount--;
|
|
|
|
|
}
|
|
|
|
|
//for (int i = 0; i < strNewNum.Length; i++)
|
|
|
|
|
//{
|
|
|
|
|
// codeArg[i] = strNewNum[i];
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int iOld = int.Parse(codeArg[codeArg.Count - 1].ToString());
|
|
|
|
|
codeArg[codeArg.Count - 1] = (iOld + 1).ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < codeArg.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
strCode += codeArg[i].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strSettleCode = strFeeType + strDateTime + strCode;
|
|
|
|
|
return strSettleCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string UnicodeToGB(string text)
|
|
|
|
|
{
|
|
|
|
|
MatchCollection mc = Regex.Matches(text, "([\\w]+)|(\\\\u([\\w]{4}))");
|
|
|
|
|
if (mc != null && mc.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (Match m2 in mc)
|
|
|
|
|
{
|
|
|
|
|
string v = m2.Value;
|
|
|
|
|
if (v.IndexOf("\\") >= 0)
|
|
|
|
|
{
|
|
|
|
|
string word = v.Substring(2);
|
|
|
|
|
byte[] codes = new byte[2];
|
|
|
|
|
int code = Convert.ToInt32(word.Substring(0, 2), 16);
|
|
|
|
|
int code2 = Convert.ToInt32(word.Substring(2), 16);
|
|
|
|
|
codes[0] = (byte)code2;
|
|
|
|
|
codes[1] = (byte)code;
|
|
|
|
|
sb.Append(Encoding.Unicode.GetString(codes));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|