public void createPaymentList() { GenRetainer genRet; string sql = @"select * from [LedgerHistory] inner join Matter on MatSysNbr = LHMatter and MatStatusFlag <> 'C' where LHType in ('6', '5')"; SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=Juris5573000;Integrated Security=SSPI;"); using (var command = new SqlCommand(sql, con)) { con.Open(); int count = 1; using (var reader = command.ExecuteReader()) { while (reader.Read()) { try { genRet = new GenRetainer(); genRet.ID = count; string[] dates = reader["lhDate"].ToString().Trim().Split(' '); string[] final = dates[0].Split('/'); if (final[0].Length < 2) { final[0] = "0" + final[0]; } if (final[1].Length < 2) { final[1] = "0" + final[1]; } genRet.date = final[2] + final[0] + final[1]; genRet.checkNo = count.ToString(); genRet.invoiceID = ""; genRet.bankAccount = "CZB"; genRet.explanation = reader["lhcomment"].ToString().Trim(); genRet.matterID = reader["lhmatter"].ToString().Trim(); genRet.payment = double.Parse(reader["lhcashamt"].ToString().Trim()); if (reader["lhtype"].ToString().Trim().Equals("6")) { genRet.payment = genRet.payment * -1; } clientList.Add(genRet); count++; } catch (Exception inner1) { MessageBox.Show("Inner: " + inner1.Message); } } } } }
public void createPaymentList() { Payment payment; GenRetainer genRet; string sql = @"SELECT * FROM [GBAlloc] inner join gbcomm on GBankCommInfID = GBankAllocInfCheckID inner join arinv on ARInvoiceInvNumber = GBankCommInfInvoice where GBankAllocInfStatus = 0 and GBankAllocInfEntryType = 1101"; SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=PCLAWDB_69606;Integrated Security=SSPI;"); using (var command = new SqlCommand(sql, con)) { con.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { try { payment = new Payment(); payment.ID = int.Parse(reader["GBankAllocInfAllocID"].ToString().Trim()); payment.date = reader["GBankCommInfDate"].ToString().Trim(); payment.client = ""; payment.glAcct = ""; payment.paymentClass = 0; payment.bankAcctID = reader["GBankCommInfAccountID"].ToString().Trim(); payment.checkNo = reader["GBankCommInfClientCheck"].ToString().Trim(); payment.transID = reader["GBankCommInfCheck"].ToString().Trim(); payment.received = double.Parse(reader["GBankAllocInfAmount"].ToString().Trim()); payment.applied = double.Parse(reader["GBankAllocInfAmount"].ToString().Trim()); payment.invoice = reader["InvoiceID"].ToString().Trim(); payment.explanation = reader["GBankAllocInfExplanation"].ToString().Trim(); payment.oldID = reader["GBankAllocInfAllocID"].ToString().Trim(); payment.paymentType = 0; payment.matter = reader["matterid"].ToString().Trim(); paymentList.Add(payment); } catch (Exception inner1) { MessageBox.Show("Inner: " + inner1.Message); } } } } sql = @"SELECT * FROM [GBAlloc] inner join gbcomm on GBankCommInfID = GBankAllocInfCheckID where GBankAllocInfStatus = 0 and GBankAllocInfEntryType = 1101 and GBankCommInfInvoice = ''"; using (var command = new SqlCommand(sql, con)) { //con.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { try { genRet = new GenRetainer(); genRet.ID = int.Parse(reader["GBankAllocInfAllocID"].ToString().Trim()); genRet.date = reader["GBankCommInfDate"].ToString().Trim(); genRet.checkNo = reader["GBankCommInfCheck"].ToString().Trim(); genRet.invoiceID = ""; genRet.bankAccount = reader["GBankCommInfAccountID"].ToString().Trim(); genRet.explanation = reader["GBankAllocInfExplanation"].ToString().Trim(); genRet.matterID = reader["matterid"].ToString().Trim(); genRet.payment = double.Parse(reader["GBankAllocInfAmount"].ToString().Trim()); gretList.Add(genRet); } catch (Exception inner1) { MessageBox.Show("Inner: " + inner1.Message); } } } } }