Пример #1
0
 //        public Dictionary<int, decimal> GetListOfTransitionToGoodLoan(DateTime launchDate)
 //        {
 //            const string q = @"SELECT a1.id,a1.olb,a1.late_days
 //                            FROM dbo.ActiveLoans(@date, 0) a1
 //                            INNER JOIN dbo.ActiveLoans(DATEADD(dd,-1,@date), 0) a2 ON a2.id = a1.id
 //                            WHERE a1.late_days = 0 and a2.late_days>0";
 //            using (var connection = GetConnection())
 //            using (var c = new OpenCbsCommand(q, connection))
 //            {
 //                c.AddParam("date", launchDate);
 //                using (var r = c.ExecuteReader())
 //                {
 //                    var dict = new Dictionary<int, decimal>();
 //                    while (r.Read())
 //                        dict.Add(r.GetInt("id"), r.GetDecimal("olb"));
 //                    return dict;
 //                }
 //            }
 //        }
 public DateTime LastLoanTransitionEventDate()
 {
     const string q = @"SELECT TOP 1 ce.event_date
                     FROM dbo.LoanTransitionEvents AS tr
                     LEFT JOIN dbo.ContractEvents AS ce ON ce.id=tr.id
                     ORDER BY ce.id DESC";
     using (var connection = GetConnection())
     using (var r = new OpenCbsCommand(q, connection).ExecuteReader())
     {
         return !r.Read() ? DateTime.Today.AddDays(-1) : r.GetDateTime("event_date");
     }
 }