private void addButton_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(symbolStockChartsEntry.Text)) { DisplayAlert("Error", "Symbol of Stock Charts must not be blank", "Accept"); symbolStockChartsEntry.Focus(); return; } if (beginDateStockChartsPicker.Date > endDateStockChartsPicker.Date) { DisplayAlert("Error", "Begin date must <= End date", "Accept"); beginDateStockChartsPicker.Focus(); return; } StockCharts stockcharts = new StockCharts { SymbolStockCharts = symbolStockChartsEntry.Text, NoteStockCharts = noteStockChartsEntry.Text, BeginDateStockCharts = beginDateStockChartsPicker.Date.AddHours(localZone.BaseUtcOffset.Hours), EndDateStockCharts = endDateStockChartsPicker.Date.AddHours(localZone.BaseUtcOffset.Hours), }; using (var data = new DataAccess()) { data.InsertStockCharts(stockcharts); stockChartsListView.ItemsSource = data.GetStockCharts(); } symbolStockChartsEntry.Text = string.Empty; noteStockChartsEntry.Text = string.Empty; beginDateStockChartsPicker.Date = DateTime.Now; endDateStockChartsPicker.Date = DateTime.Now; }
public async void SaveButton_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(symbolStockChartsEntry.Text)) { await DisplayAlert("Error", "You must enter names", "Accept"); symbolStockChartsEntry.Focus(); return; } StockCharts stockcharts = new StockCharts { IDStockCharts = this.stockcharts.IDStockCharts, SymbolStockCharts = symbolStockChartsEntry.Text, NoteStockCharts = noteStockChartsEntry.Text, BeginDateStockCharts = beginDateStockChartsPicker.Date, EndDateStockCharts = endDateStockChartsPicker.Date, }; using (var data = new DataAccess()) { data.UpdateStockCharts(stockcharts); } await DisplayAlert("Confirm", "Content of note updated correctly", "Accept"); await Navigation.PushAsync(new HomePage()); }
public static async Task <Stock> GetStocks(StockCharts stockcharts) { string queryString = String.Format( "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20in%20(%22{0}%22)%20and%20startDate%20=%20%27{1:yyyy/MM/dd}%27%20and%20endDate%20=%20%27{2:yyyy/MM/dd}%27&diagnostics=false&format=json&env=store://datatables.org/alltableswithkeys", stockcharts.SymbolStockCharts, stockcharts.BeginDateStockCharts.Date, stockcharts.EndDateStockCharts.Date); var results = await StockService.getDataFromService(queryString).ConfigureAwait(false); int count = (int)results["query"]["count"]; if (count == 0) { return(null); } Stock stock = new Stock(); stock.IDStock = 0; int id = 1; while (count > 0) { stock.IDStock = id; stock.IDsCharts = stockcharts.IDStockCharts; stock.SymbolStock = (string)results["query"]["results"]["quote"][count - 1]["Symbol"]; stock.ValueCloseStockEntry = (float)results["query"]["results"]["quote"][count - 1]["Close"]; stock.DateStock = (DateTime)results["query"]["results"]["quote"][count - 1]["Date"]; using (var data = new DataAccess()) { data.InsertStock(stock); } --count; ++id; } return(stock); }
public EditPage(StockCharts stockcharts) { InitializeComponent(); this.stockcharts = stockcharts; saveButton.Clicked += SaveButton_Clicked; deleteButton.Clicked += DeleteButton_Clicked; updateButton.Clicked += UpdateButton_Clicked; symbolStockChartsEntry.Text = stockcharts.SymbolStockCharts; noteStockChartsEntry.Text = stockcharts.NoteStockCharts; beginDateStockChartsPicker.Date = stockcharts.BeginDateStockCharts; endDateStockChartsPicker.Date = stockcharts.EndDateStockCharts; beginDateStockChartsPicker.Date = stockcharts.BeginDateStockCharts; endDateStockChartsPicker.Date = stockcharts.EndDateStockCharts; stockListView.ItemTemplate = new DataTemplate(typeof(StockCell)); using (var data = new DataAccess()) { data.DeleteStock(); } }
public void DeleteStockCharts(StockCharts stockcharts) { connection.Delete(stockcharts); }
public void UpdateStockCharts(StockCharts stockcharts) { connection.Update(stockcharts); }
public void InsertStockCharts(StockCharts stockcharts) { connection.Insert(stockcharts); }