private void SetChecked() { List <int> checked_ids = new List <int>(); foreach (var cb in pick_players_cbs) { if (cb.IsChecked == true) { var id = Convert.ToInt32(cb.Content); id = id == 14 ? 13 : id == 15 ? 14 : id; checked_ids.Add(id); } } for (int i = 0; i < 66; i++) { var record = RecordsInSession.FirstOrDefault(r => r.RoundIndex == i); int banker, tie, player; if (record == null || string.IsNullOrEmpty(record.JsonPlayerScores)) { banker = 0; tie = 0; player = 0; } else { var scores = JsonConvert.DeserializeObject <ObservableCollection <Player> >(record.JsonPlayerScores); var checked_players = scores.Where(s => checked_ids.Contains(s.Id)); banker = checked_players.Sum(p => p.BetScoreOnBank); tie = checked_players.Sum(p => p.BetScoreOnTie); player = checked_players.Sum(p => p.BetScoreOnPlayer); } CurrentRecords[i].CreateTime = record.CreateTime; CurrentRecords[i].RoundIndex = record.RoundIndex; CurrentRecords[i].SessionIndex = record.SessionIndex; CurrentRecords[i].Winner = record.Winner; CurrentRecords[i].DeskBanker = banker; CurrentRecords[i].DeskTie = tie; CurrentRecords[i].DeskPlayer = player; } ShowWaybillAndDetail(); }
public BetRecord() { InitializeComponent(); using (var db = new SQLiteDB()) { try { //不显示当前局 var last_session_idx = db.BetScoreRecords.Max(mr => mr.SessionIndex); if (last_session_idx == Game.Instance.SessionIndex) { last_session_idx = db.BetScoreRecords.Select(t => t.SessionIndex).Distinct().OrderByDescending(t => t).ElementAt(1); } RecordsInSession = db.BetScoreRecords.Where( r => r.SessionIndex == last_session_idx) .OrderBy(t => t.RoundIndex).ToList(); if (RecordsInSession == null || RecordsInSession.Count == 0) { MessageBox.Show("无记录"); Close(); return; } SessionIds = db.BetScoreRecords.Select(b => b.SessionIndex + 1).Distinct().OrderBy(t => t).ToList(); SessionIds.Remove(Game.Instance.SessionIndex + 1); cmbSessionStrIndex.ItemsSource = SessionIds; cmbSessionStrIndex.SelectedItem = RecordsInSession[0].SessionIndex + 1; } catch (Exception ex) { return; } } CurrentRecords = new ObservableCollection <BetScoreRecord>(RecordsInSession.OrderBy(r => r.RoundIndex).ToList()); ShowWaybillAndDetail(); BindCbEvent(); cmbSessionStrIndex.SelectionChanged += cbRoundStrIndex_SelectionChanged; }
private void SetDetails() { var total_count = (double)RecordsInSession.Count; var b_count = (double)RecordsInSession.Count(r => r.Winner == (int)WinnerEnum.banker); txtBetRate.Text = "庄比例:" + (b_count / total_count).ToString("P") + " 和比例:" + ((double)RecordsInSession.Count(r => r.Winner == (int)WinnerEnum.tie) / total_count).ToString("P") + " 闲比例:" + ((double)RecordsInSession.Count(r => r.Winner == (int)WinnerEnum.player) / total_count) * 100 + "%"; var b_all = CurrentRecords.Sum(b => b.DeskBanker); var t_all = CurrentRecords.Sum(b => b.DeskTie); var p_all = CurrentRecords.Sum(b => b.DeskPlayer); int profit = 0; foreach (var r in CurrentRecords) { profit += Desk.GetProfit(r.Winner, r.DeskBanker, r.DeskPlayer, r.DeskTie); } txtSessionDetails.Text = "当前局数:" + (CurrentRecords[0].SessionIndex + 1) + "\n" + "机台盈利:" + profit + "\n" + "庄总押:" + b_all + "\n" + "和总押:" + t_all + "\n" + "闲总押:" + p_all + "\n"; }