private async void nowpoints() { nfitems = await ftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day && fthingItem.User == Username) .ToCollectionAsync(); int g = 0; int t = 0; fthing[] n = nfitems.ToArray(); DateTime d = DateTime.Now; int i = 0; while (i < n.Length) { if (n[i].Type == "个人") { if (n[i].Level == "日常") { g += 5; } if (n[i].Level == "周期") { g += 8; } if (n[i].Level == "特殊") { g += 16; } if (n[i].Level == "生死攸关") { g += 30; } g -= n[i].Fhour; } if (n[i].Type == "团体") { if (n[i].Level == "日常") { t += 5; } if (n[i].Level == "周期") { t += 8; } if (n[i].Level == "特殊") { t += 16; } if (n[i].Level == "生死攸关") { t += 30; } t -= n[i].Fhour; } i++; } ntpoint = t; ngpoint = g; }
private async Task RefreshMatch() { matches = await matchesTable.Where(p => p.Id == MatchIdTextBlock.Text).ToCollectionAsync(); var matchesArray = matches.ToArray(); var match = matchesArray[0]; TeamOneScoreTextBlock.Text = match.TeamOneScore.ToString(); TeamTwoScoreTextBlock.Text = match.TeamTwoScore.ToString(); if (match.Ended == false) { EndMatchButton.IsEnabled = true; } }
private async void addtotodaypoints() { todaypoints = await tftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day && fthingItem.User == Username) .ToCollectionAsync(); if (todaypoints.Count != 0) { todayaddpoints[] ty = todaypoints.ToArray(); await tftodoTable.DeleteAsync(ty[0]); } var p = new todayaddpoints() { Year = year, Month = month, Day = day, User = Username, Nowgp = ngpoint, Nowtp = ntpoint }; await tftodoTable.InsertAsync(p); }
private async void RefreshTodoItems() { // This code refreshes the entries in the list view be querying the TodoItems table. // The query excludes completed TodoItems Zw = Zd = 0; j1.Text = j2.Text = j3.Text = ""; String time = Time.Text; char[] s = new char[1]; s[0] = '/'; String[] t = time.Split(s); //Time.Text = t[0] + t[1] + t[2]; year = int.Parse(t[0]); month = int.Parse(t[1]); day = int.Parse(t[2]); try { items = await todoTable .Where(thingItem => thingItem.Year == year && thingItem.Month == month && thingItem.Day == day && thingItem.User == Username) .ToCollectionAsync(); thing[] th = items.ToArray(); int i, j; thing T; for (i = 0; i < th.Length - 1; i++) { for (j = 0; j < th.Length - i - 1; j++) { if (th[j + 1].Hour > th[j].Hour) { T = th[j + 1]; th[j + 1] = th[j]; th[j] = T; } } } if (th.Length > 0) { j1.Text = th[0].Text; if (th.Length > 1) { j2.Text = th[1].Text; } if (th.Length > 2) { j3.Text = th[2].Text; } } } catch (MobileServiceInvalidOperationException e) { MessageBox.Show(e.Message, "Error loading items", MessageBoxButton.OK); } ListItems.ItemsSource = items; subyestoday(); addyestoday(); getpoints(); getyestodaynfthings(); getyestodayfthings(); }
private async void subyestoday() { Zw = Zd = 0; yestodaypoints = await ytftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day - 1 && fthingItem.User == Username) .ToCollectionAsync(); if (yestodaypoints.Count == 0) { yitems = await todoTable .Where(thingItem => thingItem.Year == year && thingItem.Month == month && thingItem.Day == day - 1 && thingItem.User == Username && thingItem.Is == "未完成") .ToCollectionAsync(); if (yitems.Count != 0) { int g = 0; int t = 0; thing[] th = yitems.ToArray(); int i = 0; while (i < th.Length) { if (th[i].Type == "个人") { if (th[i].Level == "日常") { g += 24; } if (th[i].Level == "周期") { g += 30; } if (th[i].Level == "特殊") { g += 40; } if (th[i].Level == "生死攸关") { g += 50; } } if (th[i].Type == "团体") { if (th[i].Level == "日常") { t += 30; } if (th[i].Level == "周期") { t += 44; } if (th[i].Level == "特殊") { t += 60; } if (th[i].Level == "生死攸关") { t += 80; } } i++; } yestodaysubpoints y = new yestodaysubpoints() { Year = year, Month = month, Day = day - 1, User = Username, Sgp = g, Stp = t }; await ytftodoTable.InsertAsync(y); } yestodaypoints = await ytftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day - 1 && fthingItem.User == Username) .ToCollectionAsync(); if (yestodaypoints.Count != 0) { stpoint = yestodaypoints.First().Stp; sgpoint = yestodaypoints.First().Sgp; /* uitems = await ut * .Where(userItem => userItem.Username == Username) * .ToCollectionAsync(); * user u = uitems.First(); * u.tp = u.tp - stpoint; * u.gp = u.gp - sgpoint; * * await ut.UpdateAsync(u);*/ Zw -= sgpoint; Zd -= stpoint; } // subyestoday(); } else { stpoint = yestodaypoints.First().Stp; sgpoint = yestodaypoints.First().Sgp; /* uitems = await ut * .Where(userItem => userItem.Username == Username) * .ToCollectionAsync(); * user u = uitems.First(); * u.tp = u.tp - stpoint; * u.gp = u.gp - sgpoint; * * await ut.UpdateAsync(u);*/ Zw -= sgpoint; Zd -= stpoint; } }