public bool LoadCheckReconcile(string accountId) { SaveRecord(); m_registerRecs.Clear(); textDate.Text = ""; comboType.SelectedIndex = -1; textCheckNumber.Text = ""; comboDescription.Text = ""; comboDescription.SelectedIndex = -1; comboDescription.Items.Clear(); textAmount.Text = ""; checkCleared.Checked = false; checkArchived.Checked = false; m_accountId = accountId; string sql = string.Format("select description from vendor_names where account_id = '{0}'", accountId); OleDbCommand selectCmd = new OleDbCommand(sql, m_dbConnection); OleDbDataReader dataReader = selectCmd.ExecuteReader(); while(dataReader.Read()) { comboDescription.Items.Add(dataReader[0].ToString()); } dataReader.Close(); sql = string.Format("select * from check_register where account_id = '{0}' and cleared = 0 order by trans_date", accountId); selectCmd = new OleDbCommand(sql, m_dbConnection); dataReader = selectCmd.ExecuteReader(); while(dataReader.Read()) { CheckRegister rec = new CheckRegister(); rec.Load(dataReader); m_registerRecs.Add(rec); } dataReader.Close(); sql = string.Format("select * from bank_transactions where account_id = '{0}' and check_register_id is null", accountId); selectCmd = new OleDbCommand(sql, m_dbConnection); dataReader = selectCmd.ExecuteReader(); listTransactions.Items.Clear(); while(dataReader.Read()) { BankTransaction tran = new BankTransaction(); tran.Load(dataReader); ListViewItem item = new ListViewItem(); item.Tag = tran; tran.Tag = item; item.Text = tran.TransType; item.SubItems.Add(tran.CheckNumber); if("" == tran.TransName) { item.SubItems.Add(tran.Description); } else { item.SubItems.Add(string.Format("{0} - {1}", tran.TransName, tran.Description)); } item.SubItems.Add(tran.TransDate.ToShortDateString()); item.SubItems.Add(tran.TransAmount.ToString("C")); listTransactions.Items.Add(item); } dataReader.Close(); UpdateBalances(); if(m_registerRecs.Count > 0) { CheckRegister rec = (CheckRegister)m_registerRecs[0]; DisplayRegisterRec(rec); } return true; }
private void FindMatches() { listMatches.Items.Clear(); CheckRegister rec = (CheckRegister)Tag; string sql = string.Format("select * from bank_transactions where account_id = '{0}' and (trans_amount = {1} or trans_amount = -{1}) and check_register_id is null", rec.AccountId, rec.Amount); OleDbCommand selectCmd = new OleDbCommand(sql, m_dbConnection); OleDbDataReader dataReader = selectCmd.ExecuteReader(); ListViewItem item = null; while(dataReader.Read()) { BankTransaction tran = new BankTransaction(); tran.Load(dataReader); item = new ListViewItem(); item.Tag = tran; tran.Tag = item; item.Text = tran.TransType; item.SubItems.Add(tran.CheckNumber); if("" != tran.TransName) { item.SubItems.Add(tran.TransName); } else { item.SubItems.Add(tran.Description); } item.SubItems.Add(tran.TransDate.ToShortDateString()); item.SubItems.Add(tran.TransAmount.ToString("C")); listMatches.Items.Add(item); } dataReader.Close(); }