Ejemplo n.º 1
0
        public static DataTable LoadRates(string currencyFrom, string currencyTo, string orderBy, string refreshFromWeb)
        {
            //should refresh from web?
            bool refreshWeb = string.IsNullOrEmpty(refreshFromWeb);

            ds.RatesDataTable rdt;
            loadRatesFromWeb(out rdt, refreshWeb);

            //filter by from
            if (!string.IsNullOrEmpty(currencyFrom))
            {
                var arr = rdt.WhereFrom(currencyFrom);
                rdt = TableTools.ImportRows(rdt, arr) as ds.RatesDataTable;
            }
            //filter by to
            if (!string.IsNullOrEmpty(currencyTo))
            {
                var arr = rdt.WhereTo(currencyTo);
                rdt = TableTools.ImportRows(rdt, arr) as ds.RatesDataTable;
            }

            //order by
            if (string.IsNullOrEmpty(orderBy))
            {
                orderBy = "from";
            }
            rdt = TableTools.SortBy(orderBy.Trim(), rdt) as ds.RatesDataTable;


            return(rdt);
        }
Ejemplo n.º 2
0
        public static DataTable LoadTransactions(string desiredCurrency, string desiredSKU, string justTotals, string orderByColumn, string refreshFromWeb)
        {
            //should refresh from web?
            bool refreshWeb = string.IsNullOrEmpty(refreshFromWeb);

            ds.TransactionsDataTable tdt;
            loadTransactionsFromWeb(out tdt, refreshWeb);

            //filter by SKU
            desiredSKU = desiredSKU.Trim();
            if (!string.IsNullOrEmpty(desiredSKU))
            {
                var arr = tdt.WhereSKU(desiredSKU);
                tdt = TableTools.ImportRows(tdt, arr) as ds.TransactionsDataTable;
            }

            //order
            if (string.IsNullOrEmpty(orderByColumn.Trim()))
            {
                orderByColumn = "sku, currency";
            }
            tdt = TableTools.SortBy(orderByColumn.Trim(), tdt) as ds.TransactionsDataTable;


            desiredCurrency = desiredCurrency.Trim();
            bool fillTotals = !string.IsNullOrEmpty(justTotals);

            ds.RatesDataTable rdt = LoadRates(string.Empty, string.Empty, string.Empty, "n") as ds.RatesDataTable;

            DataTable dtResult = convertTransactionsRates(desiredCurrency, ref tdt, ref rdt, fillTotals);


            return(dtResult);
        }