当前位置: 首页>>代码示例>>C#>>正文


C# DataProvider.Add方法代码示例

本文整理汇总了C#中DataProvider.Add方法的典型用法代码示例。如果您正苦于以下问题:C# DataProvider.Add方法的具体用法?C# DataProvider.Add怎么用?C# DataProvider.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataProvider的用法示例。


在下文中一共展示了DataProvider.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: setData

        public void setData( List<OrderDataModel> orders )
        {
            OrderDataModel order = null;
            DataProvider data = new DataProvider();
            for (int i = 0; i < orders.Count; i++)
            {
                order = orders[i];
                data.Add(new RowDataProvider());
                data[i].id = i;

                data[i].Add(new GridColumnData());
                data[i][0].value = order.orderID.ToString();
                data[i][0].numeric = order.orderID;

                data[i].Add(new GridColumnData());
                data[i][1].value = order.orderStatus;
                data[i][1].numeric = order.orderStatus.Equals("closed") ? 0 : 1;

                data[i].Add(new GridColumnData());
                data[i][2].value = order.openDate.ToString();
                data[i][2].numeric = (int)(order.openDate.Ticks / 10000);

                data[i].Add(new GridColumnData());
                data[i][3].value = order.completionDate.ToString();
                data[i][3].numeric = (int)(order.completionDate.Ticks / 10000);

                data[i].Add(new GridColumnData());
                data[i][4].value = string.Format("{0:C}", order.orderFee);
                data[i][4].numeric = (int)(order.orderFee * 100);

                data[i].Add(new GridColumnData());
                data[i][5].value = order.orderType;
                data[i][5].numeric = order.orderType.Equals("buy") ? 1 : 0;

                data[i].Add(new GridColumnData());
                data[i][6].value = order.symbol;
                data[i][6].numeric = (int)(order.quantity * 100);

                data[i].Add(new GridColumnData());
                data[i][7].value = order.quantity.ToString();
                data[i][7].numeric = (int)(order.quantity * 100);
            }

            OrderGrid.setData(data);
        }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:45,代码来源:OrderAlert.xaml.cs

示例2: LoadData

        public void LoadData()
        {
            if (App.BSL == null || Login.UserInfo == null)
            {
                this.Visibility = Visibility.Hidden;
                return;
            }

            OrderDataModel order = null;
            if (Action == TradeAction.Buy)
            {
                try
                {
                    if ((order = App.BSL.buy(Login.UserInfo.profileID, Trade.ID, Trade.Quantity, 0)) != null)
                    {
                        AlertMessage("Order " + order.orderID + " to buy " + order.quantity + " shares of " + order.symbol + " has been submitted for processing.");
                    }
                    
                }
                catch (Exception ex)
                {
                    AlertMessage("Failed to process buy order, exception: " + ex.ToString());
                }
            }
            else if( Action == TradeAction.Sell )
            {
                try
                {
                    if (Trade.Quantity == 0)
                    {
                        order = App.BSL.sell(Login.UserInfo.profileID, Convert.ToInt32(Trade.ID), 0);
                    }
                    else
                    {
                        order = App.BSL.sellEnhanced(Login.UserInfo.profileID, Convert.ToInt32(Trade.ID), Trade.Quantity);
                    }
                    if (order != null)
                    {
                        AlertMessage("Order " + order.orderID + " to sell " + order.quantity + " shares of " + order.symbol + " has been submitted for processing.");
                    }
                }
                catch (Exception ex)
                {
                    AlertMessage("Failed to process sell order, Exception: " + ex.ToString());
                }
            }
            Action = TradeAction.None;

            try
            {
                List<OrderDataModel> orders = App.BSL.getOrders(Login.UserInfo.profileID);
                Update.Text = "as of " + DateTime.Now;
                DataProvider data = new DataProvider();
                for (int i = 0; i < orders.Count; i++)
                {
                    order = orders[i];
                    data.Add(new RowDataProvider());
                    data[i].id = i;

                    data[i].Add(new GridColumnData());
                    data[i][0].value = order.orderID.ToString();
                    data[i][0].numeric = order.orderID;

                    data[i].Add(new GridColumnData());
                    data[i][1].value = order.orderStatus;
                    data[i][1].numeric = order.orderStatus.Equals("closed") ? 0 : 1;

                    data[i].Add(new GridColumnData());
                    data[i][2].value = order.openDate.ToString();
                    data[i][2].numeric = (int)(order.openDate.Ticks / 10000);

                    data[i].Add(new GridColumnData());
                    data[i][3].value = order.completionDate.ToString();
                    data[i][3].numeric = (int)(order.completionDate.Ticks / 10000);

                    data[i].Add(new GridColumnData());
                    data[i][4].value = string.Format("{0:C}", order.orderFee);
                    data[i][4].numeric = (int)(order.orderFee * 100);

                    data[i].Add(new GridColumnData());
                    data[i][5].value = order.orderType;
                    data[i][5].numeric = order.orderType.Equals("buy") ? 1 : 0;

                    data[i].Add(new GridColumnData());
                    data[i][6].value = order.symbol;
                    data[i][6].numeric = (int)(order.quantity * 100);

                    data[i].Add(new GridColumnData());
                    data[i][7].value = order.quantity.ToString();
                    data[i][7].numeric = (int)(order.quantity * 100);
                }

                OrderGrid.setData(data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            this.Visibility = Visibility.Visible;
        }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:100,代码来源:Order.xaml.cs

示例3: onSectionReady

        public override void onSectionReady()
        {
            PortfolioGrid.ApplyEffects();

            // load data
            if (App.BSL == null || Login.UserInfo == null)
            {
                this.Visibility = Visibility.Hidden;
                return;
            }

            try
            {
                List<HoldingDataModel> holdings = App.BSL.getHoldings(Login.UserInfo.profileID);
                Update.Text = "as of " + DateTime.Now;
                DataProvider data = new DataProvider();
                List<PieElement> graphData = rowsGraphData = new List<PieElement>();
                for (int i = 0; i < holdings.Count; i++)
                {
                    QuoteDataModel quote = App.BSL.getQuote(holdings[i].quoteID);

                    decimal marketValue = (decimal)holdings[i].quantity * quote.price;
                    decimal basis = (decimal)holdings[i].quantity * (decimal)holdings[i].purchasePrice;
                    decimal gain = marketValue - basis;

                    graphData.Add(new PieElement(quote.symbol, (double)marketValue));


                    RowDataProvider row = new RowDataProvider();
                    row.id = i;

                    // id, date, symbol, quantity, purchase price, current price, basis, market value, gain, trade
                    row.Add(new GridColumnData());
                    row[0].value = holdings[i].holdingID.ToString();
                    row[0].numeric = holdings[i].holdingID;

                    row.Add(new GridColumnData());
                    row[1].value = holdings[i].purchaseDate.ToString();
                    row[1].numeric = (int)(holdings[i].purchaseDate.Ticks / 10000);

                    row.Add(new GridColumnData());
                    row[2].value = holdings[i].quoteID;
                    row[2].numeric = i;

                    row.Add(new GridColumnData());
                    row[3].value = string.Format("{0:0,0}", holdings[i].quantity);
                    row[3].numeric = (int)holdings[i].quantity;

                    row.Add(new GridColumnData());
                    row[4].value = string.Format("{0:C}", holdings[i].purchasePrice);
                    row[4].numeric = (int)(holdings[i].purchasePrice * 100);

                    row.Add(new GridColumnData());
                    row[5].value = string.Format("{0:C}", quote.price);
                    row[5].numeric = (int)(quote.price * 100);

                    row.Add(new GridColumnData());
                    row[6].value = string.Format("{0:C}", basis);
                    row[6].numeric = (int)(basis * 100);

                    row.Add(new GridColumnData());
                    row[7].value = string.Format("{0:C}", marketValue);
                    row[7].numeric = (int)(marketValue * 100);

                    row.Add(new GridColumnGainData());
                    row[8].value = string.Format("{0:C}", gain);
                    row[8].numeric = (int)(gain * 100);
                    (row[8] as GridColumnGainData).increased = gain == 0 ? 0 : (gain > 0 ? 1 : -1);

                    row.Add(new GridColumnData());
                    row[9].value = "SELL";
                    row[9].numeric = i;

                    data.Add(row);
                }

                PortfolioGrid.setData(data);
                ToolTip.setData(graphData);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            this.Visibility = Visibility.Visible;
        }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:85,代码来源:Portfolio.xaml.cs

示例4: onSectionReady

        public override void onSectionReady()
        {
            if (App.BSL == null || Login.UserInfo == null)
            {
                this.Visibility = Visibility.Hidden;
                return;
            }

            Update.Text = "as of " + DateTime.Now;

            try
            {
                GetHoldingsAsync caller1 = new GetHoldingsAsync(GetHoldings);
                // Initiate the asychronous call.
                IAsyncResult result1 = caller1.BeginInvoke(null, null);
                // Repeat
                GetCustomerAsync caller2 = new GetCustomerAsync(GetCustomer);
                // Initiate the asychronous call.
                IAsyncResult result2 = caller2.BeginInvoke(null, null);
                MarketSummaryDataModelWS summary = App.BSL.getMarketSummary();
                List<HoldingDataModel> holdings = caller1.EndInvoke(result1);
                AccountDataModel customer = caller2.EndInvoke(result2);
                decimal marketValue = 0;
                decimal gain = 0;
                decimal basis = 0;
                decimal _gain = (decimal)0.00;
                decimal percentGain = (decimal)0.00;

                for (int i = 0; i < holdings.Count; i++)
                {
                    QuoteDataModel quote = App.BSL.getQuote(holdings[i].quoteID);
                    decimal _marketValue = (decimal)holdings[i].quantity * quote.price;
                    decimal _basis = (decimal)holdings[i].quantity * (decimal)holdings[i].purchasePrice;
                    gain += _marketValue - _basis;
                    marketValue += _marketValue;
                    basis += _basis;
                }

                AccountID.Text = customer.accountID.ToString();
                CreationDate.Text = customer.creationDate.ToString();
                LoginCount.Text = customer.loginCount.ToString();
                OpenBalance.Text = string.Format("{0:C}", customer.openBalance);
                Balance.Text = string.Format("{0:C}", customer.balance);
                NumHoldings.Text = holdings.Count.ToString();
                HoldingsTotal.Text = string.Format("{0:C}", marketValue);
                decimal totalcashandholdings = marketValue + customer.balance;
                SumOfCashHoldings.Text = string.Format("{0:C}", totalcashandholdings);
                _gain = totalcashandholdings - customer.openBalance;
                if (customer.openBalance != 0)
                    percentGain = gain / customer.openBalance * 100;
                else
                    percentGain = 0;

                Gain.Text = string.Format("{0:C}", _gain);
                PercentGain.Text = string.Format("{0:N}%", percentGain);
                if (_gain > 0)
                {
                    PercentGain.Foreground = new SolidColorBrush(Color.FromRgb(37, 120, 32));

                    GainIcon icon = new GainIcon();
                    icon.VerticalAlignment = VerticalAlignment.Bottom;
                    icon.HorizontalAlignment = HorizontalAlignment.Left;
                    icon.Margin = new Thickness(PercentGain.Margin.Left + PercentGain.ActualWidth + 40, PercentGain.Margin.Top, PercentGain.Margin.Right, PercentGain.Margin.Bottom);
                    LayoutRoot.Children.Add(icon);
                }
                else if (_gain < 0)
                {
                    PercentGain.Foreground = new SolidColorBrush(Color.FromRgb(191, 0, 0));
                    LossIcon icon = new LossIcon();
                    icon.VerticalAlignment = VerticalAlignment.Bottom;
                    icon.HorizontalAlignment = HorizontalAlignment.Left;
                    icon.Margin = new Thickness(PercentGain.Margin.Left + PercentGain.ActualWidth + 40, PercentGain.Margin.Top, PercentGain.Margin.Right, PercentGain.Margin.Bottom);
                    LayoutRoot.Children.Add(icon);

                }
                else
                    PercentGain.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));

                
                TSIA.Text = String.Format("{0:N}", summary.TSIA);
                Volume.Text = String.Format("{0:N}", summary.volume);

                DataProvider data = new DataProvider();
                for (int i = 0; i < summary.topGainers.Count; i++)
                {
                    QuoteDataModel quote = summary.topGainers[i];



                    RowDataProvider row = new RowDataProvider();
                    row.id = i;

                    // symbol, current price, gain
                    row.Add(new GridColumnData());
                    row[0].value = quote.symbol;
                    row[0].numeric = i;

                    row.Add(new GridColumnGainData());
                    row[1].value = string.Format("{0:C}", quote.price);
                    row[1].numeric = (int)(quote.price * 100);
//.........这里部分代码省略.........
开发者ID:vactorwu,项目名称:catch23-project,代码行数:101,代码来源:Home.xaml.cs

示例5: LoadData

        public void LoadData()
        {
            // get quotes based on QuotesParameter
            if (App.BSL == null || Login.UserInfo == null) return;

            try
            {
                Update.Text = "as of " + DateTime.Now;
                GetQuote.Text = QuotesParameter;
                string[] quotes = QuotesParameter.Split(new char[] { ' ', ',', ';' });
                DataProvider data = new DataProvider();
                foreach (string quote in quotes)
                {
                    string quoteTrim = quote.Trim();
                    if (!quoteTrim.Equals(""))
                    {
                        QuoteDataModel quoteData = App.BSL.getQuote(quoteTrim);
                        if (quoteData == null) continue;

                        RowDataProvider row = new RowDataProvider();
                        data.Add(row);
                        row.id = data.Count - 1;

                        GridColumnData symbol = new GridColumnData();
                        symbol.value = quoteData.symbol;
                        symbol.numeric = (int)(quoteData.price * 100);
                        row.Add(symbol);

                        GridColumnData company = new GridColumnData();
                        company.value = quoteData.companyName;
                        company.numeric = (int)(quoteData.price * 100);
                        row.Add(company);

                        GridColumnData volume = new GridColumnData();
                        volume.value = string.Format("{0:0,0}", quoteData.volume);
                        volume.numeric = (int)(quoteData.volume * 100);
                        row.Add(volume);

                        GridColumnData range = new GridColumnData();
                        range.value = string.Format("{0:C}", quoteData.low) + " - " + string.Format("{0:C}", quoteData.high);
                        range.numeric = (int)(quoteData.low * 100);
                        row.Add(range);

                        GridColumnData open = new GridColumnData();
                        open.value = string.Format("{0:C}", quoteData.open);
                        open.numeric = (int)(quoteData.low * 100);
                        row.Add(open);

                        GridColumnGainData current = new GridColumnGainData();
                        current.value = string.Format("{0:C}", quoteData.price);
                        current.numeric = (int)(quoteData.price * 100);
                        current.increased = quoteData.change == 0 ? 0 : (quoteData.change > 0 ? 1 : -1);
                        row.Add(current);

                        GridColumnGainData gain = new GridColumnGainData();
                        gain.value = string.Format("{0:C}", quoteData.change);
                        gain.numeric = (int)(quoteData.change * 100);
                        gain.increased = quoteData.change == 0 ? 0 : (quoteData.change > 0 ? 1 : -1);
                        row.Add(gain);

                        GridColumnData buy = new GridColumnData();
                        buy.value = "BUY";
                        buy.numeric = (int)(quoteData.change * 100);
                        row.Add(buy);
                    }
                }

                QuoteGrid.setData(data);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "StockTrader - Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:74,代码来源:Quotes.xaml.cs


注:本文中的DataProvider.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。