コード例 #1
0
        public static List <int> SelectAllNotPaidNotaDebitoInvoicesDistByNumberPerDate(int countryId, DateTime date)
        {
            #region SQL

            const string SQL = @"SELECT DISTINCT in_number FROM NotaDebitoInvoice 
                              WHERE in_iso_id = @iso and in_paid = 'N' and CAST(in_date as DATE) = @date and in_sepa_msgid is NULL and in_type in ('N', '0') 
                              ORDER BY in_number;";

            #endregion

            var list = new List <int>();

            using (var comm = new SqlCommand(SQL))
            {
                comm.Parameters.AddWithValue("@iso", countryId);
                comm.Parameters.AddWithValue("@date", date.Date);
                var data = comm.CreateSerializationData().ToList().ToArray();
                DataServiceClient client = new DataServiceClient();
                var result = client.TRSExecuteReader(data);
                using (DataTableReader reader = new DataTableReader(result.Data.ToDataTable()))
                    while (reader.Read())
                    {
                        var number = reader.Get <int>("in_number").GetValueOrDefault();
                        list.Add(number);
                    }
            }
            return(list);
        }