【发布时间】:2017-02-17 12:54:46
【问题描述】:
我在 Acumatica 屏幕的“支票和付款”屏幕中创建并发布了付款。请参考以下截图。
我已经创建了以下代码来提供它。
protected virtual void APPayment_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
{
string serverJade, dbJade, userJade, passJade;
serverJade = Properties.Settings.Default.serverJade;
dbJade = Properties.Settings.Default.dbJade;
userJade = Properties.Settings.Default.userJade;
passJade = Properties.Settings.Default.passJade;
APPayment app = (APPayment)e.Row;
if (e.Operation == PXDBOperation.Update && e.TranStatus == PXTranStatus.Completed)
{
if (app.DocType == APPaymentType.Check || app.DocType == APPaymentType.Prepayment)
{
if (app.RefNbr != null)
{
using (SqlConnection con = new SqlConnection("server = " + serverJade + "; database = " + dbJade + "; user = " + userJade + "; password = " + passJade + ""))
{
con.Open();
//---- query to update a field in the table of another database -------//
string query = "Update EVMaster set AcuRefNo = '" + app.RefNbr + "' where VchNo = 'DD02/16-VIII/12206-VCH-01'";
using (SqlCommand com = new SqlCommand(query, con))
{
SqlDataReader sdr = com.ExecuteReader();
sdr.Close();
}
con.Close();
}
}
}
}
}
我已经尝试调试此代码,但没有成功。然后我尝试使用以下代码。
protected virtual void APPayment_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
{
string serverJade, dbJade, userJade, passJade;
serverJade = Properties.Settings.Default.serverJade;
dbJade = Properties.Settings.Default.dbJade;
userJade = Properties.Settings.Default.userJade;
passJade = Properties.Settings.Default.passJade;
APPayment app = (APPayment)e.Row;
if (app.DocType == APPaymentType.Check || app.DocType == APPaymentType.Prepayment)
{
if (app.RefNbr != null)
{
using (SqlConnection con = new SqlConnection("server = " + serverJade + "; database = " + dbJade + "; user = " + userJade + "; password = " + passJade + ""))
{
con.Open();
//---- query to update a field in the table of another database -------//
string query = "Update EVMaster set AcuRefNo = '" + app.RefNbr + "' where VchNo = 'DD02/16-VIII/12206-VCH-01'";
using (SqlCommand com = new SqlCommand(query, con))
{
SqlDataReader sdr = com.ExecuteReader();
sdr.Close();
}
con.Close();
}
}
}
}
上面的代码有效,我只是删除了 if 条件(if (e.Operation == PXDBOperation.Update && e.TranStatus == PXTranStatus.Completed) {})。
但这不是我的目标,我只需要从文档中筛选出 Doc Status = 'printed' 的文档,当点击 'Release' 按钮时会执行此过程。
还有任何想法如何获取当前文档的 APAdjust 中的所有记录?因为我需要根据 adjgrefnbr (apadjust) = refnbr (apinvoice) 比较 apadjust 中的 adjgrefnbr 和 APInvoice 中的 refnbr。所以我也可以得到基于 refnbr (APinvoice) = ajgrefnbr (current apadjust) 的所有 APinvoice 记录。此条件用于使查询的“where”条件不必硬编码,我将使用变量来提供它。
有什么建议可以解决这个问题吗?
【问题讨论】: