示例#1
0
        /// <summary>
        ///     Returns a list of ItemDesc object
        /// </summary>
        /// <returns></returns>
        public List <ItemDescription> GetAllItems()
        {
            const string sql = "select * from ItemDesc";

            var result = new List <ItemDescription>();
            var ds     = _dataAccess.ExecuteSqlStatement(sql).Tables[0].AsEnumerable();

            foreach (var row in ds)
            {
                var itemDescription = new ItemDescription {
                    ItemCode = row.Field <int>("ItemCode"),
                    ItemDesc = row.Field <string>("ItemDesc"),
                    ItemCost = row.Field <decimal>("Cost")
                };

                result.Add(itemDescription);
            }

            return(result);
        }
示例#2
0
        /// <summary>
        ///     Returns a data set containing all invoices from the database
        /// </summary>
        /// <returns></returns>
        public List <Invoice> GetAllItems()
        {
            var sql = $"SELECT Invoices.InvoiceNum, Invoices.InvoiceDate, Invoices.TotalCost FROM Invoices;";

            var result = new List <Invoice>();
            var ds     = _dataAccess.ExecuteSqlStatement(sql).Tables[0].AsEnumerable();

            foreach (var row in ds)
            {
                var inv = new Invoice
                {
                    InvoiceNumber = row.Field <int>("InvoiceNum"),
                    InvoiceDate   = row.Field <DateTime>("InvoiceDate"),
                    TotalCost     = row.Field <int>("TotalCost")
                };

                result.Add(inv);
            }

            return(result);
        }