Hi guys, I have a question regarding RowMod. I have a post process BPM on the quote update. That does not work when I use RowMod == “U” but works when I comment out that line.
What I am doing is; I have a text box on the Header which contains a decimal between 1.2 and 3. This figure is used as a multiplier on the configured costs stored in QuoteDtl Number01 to give me a selling price. Sammples (SMP) are zero price and No Judgement Multiplier (NOJM) is at cost.
I also occasionally get the message that the line has been updated by another user and am wondering if I am doing something wrong.
Here is the code.
// Get the first "updated" row from the dataset.
var ttQuoteHed_iterator = (from ttQuoteHed_Row in ttQuoteHed
//where (ttQuoteHed_Row.RowMod == "U")
select ttQuoteHed_Row).FirstOrDefault();
// Check if a row exists.
if (ttQuoteHed_iterator != null)
{
using (var txScope = Erp.ErpContext.CreateDefaultTransactionScope())
{
/* check if checkbox01 is true and judgement multiplier is present */
bool cb1 = Convert.ToBoolean(ttQuoteHed_iterator["CheckBox01"]);
decimal num1 = System.Convert.ToDecimal(ttQuoteHed_iterator["Number01"]);
if (cb1 == true && num1 > 0)
{
decimal newprice = 0;
foreach (var QuoteDtl in (from Row in Db.QuoteDtl
where (Row.Company == Session.CompanyID &&
Row.QuoteNum == ttQuoteHed_iterator.QuoteNum &&
Row.AnalysisCode != "NOJM")
select Row))
{
newprice = System.Convert.ToDecimal(QuoteDtl["Number01"]);
/* if number01 = 0 this is the first time we are updating this quote so store the price in number01 */
if (newprice == 0)
{
QuoteDtl["Number01"] = QuoteDtl.DocExpUnitPrice;
newprice = QuoteDtl.DocExpUnitPrice;
}
if (QuoteDtl.AnalysisCode == "SMP")
{
newprice = 0;
}
newprice = newprice * num1;
QuoteDtl.DocExpUnitPrice = newprice;
foreach (var QuoteQty in (from Row in Db.QuoteQty
where (Row.Company == Session.CompanyID &&
Row.QuoteNum == QuoteDtl.QuoteNum &&
Row.QuoteLine == QuoteDtl.QuoteLine)
select Row))
{
QuoteQty.DocUnitPrice = newprice;
}
}
Db.Validate();
txScope.Complete();
}
}
}
Thanks
Adrian.