c#之tcbs 列印憑證示例
//**************************************************************************//
//**************** 資金型別處理 ***************************//
//**************************************************************************//
private bool ProcessFundGrid(long clearingAcctNumber, long deductSchedNbr, long? submNbrToCopy, string deductSubOrgNbr)//
{
if (base.ExceptionList.Count <= 0)
{
string rtxnTranTypeCode = string.Empty;
decimal availaibleSubAcctBalance = decimal.MinValue;
decimal glavailaibleSubAcctBalance = 0M;
string rtxnTypeCode = string.Empty;
string intlRtxnDesc = string.Empty;
bool isCopy = this._formMode == FormMode.Copy;
if ((((base.ActiveTask != null) && (base.ActiveTask.ActiveAccount != null)) && (base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"] != null)) && (this.txtAmount.Value != null))
{
decimal totCash = 0M;
//是否超過最大限額的判斷--start
if (base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].OrigBal.HasValue)
{
availaibleSubAcctBalance = base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].OrigBal.Value;
}
else
{
availaibleSubAcctBalance = 0M;
}
if ((this.txtAmount.Value + availaibleSubAcctBalance) > 999999999999999.99M)
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "賬戶餘額{0} 與交易金額{1} 之和已超過最大限額【999,999,999,999,999.99】", new object[] { FI.FormatCurrency(availaibleSubAcctBalance), FI.FormatCurrency((decimal)this.txtAmount.Value) });
return false;
}
//是否超過最大限額的判斷--end
//if (base.ActiveTask.ActiveAccount.CurrAcctStatCd == "APPR")
//{
// rtxnTypeCode = "NA";
//}
//交易型別
rtxnTypeCode = "PAYD";//
Rtxn rtxn = Rtxn.NewRtxn(new long?(base.ActiveTask.ActiveAccount.AcctNbr.Value), rtxnTypeCode);
//現金箱
if (CoreUser.CashboxNbr != long.MinValue)
{
rtxn.CashboxNbr = CoreUser.CashboxNbr;
}
//生效日期
if (this.calDepositEffectiveDate.SelectedDate.HasValue)
{
rtxn.EffectiveDate = this.calDepositEffectiveDate.SelectedDate.Value;
}
//交易發生額
if (this.txtAmount.Text != null)
{
rtxn.TranAmt = decimal.Parse(this.txtAmount.Text);
}
//交易子賬號
rtxn.HoldSubAcctNbr = base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].SubAcctNbr;
//資金列表的判斷
for (int iCount = 0; iCount < this.grdFundGrid.Funds.Count; iCount++)
{
if (!((this.grdFundGrid.Funds[iCount].Amt != 0M) && this.grdFundGrid.Funds[iCount].Amt.HasValue))
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "金額無效", new object[0]);
return false;
}
if (this.grdFundGrid.Funds[iCount].FundTypCd == null)
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "資金型別不可為空", new object[0]);
return false;
}
if (this.grdFundGrid.Funds[iCount].FundTypCd == "CASH")
{
totCash += this.grdFundGrid.Funds[iCount].Amt.Value;
}
if (!this.grdFundGrid.Funds[iCount].ParentRtxnIsNull)
{
rtxnTranTypeCode = this.grdFundGrid.Funds[iCount].ParentRtxn.RtxnTypCd;
}
if ((!this.grdFundGrid.Funds[iCount].AcctNbr.HasValue && (rtxnTranTypeCode != string.Empty)) && (rtxnTranTypeCode != null))
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "賬號不可為空.", new object[0]);
return false;
}
string wthacctnbr = string.Empty;
string wthacctorgnbr = string.Empty;
this.approvepersnbr = long.MinValue;
wthacctnbr = this.grdFundGrid.WthAccount;
if (wthacctnbr != string.Empty)
{
if (this._contractAcctNbr.ToString() != wthacctnbr)
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "劃款賬戶不是簽約賬戶!");
return false;
}
Acct acctOrgNbr = Acct.GetAcct(long.Parse(wthacctnbr), new object[] { AcctFetch.Basic });
//20110417--款項有內部賬劃出時加授權頁面
if (acctOrgNbr.MjAcctType.ToString() == "GL")
{
////判斷取款賬戶內是否有足夠的資金
//if (acctOrgNbr.SubAccounts["NOTE", "BAL"].BalanceHistoryIsNull==false)
//{
// glavailaibleSubAcctBalance = decimal.Parse(acctOrgNbr.GetAvailableFunds(acctOrgNbr.SubAccounts["NOTE", "BAL"].SubAcctNbr.Value).ToString());
//}
//else
//{
// glavailaibleSubAcctBalance = 0M;
//}
//判斷取款賬戶內是否有足夠的資金
try
{
glavailaibleSubAcctBalance = decimal.Parse(acctOrgNbr.GetAvailableFunds(acctOrgNbr.SubAccounts["NOTE", "BAL"].SubAcctNbr.Value).ToString());
}
catch (Exception ex)
{
glavailaibleSubAcctBalance = 0M;
}
if (glavailaibleSubAcctBalance > (decimal?)(this.txtAmount.Value * -1M))
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "此內部戶內餘額不足!");
return false;
}
if (!this.InvokeOverrideScreen(0x185L))
{
return false;
}
}
}
//交易描述
if (CalcTypVarValue.BankVariables["BANK", "TRAN", CoreUser.PostingDate] != null)
{
CalcTypVarValue calcTypVarValue = CalcTypVarValue.BankVariables["BANK", "TRAN", CoreUser.PostingDate];
if ((calcTypVarValue.CalcVarValue == "Y") && (((rtxnTypeCode == "PAYD") && ((rtxnTranTypeCode == "WTH") || (rtxnTranTypeCode == "GLD"))) && (Math.Abs(this.grdFundGrid.Funds[iCount].Amt.Value) == Math.Abs(this.grdFundGrid.TotalAmount))))
{
intlRtxnDesc = "Transfer from " + this.grdFundGrid.Funds[iCount].AcctNbr.ToString();
}
}
//子交易的新增
rtxn.AddFund(this.grdFundGrid.Funds[iCount].FundTypCd, this.grdFundGrid.Funds[iCount].FundTypDtlCd, this.grdFundGrid.Funds[iCount].ClearCatCd, this.grdFundGrid.Funds[iCount].Amt, this.grdFundGrid.Funds[iCount].NbrOfItems);
}
rtxn.AddBalance(base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].SubAcctNbr, "NOTE", "BAL", (decimal?)(this.txtAmount.Value * -1M));//20110321將【RTXNBAL】表中變為負數
rtxn.InternalDescription = intlRtxnDesc;
long? numberOfItems = long.MinValue;
RtxnCollection rtxnCollection = this.grdFundGrid.ChildTrxns;
//string strCheckNbr = string.Empty;
//string[] strArrayCheckNbr;
bool flag = false;
foreach (Rtxn rtxnChild in rtxnCollection)
{
//if (rtxnChild.CheckNbr != null)
//{
// strCheckNbr = strCheckNbr + rtxnChild.CheckNbr.ToString() + ";";
//}
if (rtxnChild.RtxnFundTyps.Count > 0)
{
//strCheckNbr = rtxnChild.CheckNbr.ToString();
long? nbrOfItemsTemp = rtxnChild.RtxnFundTyps[0].NbrOfItems;
if (!nbrOfItemsTemp.HasValue || nbrOfItemsTemp.GetValueOrDefault() <= 0L)
{
numberOfItems = 1L;
}
else
{
numberOfItems = rtxnChild.RtxnFundTyps[0].NbrOfItems;
}
rtxn.ChildRtxns.Add(rtxnChild);
}
}
////重複支票號的判斷
//if (strCheckNbr.Length > 0)
//{
// strArrayCheckNbr = strCheckNbr.Split(';');
// if (strArrayCheckNbr.Length > 1)
// {
// CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "轉賬失敗!批次入賬一次只能使用一張轉賬支票!");
// return false;
// }
// for (int i = 0; i < strArrayCheckNbr.Length - 1; i++)
// {
// for (int j = i + 1; j < strArrayCheckNbr.Length; j++)
// {
// if (strArrayCheckNbr[i] == strArrayCheckNbr[j])
// {
// flag = true;
// break;
// }
// }
// }
// if (flag)
// {
// CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "發現重複的支票號,轉賬失敗!");
// return false;
// }
//}
rtxn.SetupDeposit(RtxnValidator.Deposit);
DeductSchedSubmProcessor deductSchedSubmProcessor = new DeductSchedSubmProcessor();
try
{
if (rtxn != null)
{
deductSchedSubmProcessor.PostOptionalCopy(rtxn, deductSchedNbr, clearingAcctNumber, this.calSubmissionEffectiveDate.SelectedDate, isCopy, false, submNbrToCopy);
deductSchedSubmProcessor = deductSchedSubmProcessor.Save(base.ActvCatCd, base.ActvTypCd) as DeductSchedSubmProcessor;
rtxn = deductSchedSubmProcessor.RtxnObj;
}
}
catch (CoreTransactionException tExcp)
{
if (rtxn != null)
{
frmOverride verrideFrm = new frmOverride(tExcp.Transaction);
if (overrideFrm.ShowDialog(this) == DialogResult.Cancel)
{
return false;
}
rtxn.ApproverPersNbr = overrideFrm.PersNbr;
deductSchedSubmProcessor.PostOptionalCopy(rtxn, deductSchedNbr, clearingAcctNumber, this.calSubmissionEffectiveDate.SelectedDate, isCopy, true, submNbrToCopy);
deductSchedSubmProcessor = deductSchedSubmProcessor.Save(base.ActvCatCd, base.ActvTypCd) as DeductSchedSubmProcessor;
rtxn = deductSchedSubmProcessor.RtxnObj;
}
}
if (totCash > 0M)
{
TxnCashCount.ClearCashCounts();
TxnCashCount.IsRtxn = true;
TxnCashCount.TxnTypCd = rtxn.RtxnTypCd;
TxnCashCount.AcctNbr = rtxn.Account.AcctNbr.Value;
TxnCashCount.CashboxNbr = CoreUser.CashboxNbr;
TxnCashCount.TxnNbr = rtxn.RtxnNbr.Value;
TxnCashCount.RequestAmount = totCash;
TxnCashCount.DispenseOrCashCount();
TxnCashCount.CallCashCount();
}
if (deductSchedSubmProcessor.ErrorNbr <= 0)
{
this.PopulateGrid();
//列印憑證的方法
PrePrint(rtxn, rtxnCollection, deductSchedNbr.ToString().PadLeft(8, '0'), deductSchedSubmProcessor.SubmdNbr.ToString(), approvepersnbr);
}
return true;
}
}
return false;
}
//**************************************************************************//
//**************** 轉賬支票取款時列印憑條 ***************************//
//**************************************************************************//
private void PrePrint(Rtxn rtxn, RtxnCollection childRtxn, string deductSchedNbr, string submdNbr, long approvepersnbr)
{
string rgAcctnbr = null;//付款人賬號
string rgName = null;//付款人名稱
string rgChecknbr = null;//轉賬支票號
Acct rgAcct = null;
string resultString = string.Empty;
if ((childRtxn != null) && (childRtxn[0].CheckNbr.ToString() != null) && (childRtxn[0].CheckNbr.ToString() != ""))
{
resultString = CoreMessageBox.Show(new string[] { "確定" }, 0L, "請插入支票背面,按確定按鈕開始列印", new object[0]);
}
else
{
resultString = CoreMessageBox.Show(new string[] { "確定" }, 0L, "請插入通用業務憑證,按確定按鈕開始列印", new object[0]);
}
if (resultString == "確定")
{
try
{
//子交易(透過轉賬支票從單位賬戶取款)
if (childRtxn != null)
{
Rtxn rtxnChild = childRtxn[0];
rgAcct = Acct.GetAcct(rtxnChild.AcctNbr, new object[] { 0L });
if ((orgAcct != null) && (orgAcct.MjAcctTypCd.ToString() == "GL"))
{
rgAcctnbr = rtxnChild.AcctNbr.ToString();
//orgName = orgAcct.BranchOrg.OrgName;//透過內部戶轉到清算賬戶
rgName = GlAcctTitle.GetDecodeGLAccttitl(rtxnChild.AcctNbr, new object[] { }).GlAcctTitleName.ToString();//
}
else
{
rgAcctnbr = rtxnChild.MediumId; //單位帳號
if (orgAcct != null && orgAcct.TaxRptForOrgNbr.HasValue && (orgAcct.TaxRptForOrgNbr.Value > 0L))
{
rgName = orgAcct.TaxRptForOrganization.OrgName; //單位名稱
}
else
{
rgName = ""; //單位名稱
}
}
rgChecknbr = rtxnChild.CheckNbr.ToString(); //轉賬支票號
}
else
{
CoreMessageBox.Show("沒有需要列印的交易!");
return;
}
System.Collections.Hashtable ht = new System.Collections.Hashtable();
ht.Add("serialNumber", string.Concat(rtxn.AcctNbr, rtxn.RtxnNbr)); //交易流水號
ht.Add("tranType", "(代發工資)批次入賬"); //交易型別
RtxnStatHist _rtxnStatHist = RtxnStatHist.GetRtxnStatHist(rtxn.AcctNbr, rtxn.RtxnNbr, new object[] { RtxnStatHistFetch.TransDetail });
if (_rtxnStatHist != null)
{
ht.Add("tranDate", _rtxnStatHist.PostDate.Value.ToString("yyyy-MM-dd")); //交易記賬日期
ht.Add("tranTime", ((DateTime)_rtxnStatHist.ActDateTime).ToString("HH:mm:ss")); //交易時間
}
else
{
ht.Add("tranDate", CoreUser.PostingDate.ToString("yyyy-MM-dd")); //交易記賬日期
ht.Add("tranTime", base.CurrTime.ToString("HH:mm:ss")); //交易時間
}
ht.Add("checkno", orgChecknbr); //支票號
ht.Add("deductschednbr", deductSchedNbr); //協議號
ht.Add("submdnbr", submdNbr); //批次號
ht.Add("payeeName", orgName); //付款人名稱(單位賬戶)
ht.Add("payeeAcctnbr", orgAcctnbr); //付款人賬號
if (rtxn.Account != null && rtxn.Account.BranchOrgNbr.HasValue && (rtxn.Account.BranchOrgNbr.Value > 0L))
{
ht.Add("receiverName", rtxn.Account.BranchOrg.OrgName); //收款人名稱(銀行內部戶)
ht.Add("receiverBankName", rtxn.Account.BranchOrg.OrgName); //收款人開戶行(銀行內部戶)
}
else
{
ht.Add("receiverName", ""); //收款人名稱(銀行內部戶)
ht.Add("receiverBankName", ""); //收款人開戶行(銀行內部戶)
}
ht.Add("receiverAcctnbr", rtxn.AcctNbr); //收款人賬號(銀行內部戶)
ht.Add("Currency", Acct.GetAcct(rtxn.AcctNbr).AccountCurrency.CurrencyDesc); //幣種
ht.Add("traamtxiaoxie", Math.Abs(rtxn.TranAmt.Value).ToString("C"));//金額 (小寫)
ht.Add("traamtdaxie", Math.Abs(rtxn.TranAmt.Value).ToString());//金額 (大寫)
//ht.Add("des", "代發單位透過轉賬支票進行代發工資批次入賬");//備 注
if ((orgAcct != null) && (orgAcct.MjAcctTypCd.ToString() == "GL"))
{
ht.Add("des", "代發單位透過【內部賬戶】進行代發工資批次入賬");//備 注
}
else
{
if (orgChecknbr != null && orgChecknbr != "")
{
ht.Add("des", "代發單位透過【轉賬支票】進行代發工資批次入賬");//備 注
}
else
{
ht.Add("des", "代發單位透過【提款】進行代發工資批次入賬");//備 注
}
}
ht.Add("transactor", CoreUser.SAFUserName);//經 辦
Pers pers;
string approverPersName = "";
if (approvepersnbr != long.MinValue)
{
pers = Pers.GetPers(approvepersnbr, new object[] { });
if (pers != null)
{
approverPersName = pers.LastName;
}
}
if (rtxn != null && rtxn.ApproverPersNbr != long.MinValue)
{
pers = Pers.GetPers(rtxn.ApproverPersNbr, new object[] { });
if (pers != null)
{
approverPersName = pers.LastName;
}
}
ht.Add("authorization", approverPersName);//授 權
//資料準備完成開始列印
#region 轉賬支票取款憑證
//OSI.Core.Windows.Printing.PrintManager pm = new OSI.Core.Windows.Printing.PrintManager();
//OSI.Core.Windows.Query.DynamicQueryManager dqm = new OSI.Core.Windows.Query.DynamicQueryManager();
//CoreMessageBox.Show("請插入支票背面,開始列印");
//20110916 zxy 修改 {16} 自2623換行到2628 新加 {18},用於在通用憑證右上角列印 年 月 日
string str = string.Format(
@"
{18}
{0}{1}
{2}{3}
{4}{5}
{6}
{7}
{8}
{9}
{10}
{11}
{12}
{13}{14}
{15}
{16}{17}
",
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("流 水 號:", ht["serialNumber"]), 39),
string.Concat("交易型別:", ht["tranType"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("交易日期:", ht["tranDate"]), 39),
string.Concat("交易時間:", ht["tranTime"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("協 議 號:", ht["deductschednbr"]), 39),
string.Concat("批 次 號:", ht["submdnbr"]),
string.Concat("支 票 號:", ht["checkno"]),
string.Concat("付 款 人:", ht["payeeName"]),
string.Concat("付款賬號:", ht["payeeAcctnbr"]),
string.Concat("收 款 人:", ht["receiverName"]),
string.Concat("收款賬號:", ht["receiverAcctnbr"]),
string.Concat("收款人開戶行:", ht["receiverBankName"]),
string.Concat("幣 種:", ht["Currency"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("金 額(小寫):", ht["traamtxiaoxie"]), 39),
string.Concat("金 額(大寫):", OSI.Core.Windows.Printing.PrintUtil.MoneyToChinese(ht["traamtdaxie"].ToString())),
string.Concat("備 注:", ht["des"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("經 辦:", ht["transactor"].ToString().Trim()), 39),//20110916 zxy 新增OSI.Core.Windows.Printing.PrintUtil.PadLeft(
string.Concat("授 權:", ht["authorization"]),//20110916 zxy 新加右括號及逗號
OSI.Core.Windows.Printing.PrintUtil.PadLeft("年" + OSI.Core.Security.CoreUser.PostingDate.Year.ToString() + "月" + OSI.Core.Security.CoreUser.PostingDate.Month.ToString() + "日" + OSI.Core.Security.CoreUser.PostingDate.Day.ToString(), 100));//20110916 zxy 新添
OSI.Framework.Trace.TraceWriter.WriteFile(str);
//dqm.ClearPrtVarArray();
//dqm.SetPrtVarArrayText(0, str);
//pm.Print(6000020, dqm);
RtxnStatHistPrt rxhp = RtxnStatHistPrt.NewRtxnStatHistPrt();
rxhp.AcctNbr = Convert.ToInt64(rtxn.AcctNbr);
rxhp.RtxnNbr = Convert.ToInt32(rtxn.RtxnNbr);
rxhp.ActDateTime = _rtxnStatHist.ActDateTime.GetValueOrDefault();
rxhp.TimeUniquExtn = _rtxnStatHist.TimeUniqueExtn.GetValueOrDefault();
rxhp.PrtItemTypCd = "PAYD";
rxhp.PrtItemStr = str;
rxhp.Save();
OSI.Core.Windows.Printing.PrintManager pm = new OSI.Core.Windows.Printing.PrintManager();
pm.Print(6000223, str, "代發工資批次入賬憑條列印");
#endregion
}
catch (Exception ex)
{
CoreMessageBox.Show("列印失敗");
}
}
}
//列印憑證的結果
年2012月5日15
流 水 號:183903053010ss290 交易型別:(xss)abc
交易日期:2023-05-15 交易時間:19:40:23
協 議 號:00000192 批 次 號:6
支 票 號:
付 款 人:ab
付款賬號:2334
收 款 人:sx銀行結算管理部(清算中心)
收款賬號:22333
收款人開戶行:sx銀行結算管理部(清算中心)
幣 種:人民幣
金 額(小寫):¥20.00 金 額(大寫):貳拾元整
備 注:代發單位透過【提款】進行代發工資批次入賬
經 辦:axs 授 權:
//**************** 資金型別處理 ***************************//
//**************************************************************************//
private bool ProcessFundGrid(long clearingAcctNumber, long deductSchedNbr, long? submNbrToCopy, string deductSubOrgNbr)//
{
if (base.ExceptionList.Count <= 0)
{
string rtxnTranTypeCode = string.Empty;
decimal availaibleSubAcctBalance = decimal.MinValue;
decimal glavailaibleSubAcctBalance = 0M;
string rtxnTypeCode = string.Empty;
string intlRtxnDesc = string.Empty;
bool isCopy = this._formMode == FormMode.Copy;
if ((((base.ActiveTask != null) && (base.ActiveTask.ActiveAccount != null)) && (base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"] != null)) && (this.txtAmount.Value != null))
{
decimal totCash = 0M;
//是否超過最大限額的判斷--start
if (base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].OrigBal.HasValue)
{
availaibleSubAcctBalance = base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].OrigBal.Value;
}
else
{
availaibleSubAcctBalance = 0M;
}
if ((this.txtAmount.Value + availaibleSubAcctBalance) > 999999999999999.99M)
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "賬戶餘額{0} 與交易金額{1} 之和已超過最大限額【999,999,999,999,999.99】", new object[] { FI.FormatCurrency(availaibleSubAcctBalance), FI.FormatCurrency((decimal)this.txtAmount.Value) });
return false;
}
//是否超過最大限額的判斷--end
//if (base.ActiveTask.ActiveAccount.CurrAcctStatCd == "APPR")
//{
// rtxnTypeCode = "NA";
//}
//交易型別
rtxnTypeCode = "PAYD";//
Rtxn rtxn = Rtxn.NewRtxn(new long?(base.ActiveTask.ActiveAccount.AcctNbr.Value), rtxnTypeCode);
//現金箱
if (CoreUser.CashboxNbr != long.MinValue)
{
rtxn.CashboxNbr = CoreUser.CashboxNbr;
}
//生效日期
if (this.calDepositEffectiveDate.SelectedDate.HasValue)
{
rtxn.EffectiveDate = this.calDepositEffectiveDate.SelectedDate.Value;
}
//交易發生額
if (this.txtAmount.Text != null)
{
rtxn.TranAmt = decimal.Parse(this.txtAmount.Text);
}
//交易子賬號
rtxn.HoldSubAcctNbr = base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].SubAcctNbr;
//資金列表的判斷
for (int iCount = 0; iCount < this.grdFundGrid.Funds.Count; iCount++)
{
if (!((this.grdFundGrid.Funds[iCount].Amt != 0M) && this.grdFundGrid.Funds[iCount].Amt.HasValue))
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "金額無效", new object[0]);
return false;
}
if (this.grdFundGrid.Funds[iCount].FundTypCd == null)
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "資金型別不可為空", new object[0]);
return false;
}
if (this.grdFundGrid.Funds[iCount].FundTypCd == "CASH")
{
totCash += this.grdFundGrid.Funds[iCount].Amt.Value;
}
if (!this.grdFundGrid.Funds[iCount].ParentRtxnIsNull)
{
rtxnTranTypeCode = this.grdFundGrid.Funds[iCount].ParentRtxn.RtxnTypCd;
}
if ((!this.grdFundGrid.Funds[iCount].AcctNbr.HasValue && (rtxnTranTypeCode != string.Empty)) && (rtxnTranTypeCode != null))
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "賬號不可為空.", new object[0]);
return false;
}
string wthacctnbr = string.Empty;
string wthacctorgnbr = string.Empty;
this.approvepersnbr = long.MinValue;
wthacctnbr = this.grdFundGrid.WthAccount;
if (wthacctnbr != string.Empty)
{
if (this._contractAcctNbr.ToString() != wthacctnbr)
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "劃款賬戶不是簽約賬戶!");
return false;
}
Acct acctOrgNbr = Acct.GetAcct(long.Parse(wthacctnbr), new object[] { AcctFetch.Basic });
//20110417--款項有內部賬劃出時加授權頁面
if (acctOrgNbr.MjAcctType.ToString() == "GL")
{
////判斷取款賬戶內是否有足夠的資金
//if (acctOrgNbr.SubAccounts["NOTE", "BAL"].BalanceHistoryIsNull==false)
//{
// glavailaibleSubAcctBalance = decimal.Parse(acctOrgNbr.GetAvailableFunds(acctOrgNbr.SubAccounts["NOTE", "BAL"].SubAcctNbr.Value).ToString());
//}
//else
//{
// glavailaibleSubAcctBalance = 0M;
//}
//判斷取款賬戶內是否有足夠的資金
try
{
glavailaibleSubAcctBalance = decimal.Parse(acctOrgNbr.GetAvailableFunds(acctOrgNbr.SubAccounts["NOTE", "BAL"].SubAcctNbr.Value).ToString());
}
catch (Exception ex)
{
glavailaibleSubAcctBalance = 0M;
}
if (glavailaibleSubAcctBalance > (decimal?)(this.txtAmount.Value * -1M))
{
CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "此內部戶內餘額不足!");
return false;
}
if (!this.InvokeOverrideScreen(0x185L))
{
return false;
}
}
}
//交易描述
if (CalcTypVarValue.BankVariables["BANK", "TRAN", CoreUser.PostingDate] != null)
{
CalcTypVarValue calcTypVarValue = CalcTypVarValue.BankVariables["BANK", "TRAN", CoreUser.PostingDate];
if ((calcTypVarValue.CalcVarValue == "Y") && (((rtxnTypeCode == "PAYD") && ((rtxnTranTypeCode == "WTH") || (rtxnTranTypeCode == "GLD"))) && (Math.Abs(this.grdFundGrid.Funds[iCount].Amt.Value) == Math.Abs(this.grdFundGrid.TotalAmount))))
{
intlRtxnDesc = "Transfer from " + this.grdFundGrid.Funds[iCount].AcctNbr.ToString();
}
}
//子交易的新增
rtxn.AddFund(this.grdFundGrid.Funds[iCount].FundTypCd, this.grdFundGrid.Funds[iCount].FundTypDtlCd, this.grdFundGrid.Funds[iCount].ClearCatCd, this.grdFundGrid.Funds[iCount].Amt, this.grdFundGrid.Funds[iCount].NbrOfItems);
}
rtxn.AddBalance(base.ActiveTask.ActiveAccount.SubAccounts["NOTE", "BAL"].SubAcctNbr, "NOTE", "BAL", (decimal?)(this.txtAmount.Value * -1M));//20110321將【RTXNBAL】表中變為負數
rtxn.InternalDescription = intlRtxnDesc;
long? numberOfItems = long.MinValue;
RtxnCollection rtxnCollection = this.grdFundGrid.ChildTrxns;
//string strCheckNbr = string.Empty;
//string[] strArrayCheckNbr;
bool flag = false;
foreach (Rtxn rtxnChild in rtxnCollection)
{
//if (rtxnChild.CheckNbr != null)
//{
// strCheckNbr = strCheckNbr + rtxnChild.CheckNbr.ToString() + ";";
//}
if (rtxnChild.RtxnFundTyps.Count > 0)
{
//strCheckNbr = rtxnChild.CheckNbr.ToString();
long? nbrOfItemsTemp = rtxnChild.RtxnFundTyps[0].NbrOfItems;
if (!nbrOfItemsTemp.HasValue || nbrOfItemsTemp.GetValueOrDefault() <= 0L)
{
numberOfItems = 1L;
}
else
{
numberOfItems = rtxnChild.RtxnFundTyps[0].NbrOfItems;
}
rtxn.ChildRtxns.Add(rtxnChild);
}
}
////重複支票號的判斷
//if (strCheckNbr.Length > 0)
//{
// strArrayCheckNbr = strCheckNbr.Split(';');
// if (strArrayCheckNbr.Length > 1)
// {
// CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "轉賬失敗!批次入賬一次只能使用一張轉賬支票!");
// return false;
// }
// for (int i = 0; i < strArrayCheckNbr.Length - 1; i++)
// {
// for (int j = i + 1; j < strArrayCheckNbr.Length; j++)
// {
// if (strArrayCheckNbr[i] == strArrayCheckNbr[j])
// {
// flag = true;
// break;
// }
// }
// }
// if (flag)
// {
// CoreMessageBox.Show(MessageBoxOption.Error, 99999L, "發現重複的支票號,轉賬失敗!");
// return false;
// }
//}
rtxn.SetupDeposit(RtxnValidator.Deposit);
DeductSchedSubmProcessor deductSchedSubmProcessor = new DeductSchedSubmProcessor();
try
{
if (rtxn != null)
{
deductSchedSubmProcessor.PostOptionalCopy(rtxn, deductSchedNbr, clearingAcctNumber, this.calSubmissionEffectiveDate.SelectedDate, isCopy, false, submNbrToCopy);
deductSchedSubmProcessor = deductSchedSubmProcessor.Save(base.ActvCatCd, base.ActvTypCd) as DeductSchedSubmProcessor;
rtxn = deductSchedSubmProcessor.RtxnObj;
}
}
catch (CoreTransactionException tExcp)
{
if (rtxn != null)
{
frmOverride verrideFrm = new frmOverride(tExcp.Transaction);
if (overrideFrm.ShowDialog(this) == DialogResult.Cancel)
{
return false;
}
rtxn.ApproverPersNbr = overrideFrm.PersNbr;
deductSchedSubmProcessor.PostOptionalCopy(rtxn, deductSchedNbr, clearingAcctNumber, this.calSubmissionEffectiveDate.SelectedDate, isCopy, true, submNbrToCopy);
deductSchedSubmProcessor = deductSchedSubmProcessor.Save(base.ActvCatCd, base.ActvTypCd) as DeductSchedSubmProcessor;
rtxn = deductSchedSubmProcessor.RtxnObj;
}
}
if (totCash > 0M)
{
TxnCashCount.ClearCashCounts();
TxnCashCount.IsRtxn = true;
TxnCashCount.TxnTypCd = rtxn.RtxnTypCd;
TxnCashCount.AcctNbr = rtxn.Account.AcctNbr.Value;
TxnCashCount.CashboxNbr = CoreUser.CashboxNbr;
TxnCashCount.TxnNbr = rtxn.RtxnNbr.Value;
TxnCashCount.RequestAmount = totCash;
TxnCashCount.DispenseOrCashCount();
TxnCashCount.CallCashCount();
}
if (deductSchedSubmProcessor.ErrorNbr <= 0)
{
this.PopulateGrid();
//列印憑證的方法
PrePrint(rtxn, rtxnCollection, deductSchedNbr.ToString().PadLeft(8, '0'), deductSchedSubmProcessor.SubmdNbr.ToString(), approvepersnbr);
}
return true;
}
}
return false;
}
//**************************************************************************//
//**************** 轉賬支票取款時列印憑條 ***************************//
//**************************************************************************//
private void PrePrint(Rtxn rtxn, RtxnCollection childRtxn, string deductSchedNbr, string submdNbr, long approvepersnbr)
{
string rgAcctnbr = null;//付款人賬號
string rgName = null;//付款人名稱
string rgChecknbr = null;//轉賬支票號
Acct rgAcct = null;
string resultString = string.Empty;
if ((childRtxn != null) && (childRtxn[0].CheckNbr.ToString() != null) && (childRtxn[0].CheckNbr.ToString() != ""))
{
resultString = CoreMessageBox.Show(new string[] { "確定" }, 0L, "請插入支票背面,按確定按鈕開始列印", new object[0]);
}
else
{
resultString = CoreMessageBox.Show(new string[] { "確定" }, 0L, "請插入通用業務憑證,按確定按鈕開始列印", new object[0]);
}
if (resultString == "確定")
{
try
{
//子交易(透過轉賬支票從單位賬戶取款)
if (childRtxn != null)
{
Rtxn rtxnChild = childRtxn[0];
rgAcct = Acct.GetAcct(rtxnChild.AcctNbr, new object[] { 0L });
if ((orgAcct != null) && (orgAcct.MjAcctTypCd.ToString() == "GL"))
{
rgAcctnbr = rtxnChild.AcctNbr.ToString();
//orgName = orgAcct.BranchOrg.OrgName;//透過內部戶轉到清算賬戶
rgName = GlAcctTitle.GetDecodeGLAccttitl(rtxnChild.AcctNbr, new object[] { }).GlAcctTitleName.ToString();//
}
else
{
rgAcctnbr = rtxnChild.MediumId; //單位帳號
if (orgAcct != null && orgAcct.TaxRptForOrgNbr.HasValue && (orgAcct.TaxRptForOrgNbr.Value > 0L))
{
rgName = orgAcct.TaxRptForOrganization.OrgName; //單位名稱
}
else
{
rgName = ""; //單位名稱
}
}
rgChecknbr = rtxnChild.CheckNbr.ToString(); //轉賬支票號
}
else
{
CoreMessageBox.Show("沒有需要列印的交易!");
return;
}
System.Collections.Hashtable ht = new System.Collections.Hashtable();
ht.Add("serialNumber", string.Concat(rtxn.AcctNbr, rtxn.RtxnNbr)); //交易流水號
ht.Add("tranType", "(代發工資)批次入賬"); //交易型別
RtxnStatHist _rtxnStatHist = RtxnStatHist.GetRtxnStatHist(rtxn.AcctNbr, rtxn.RtxnNbr, new object[] { RtxnStatHistFetch.TransDetail });
if (_rtxnStatHist != null)
{
ht.Add("tranDate", _rtxnStatHist.PostDate.Value.ToString("yyyy-MM-dd")); //交易記賬日期
ht.Add("tranTime", ((DateTime)_rtxnStatHist.ActDateTime).ToString("HH:mm:ss")); //交易時間
}
else
{
ht.Add("tranDate", CoreUser.PostingDate.ToString("yyyy-MM-dd")); //交易記賬日期
ht.Add("tranTime", base.CurrTime.ToString("HH:mm:ss")); //交易時間
}
ht.Add("checkno", orgChecknbr); //支票號
ht.Add("deductschednbr", deductSchedNbr); //協議號
ht.Add("submdnbr", submdNbr); //批次號
ht.Add("payeeName", orgName); //付款人名稱(單位賬戶)
ht.Add("payeeAcctnbr", orgAcctnbr); //付款人賬號
if (rtxn.Account != null && rtxn.Account.BranchOrgNbr.HasValue && (rtxn.Account.BranchOrgNbr.Value > 0L))
{
ht.Add("receiverName", rtxn.Account.BranchOrg.OrgName); //收款人名稱(銀行內部戶)
ht.Add("receiverBankName", rtxn.Account.BranchOrg.OrgName); //收款人開戶行(銀行內部戶)
}
else
{
ht.Add("receiverName", ""); //收款人名稱(銀行內部戶)
ht.Add("receiverBankName", ""); //收款人開戶行(銀行內部戶)
}
ht.Add("receiverAcctnbr", rtxn.AcctNbr); //收款人賬號(銀行內部戶)
ht.Add("Currency", Acct.GetAcct(rtxn.AcctNbr).AccountCurrency.CurrencyDesc); //幣種
ht.Add("traamtxiaoxie", Math.Abs(rtxn.TranAmt.Value).ToString("C"));//金額 (小寫)
ht.Add("traamtdaxie", Math.Abs(rtxn.TranAmt.Value).ToString());//金額 (大寫)
//ht.Add("des", "代發單位透過轉賬支票進行代發工資批次入賬");//備 注
if ((orgAcct != null) && (orgAcct.MjAcctTypCd.ToString() == "GL"))
{
ht.Add("des", "代發單位透過【內部賬戶】進行代發工資批次入賬");//備 注
}
else
{
if (orgChecknbr != null && orgChecknbr != "")
{
ht.Add("des", "代發單位透過【轉賬支票】進行代發工資批次入賬");//備 注
}
else
{
ht.Add("des", "代發單位透過【提款】進行代發工資批次入賬");//備 注
}
}
ht.Add("transactor", CoreUser.SAFUserName);//經 辦
Pers pers;
string approverPersName = "";
if (approvepersnbr != long.MinValue)
{
pers = Pers.GetPers(approvepersnbr, new object[] { });
if (pers != null)
{
approverPersName = pers.LastName;
}
}
if (rtxn != null && rtxn.ApproverPersNbr != long.MinValue)
{
pers = Pers.GetPers(rtxn.ApproverPersNbr, new object[] { });
if (pers != null)
{
approverPersName = pers.LastName;
}
}
ht.Add("authorization", approverPersName);//授 權
//資料準備完成開始列印
#region 轉賬支票取款憑證
//OSI.Core.Windows.Printing.PrintManager pm = new OSI.Core.Windows.Printing.PrintManager();
//OSI.Core.Windows.Query.DynamicQueryManager dqm = new OSI.Core.Windows.Query.DynamicQueryManager();
//CoreMessageBox.Show("請插入支票背面,開始列印");
//20110916 zxy 修改 {16} 自2623換行到2628 新加 {18},用於在通用憑證右上角列印 年 月 日
string str = string.Format(
@"
{18}
{0}{1}
{2}{3}
{4}{5}
{6}
{7}
{8}
{9}
{10}
{11}
{12}
{13}{14}
{15}
{16}{17}
",
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("流 水 號:", ht["serialNumber"]), 39),
string.Concat("交易型別:", ht["tranType"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("交易日期:", ht["tranDate"]), 39),
string.Concat("交易時間:", ht["tranTime"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("協 議 號:", ht["deductschednbr"]), 39),
string.Concat("批 次 號:", ht["submdnbr"]),
string.Concat("支 票 號:", ht["checkno"]),
string.Concat("付 款 人:", ht["payeeName"]),
string.Concat("付款賬號:", ht["payeeAcctnbr"]),
string.Concat("收 款 人:", ht["receiverName"]),
string.Concat("收款賬號:", ht["receiverAcctnbr"]),
string.Concat("收款人開戶行:", ht["receiverBankName"]),
string.Concat("幣 種:", ht["Currency"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("金 額(小寫):", ht["traamtxiaoxie"]), 39),
string.Concat("金 額(大寫):", OSI.Core.Windows.Printing.PrintUtil.MoneyToChinese(ht["traamtdaxie"].ToString())),
string.Concat("備 注:", ht["des"]),
OSI.Core.Windows.Printing.PrintUtil.PadLeft(string.Concat("經 辦:", ht["transactor"].ToString().Trim()), 39),//20110916 zxy 新增OSI.Core.Windows.Printing.PrintUtil.PadLeft(
string.Concat("授 權:", ht["authorization"]),//20110916 zxy 新加右括號及逗號
OSI.Core.Windows.Printing.PrintUtil.PadLeft("年" + OSI.Core.Security.CoreUser.PostingDate.Year.ToString() + "月" + OSI.Core.Security.CoreUser.PostingDate.Month.ToString() + "日" + OSI.Core.Security.CoreUser.PostingDate.Day.ToString(), 100));//20110916 zxy 新添
OSI.Framework.Trace.TraceWriter.WriteFile(str);
//dqm.ClearPrtVarArray();
//dqm.SetPrtVarArrayText(0, str);
//pm.Print(6000020, dqm);
RtxnStatHistPrt rxhp = RtxnStatHistPrt.NewRtxnStatHistPrt();
rxhp.AcctNbr = Convert.ToInt64(rtxn.AcctNbr);
rxhp.RtxnNbr = Convert.ToInt32(rtxn.RtxnNbr);
rxhp.ActDateTime = _rtxnStatHist.ActDateTime.GetValueOrDefault();
rxhp.TimeUniquExtn = _rtxnStatHist.TimeUniqueExtn.GetValueOrDefault();
rxhp.PrtItemTypCd = "PAYD";
rxhp.PrtItemStr = str;
rxhp.Save();
OSI.Core.Windows.Printing.PrintManager pm = new OSI.Core.Windows.Printing.PrintManager();
pm.Print(6000223, str, "代發工資批次入賬憑條列印");
#endregion
}
catch (Exception ex)
{
CoreMessageBox.Show("列印失敗");
}
}
}
//列印憑證的結果
年2012月5日15
流 水 號:183903053010ss290 交易型別:(xss)abc
交易日期:2023-05-15 交易時間:19:40:23
協 議 號:00000192 批 次 號:6
支 票 號:
付 款 人:ab
付款賬號:2334
收 款 人:sx銀行結算管理部(清算中心)
收款賬號:22333
收款人開戶行:sx銀行結算管理部(清算中心)
幣 種:人民幣
金 額(小寫):¥20.00 金 額(大寫):貳拾元整
備 注:代發單位透過【提款】進行代發工資批次入賬
經 辦:axs 授 權:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-707749/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- c#之tcbs方法示例hasvalueC#
- c#之tcbs method方法示例C#
- c# tcbs之switch多分支case示例C#
- c# tcbs之建構函式呼叫建構函式示例C#函式
- c#之tcbs method方法_getC#
- c# tcbs之外部類成員型別為內部類之示例C#型別
- tcbs之集合類與子類的示例
- c#之tcbs struct(2)小記C#Struct
- c#之tcbs class的小記C#
- c#之tcbs extern修飾符C#
- c# tcbs之類中方法的特徵C#特徵
- c#之tcbs 建構函式小記C#函式
- c#之異常處理tcbs_try_catch_finallyC#
- c# tcbs屬性訪問器C#
- cookie之登入使用者憑證Cookie
- tcbs sqr之轉睡眠戶_sqr示例學習筆記_報表report筆記
- c# tcbs專案學習體悟C#
- 用Ehlib二次開發報表列印程式,實現財務憑證的列印(三) (轉)
- 憑證結構
- FI憑證拆分
- c# 之tcbs在winform介面如何以mvc方法呼叫oracle函式C#ORMMVCOracle函式
- c# tcbs之遞迴方法查詢符合條件的控制元件C#遞迴控制元件
- SAP憑證錄入之記賬碼—科萊特
- c#之tcbs靜態方法_返回值為類的型別_小記C#型別
- c#之string.format方法示例C#ORM
- SAP SD基礎知識之憑證流(Document Flow)
- tcbs_批量儲存過程_sql_case when_示例儲存過程SQL
- PackingSlip時生成憑證
- 憑證分割官方文件 地址
- SD憑證的型別型別
- SAP R/3 中會計憑證和物料憑證的對應關係
- C# 列印小票 POSC#
- 細說API - 認證、授權和憑證API
- VPN憑證嗅探工具fiked
- 會計憑證的傳遞
- 網際網路+列印的印萌自助列印系統,憑什麼給傳統列印店增加50%營收?營收
- SAP QM Quality Notification的憑證流
- c#列印99乘法表C#