protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); App app = Application.Current as App; if (app.AuxParam != null && app.AuxParam.GetType() == typeof(Task)) { task = (Task)app.AuxParam; txtDescription.Text = task.Description; using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { List<SubTask> subTasks = (from subtask in banco.SubTasks where subtask.TaskId == task.Id select subtask).ToList(); foreach (var subTask in subTasks) { if (subTask.Status == 0) { subTask.Color = new SolidColorBrush(Colors.Red); } else { subTask.Color = new SolidColorBrush(Colors.Green); } } lstResultado.ItemsSource = subTasks; } } }
public void CarregarLista() { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { List<Task> tasks = (from task in banco.Tasks select task).ToList(); lstResultado.ItemsSource = tasks; } ItemTurnstileTransition.SetItemContinuumMode(lstResultado as UIElement, ContinuumModeEnum.ForwardOutBackwardIn); }
// Constructor public MainPage() { InitializeComponent(); using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { if (!banco.DatabaseExists()) { banco.CreateDatabase(); } } CarregarLista(); //UpdateLiveTiles(); }
public void CarregarLista() { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { List<GpsPoint> gpsList = (from gpspoint in banco.GpsPoints where gpspoint.TaskId == task.Id select gpspoint).ToList(); if (gpsList.Count > 0) { showAddress(gpsList.Last()); } List<SubTask> subTasks = (from subtask in banco.SubTasks where subtask.TaskId == task.Id select subtask).ToList(); lstResultado.ItemsSource = subTasks; } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); App app = Application.Current as App; if (app.AuxParam != null && app.AuxParam.GetType() == typeof(Task)) { task = (Task)app.AuxParam; using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { List<GpsPoint> gpsList = (from gpspoint in banco.GpsPoints where gpspoint.TaskId == task.Id select gpspoint).ToList(); if (gpsList.Count > 0) { showAddress(gpsList.Last()); } } } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (State.ContainsKey("subTaskName")) { txtDescription.Text = State["subTaskName"].ToString(); } string idSubTask = NavigationContext.QueryString["idSubTask"]; //Caso seja uma edicao de subTask if (idSubTask != "") { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { //Busca no BD pelo id passado por parametro e seta o objeto de classe subTask subTask = banco.SubTasks.Where(o => o.Id.Equals(idSubTask)).First(); //Seta o txt da view txtDescription.Text = subTask.Description; //Verifica se o Alert esta true no BD if (subTask.Alert == 1) { btCheck.IsChecked = true; } } } App app = Application.Current as App; if (app.AuxParam != null && app.AuxParam.GetType() == typeof(Task)) { task = (Task)app.AuxParam; } }
void timer_Tick(object sender, EventArgs e) { GeoCoordinate coord = geo.Position.Location; string msgAlert = "Task has to be done at this location:"; bool podeMandarMsg = false; if (coord.IsUnknown != true) { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { List<GpsPoint> gpsList = (from gpspoint in banco.GpsPoints select gpspoint).ToList(); //MessageBox.Show("geoList= " + gpsList.Count()); foreach (var item in gpsList) { double metros = coord.GetDistanceTo(new GeoCoordinate(Double.Parse(item.Latitude), Double.Parse(item.Longitude))); if (metros < 40.0) { Task t = banco.Tasks.Where(o => o.Id.Equals(item.TaskId)).First(); List<SubTask> subTasks = (from subtask in banco.SubTasks where subtask.TaskId == t.Id select subtask).ToList(); foreach (var subTask in subTasks) { if (subTask.Alert == 1) { podeMandarMsg = true; msgAlert = msgAlert + Environment.NewLine + " Task: " + t.Description+ ", SubTask => " + subTask.Description; subTask.Alert = 0; banco.SubmitChanges(); } } } } } } if (podeMandarMsg) { MessageBox.Show(msgAlert); } podeMandarMsg = false; }
private void btIcoDelete_Click(object sender, EventArgs e) { if (subTask != null) { if (MessageBox.Show("Deseja realmente remover?", "Confirmar", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { subTask = banco.SubTasks.Where(o => o.Id.Equals(subTask.Id)).First(); banco.SubTasks.DeleteOnSubmit(subTask); banco.SubmitChanges(); NavigationService.GoBack(); } } } else { NavigationService.GoBack(); } }
private void btSave_Click(object sender, RoutedEventArgs e) { if (txtDescription.Text != "") { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { int boolChecked = (Convert.ToBoolean(btCheck.IsChecked)) ? 1 : 0; if (subTask != null) { subTask.Description = txtDescription.Text; subTask.Alert = boolChecked; SubTask subTaskOld = banco.SubTasks.Where(o => o.Id.Equals(subTask.Id)).First(); subTaskOld.Description = subTask.Description; subTaskOld.Alert = subTask.Alert; } else { subTask = new SubTask() { Description = txtDescription.Text, Status = 0, Alert = boolChecked, TaskId = task.Id }; banco.SubTasks.InsertOnSubmit(subTask); } banco.SubmitChanges(); } NavigationService.GoBack(); } }
private void salvarGps(string latitude, string longitude) { try { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { if (gpsPoint.TaskId != 0) { gpsPoint.Latitude = latitude; gpsPoint.Longitude = longitude; GpsPoint gpsPointOld = banco.GpsPoints.Where(o => o.Id.Equals(gpsPoint.Id)).First(); gpsPointOld.Latitude = gpsPoint.Latitude; gpsPointOld.Longitude = gpsPoint.Longitude; } else { gpsPoint = new GpsPoint() { Latitude = latitude, Longitude = longitude, TaskId = task.Id }; banco.GpsPoints.InsertOnSubmit(gpsPoint); } banco.SubmitChanges(); MessageBox.Show("Location finded."); } } catch (NullReferenceException e) { MessageBox.Show("Ops, We just got an error."); } }
private void btSave_Click_1(object sender, RoutedEventArgs e) { if (txtNameInput.Text.Length > 0) { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { if (task != null) { task.Description = txtNameInput.Text; Task taskOld = banco.Tasks.Where(o => o.Id.Equals(task.Id)).First(); taskOld.Description = task.Description; } else { task = new Task() { Description = txtNameInput.Text, Status = 0 }; banco.Tasks.InsertOnSubmit(task); } banco.SubmitChanges(); } txtNameTitle.Text = txtNameInput.Text; inputs.Children.Remove(txtNameInput); inputs.Children.Remove(btSave); addSubTasks.Visibility = System.Windows.Visibility.Visible; } else { MessageBox.Show("A task must have a name!"); } }
private void btDelete_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Deseja realmente remover?", "Confirmar", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { banco.Tasks.Attach(task); banco.Tasks.DeleteOnSubmit(task); banco.SubmitChanges(); NavigationService.GoBack(); } } }
private void ApplicationBarIconButton_Click_2(object sender, EventArgs e) { if (MessageBox.Show("Deseja realmente remover?", "Confirmar", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { task = banco.Tasks.Where(o => o.Id.Equals(task.Id)).First(); List<SubTask> subTasks = (from subtask in banco.SubTasks where subtask.TaskId == task.Id select subtask).ToList(); List<GpsPoint> gpsList = (from gpspoint in banco.GpsPoints where gpspoint.TaskId == task.Id select gpspoint).ToList(); if (subTasks.Count > 0) { foreach (var subTask in subTasks) { banco.SubTasks.DeleteOnSubmit(subTask); } } if (gpsList.Count > 0) { foreach (var gps in gpsList) { banco.GpsPoints.DeleteOnSubmit(gps); } } banco.Tasks.DeleteOnSubmit(task); banco.SubmitChanges(); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } } }
private void CheckBox_Click(object sender, RoutedEventArgs e) { Button bt = (Button)sender; SubTask subTask = (SubTask)bt.DataContext; if (subTask.Status == 0) { subTask.Status = 1; bt.Background = new SolidColorBrush(Colors.Red); } else { subTask.Status = 0; bt.Background = new SolidColorBrush(Colors.Green); } SubTask s; using (MyLocalDatabase banco = new MyLocalDatabase(MyLocalDatabase.ConnectionString)) { s = banco.SubTasks.Where(o => o.Id.Equals(subTask.Id)).First(); s.Status = subTask.Status; banco.SubmitChanges(); } if (s.Status == 0) { bt.Background = new SolidColorBrush(Colors.Red); } else { bt.Background = new SolidColorBrush(Colors.Green); } }