本文整理汇总了C#中System.Data.DataView.FindRows方法的典型用法代码示例。如果您正苦于以下问题:C# DataView.FindRows方法的具体用法?C# DataView.FindRows怎么用?C# DataView.FindRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataView
的用法示例。
在下文中一共展示了DataView.FindRows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInvestorByAccount
public static databases.tmpDS.investorRow GetInvestorByAccount(string account)
{
DataView dataView = new DataView(myCacheBaseDS.investor);
dataView.Sort = myCacheBaseDS.investor.accountColumn.ColumnName;
DataRowView[] foundRows = dataView.FindRows(new object[] {account});
if (foundRows.Length == 0) LoadInvestor(myCacheBaseDS.investor, false);
foundRows = dataView.FindRows(new object[] { account });
if (foundRows.Length > 0) return (databases.tmpDS.investorRow)foundRows[0].Row;
return null;
}
示例2: CreateTradeAlert
/// <summary>
/// Create alerts for all stock in portfolio
/// </summary>
/// <param name="alertList"> all alert resulted from analysis </param>
/// <param name="frDate">Alert will only create alert in range [frDate,toDate].
/// It also ensure that in the same day,there in ONLY one new alert of the same type</param>
/// <param name="toDate"></param>
private static void CreateTradeAlert(TradeAlert[] alertList,DateTime frDate,DateTime toDate)
{
decimal availabeQty;
string msg;
StringCollection timeScaleList;
data.baseDS.tradeAlertRow tradeAlertRow;
data.baseDS.tradeAlertDataTable tradeAlertTbl = new data.baseDS.tradeAlertDataTable();
data.baseDS.portfolioDetailDataTable portfolioDetailTbl = new data.baseDS.portfolioDetailDataTable();
DataView portfolioDetailView = new DataView(portfolioDetailTbl);
//Sort by Stock code + Strategy code
portfolioDetailView.Sort = portfolioDetailTbl.codeColumn.ColumnName + "," + portfolioDetailTbl.subCodeColumn.ColumnName;
DataRowView[] portfolioDetailFound;
data.baseDS.portfolioDetailRow portfolioDataRow;
portfolioDetailTbl = data.DbAccess.GetPortfolioDetail_ByType(new AppTypes.PortfolioTypes[] { AppTypes.PortfolioTypes.WatchList, AppTypes.PortfolioTypes.Portfolio });
// Only alert on stock codes that were selected by user.
for (int alertId = 0; alertId < alertList.Length; alertId++)
{
// Check if alert's strategy in user's wish list ??
portfolioDetailFound = portfolioDetailView.FindRows(new object[] { alertList[alertId].StockCode, alertList[alertId].Strategy.Trim() });
for (int dataIdx = 0; dataIdx < portfolioDetailFound.Length; dataIdx++)
{
// Check if time alert's time scale in user's wish list ??
portfolioDataRow = ((data.baseDS.portfolioDetailRow)portfolioDetailFound[dataIdx].Row);
timeScaleList = common.MultiValueString.String2List(portfolioDataRow.data.Trim());
if (!timeScaleList.Contains(alertList[alertId].TimeScale.Code)) continue;
//Do not crete alert if there is a NEW one.
tradeAlertRow = data.DbAccess.GetLastAlert( frDate, toDate, portfolioDataRow.portfolio,
alertList[alertId].StockCode,
alertList[alertId].Strategy,
alertList[alertId].TimeScale.Code,
(byte)AppTypes.CommonStatus.New);
if (tradeAlertRow != null) continue;
//Availabe stock
if (withAplicableCheckInAlert)
{
availabeQty = data.AppLibs.GetAvailableStock(alertList[alertId].StockCode, portfolioDataRow.portfolio,
Settings.sysStockSell2BuyInterval, alertList[alertId].OnDateTime);
}
else availabeQty = int.MaxValue;
//Aplicable to sell
if ((alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.Sell ||
alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.ClearAll) && (availabeQty <= 0)) continue;
msg = " - Giá : " + alertList[alertId].Price.ToString() + common.Consts.constCRLF +
" - K/L giao dịch : " + alertList[alertId].Volume.ToString() + common.Consts.constCRLF +
" - Xu hướng : (" + alertList[alertId].TradePoint.BusinessInfo.ToString() + "," +
alertList[alertId].TradePoint.BusinessInfo.LongTermTrend + ")" + common.Consts.constCRLF +
" - K/L sở hữu hợp lệ : " + availabeQty.ToString() + common.Consts.constCRLF;
CreateTradeAlert(tradeAlertTbl, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy,
alertList[alertId].TimeScale, alertList[alertId].TradePoint, toDate, msg);
}
}
data.DbAccess.UpdateData(tradeAlertTbl);
}
示例3: btnImport_Click
private void btnImport_Click(object sender, EventArgs e)
{
int selected = DB.getSelectedRows(dataGridView1.DataSource, "Import");
if (!doImport(selected, "IsoReport", "IsoReports"))
return;
Cursor.Current = Cursors.WaitCursor;
System.Data.SqlClient.SqlConnection sqlConnection = null;
int imported = 0;
int notImported = 0;
try
{
DataView dataView = new DataView(wizard.validator.ExcelTable);
dataView.Sort = "accountno";
sqlConnection = DB.getSqlConnection();
foreach (DataRow row in newIsoReportTable.Rows)
{
if ((Boolean)row[DB.IMPORT])
{
DataRowView[] rows = dataView.FindRows(row["accountno"]);
if ((rows != null) && (rows.Length == 1))
{
if (db.addIso(sqlConnection, null, wizard.YearMonth, rows[0]))
imported++;
else {
wizard.ImportErrors.Add(string.Format("ISO: Account: {0} - siccode: {1}", rows[0]["accountno"], rows[0]["siccode"]));
notImported++;
}
}
}
}
//fillGrid();
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
MessageBox.Show("Import Error Encountered: " + ex.Message);
}
finally
{
Cursor.Current = Cursors.Default;
MessageBox.Show(Helper.importedMessage(imported, notImported, "IsoReport", "IsoReports"));
//DB.closeConnection(sqlConnection);
fillGrid();
if (DialogResult.Yes == MessageBox.Show("Consider this file as Imported?", "Close Excel File", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
db.setExcelFileAsImported(sqlConnection, wizard.ExcelRow, wizard.YearMonth, wizard.validator.Errors, wizard.ImportErrors);
sqlConnection.Close();
if (newIsoReportTable.Rows.Count == 0)
btnNext.PerformClick();
}
}
示例4: EFinanceSystemDataObjectNullOrEmptyException
/// <summary>
/// mark each journal, each transaction as being posted;
/// add sums for costcentre/account combinations
/// </summary>
/// <param name="AMainDS">can contain several batches and journals and transactions</param>
/// <param name="APostingDS"></param>
/// <param name="APostingLevel">the balance changes at the posting level</param>
/// <param name="ABatchToPost">the batch to post</param>
/// <returns>a list with the sums for each costcentre/account combination</returns>
private static SortedList <string, TAmount>MarkAsPostedAndCollectData(GLBatchTDS AMainDS,
GLPostingTDS APostingDS,
SortedList <string, TAmount>APostingLevel, ABatchRow ABatchToPost)
{
#region Validate Arguments
if (AMainDS == null)
{
throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString("Function:{0} - The GL Batch dataset is null!"),
Utilities.GetMethodName(true)));
}
else if (APostingDS == null)
{
throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString(
"Function:{0} - The GL Posting dataset is null!"),
Utilities.GetMethodName(true)));
}
else if (ABatchToPost == null)
{
throw new EFinanceSystemDataObjectNullOrEmptyException(String.Format(Catalog.GetString(
"Function:{0} - The GL Batch to post data row is null!"),
Utilities.GetMethodName(true)));
}
#endregion Validate Arguments
DataView TransactionsDV = new DataView(AMainDS.ATransaction);
TransactionsDV.Sort = ATransactionTable.GetJournalNumberDBName();
foreach (AJournalRow journal in AMainDS.AJournal.Rows)
{
if (journal.BatchNumber != ABatchToPost.BatchNumber)
{
continue;
}
foreach (DataRowView transactionview in TransactionsDV.FindRows(journal.JournalNumber))
{
ATransactionRow transaction = (ATransactionRow)transactionview.Row;
if (transaction.BatchNumber != ABatchToPost.BatchNumber)
{
continue;
}
transaction.TransactionStatus = true;
// get the account that this transaction is writing to
AAccountRow accountRow = (AAccountRow)APostingDS.AAccount.Rows.Find(new object[] { transaction.LedgerNumber,
transaction.AccountCode });
#region Validate Data
if (accountRow == null)
{
throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
"Function:{0} - Account row data for Account code {1} in Ledger number {2} does not exist or could not be accessed!"),
Utilities.GetMethodName(true),
transaction.AccountCode,
transaction.LedgerNumber));
}
#endregion Validate Data
// Set the sign of the amounts according to the debit/credit indicator
decimal SignBaseAmount = transaction.AmountInBaseCurrency;
decimal SignIntlAmount = transaction.AmountInIntlCurrency;
decimal SignTransAmount = transaction.TransactionAmount;
if (accountRow.DebitCreditIndicator != transaction.DebitCreditIndicator)
{
SignBaseAmount *= -1.0M;
SignIntlAmount *= -1.0M;
SignTransAmount *= -1.0M;
}
// TODO: do we need to check for base currency corrections?
// or do we get rid of these problems by not having international currency?
string key = TAmount.MakeKey(transaction.AccountCode, transaction.CostCentreCode);
if (!APostingLevel.ContainsKey(key))
{
APostingLevel.Add(key, new TAmount());
}
APostingLevel[key].BaseAmount += SignBaseAmount;
APostingLevel[key].IntlAmount += SignIntlAmount;
// Only foreign currency accounts store a value in the transaction currency,
//.........这里部分代码省略.........
示例5: CSV_ImportParse
//Use the idea from http://www.codeproject.com/KB/database/CsvReader.aspx by Sebastien Lorion
public static bool CSV_ImportParse(string csvFileName, char delimiter,
common.dateTimeLibs.DateTimeFormats dateDataFormat,
string marketCode, CultureInfo dataCulture,
databases.baseDS.priceDataDataTable priceDataTbl,
ImportRowHandler ImportRowFunc,
OnUpdatePriceData onUpdateDataFunc,
OnEndImportPriceData onEndImportFunc)
{
importStat myImportStat = new importStat();
myImportStat.Reset();
myImportStat.dateDataFormat = dateDataFormat;
myImportStat.srcCulture = dataCulture;
databases.baseDS.stockCodeDataTable stockCodeTbl = new databases.baseDS.stockCodeDataTable();
databases.baseDS.priceDataRow priceDataRow;
DataRowView[] foundRows;
databases.DbAccess.LoadData(stockCodeTbl, AppTypes.CommonStatus.Enable);
DataView stockCodeView = new DataView(stockCodeTbl);
stockCodeView.Sort = stockCodeTbl.codeColumn.ColumnName;
bool fCanceled = false;
DateTime lastPriceDate = common.Consts.constNullDate;
importOHLCV data;
// open the file "data.csv" which is a CSV file with headers
using (CsvReader csv = new CsvReader(new StreamReader(csvFileName), true, delimiter))
{
// missing fields will not throw an exception,
// but will instead be treated as if there was a null value
csv.MissingFieldAction = MissingFieldAction.ReplaceByNull;
int fieldCount = csv.FieldCount;
if (fieldCount < 7) return false;
while (csv.ReadNextRecord())
{
Application.DoEvents();
myImportStat.dataCount++;
data = ImportRowFunc(csv, myImportStat);
if (myImportStat.cancel)
{
fCanceled = true; break;
}
if (data == null)
{
myImportStat.errorCount++;
continue;
}
//Assume that all price must be valid
if (data.Open <= 0 || data.High <= 0 || data.Low <= 0 || data.Close <= 0) continue;
foundRows = stockCodeView.FindRows(data.code);
if (foundRows.Length == 0)
{
//Try to add new stock code
Libs.AddNewCode(data.code, marketCode, stockCodeTbl);
databases.DbAccess.UpdateData(stockCodeTbl);
}
// Ignore all data that was in database
//if (!foundLastPriceDate)
//{
// lastPriceDate = FindLastPriceDate(data.code);
// foundLastPriceDate = true;
//}
if (lastPriceDate != common.Consts.constNullDate && data.dateTime <= lastPriceDate)
{
continue;
}
if (priceDataTbl.FindBystockCodeonDate(data.code, data.dateTime) != null)
{
myImportStat.errorCount++;
continue;
}
myImportStat.updateCount++;
priceDataRow = priceDataTbl.NewpriceDataRow();
databases.AppLibs.InitData(priceDataRow);
priceDataRow.stockCode = data.code;
priceDataRow.onDate = data.dateTime;
//Try to fix some error in data
priceDataRow.openPrice = (decimal)data.Open;
priceDataRow.highPrice = (decimal)data.High;
priceDataRow.lowPrice = (decimal)data.Low;
priceDataRow.closePrice = (decimal)data.Close;
priceDataRow.volume = (decimal)data.Volume;
priceDataTbl.AddpriceDataRow(priceDataRow);
if (onUpdateDataFunc != null) onUpdateDataFunc(priceDataRow, myImportStat);
}
}
if (fCanceled)
{
priceDataTbl.Clear();
return false;
}
if (onEndImportFunc != null) onEndImportFunc(priceDataTbl);
return true;
}
示例6: TestFindRows
public void TestFindRows ()
{
DataView TestView = new DataView (dataTable);
TestView.Sort = "itemId";
DataRowView[] Result = TestView.FindRows ("item 3");
Assertion.AssertEquals ("Dv #1", 1, Result.Length);
Assertion.AssertEquals ("Dv #2", "item 3", Result [0]["itemId"]);
}
示例7: GetReportingCostCentres
private static void GetReportingCostCentres(ACostCentreTable ACostCentres, List <string>AResult, string ASummaryCostCentreCode)
{
if (ASummaryCostCentreCode.Length == 0)
{
return;
}
string[] CostCentres = ASummaryCostCentreCode.Split(new char[] { ',' });
foreach (string costcentre in CostCentres)
{
DataRowView[] ReportingCostCentres = ACostCentres.DefaultView.FindRows(costcentre);
if (ReportingCostCentres.Length > 0)
{
foreach (DataRowView rv in ReportingCostCentres)
{
ACostCentreRow row = (ACostCentreRow)rv.Row;
if (row.PostingCostCentreFlag)
{
AResult.Add(row.CostCentreCode);
}
else
{
GetReportingCostCentres(ACostCentres, AResult, row.CostCentreCode);
}
}
}
else
{
DataView dv = new DataView(ACostCentres);
dv.Sort = ACostCentreTable.GetCostCentreCodeDBName();
ACostCentreRow cc = (ACostCentreRow)dv.FindRows(costcentre)[0].Row;
if (cc.PostingCostCentreFlag)
{
AResult.Add(costcentre);
}
}
}
}
示例8: LoadARecurringGiftBatchAndRelatedData
private static GiftBatchTDS LoadARecurringGiftBatchAndRelatedData(Int32 ALedgerNumber,
Int32 ABatchNumber,
TDBTransaction ATransaction,
out bool AChangesToCommit,
bool AExcludeBatchRow = false)
{
#region Validate Arguments
if (ALedgerNumber <= 0)
{
throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString(
"Function:{0} - The Ledger number must be greater than 0!"),
Utilities.GetMethodName(true)), ALedgerNumber);
}
else if (ABatchNumber <= 0)
{
throw new EFinanceSystemInvalidBatchNumberException(String.Format(Catalog.GetString(
"Function:{0} - The Batch number must be greater than 0!"),
Utilities.GetMethodName(true)), ALedgerNumber, ABatchNumber);
}
else if (ATransaction == null)
{
throw new EFinanceSystemDBTransactionNullException(String.Format(Catalog.GetString(
"Function:{0} - Database Transaction must not be NULL!"),
Utilities.GetMethodName(true)));
}
#endregion Validate Arguments
AChangesToCommit = false;
GiftBatchTDS MainDS = new GiftBatchTDS();
ALedgerAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, ATransaction);
ARecurringGiftBatchAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, ABatchNumber, ATransaction);
ARecurringGiftAccess.LoadViaARecurringGiftBatch(MainDS, ALedgerNumber, ABatchNumber, ATransaction);
ARecurringGiftDetailAccess.LoadViaARecurringGiftBatch(MainDS, ALedgerNumber, ABatchNumber, ATransaction);
AMotivationDetailAccess.LoadViaALedger(MainDS, ALedgerNumber, ATransaction);
#region Validate Data 1
//Only the following tables should not be empty when posting.
if ((MainDS.ALedger == null) || (MainDS.ALedger.Count == 0))
{
throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
"Function:{0} - Ledger data for Ledger number {1} does not exist or could not be accessed!"),
Utilities.GetMethodSignature(),
ALedgerNumber));
}
else if ((MainDS.AMotivationDetail == null) || (MainDS.AMotivationDetail.Count == 0))
{
throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
"Function:{0} - Motivation Detail data for Ledger number {1} does not exist or could not be accessed!"),
Utilities.GetMethodSignature(),
ALedgerNumber));
}
//Not needed as recurring batch number passed in may only be on the client side
//else if ((MainDS.ARecurringGiftBatch == null) || (MainDS.ARecurringGiftBatch.Count == 0))
//{
// throw new EFinanceSystemDataTableReturnedNoDataException(String.Format(Catalog.GetString(
// "Function:{0} - Recurring Gift Batch data for Ledger number {1} Batch {2} does not exist or could not be accessed!"),
// Utilities.GetMethodSignature(),
// ALedgerNumber,
// ABatchNumber));
//}
#endregion Validate Data 1
LoadGiftDonorRelatedData(MainDS, true, ALedgerNumber, ABatchNumber, ref ATransaction);
DataView giftView = new DataView(MainDS.ARecurringGift);
giftView.Sort = ARecurringGiftTable.GetGiftTransactionNumberDBName();
// fill the columns in the modified GiftDetail Table to show donorkey, dateentered etc in the grid
foreach (GiftBatchTDSARecurringGiftDetailRow giftDetail in MainDS.ARecurringGiftDetail.Rows)
{
// get the gift
ARecurringGiftRow giftRow = (ARecurringGiftRow)giftView.FindRows(giftDetail.GiftTransactionNumber)[0].Row;
PPartnerRow DonorRow = (PPartnerRow)MainDS.DonorPartners.Rows.Find(giftRow.DonorKey);
giftDetail.DonorKey = giftRow.DonorKey;
giftDetail.DonorName = DonorRow.PartnerShortName;
giftDetail.DonorClass = DonorRow.PartnerClass;
giftDetail.MethodOfGivingCode = giftRow.MethodOfGivingCode;
giftDetail.MethodOfPaymentCode = giftRow.MethodOfPaymentCode;
AMotivationDetailRow motivationDetailRow = (AMotivationDetailRow)MainDS.AMotivationDetail.Rows.Find(
new object[] { ALedgerNumber, giftDetail.MotivationGroupCode, giftDetail.MotivationDetailCode });
//do the same for the Recipient
if (giftDetail.RecipientKey > 0)
{
// GiftAmount should never be negative. Negative Recurring gifts are not allowed!
if (giftDetail.GiftAmount < 0)
{
giftDetail.RecipientField = giftDetail.RecipientLedgerNumber;
}
else
//.........这里部分代码省略.........
示例9: SumAmounts
private static Decimal SumAmounts(DataView AGiftDetailViewByTransactionNumber,
Int32 AGiftTransactionNumber)
{
Decimal Result = 0.0m;
DataRowView[] detailsOfGift = AGiftDetailViewByTransactionNumber.FindRows(
new object[] { AGiftTransactionNumber });
foreach (DataRowView rv in detailsOfGift)
{
BankImportTDSAGiftDetailRow detailrow = (BankImportTDSAGiftDetailRow)rv.Row;
Result += detailrow.GiftTransactionAmount;
}
return Result;
}
示例10: FindDonorByAccountNumber
private static bool FindDonorByAccountNumber(AEpMatchRow AMatchRow,
DataView APartnerByBankAccount,
string ABankSortCode,
string AAccountNumber)
{
DataRowView[] rows = APartnerByBankAccount.FindRows(new object[] { ABankSortCode, AAccountNumber });
if (rows.Length == 1)
{
AMatchRow.DonorShortName = rows[0].Row["ShortName"].ToString();
AMatchRow.DonorKey = Convert.ToInt64(rows[0].Row["PartnerKey"]);
return true;
}
return false;
}
示例11: TestFindRows
public void TestFindRows ()
{
DataView TestView = new DataView (dataTable);
TestView.Sort = "itemId";
DataRowView[] Result = TestView.FindRows ("item 3");
Assert.AreEqual (1, Result.Length, "Dv #1");
Assert.AreEqual ("item 3", Result [0]["itemId"], "Dv #2");
}
示例12: StoreCurrentMatches
/// <summary>
/// store historic Gift matches
/// </summary>
private static void StoreCurrentMatches(BankImportTDS AMatchDS, string ABankAccountCode)
{
TLogging.LogAtLevel(1, "StoreCurrentMatches...");
DataView GiftDetailView = new DataView(
AMatchDS.AGiftDetail, string.Empty,
BankImportTDSAGiftDetailTable.GetGiftTransactionNumberDBName() + "," +
BankImportTDSAGiftDetailTable.GetDetailNumberDBName(),
DataViewRowState.CurrentRows);
SortedList <string, AEpMatchRow>MatchesToAddLater = new SortedList <string, AEpMatchRow>();
// for speed reasons, use a sortedlist instead of a dataview
SortedList <string, AEpMatchRow>MatchesByText = new SortedList <string, AEpMatchRow>();
foreach (AEpMatchRow r in AMatchDS.AEpMatch.Rows)
{
MatchesByText[r.MatchText + ":::" + r.Detail.ToString()] = r;
}
foreach (BankImportTDSAEpTransactionRow tr in AMatchDS.AEpTransaction.Rows)
{
// create a match text which uniquely identifies this transaction
string MatchText = CalculateMatchText(ABankAccountCode, tr);
if (tr.MatchAction != MFinanceConstants.BANK_STMT_STATUS_MATCHED)
{
continue;
}
// get the gift details assigned to this transaction
StringCollection GiftDetailNumbers = StringHelper.GetCSVList(tr.GiftDetailNumbers, ",", false);
foreach (string strDetailNumber in GiftDetailNumbers)
{
DataRowView[] FilteredGiftDetails =
GiftDetailView.FindRows(
new object[] {
tr.GiftTransactionNumber,
Convert.ToInt32(strDetailNumber)
});
// add new matches, and modify existing matches
UpdateMatches(
AMatchDS,
(BankImportTDSAGiftDetailRow)FilteredGiftDetails[0].Row,
MatchText,
Convert.ToInt32(strDetailNumber) - 1,
MatchesByText,
MatchesToAddLater);
}
}
// for speed reasons, add the new rows at the end
foreach (AEpMatchRow m in MatchesToAddLater.Values)
{
AMatchDS.AEpMatch.Rows.Add(m);
}
AMatchDS.PBankingDetails.Clear();
AMatchDS.AGiftDetail.Clear();
AMatchDS.AGift.Clear();
AMatchDS.ThrowAwayAfterSubmitChanges = true;
TLogging.LogAtLevel(1, "before submitchanges");
BankImportTDSAccess.SubmitChanges(AMatchDS);
TLogging.LogAtLevel(1, "after submitchanges");
}
示例13: CreateTradeAlert
/// <summary>
/// Create alerts for all stock in portfolio
/// </summary>
/// <param name="alertList"> all alert resulted from analysis </param>
private static void CreateTradeAlert(TradeAlert[] alertList)
{
decimal availabeQty;
string msg;
StringCollection timeScaleList;
data.baseDS.tradeAlertRow tradeAlertRow;
data.baseDS.tradeAlertDataTable tradeAlertTbl = new data.baseDS.tradeAlertDataTable();
data.baseDS.portfolioDetailDataTable portfolioDetailTbl = application.DbAccess.GetPortfolioDetail_ByType(new AppTypes.PortfolioTypes[] { AppTypes.PortfolioTypes.WatchList, AppTypes.PortfolioTypes.Portfolio });
DataView portfolioDetailView = new DataView(portfolioDetailTbl);
//Sort by Stock code + Strategy code
portfolioDetailView.Sort = portfolioDetailTbl.codeColumn.ColumnName + "," + portfolioDetailTbl.subCodeColumn.ColumnName;
DataRowView[] portfolioDetailFound;
data.baseDS.portfolioDetailRow portfolioDataRow;
// Only alert on stock codes that were selected by user.
for (int alertId = 0; alertId < alertList.Length; alertId++)
{
// Check if alert's strategy in user's wish list ??
portfolioDetailFound = portfolioDetailView.FindRows(new object[] { alertList[alertId].StockCode, alertList[alertId].Strategy.Trim() });
for (int dataIdx = 0; dataIdx < portfolioDetailFound.Length; dataIdx++)
{
// Check if time alert's time scale in user's wish list ??
portfolioDataRow = ((data.baseDS.portfolioDetailRow)portfolioDetailFound[dataIdx].Row);
timeScaleList = common.MultiValueString.String2List(portfolioDataRow.data.Trim());
if (!timeScaleList.Contains(alertList[alertId].TimeScale.Code)) continue;
//Ignore duplicate alerts.
tradeAlertRow = application.DbAccess.GetAlert(alertList[alertId].OnDateTime,
portfolioDataRow.portfolio,
alertList[alertId].StockCode,
alertList[alertId].Strategy,
alertList[alertId].TimeScale.Code,
AppTypes.CommonStatus.All);
if (tradeAlertRow != null) continue;
//Availabe stock
if (withAplicableCheckInAlert)
{
data.baseDS.stockExchangeRow stockExchangeRow = application.AppLibs.GetStockExchange(alertList[alertId].StockCode);
int sell2BuyInterval = (stockExchangeRow==null?0:stockExchangeRow.minBuySellDay);
availabeQty = application.DbAccess.GetAvailableStock(alertList[alertId].StockCode, portfolioDataRow.portfolio,
sell2BuyInterval, alertList[alertId].OnDateTime);
}
else availabeQty = 0;
//Aplicable to sell
if ((alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.Sell ||
alertList[alertId].TradePoint.TradeAction == AppTypes.TradeActions.ClearAll) && (availabeQty <= 0)) continue;
string infoText = alertList[alertId].TradePoint.BusinessInfo.ToText().Trim();
infoText = (infoText != "" ? infoText : common.Consts.constNotAvailable);
//Create alert template message, AlertMessageText() will convert it to specified-language text.
msg = commonClass.Consts.constTextMergeMarkerLEFT + "price" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + alertList[alertId].Price.ToString() + common.Consts.constCRLF +
commonClass.Consts.constTextMergeMarkerLEFT + "volume" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + alertList[alertId].Volume.ToString() + common.Consts.constCRLF +
commonClass.Consts.constTextMergeMarkerLEFT + "marketInfo" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + infoText + common.Consts.constCRLF;
if (availabeQty >0)
{
msg += commonClass.Consts.constTextMergeMarkerLEFT + "ownedQty" + commonClass.Consts.constTextMergeMarkerRIGHT + " : " + availabeQty.ToString() + common.Consts.constCRLF;
}
CreateTradeAlert(tradeAlertTbl, portfolioDataRow.portfolio, alertList[alertId].StockCode, alertList[alertId].Strategy,
alertList[alertId].TimeScale, alertList[alertId].TradePoint, alertList[alertId].OnDateTime, msg);
}
}
application.DbAccess.UpdateData(tradeAlertTbl);
}
示例14: MatchTransactionsToGiftBatch
/// <summary>
/// match imported transactions from bank statement to an existing gift batch
/// </summary>
/// <returns>true while new matches are found</returns>
private static bool MatchTransactionsToGiftBatch(BankImportTDS AMainDS)
{
bool newMatchFound = false;
DataView GiftDetailWithoutAmountView = new DataView(AMainDS.AGiftDetail,
string.Empty,
BankImportTDSAGiftDetailTable.GetDonorKeyDBName() + "," +
BankImportTDSAGiftDetailTable.GetAlreadyMatchedDBName(),
DataViewRowState.CurrentRows);
DataView GiftDetailByBatchNumberMatchStatus = new DataView(AMainDS.AGiftDetail,
string.Empty,
BankImportTDSAGiftDetailTable.GetAlreadyMatchedDBName(),
DataViewRowState.CurrentRows);
DataView TransactionsByBankAccountView = new DataView(AMainDS.AEpTransaction,
string.Empty,
BankImportTDSAEpTransactionTable.GetBankAccountNumberDBName() + "," +
BankImportTDSAEpTransactionTable.GetBranchCodeDBName() + "," +
BankImportTDSAEpTransactionTable.GetMatchActionDBName(),
DataViewRowState.CurrentRows);
foreach (BankImportTDSAEpTransactionRow transaction in AMainDS.AEpTransaction.Rows)
{
if (transaction.MatchAction == Ict.Petra.Shared.MFinance.MFinanceConstants.BANK_STMT_STATUS_UNMATCHED)
{
DataRowView[] filteredRows = GiftDetailByBatchNumberMatchStatus.FindRows(new object[] { false });
BankImportTDSAGiftDetailRow BestMatch = null;
int BestMatchNumber = 0;
foreach (DataRowView rv in filteredRows)
{
BankImportTDSAGiftDetailRow detailrow = (BankImportTDSAGiftDetailRow)rv.Row;
int matchNumberDonorSurname =
MatchingWords(Calculations.FormatShortName(detailrow.DonorShortName,
eShortNameFormat.eOnlySurname), transaction.AccountName);
if (matchNumberDonorSurname == 0)
{
// if surname does not match: ignore, just to be sure
// problem: will ignore umlaut etc. can be fixed for the next time by entering the bank account into OpenPetra
continue;
}
int matchNumberDonor = MatchingWords(detailrow.DonorShortName, transaction.AccountName) +
matchNumberDonorSurname * 3;
int matchNumberRecipient = MatchingWords(detailrow.RecipientDescription, transaction.Description);
if ((matchNumberDonor > 0) && (matchNumberRecipient > 0)
&& ((matchNumberDonor > 1) || (matchNumberRecipient > 1))
&& (matchNumberRecipient + matchNumberDonor > BestMatchNumber))
{
BestMatchNumber = matchNumberRecipient + matchNumberDonor;
BestMatch = detailrow;
}
}
if (BestMatch != null)
{
// get all gifts of this donor, and all bank statement transactions
DataRowView[] GiftDetailWithoutAmount = GiftDetailWithoutAmountView.FindRows(
new object[] { BestMatch.DonorKey, false });
DataRowView[] TransactionsByBankAccount = TransactionsByBankAccountView.FindRows(
new object[] { transaction.BankAccountNumber, transaction.BranchCode, MFinanceConstants.BANK_STMT_STATUS_UNMATCHED });
while (MatchOneDonor(AMainDS, GiftDetailWithoutAmount, TransactionsByBankAccount))
{
GiftDetailWithoutAmount = GiftDetailWithoutAmountView.FindRows(
new object[] { BestMatch.DonorKey, false });
TransactionsByBankAccount = TransactionsByBankAccountView.FindRows(
new object[] { transaction.BankAccountNumber, transaction.BranchCode, MFinanceConstants.BANK_STMT_STATUS_UNMATCHED });
newMatchFound = true;
}
}
}
}
return newMatchFound;
}
示例15: MatchDonorsWithKnownBankaccount
/// <summary>
/// match imported transactions from bank statement to an existing gift batch;
/// this method is only for donors that can be identified by their bank account
/// </summary>
private static void MatchDonorsWithKnownBankaccount(BankImportTDS AMainDS)
{
DataView GiftDetailWithoutAmountView = new DataView(AMainDS.AGiftDetail,
string.Empty,
BankImportTDSAGiftDetailTable.GetDonorKeyDBName() + "," +
BankImportTDSAGiftDetailTable.GetAlreadyMatchedDBName(),
DataViewRowState.CurrentRows);
DataView TransactionsByDonorView = new DataView(AMainDS.AEpTransaction,
string.Empty,
BankImportTDSAEpTransactionTable.GetDonorKeyDBName() + "," +
BankImportTDSAEpTransactionTable.GetMatchActionDBName(),
DataViewRowState.CurrentRows);
foreach (BankImportTDSAEpTransactionRow transaction in AMainDS.AEpTransaction.Rows)
{
if ((transaction.DonorKey != -1)
&& (transaction.MatchAction == MFinanceConstants.BANK_STMT_STATUS_UNMATCHED))
{
// get all gifts of this donor, and all bank statement transactions
DataRowView[] GiftDetailWithoutAmount = GiftDetailWithoutAmountView.FindRows(
new object[] { transaction.DonorKey, false });
DataRowView[] TransactionsByDonor = TransactionsByDonorView.FindRows(
new object[] { transaction.DonorKey, MFinanceConstants.BANK_STMT_STATUS_UNMATCHED });
while (MatchOneDonor(AMainDS, GiftDetailWithoutAmount, TransactionsByDonor))
{
GiftDetailWithoutAmount = GiftDetailWithoutAmountView.FindRows(
new object[] { transaction.DonorKey, false });
TransactionsByDonor = TransactionsByDonorView.FindRows(
new object[] { transaction.DonorKey, MFinanceConstants.BANK_STMT_STATUS_UNMATCHED });
}
}
}
}