// General Information private void ShowInfoGeneral(Excel.Worksheet ws, int posY, csSummary s) { ws.Range["A" + (posY).ToString()].Value = s.ContLeansBets; ws.Range["B" + (posY).ToString()].Value = s.RiskLeans; ws.Range["C" + (posY).ToString()].Value = s.NetLeans; ws.Range["D" + (posY).ToString()].Value = s.WinPerLeans + "%"; ws.Range["E" + (posY).ToString()].Value = (Int32)s.LeansHold + "%"; ws.Range["A" + (posY).ToString()].BorderAround2(); ws.Range["B" + (posY).ToString()].BorderAround2(); ws.Range["C" + (posY).ToString()].BorderAround2(); ws.Range["D" + (posY).ToString()].BorderAround2(); ws.Range["E" + (posY).ToString()].BorderAround2(); // AGAINST LEANS ws.Range["I" + (posY).ToString()].Value = s.ContNoLeansBets; ws.Range["J" + (posY).ToString()].Value = s.RiskNoLeans; ws.Range["K" + (posY).ToString()].Value = s.NetNoLeans; ws.Range["L" + (posY).ToString()].Value = s.WinPerNoLeans + "%"; ws.Range["M" + (posY).ToString()].Value = (Int32)s.NoLeansHold + "%"; ws.Range["I" + (posY).ToString()].BorderAround2(); ws.Range["J" + (posY).ToString()].BorderAround2(); ws.Range["K" + (posY).ToString()].BorderAround2(); ws.Range["L" + (posY).ToString()].BorderAround2(); ws.Range["M" + (posY).ToString()].BorderAround2(); }
private void ShowInfoSport(Excel.Worksheet ws, int posY, string sport, csSummary s) { ws.Range["A" + (posY + 2).ToString()].Value = sport; ws.Range["B" + (posY + 2).ToString()].Value = s.RiskLeans; ws.Range["C" + (posY + 2).ToString()].Value = s.NetLeans; ws.Range["D" + (posY + 2).ToString()].Value = s.ContLeansBets; ws.Range["E" + (posY + 2).ToString()].Value = s.WinBetsLeans; ws.Range["F" + (posY + 2).ToString()].Value = s.LostBetsLeans; ws.Range["G" + (posY + 2).ToString()].Value = s.WinPerLeans + "%"; ws.Range["I" + (posY + 2).ToString()].Value = s.RiskNoLeans; ws.Range["J" + (posY + 2).ToString()].Value = s.NetNoLeans; ws.Range["K" + (posY + 2).ToString()].Value = s.ContNoLeansBets; ws.Range["L" + (posY + 2).ToString()].Value = s.WinBetsNoLeans; ws.Range["M" + (posY + 2).ToString()].Value = s.LostBetsNoLeans; ws.Range["N" + (posY + 2).ToString()].Value = s.WinPerNoLeans + "%"; ws.Range["A" + (posY + 2).ToString()].BorderAround2(); ws.Range["B" + (posY + 2).ToString()].BorderAround2(); ws.Range["C" + (posY + 2).ToString()].BorderAround2(); ws.Range["D" + (posY + 2).ToString()].BorderAround2(); ws.Range["E" + (posY + 2).ToString()].BorderAround2(); ws.Range["F" + (posY + 2).ToString()].BorderAround2(); ws.Range["G" + (posY + 2).ToString()].BorderAround2(); ws.Range["I" + (posY + 2).ToString()].BorderAround2(); ws.Range["J" + (posY + 2).ToString()].BorderAround2(); ws.Range["K" + (posY + 2).ToString()].BorderAround2(); ws.Range["L" + (posY + 2).ToString()].BorderAround2(); ws.Range["M" + (posY + 2).ToString()].BorderAround2(); ws.Range["N" + (posY + 2).ToString()].BorderAround2(); }
private void ShowInfoGame(Excel.Worksheet ws, int posY, csSummary s) { ws.Range["A" + (posY + 2).ToString()].Value = s.Event; ws.Range["B" + (posY + 2).ToString()].Value = s.Team; ws.Range["C" + (posY + 2).ToString()].Value = s.Line; ws.Range["D" + (posY + 2).ToString()].Value = s.CrisLine; ws.Range["E" + (posY + 2).ToString()].Value = s.PinniLine; ws.Range["F" + (posY + 2).ToString()].Value = s.OurLine; ws.Range["G" + (posY + 2).ToString()].Value = s.Time; ws.Range["H" + (posY + 2).ToString()].Value = s.sport; ws.Range["I" + (posY + 2).ToString()].Value = s.TotalBets; ws.Range["J" + (posY + 2).ToString()].Value = s.WinAmount; ws.Range["K" + (posY + 2).ToString()].Value = s.RiskAmount; ws.Range["L" + (posY + 2).ToString()].Value = s.Net; ws.Range["A" + (posY + 2).ToString()].BorderAround2(); ws.Range["B" + (posY + 2).ToString()].BorderAround2(); ws.Range["C" + (posY + 2).ToString()].BorderAround2(); ws.Range["D" + (posY + 2).ToString()].BorderAround2(); ws.Range["E" + (posY + 2).ToString()].BorderAround2(); ws.Range["F" + (posY + 2).ToString()].BorderAround2(); ws.Range["G" + (posY + 2).ToString()].BorderAround2(); ws.Range["H" + (posY + 2).ToString()].BorderAround2(); ws.Range["I" + (posY + 2).ToString()].BorderAround2(); ws.Range["J" + (posY + 2).ToString()].BorderAround2(); ws.Range["K" + (posY + 2).ToString()].BorderAround2(); ws.Range["L" + (posY + 2).ToString()].BorderAround2(); ws.Range["L" + (posY + 2).ToString()].Interior.Color = (s.Net < 0) ? System.Drawing.Color.FromArgb(255, 199, 206) : System.Drawing.Color.FromArgb(198, 239, 206); ws.Range["L" + (posY + 2).ToString()].Borders.Color = (s.Net < 0) ? System.Drawing.Color.FromArgb(156, 0, 6) : System.Drawing.Color.FromArgb(0, 97, 0); }
public csSummary InfoBySeasons(string dt1, string dt2, string idSport, string Player, string wagerType) { var data = new csSummary(); try { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", idSport); parameters.Add("@pIdLeague", "-1"); parameters.Add("@pPlayer", Player); parameters.Add("@pWagerType", wagerType.ToUpper()); parameters.Add("@pWagerPlay", ""); dataset = csG8Apps.ExecutePA("[dbo].[web_topPlayers]", parameters); if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { data = new csSummary( Convert.ToString(fila["PLAYER"]), Convert.ToString(fila["AGENT"]), Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["NET"]), Convert.ToInt32(fila["BETS"]), Convert.ToInt32(fila["WINS"])); data = TotalWagerType(dt1, dt2, idSport, Player, "STRAIGHT", data); data = TotalWagerType(dt1, dt2, idSport, Player, "PARLAY", data); data = TotalWagerType(dt1, dt2, idSport, Player, "TEASER", data); } } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return(data); }
private csSummary setSummary3Games(csAgrupation a, csSummary s, csMlbStat i) { s.range = i.SeriesRange; s.games += 3; if (a.Game1 == 1 && a.Game2 == 1) { s.wins += 1; } else if (a.Game1 == 0 && a.Game2 == 0) { s.loses += 1; } s.risk += Convert.ToInt32(a.Risk1 + a.Risk2); s.net += Convert.ToInt32(a.Net1 + a.Net2); s.hold = Convert.ToDouble(s.net) / Convert.ToDouble(s.risk); return(s); }
//************************************************************************* public ObservableCollection <csSummary> BusinessBySport(string dt1, string dt2, int idAgent, string sport) { ObservableCollection <csSummary> data = new ObservableCollection <csSummary>(); try { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdAgent", idAgent); parameters.Add("@pIdSport", sport); dataset = csG8Apps.ExecutePA("[dbo].[web_reviewBysPORT]", parameters); if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { csSummary u = new csSummary( Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["NET"]), Convert.ToString(fila["SPORT"])); data.Add(u); } } else { data = null; } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return((data == null) ? null : new ObservableCollection <csSummary>(data.Reverse())); }
public Object SumRangeDate(string dt1, string dt2, string idSport, string Player, string wagerType, int caso) { var data = new ObservableCollection <csSummary>(); try { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", (idSport == "ALL") ? "" : idSport); parameters.Add("@pPlayer", Player); parameters.Add("@pCase", caso); parameters.Add("@pWagerType", wagerType.ToUpper()); dataset = csG8Apps.ExecutePA("[dbo].[web_SummaryByRange]", parameters); if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { var s = new csSummary( Convert.ToDateTime(fila["DAYY"]), Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["NET"])); data.Add(s); } } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return(data); }
//By player private void ShowPlayer(Excel.Worksheet ws, int posY, csSummary s) { ws.Range["A" + (posY + 2).ToString()].Value = s.Player; ws.Range["B" + (posY + 2).ToString()].Value = s.RiskLeans; ws.Range["C" + (posY + 2).ToString()].Value = s.NetLeans; ws.Range["D" + (posY + 2).ToString()].Value = s.ContLeansBets; ws.Range["E" + (posY + 2).ToString()].Value = s.WinBetsLeans; ws.Range["F" + (posY + 2).ToString()].Value = s.LostBetsLeans; ws.Range["G" + (posY + 2).ToString()].Value = s.WinPerLeans + "%"; ws.Range["H" + (posY + 2).ToString()].Value = (Int32)s.LeansHold + "%"; ws.Range["J" + (posY + 2).ToString()].Value = s.Player; ws.Range["K" + (posY + 2).ToString()].Value = s.RiskNoLeans; ws.Range["L" + (posY + 2).ToString()].Value = s.NetNoLeans; ws.Range["M" + (posY + 2).ToString()].Value = s.ContNoLeansBets; ws.Range["N" + (posY + 2).ToString()].Value = s.WinBetsNoLeans; ws.Range["O" + (posY + 2).ToString()].Value = s.LostBetsNoLeans; ws.Range["P" + (posY + 2).ToString()].Value = s.WinPerNoLeans + "%"; ws.Range["Q" + (posY + 2).ToString()].Value = (Int32)s.NoLeansHold + "%"; ws.Range["A" + (posY + 2).ToString()].BorderAround2(); ws.Range["B" + (posY + 2).ToString()].BorderAround2(); ws.Range["C" + (posY + 2).ToString()].BorderAround2(); ws.Range["D" + (posY + 2).ToString()].BorderAround2(); ws.Range["E" + (posY + 2).ToString()].BorderAround2(); ws.Range["F" + (posY + 2).ToString()].BorderAround2(); ws.Range["G" + (posY + 2).ToString()].BorderAround2(); ws.Range["H" + (posY + 2).ToString()].BorderAround2(); ws.Range["J" + (posY + 2).ToString()].BorderAround2(); ws.Range["K" + (posY + 2).ToString()].BorderAround2(); ws.Range["L" + (posY + 2).ToString()].BorderAround2(); ws.Range["M" + (posY + 2).ToString()].BorderAround2(); ws.Range["N" + (posY + 2).ToString()].BorderAround2(); ws.Range["O" + (posY + 2).ToString()].BorderAround2(); ws.Range["P" + (posY + 2).ToString()].BorderAround2(); ws.Range["Q" + (posY + 2).ToString()].BorderAround2(); }
private csSummary TotalWagerType(string dt1, string dt2, string idSport, string Player, string wagerType, csSummary data) { try { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", idSport); parameters.Add("@pIdLeague", "-1"); parameters.Add("@pPlayer", Player); parameters.Add("@pWagerType", wagerType.ToUpper()); parameters.Add("@pWagerPlay", ""); dataset = csG8Apps.ExecutePA("[dbo].[web_topPlayers]", parameters); if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { if (wagerType.ToUpper().Contains("STRAIGHT")) { data.StraightNet = Convert.ToInt32(fila["NET"]); } else if (wagerType.ToUpper().Contains("PARLAY")) { data.ParlayNet = Convert.ToInt32(fila["NET"]); } else if (wagerType.ToUpper().Contains("TEASER")) { data.TeaserNet = Convert.ToInt32(fila["NET"]); } } } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return(data); }
//************************************************************************* public ObservableCollection <csSummary> OverAll(string dt1, string dt2, int idAgent, string IdSport) { ObservableCollection <csSummary> data = new ObservableCollection <csSummary>(); int m = 0; try { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdAgent", idAgent); parameters.Add("@pCase", 1); parameters.Add("@pIdSport", IdSport); dataset = csG8Apps.ExecutePA("[dbo].[web_reviewByDay]", parameters); if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { if (!String.IsNullOrWhiteSpace(fila["NET"].ToString()) && !String.IsNullOrWhiteSpace(fila["RISK"].ToString())) { csSummary u = new csSummary( Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["NET"]), Convert.ToDateTime(fila["DAYY"]), Convert.ToInt32(fila["PLAYERS"])); data.Add(u); } } } parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdAgent", idAgent); parameters.Add("@pCase", 0); parameters.Add("@pIdSport", IdSport); dataset = csG8Apps.ExecutePA("[dbo].[web_reviewByDay]", parameters); if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { if (!String.IsNullOrWhiteSpace(fila["NET"].ToString()) && !String.IsNullOrWhiteSpace(fila["RISK"].ToString())) { csSummary u = new csSummary( Convert.ToInt32(fila["NET"]), Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["PLAYERS"])); data.Add(u); } } } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return(new ObservableCollection <csSummary>(data.Reverse())); }
public ObservableCollection <csSummary> SummaryProfile(string dt1, string dt2, string idSport, string idLeague, int idAgent, string Player, bool flag = false) { ObservableCollection <csSummary> data = new ObservableCollection <csSummary>(); try { if (idAgent == -1) { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", idSport); parameters.Add("@pIdLeague", idLeague); parameters.Add("@pPlayer", Player); dataset = csG8Apps.ExecutePA("[dbo].[spSummaryProfile]", parameters); } else if (idAgent != -1) { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", idSport); parameters.Add("@pIdLeague", idLeague); parameters.Add("@pIdAgent", idAgent); parameters.Add("@pPlayer", Player); dataset = csG8Apps.ExecutePA("[dbo].[spSummaryProfileWithAll]", parameters); } if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { csSummary u = new csSummary( Convert.ToString(fila["PLAYER"]), Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["WIN"]), Convert.ToInt32(fila["NET"]), Convert.ToInt32(fila["BETS"]), Convert.ToInt32(fila["WINS"]), Convert.ToInt32(fila["DRAW"]), Convert.ToInt32(fila["LOST"]), Math.Round(Convert.ToDouble(fila["WIN_PER"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["HOLD_PER"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["SCALPINGPPH"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["SCALPINGJAZZ"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["SCALPINGPINNI"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["SCALPING5DIMES"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["SCALPINGCRIS"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["MOVELINE"]), 2, MidpointRounding.AwayFromZero), Math.Round(Convert.ToDouble(fila["BEATLINE"]), 2, MidpointRounding.AwayFromZero), Convert.ToInt32(fila["SYNDICATE"])); data.Add(u); } } else { if (flag) { csSummary u = new csSummary(Player, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); data.Add(u); } else { data = null; } } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return(data); }
public ObservableCollection <csSummary> TopPlayerList(string dt1, string dt2, string idSport, string idLeague, int idAgent, string Player, string wagerType, string wagerPlay) { ObservableCollection <csSummary> data = new ObservableCollection <csSummary>(); try { if (idAgent == -1) { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", idSport); parameters.Add("@pIdLeague", idLeague); parameters.Add("@pPlayer", Player); parameters.Add("@pWagerType", wagerType); parameters.Add("@pWagerPlay", wagerPlay); dataset = csG8Apps.ExecutePA("[dbo].[web_topPlayers]", parameters); } else if (idAgent != -1) { parameters.Clear(); parameters.Add("@pStartDate", dt1); parameters.Add("@pEndDate", dt2); parameters.Add("@pIdSport", idSport); parameters.Add("@pIdLeague", idLeague); parameters.Add("@pIdAgent", idAgent); parameters.Add("@pPlayer", Player); parameters.Add("@pWagerType", wagerType); parameters.Add("@pWagerPlay", wagerPlay); dataset = csG8Apps.ExecutePA("[dbo].[web_topPlayersAll]", parameters); } if (dataset.Tables[0].Rows.Count > 0) { foreach (DataRow fila in dataset.Tables[0].Rows) { csSummary u = new csSummary( Convert.ToString(fila["PLAYER"]), Convert.ToString(fila["AGENT"]), Convert.ToInt32(fila["RISK"]), Convert.ToInt32(fila["NET"]), Convert.ToInt32(fila["BETS"]), Convert.ToInt32(fila["WINS"])); data.Add(u); } } else { data = null; } } catch (Exception ex) { data = null; throw new Exception("Error: " + ex.Message); } finally { parameters.Clear(); } return((data == null) ? null : new ObservableCollection <csSummary>(data.Reverse())); }
private csSummary GetValuesFromSummary(string sport, ObservableCollection <csBet> LBets, ObservableCollection <csBet> NoLBets) { csSummary s = new csSummary(); s.sport = sport; if (LBets != null) { foreach (var i in LBets) { if (i.IdSport == sport) { s.ContLeansBets += 1; s.NetLeans += i.Net; s.WinLeans += i.WinAmount; s.RiskLeans += i.RiskAmount; s.sport = sport; if (i.Result.Trim(' ') == "WIN") { s.WinBetsLeans += 1; } else { s.LostBetsLeans += 1; } } } try{ s.WinPerLeans = (s.WinBetsLeans * 100 / s.ContLeansBets); }catch (Exception) { s.WinPerLeans = 0; } } if (NoLBets != null) { foreach (var i in NoLBets) { if (i.IdSport == sport) { s.ContNoLeansBets += 1; s.NetNoLeans += i.Net; s.WinNoLeans += i.WinAmount; s.RiskNoLeans += i.RiskAmount; if (i.Result.Trim(' ') == "WIN") { s.WinBetsNoLeans += 1; } else { s.LostBetsNoLeans += 1; } } } try { s.WinPerNoLeans = (s.WinBetsNoLeans * 100 / s.ContNoLeansBets); } catch (Exception) { s.WinPerNoLeans = 0; } } return(s); }
public void GenerateExcel(ObservableCollection <csGame> Games, String path) { try { if (Games != null) { Excel.Application app = new Microsoft.Office.Interop.Excel.Application(); Excel.Workbook wb = app.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet); ObservableCollection <csBet> BetsWithLeans = new ObservableCollection <csBet>(); ObservableCollection <csBet> NoLeansBets = new ObservableCollection <csBet>(); ObservableCollection <csSummary> SummaryListGame = new ObservableCollection <csSummary>(); foreach (var g in Games) { ObservableCollection <csBet> LeansBets = betDB.BetListFromIdGame(g); csSummary GameSum = new csSummary(); GameSum.Event = g.VisitorTeam + " vs " + g.HomeTeam; GameSum.sport = g.IdSport; if (LeansBets != null) { foreach (var l in LeansBets) { ObservableCollection <csBet> bets = betDB.GetBetsAfterLeans(g.IdGame, l, l.WagerPlay); GameSum.Line += l.WagerPlay + " [Odd: " + l.Odds + ", PTs: " + l.OverUnder + l.Points + "] "; GameSum.CrisLine += l.WagerPlay + " [Odd: " + l.CrisJuice + ", PTs: " + l.OverUnder + l.CrisPoints + "] "; GameSum.PinniLine += l.WagerPlay + " [Odd: " + l.PinniJuice + ", PTs: " + l.OverUnder + l.PinniPoints + "] "; GameSum.OurLine += l.WagerPlay + " [Odd: " + l.OurJuice + ", PTs: " + l.OverUnder + l.OurPoints + "] "; GameSum.Team += (l.Rot == g.HomeNumber) ? l.WagerPlay + " [" + g.HomeTeam + "] " : l.WagerPlay + " [" + g.VisitorTeam + "] "; GameSum.Time = l.PlacedDate.ToString(); LeansBetsList.Add(l); // to check if the sport doesn't exist. bool has = Sports.Any(x => x == l.IdSport); if (!has) { Sports.Add(l.IdSport); } if (bets != null) { foreach (var b in bets) { // **************************** Aqui es donde hay que generar el excel *********************** try { if (b.Rot == l.Rot) { //Same team with LEANS BetsWithLeans.Add(b); summary.ContLeansBets += 1; } else { //Different team with LEANS NoLeansBets.Add(b); summary.ContNoLeansBets += 1; } bool flag = Players.Any(x => x.IdPlayer == b.IdPlayer); if (!flag) { csSummary s = new csSummary(); s.IdPlayer = b.IdPlayer; s.Player = b.Player; Players.Add(s); } // sum total GameSum.TotalBets += 1; GameSum.WinAmount += b.WinAmount; GameSum.RiskAmount += b.RiskAmount; GameSum.Net += b.Net; } catch (Exception) { } // fin generacion de Excel } } } } SummaryListGame.Add(GameSum); } // (sender as BackgroundWorker).ReportProgress(20); // ************************* bets with the same bet from Leans ********************* if (Sports != null) { ObservableCollection <csSummary> SummaryList = new ObservableCollection <csSummary>(); foreach (var sp in Sports) { Excel.Worksheet wsSport = wb.Sheets.Add(); wsSport.Name = sp; CompleteRange(wsSport); index = 0; bool flag = true; foreach (var g in Games) { if (g.IdSport.Trim(' ') == sp) { if (!flag) { index += 1; } if (LeansBetsList != null) { for (int j = 0; j < LeansBetsList.Count; j++) { if (LeansBetsList[j].IdGame == g.IdGame) { if (BetsWithLeans != null) { if (LeansBetsList[j].IdSport == sp) { if (!flag) { index += 1; } else { flag = false; } ShowInfo(wsSport, index, j, LeansBetsList, 3, g); CenterAllInfo(wsSport, index); for (int i = 0; i < BetsWithLeans.Count; i++) { if (LeansBetsList[j].IdGame == BetsWithLeans[i].IdGame && LeansBetsList[j].Rot == BetsWithLeans[i].Rot && LeansBetsList[j].WagerPlay == BetsWithLeans[i].WagerPlay) { index += 1; ShowInfo(wsSport, index, i, BetsWithLeans, 1, g); CenterAllInfo(wsSport, index); } } } } if (LeansBetsList[j].IdSport == sp) { if (NoLeansBets != null) { for (int i = 0; i < NoLeansBets.Count; i++) { if (LeansBetsList[j].IdGame == NoLeansBets[i].IdGame && LeansBetsList[j].Rot != NoLeansBets[i].Rot && LeansBetsList[j].WagerPlay == NoLeansBets[i].WagerPlay) { index += 1; ShowInfo(wsSport, index, i, NoLeansBets, 2, g); CenterAllInfo(wsSport, index); } } } } } } } index += 2; } } SummaryList.Add(GetValuesFromSummary(sp, BetsWithLeans, NoLeansBets)); } // (sender as BackgroundWorker).ReportProgress(40); Excel.Worksheet ws3 = wb.Sheets.Add(); ws3.Name = "SUMMARY"; index = 0; csSummary general = new csSummary(); if (SummaryList != null) { CompleteRangeSport(ws3); for (int i = 0; i < SummaryList.Count; i++) { ShowInfoSport(ws3, i, SummaryList[i].sport, SummaryList[i]); CenterAllInfoSport(ws3, i); general.ContLeansBets += SummaryList[i].ContLeansBets; general.RiskLeans += SummaryList[i].RiskLeans; general.NetLeans += SummaryList[i].NetLeans; general.WinBetsLeans += SummaryList[i].WinBetsLeans; general.ContNoLeansBets += SummaryList[i].ContNoLeansBets; general.RiskNoLeans += SummaryList[i].RiskNoLeans; general.NetNoLeans += SummaryList[i].NetNoLeans; general.WinBetsNoLeans += SummaryList[i].WinBetsNoLeans; index = i; } } try { general.WinPerLeans = (general.WinBetsLeans * 100 / general.ContLeansBets); } catch (Exception) { general.WinPerLeans = 0; } try { general.WinPerNoLeans = (general.WinBetsNoLeans * 100 / general.ContNoLeansBets); } catch (Exception) { general.WinPerNoLeans = 0; } try { general.LeansHold = (general.NetLeans * 100 / general.RiskLeans); } catch (Exception) { general.LeansHold = 0; } try { general.NoLeansHold = (general.NetNoLeans * 100 / general.RiskNoLeans); } catch (Exception) { general.NoLeansHold = 0; } index += 6; RangeGeneral(ws3, index); index += 1; ShowInfoGeneral(ws3, index, general); CenterAllInfoGeneral(ws3, index - 2); // (sender as BackgroundWorker).ReportProgress(60); } // ********************** area by player ********************************** // if (Players != null) { Excel.Worksheet wsp = wb.Sheets.Add(); wsp.Name = "By Player"; index = 1; CompleteRangePlayer(wsp, index); index -= 2; foreach (var p in Players) { index += 1; if (BetsWithLeans != null) { foreach (var s in BetsWithLeans) { if (p.IdPlayer == s.IdPlayer) { p.ContLeansBets += 1; p.RiskLeans += s.RiskAmount; p.NetLeans += s.Net; if (s.Result == "WIN") { p.WinBetsLeans += 1; } else { p.LostBetsLeans += 1; } } } try { p.WinPerLeans = (p.WinBetsLeans * 100 / p.ContLeansBets); } catch (Exception) { p.WinPerLeans = 0; } try { if (p.ContLeansBets > 0) { p.LeansHold = (p.NetLeans * 100 / p.RiskLeans); } else { p.LeansHold = 0; } } catch (Exception) { p.LeansHold = 0; } } if (NoLeansBets != null) { foreach (var s in NoLeansBets) { if (p.IdPlayer == s.IdPlayer) { p.ContNoLeansBets += 1; p.RiskNoLeans += s.RiskAmount; p.NetNoLeans += s.Net; if (s.Result == "WIN") { p.WinBetsNoLeans += 1; } else { p.LostBetsNoLeans += 1; } } } try { p.WinPerNoLeans = (p.WinBetsNoLeans * 100 / p.ContNoLeansBets); } catch (Exception) { p.WinPerNoLeans = 0; } try { if (p.ContNoLeansBets > 0) { p.NoLeansHold = (p.NetNoLeans * 100 / p.RiskNoLeans); } else { p.NoLeansHold = 0; } } catch (Exception) { p.NoLeansHold = 0; } } ShowPlayer(wsp, index, p); CenterAllInfoSport(wsp, index); } //(sender as BackgroundWorker).ReportProgress(80); } //fin area player // ********************** Shett by game ********************************** // if (SummaryListGame != null) { Excel.Worksheet ws4 = wb.Sheets.Add(); ws4.Name = "BY GAME"; index = 0; CompleteRangeGame(ws4); foreach (var i in SummaryListGame) { ShowInfoGame(ws4, index, i); CenterAllInfoGame(ws4, index); index += 2; } // (sender as BackgroundWorker).ReportProgress(100); } // ************************* SAVE THE DOCUMENT ********************* if (path != null) { wb.SaveAs(path); wb.Saved = true; wb.Close(true); app.Quit(); } else { string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); wb.SaveAs(mydocpath + @"\" + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + " LeansReport.xls"); wb.Saved = true; wb.Close(true); app.Quit(); } } } catch (Exception ex) { MessageBox.Show("Error to generate the Excel document: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void GenerateExcel(ObservableCollection <csGame> Games, string player, ObservableCollection <csBet> BetsWithLeans, ObservableCollection <csBet> NoLeansBets, ObservableCollection <csBet> L, ObservableCollection <csBet> SumGames) { try { if (Games != null) { //Excel.Application app = new Microsoft.Office.Interop.Excel.Application(); // Excel.Workbook wb = app.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet); //ObservableCollection<csBet> BetsWithLeans = new ObservableCollection<csBet>(); //ObservableCollection<csBet> NoLeansBets = new ObservableCollection<csBet>(); //ObservableCollection<csSummary> SummaryListGame = new ObservableCollection<csSummary>(); foreach (var g in Games) { ObservableCollection <csBet> LeansBets = betDB.BetListFromIdGame(g, player); csBet GameSum = new csBet(); GameSum.Event = g.VisitorTeam + " vs " + g.HomeTeam; GameSum.Sport = g.IdSport; GameSum.GameDate = g.EventDate.Month + "/" + g.EventDate.Day + "/" + g.EventDate.Year; if (LeansBets != null) { foreach (var l in LeansBets) { ObservableCollection <csBet> bets = betDB.GetBetsAfterLeans(g.IdGame, l, l.WagerPlay, player); GameSum.Line += l.Odds + ", " + l.OverUnder + l.Points; GameSum.CrisLine += l.CrisJuice + ", " + l.OverUnder + l.CrisPoints; GameSum.PinniLine += l.PinniJuice + ", " + l.OverUnder + l.PinniPoints; GameSum.OurLine += l.OurNextLine; GameSum.Team += (l.Rot == g.HomeNumber) ? g.HomeTeam : g.VisitorTeam; GameSum.WagerPlay = l.WagerPlay; l.GameDate = GameSum.GameDate; //GameSum.Time = l.PlacedDate.ToString(); LeansBetsList.Add(l); L.Add(l); // to check if the sport doesn't exist. //bool has = Sports.Any(x => x == l.IdSport); //if (!has) //{ // Sports.Add(l.IdSport); //} if (bets != null && bets.Count > 0) { foreach (var b in bets) { // **************************** Aqui es donde hay que generar el excel *********************** b.EventDate = g.EventDate; b.EventName = g.VisitorTeam + " vs " + g.HomeTeam; b.GameDate = GameSum.GameDate; try { if (b.Rot == l.Rot) { //Same team with LEANS b.Pick = (g.VisitorNumber == b.Rot) ? g.VisitorTeam : g.HomeTeam; GameSum.ContLeansBets += 1; GameSum.WinLeans += b.WinAmount; GameSum.RiskLeans += b.RiskAmount; GameSum.NetLeans += b.Net; BetsWithLeans.Add(b); summary.ContLeansBets += 1; } else { //Different team with LEANS b.Pick = (g.VisitorNumber == b.Rot) ? g.VisitorTeam : g.HomeTeam; GameSum.ContNoLeansBets += 1; GameSum.WinNoLeans += b.WinAmount; GameSum.RiskNoLeans += b.RiskAmount; GameSum.NetNoLeans += b.Net; NoLeansBets.Add(b); summary.ContNoLeansBets += 1; } //by player bool flag = Players.Any(x => x.IdPlayer == b.IdPlayer); if (!flag) { csSummary s = new csSummary(); s.IdPlayer = b.IdPlayer; s.Player = b.Player; Players.Add(s); } // sum total //GameSum.TotalBets += 1; //GameSum.WinAmount += b.WinAmount; //GameSum.RiskAmount += b.RiskAmount; //GameSum.Net += b.Net; } catch (Exception) { } // fin generacion de Excel } } } } GameSum.LeansHold = Math.Round(Convert.ToDouble((GameSum.NetLeans * 100) / GameSum.RiskLeans), 2, MidpointRounding.AwayFromZero); GameSum.NoLeansHold = Math.Round(Convert.ToDouble((GameSum.NetNoLeans * 100) / GameSum.RiskNoLeans), 2, MidpointRounding.AwayFromZero); SumGames.Add(GameSum); } // ************************* bets with the same bet from Leans ********************* //if (Sports != null) //{ // ObservableCollection<csSummary> SummaryList = new ObservableCollection<csSummary>(); // foreach (var sp in Sports) // { // //Excel.Worksheet wsSport = wb.Sheets.Add(); // //wsSport.Name = sp; // //CompleteRange(wsSport); // index = 0; // bool flag = true; // foreach (var g in Games) // { // if (g.IdSport.Trim(' ') == sp) // { // if(!flag) index += 1; // if (LeansBetsList != null) // { // for (int j = 0; j < LeansBetsList.Count; j++) // { // if (LeansBetsList[j].IdGame == g.IdGame) // { // if (BetsWithLeans != null) // { // if (LeansBetsList[j].IdSport == sp) // { // if (!flag) index += 1; // else flag = false; // //ShowInfo(wsSport, index, j, LeansBetsList, 3, g); // //CenterAllInfo(wsSport, index); // for (int i = 0; i < BetsWithLeans.Count; i++) // { // if (LeansBetsList[j].IdGame == BetsWithLeans[i].IdGame && // LeansBetsList[j].Rot == BetsWithLeans[i].Rot && // LeansBetsList[j].WagerPlay == BetsWithLeans[i].WagerPlay) // { // index += 1; // //ShowInfo(wsSport, index, i, BetsWithLeans, 1, g); // //CenterAllInfo(wsSport, index); // } // } // } // } // if (LeansBetsList[j].IdSport == sp) // { // if (NoLeansBets != null) // { // for (int i = 0; i < NoLeansBets.Count; i++) // { // if (LeansBetsList[j].IdGame == NoLeansBets[i].IdGame && // LeansBetsList[j].Rot != NoLeansBets[i].Rot && // LeansBetsList[j].WagerPlay == NoLeansBets[i].WagerPlay) // { // index += 1; // //ShowInfo(wsSport, index, i, NoLeansBets, 2, g); // //CenterAllInfo(wsSport, index); // } // } // } // } // } // } // } // index += 2; // } // } // SummaryList.Add(GetValuesFromSummary(sp, BetsWithLeans, NoLeansBets)); // } // // (sender as BackgroundWorker).ReportProgress(40); // //Excel.Worksheet ws3 = wb.Sheets.Add(); // //ws3.Name = "SUMMARY"; // index = 0; // csSummary general = new csSummary(); // if (SummaryList != null) // { // //CompleteRangeSport(ws3); // for (int i = 0; i < SummaryList.Count; i++) // { // //ShowInfoSport(ws3, i, SummaryList[i].sport, SummaryList[i]); // //CenterAllInfoSport(ws3, i); // general.ContLeansBets += SummaryList[i].ContLeansBets; // general.RiskLeans += SummaryList[i].RiskLeans; // general.NetLeans += SummaryList[i].NetLeans; // general.WinBetsLeans += SummaryList[i].WinBetsLeans; // general.ContNoLeansBets += SummaryList[i].ContNoLeansBets; // general.RiskNoLeans += SummaryList[i].RiskNoLeans; // general.NetNoLeans += SummaryList[i].NetNoLeans; // general.WinBetsNoLeans += SummaryList[i].WinBetsNoLeans; // index = i; // } // } // try { general.WinPerLeans = (general.WinBetsLeans * 100 / general.ContLeansBets); } catch (Exception) { general.WinPerLeans = 0; } // try { general.WinPerNoLeans = (general.WinBetsNoLeans * 100 / general.ContNoLeansBets); } catch (Exception) { general.WinPerNoLeans = 0; } // try { general.LeansHold = (general.NetLeans * 100 / general.RiskLeans); } catch (Exception) { general.LeansHold = 0; } // try { general.NoLeansHold = (general.NetNoLeans * 100 / general.RiskNoLeans); } catch (Exception) { general.NoLeansHold = 0; } // index += 6; // //RangeGeneral(ws3, index); // index += 1; // //ShowInfoGeneral(ws3, index, general); // //CenterAllInfoGeneral(ws3, index - 2); // // (sender as BackgroundWorker).ReportProgress(60); //} //// ********************** area by player ********************************** // //if (Players != null) //{ // //Excel.Worksheet wsp = wb.Sheets.Add(); // //wsp.Name = "By Player"; // index = 1; // //CompleteRangePlayer(wsp, index); // index -= 2; // foreach (var p in Players) // { // index += 1; // if (BetsWithLeans != null) // { // foreach (var s in BetsWithLeans) // { // if (p.IdPlayer == s.IdPlayer) // { // p.ContLeansBets += 1; // p.RiskLeans += s.RiskAmount; // p.NetLeans += s.Net; // if (s.Result == "WIN") p.WinBetsLeans += 1; // else p.LostBetsLeans += 1; // } // } // try { p.WinPerLeans = (p.WinBetsLeans * 100 / p.ContLeansBets); } catch (Exception) { p.WinPerLeans = 0; } // try { if (p.ContLeansBets > 0) { p.LeansHold = (p.NetLeans * 100 / p.RiskLeans); } else p.LeansHold = 0; } catch (Exception) { p.LeansHold = 0; } // } // if (NoLeansBets != null) // { // foreach (var s in NoLeansBets) // { // if (p.IdPlayer == s.IdPlayer) // { // p.ContNoLeansBets += 1; // p.RiskNoLeans += s.RiskAmount; // p.NetNoLeans += s.Net; // if (s.Result == "WIN") p.WinBetsNoLeans += 1; // else p.LostBetsNoLeans += 1; // } // } // try { p.WinPerNoLeans = (p.WinBetsNoLeans * 100 / p.ContNoLeansBets); } catch (Exception) { p.WinPerNoLeans = 0; } // try { if (p.ContNoLeansBets > 0) { p.NoLeansHold = (p.NetNoLeans * 100 / p.RiskNoLeans); } else p.NoLeansHold = 0; } catch (Exception) { p.NoLeansHold = 0; } // } // //ShowPlayer(wsp, index, p); // //CenterAllInfoSport(wsp, index); // } //} //fin area player //// ********************** Shett by game ********************************** // //if (SummaryListGame != null) //{ // //Excel.Worksheet ws4 = wb.Sheets.Add(); // //ws4.Name = "BY GAME"; // index = 0; // //CompleteRangeGame(ws4,player); // foreach (var i in SummaryListGame) // { // //ShowInfoGame(ws4, index, i); // //CenterAllInfoGame(ws4, index); // index += 2; // } // // (sender as BackgroundWorker).ReportProgress(100); //} //// ************************* SAVE THE DOCUMENT ********************* ////wb.SaveAs(path + @"/LeansReport.xls"); ////wb.Saved = true; ////wb.Close(true); ////app.Quit(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void LoadData(object sender, EventArgs e) { try { string HAB = inOrder.Items[inOrder.SelectedIndex].Value; string favDog = inRef.Items[inRef.SelectedIndex].Value; string Team = inTeam.Items[inTeam.SelectedIndex].Value.ToUpper(); string startD = Request[startDate.UniqueID]; string endD = Request[endDate.UniqueID]; var spli1 = startD.Split('/'); var spli2 = endD.Split('/'); startD = spli1[2] + "-" + spli1[0] + "-" + spli1[1]; endD = spli2[2] + "-" + spli2[0] + "-" + spli2[1]; ObservableCollection <csMlbSeries> data = MlbSeriesDB.GetAllSeries(Team, favDog, startD, endD); ObservableCollection <csMlbStat> List = new ObservableCollection <csMlbStat>(); ObservableCollection <csAgrupation> Agrupation = new ObservableCollection <csAgrupation>(); ObservableCollection <csSummary> SummaryList = new ObservableCollection <csSummary>(); csMlbStat mlbStat = null; if (data != null) { foreach (var i in data) { i.CompleteSerieList = GroupSerieDB.GetAllGamesBySerie(i); mlbStat = new csMlbStat(); mlbStat.SeriesRange = i.Range; mlbStat.Name = i.Name; mlbStat.Date = i.EventDate.Month + "/" + i.EventDate.Day + "/" + i.EventDate.Year; mlbStat.SeriesType = (i.CompleteSerieList != null) ? i.CompleteSerieList.Count.ToString() + " Games" : 0 + " Games"; mlbStat.CountGames = (i.CompleteSerieList != null) ? i.CompleteSerieList.Count : 0; mlbStat.Fav = i.Reference; mlbStat.VTeam = i.VisitorTeam; mlbStat.HTeam = i.HomeTeam; mlbStat.Line = i.Line; if (i.CompleteSerieList != null) { int k = 0; foreach (var g in i.CompleteSerieList) { g.GamesBySerieList = GamesSerieDB.GetGamesBySerie(g, i.Reference); if (g.GamesBySerieList != null && g.GamesBySerieList.Count > 0) { foreach (var game in g.GamesBySerieList) { if (game != null) { if (k == 0) //is the first game { if (i.Reference == "AWAY") { if (game.VisitorScore > game.HomeScore) { mlbStat.Game1 = 1; } else { mlbStat.Game1 = 0; } } else { if (game.VisitorScore < game.HomeScore) { mlbStat.Game1 = 1; } else { mlbStat.Game1 = 0; } } mlbStat.Game1Line = game.Line; mlbStat.Spread1 = game.Spread; mlbStat.SpreadOdds1 = game.SpreadOdds; mlbStat.Total1 = game.Total; mlbStat.TotalUnder1 = game.TotalUnder; mlbStat.TotalOver1 = game.TotalOver; mlbStat.HomeScore1 = game.HomeScore; mlbStat.VisitorScore1 = game.VisitorScore; } else if (k == 1)//is the second game { if (i.Reference == "AWAY") { if (game.VisitorScore > game.HomeScore) { mlbStat.Game2 = 1; } else { mlbStat.Game2 = 0; } } else { if (game.VisitorScore < game.HomeScore) { mlbStat.Game2 = 1; } else { mlbStat.Game2 = 0; } } mlbStat.Game2Line = game.Line; mlbStat.Spread2 = game.Spread; mlbStat.SpreadOdds2 = game.SpreadOdds; mlbStat.Total2 = game.Total; mlbStat.TotalUnder2 = game.TotalUnder; mlbStat.TotalOver2 = game.TotalOver; mlbStat.HomeScore2 = game.HomeScore; mlbStat.VisitorScore2 = game.VisitorScore; } else if (k == 2)//is the third game { if (i.Reference == "AWAY") { if (game.VisitorScore > game.HomeScore) { mlbStat.Game3 = 1; } else { mlbStat.Game3 = 0; } } else { if (game.VisitorScore < game.HomeScore) { mlbStat.Game3 = 1; } else { mlbStat.Game3 = 0; } } mlbStat.Game3Line = game.Line; mlbStat.Spread3 = game.Spread; mlbStat.SpreadOdds3 = game.SpreadOdds; mlbStat.Total3 = game.Total; mlbStat.TotalUnder3 = game.TotalUnder; mlbStat.TotalOver3 = game.TotalOver; mlbStat.HomeScore3 = game.HomeScore; mlbStat.VisitorScore3 = game.VisitorScore; } else if (k == 3) //is the fourth game { if (i.Reference == "AWAY") { if (game.VisitorScore > game.HomeScore) { mlbStat.Game4 = 1; } else { mlbStat.Game4 = 0; } } else { if (game.VisitorScore < game.HomeScore) { mlbStat.Game4 = 1; } else { mlbStat.Game4 = 0; } } mlbStat.Game4Line = game.Line; mlbStat.Spread4 = game.Spread; mlbStat.SpreadOdds4 = game.SpreadOdds; mlbStat.Total4 = game.Total; mlbStat.TotalUnder4 = game.TotalUnder; mlbStat.TotalOver4 = game.TotalOver; mlbStat.HomeScore4 = game.HomeScore; mlbStat.VisitorScore4 = game.VisitorScore; } k += 1; } } } else { if (k == 0) { mlbStat.Game1 = 2; } else if (k == 1) { mlbStat.Game2 = 2; } else if (k == 2) { mlbStat.Game3 = 2; } else if (k == 3) { mlbStat.Game4 = 2; } k += 1; } } } // detect Sweep if (mlbStat.CountGames == i.CountGames && i.CountGames == 3) { if (favDog == "Fav") // favorites { if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1 && mlbStat.Game3 == 1) { mlbStat.FavSwip = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0 && mlbStat.Game3 == 0) { mlbStat.DogSwip = 1; } if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1) { mlbStat.FavSwipPossible = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0) { mlbStat.DogSwipPossible = 1; } } else // dogs { if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1 && mlbStat.Game3 == 1) { mlbStat.DogSwip = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0 && mlbStat.Game3 == 0) { mlbStat.FavSwip = 1; } if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1) { mlbStat.DogSwipPossible = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0) { mlbStat.FavSwipPossible = 1; } } } else if (mlbStat.CountGames == i.CountGames && i.CountGames == 4) { if (favDog == "Fav") { if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1 && mlbStat.Game3 == 1 && mlbStat.Game4 == 1) { mlbStat.FavSwip = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0 && mlbStat.Game3 == 0 && mlbStat.Game4 == 0) { mlbStat.DogSwip = 1; } if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1 && mlbStat.Game3 == 1) { mlbStat.FavSwipPossible = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0 && mlbStat.Game3 == 0) { mlbStat.DogSwipPossible = 1; } } else { if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1 && mlbStat.Game3 == 1 && mlbStat.Game4 == 1) { mlbStat.DogSwip = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0 && mlbStat.Game3 == 0 && mlbStat.Game4 == 0) { mlbStat.FavSwip = 1; } if (mlbStat.Game1 == 1 && mlbStat.Game2 == 1 && mlbStat.Game3 == 1) { mlbStat.DogSwipPossible = 1; } else if (mlbStat.Game1 == 0 && mlbStat.Game2 == 0 && mlbStat.Game3 == 0) { mlbStat.FavSwipPossible = 1; } } } if (i.Reference == "AWAY" && (HAB == "A" || HAB == "B")) { if (i.VisitorTeam.ToUpper().Contains(inTeam.Items[inTeam.SelectedIndex].Value) || inTeam.Items[inTeam.SelectedIndex].Value == "") { if (mlbStat.CountGames == i.CountGames) { List.Add(mlbStat); } } } else if (i.Reference == "HOME" && (HAB == "H" || HAB == "B")) { if (i.HomeTeam.ToUpper().Contains(inTeam.Items[inTeam.SelectedIndex].Value) || inTeam.Items[inTeam.SelectedIndex].Value == "") { if (mlbStat.CountGames == i.CountGames) { List.Add(mlbStat); } } } } } csAgrupation agrupation3_180H = new csAgrupation(); csAgrupation agrupation3_179H = new csAgrupation(); csAgrupation agrupation3_130H = new csAgrupation(); csAgrupation agrupation4_180H = new csAgrupation(); csAgrupation agrupation4_179H = new csAgrupation(); csAgrupation agrupation4_130H = new csAgrupation(); csAgrupation agrupation3_180V = new csAgrupation(); csAgrupation agrupation3_179V = new csAgrupation(); csAgrupation agrupation3_130V = new csAgrupation(); csAgrupation agrupation4_180V = new csAgrupation(); csAgrupation agrupation4_179V = new csAgrupation(); csAgrupation agrupation4_130V = new csAgrupation(); csSummary range3_130 = new csSummary(); csSummary range3_179 = new csSummary(); csSummary range3_180 = new csSummary(); agrupation3_180H.SeriesType = agrupation3_179H.SeriesType = agrupation3_130H.SeriesType = "3 Games"; agrupation4_180H.SeriesType = agrupation4_179H.SeriesType = agrupation4_130H.SeriesType = "4 Games"; agrupation3_180V.SeriesType = agrupation3_179V.SeriesType = agrupation3_130V.SeriesType = "3 Games"; agrupation4_180V.SeriesType = agrupation4_179V.SeriesType = agrupation4_130V.SeriesType = "4 Games"; if (List != null) { foreach (var i in List) { // ********************* HOME ********************** if ((i.SeriesRange == "-100 to -130" || i.SeriesRange == "100 to 130") && i.CountGames == 3 && ((HAB == "H" || HAB == "B") && i.Fav == "HOME")) { agrupation3_130H = Set(agrupation3_130H, i); range3_130 = setSummary3Games(agrupation3_130H, range3_130, i); } else if ((i.SeriesRange == "-131 to -179" || i.SeriesRange == "131 to 179") && i.CountGames == 3 && ((HAB == "H" || HAB == "B") && i.Fav == "HOME")) { agrupation3_179H = Set(agrupation3_179H, i); range3_179 = setSummary3Games(agrupation3_179H, range3_179, i); } else if ((i.SeriesRange == "-180 and above" || i.SeriesRange == "180 and above") && i.CountGames == 3 && ((HAB == "H" || HAB == "B") && i.Fav == "HOME")) { agrupation3_180H = Set(agrupation3_180H, i); range3_180 = setSummary3Games(agrupation3_180H, range3_180, i); } // ********************************* RANGE 4 ************************************ else if ((i.SeriesRange == "-100 to -130" || i.SeriesRange == "100 to 130") && i.CountGames == 4 && ((HAB == "H" || HAB == "B") && i.Fav == "HOME")) { agrupation4_130H = Set(agrupation4_130H, i); } else if ((i.SeriesRange == "-131 to -179" || i.SeriesRange == "131 to 179") && i.CountGames == 4 && ((HAB == "H" || HAB == "B") && i.Fav == "HOME")) { agrupation4_179H = Set(agrupation4_179H, i); } else if ((i.SeriesRange == "-180 and above" || i.SeriesRange == "180 and above") && i.CountGames == 4 && ((HAB == "H" || HAB == "B") && i.Fav == "HOME")) { agrupation4_180H = Set(agrupation4_180H, i); } // ***************************** VISITOR ********************** else if ((i.SeriesRange == "-100 to -130" || i.SeriesRange == "100 to 130") && i.CountGames == 3 && ((HAB == "A" || HAB == "B") && i.Fav == "AWAY")) { agrupation3_130V = Set(agrupation3_130V, i); range3_130 = setSummary3Games(agrupation3_130V, range3_130, i); } else if ((i.SeriesRange == "-131 to -179" || i.SeriesRange == "131 to 179") && i.CountGames == 3 && ((HAB == "A" || HAB == "B") && i.Fav == "AWAY")) { agrupation3_179V = Set(agrupation3_179V, i); range3_179 = setSummary3Games(agrupation3_179V, range3_179, i); } else if ((i.SeriesRange == "-180 and above" || i.SeriesRange == "180 and above") && i.CountGames == 3 && ((HAB == "A" || HAB == "B") && i.Fav == "AWAY")) { agrupation3_180V = Set(agrupation3_180V, i); range3_180 = setSummary3Games(agrupation3_180V, range3_180, i); } // ********************************* RANGE 4 ************************************ else if ((i.SeriesRange == "-100 to -130" || i.SeriesRange == "100 to 130") && i.CountGames == 4 && ((HAB == "A" || HAB == "B") && i.Fav == "AWAY")) { agrupation4_130V = Set(agrupation4_130V, i); } else if ((i.SeriesRange == "-131 to -179" || i.SeriesRange == "131 to 179") && i.CountGames == 4 && ((HAB == "A" || HAB == "B") && i.Fav == "AWAY")) { agrupation4_179V = Set(agrupation4_179V, i); } else if ((i.SeriesRange == "-180 and above" || i.SeriesRange == "180 and above") && i.CountGames == 4 && ((HAB == "A" || HAB == "B") && i.Fav == "AWAY")) { agrupation4_180V = Set(agrupation4_180V, i); } } //ADD THE INFORMATION TO THE FINAL LIST WHERE WE AGROUPED THE INFORMATION if (HAB == "H" || HAB == "B") { if (agrupation3_130H.TotalGames > 0) { Agrupation.Add(agrupation3_130H); } if (agrupation3_179H.TotalGames > 0) { Agrupation.Add(agrupation3_179H); } if (agrupation3_180H.TotalGames > 0) { Agrupation.Add(agrupation3_180H); } if (agrupation4_130H.TotalGames > 0) { Agrupation.Add(agrupation4_130H); } if (agrupation4_179H.TotalGames > 0) { Agrupation.Add(agrupation4_179H); } if (agrupation4_180H.TotalGames > 0) { Agrupation.Add(agrupation4_180H); } } if (HAB == "A" || HAB == "B") { if (agrupation3_130V.TotalGames > 0) { Agrupation.Add(agrupation3_130V); } if (agrupation3_179V.TotalGames > 0) { Agrupation.Add(agrupation3_179V); } if (agrupation3_180V.TotalGames > 0) { Agrupation.Add(agrupation3_180V); } if (agrupation4_130V.TotalGames > 0) { Agrupation.Add(agrupation4_130V); } if (agrupation4_179V.TotalGames > 0) { Agrupation.Add(agrupation4_179V); } if (agrupation4_180V.TotalGames > 0) { Agrupation.Add(agrupation4_180V); } } rpTable2.DataSource = Agrupation; rpTable2.DataBind(); } if (range3_130.games > 0) { SummaryList.Add(range3_130); } if (range3_179.games > 0) { SummaryList.Add(range3_179); } if (range3_180.games > 0) { SummaryList.Add(range3_180); } if (List != null) { rptTable.DataSource = List; rptTable.DataBind(); } } catch (Exception ex) { Response.Write("<script>window.alert('Error to get the series: " + ex.Message + "');</script>"); } }