private void button4_Click(object sender, EventArgs e) { TeamsEntity team = storeHelper.TeamsList.FirstOrDefault(t => t.TeamName == cbxTeams.SelectedItem.ToString()); team.TeamName = tbNewName.Text; team.BrandName = cbxAsscBrand.SelectedItem.ToString(); team.Wins = Convert.ToInt32(tbWins.Text); team.Losses = Convert.ToInt32(tbLosses.Text); team.Draws = Convert.ToInt32(tbDraws.Text); tHelper.SaveTeamsList(team); ModifyMain main = new ModifyMain(OrgName); main.Show(); this.Hide(); }
private void btnSave_Click(object sender, EventArgs e) { TeamsEntity newTeam = new TeamsEntity(); List <WrestlersEntity> wrestUpdate = new List <WrestlersEntity>(); for (int i = 0; i < lbSelWrestlers.Items.Count; i++) { switch (lbSelWrestlers.Items.Count) { case 2: newTeam = new TeamsEntity() { TeamName = TeamName, OrgName = OrgName, Wins = 0, Losses = 0, Draws = 0, MemberName1 = lbSelWrestlers.Items[0].ToString(), MemberName2 = lbSelWrestlers.Items[1].ToString() }; wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[0].ToString())); wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[1].ToString())); break; case 3: newTeam = new TeamsEntity() { TeamName = TeamName, OrgName = OrgName, Wins = 0, Losses = 0, Draws = 0, MemberName1 = lbSelWrestlers.Items[0].ToString(), MemberName2 = lbSelWrestlers.Items[1].ToString(), MemberName3 = lbSelWrestlers.Items[2].ToString() }; wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[0].ToString())); wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[1].ToString())); wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[2].ToString())); break; case 4: newTeam = new TeamsEntity() { TeamName = TeamName, OrgName = OrgName, Wins = 0, Losses = 0, Draws = 0, MemberName1 = lbSelWrestlers.Items[0].ToString(), MemberName2 = lbSelWrestlers.Items[1].ToString(), MemberName3 = lbSelWrestlers.Items[2].ToString(), MemberName4 = lbSelWrestlers.Items[3].ToString() }; wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[0].ToString())); wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[1].ToString())); wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[2].ToString())); wrestUpdate.Add(storeHelper.WrestlersList.FirstOrDefault(w => w.Name == lbSelWrestlers.Items[3].ToString())); break; default: lbSelWrestlers.BackColor = Color.MistyRose; break; } } foreach (WrestlersEntity w in wrestUpdate) { w.TeamName = TeamName; wHelper.SaveWrestlersList(w); } tHelper.SaveTeamsList(newTeam); this.Hide(); }
private void button4_Click(object sender, EventArgs e) { if (lbRoster.Items.Count > 1) { foreach (var unSel in lbRoster.Items) { foreach (WrestlersEntity w in storeHelper.WrestlersList) { if (unSel.ToString() == w.Name && w.TeamName == TeamName) { w.TeamName = ""; wHelper.SaveWrestlersList(w); } } } } if (lbSelected.Items.Count >= 2) { List <WrestlersEntity> all = wHelper.PopulateWrestlersList(); TeamsEntity t = storeHelper.TeamsList.FirstOrDefault(tw => tw.TeamName == TeamName); WrestlersEntity w1 = new WrestlersEntity(); WrestlersEntity w2 = new WrestlersEntity(); WrestlersEntity w3 = new WrestlersEntity(); WrestlersEntity w4 = new WrestlersEntity(); if (lbSelected.Items.Count == 2) { w1 = all.FirstOrDefault(s => s.Name == lbSelected.Items[0].ToString()); w2 = all.FirstOrDefault(s => s.Name == lbSelected.Items[1].ToString()); w1.TeamName = TeamName; w2.TeamName = TeamName; t.MemberName1 = w1.Name; t.MemberName2 = w2.Name; wHelper.SaveWrestlersList(w1); wHelper.SaveWrestlersList(w2); tHelper.SaveTeamsList(t); this.Hide(); } else if (lbSelected.Items.Count == 3) { w1 = all.FirstOrDefault(s => s.Name == lbSelected.Items[0].ToString()); w2 = all.FirstOrDefault(s => s.Name == lbSelected.Items[1].ToString()); w3 = all.FirstOrDefault(s => s.Name == lbSelected.Items[2].ToString()); w1.TeamName = TeamName; w2.TeamName = TeamName; w3.TeamName = TeamName; t.MemberName1 = w1.Name; t.MemberName2 = w2.Name; t.MemberName3 = w3.Name; wHelper.SaveWrestlersList(w1); wHelper.SaveWrestlersList(w2); wHelper.SaveWrestlersList(w3); tHelper.SaveTeamsList(t); this.Hide(); } else if (lbSelected.Items.Count == 4) { w1 = all.FirstOrDefault(s => s.Name == lbSelected.Items[0].ToString()); w2 = all.FirstOrDefault(s => s.Name == lbSelected.Items[1].ToString()); w3 = all.FirstOrDefault(s => s.Name == lbSelected.Items[2].ToString()); w4 = all.FirstOrDefault(s => s.Name == lbSelected.Items[3].ToString()); w1.TeamName = TeamName; w2.TeamName = TeamName; w3.TeamName = TeamName; w4.TeamName = TeamName; t.MemberName1 = w1.Name; t.MemberName2 = w2.Name; t.MemberName3 = w3.Name; t.MemberName4 = w4.Name; wHelper.SaveWrestlersList(w1); wHelper.SaveWrestlersList(w2); wHelper.SaveWrestlersList(w3); wHelper.SaveWrestlersList(w4); tHelper.SaveTeamsList(t); this.Hide(); } } }
public void SaveGame( List <Brands> brands, List <Cards> cards, List <Matches> matches, List <Promotions> promotions, List <Teams> teams, List <TitlesMain> titles, List <WrestlersMain> wrestlers ) { string dir = string.Concat(Directory.GetCurrentDirectory(), "\\Saves"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(string.Concat(Directory.GetCurrentDirectory(), "\\Saves")); } else { string main = string.Concat(Directory.GetCurrentDirectory(), "\\Saves\\" + "\\" + "Main"); if (!Directory.Exists(main)) { Directory.CreateDirectory(string.Concat(Directory.GetCurrentDirectory(), "\\Saves\\" + "\\" + "Main")); } else { BrandHelper bHelper = new BrandHelper(); CardHelper cHelper = new CardHelper(); MatchHelper mHelper = new MatchHelper(); PromotionHelper pHelper = new PromotionHelper(); TeamHelper tHelper = new TeamHelper(); TitleHelper tlHelper = new TitleHelper(); WrestlerHelper wHelper = new WrestlerHelper(); foreach (Brands b in brands) { bHelper.SaveBrandsList(b); } foreach (Cards c in cards) { cHelper.SaveCardsList(c); } foreach (Matches m in matches) { mHelper.SaveMatchesList(m); } foreach (Promotions p in promotions) { pHelper.SavePromotionsList(p); } foreach (Teams t in teams) { tHelper.SaveTeamsList(t); } foreach (TitlesMain tl in titles) { tlHelper.SaveTitlesList(tl); } foreach (WrestlersMain w in wrestlers) { wHelper.SaveWrestlersList(w); } } } }
private void button4_Click(object sender, EventArgs e) { if (isEdit) { TeamsEntity team = storeHelper.TeamsList.FirstOrDefault(t => t.TeamName == lbTeamList.SelectedItem.ToString()); foreach (TeamsEntity t in storeHelper.TeamsList) { if (team.TeamID == t.TeamID) { if (tbNewName.Text == "") { tbNewName.BackColor = Color.MistyRose; } else { int wins = 0; int losses = 0; int draws = 0; string asscCo; int tempWins = 0; int tempLoss = 0; int tempDraws = 0; if (tbWins.Text == "" || tbLosses.Text == "" || tbDraws.Text == "") { wins = 0; losses = 0; draws = 0; } else if (int.TryParse(tbWins.Text, out tempWins) && int.TryParse(tbLosses.Text, out tempLoss) && int.TryParse(tbDraws.Text, out tempDraws)) { wins = tempWins; losses = tempLoss; draws = tempDraws; if (string.IsNullOrWhiteSpace(cbxAsscCo.SelectedItem.ToString())) { asscCo = ""; } else { asscCo = cbxAsscCo.SelectedItem.ToString(); } team.TeamName = tbNewName.Text; team.OrgName = asscCo; team.Wins = wins; team.Losses = losses; team.Draws = draws; tHelper.SaveTeamsList(team); EditMain main = new EditMain(); main.Show(); this.Hide(); } else { tbWins.BackColor = Color.MistyRose; tbLosses.BackColor = Color.MistyRose; tbDraws.BackColor = Color.MistyRose; } } } } } else { if (tbNewName.Text == "") { tbNewName.BackColor = Color.MistyRose; } else { int wins = 0; int losses = 0; int draws = 0; string asscCo; int tempWins = 0; int tempLoss = 0; int tempDraws = 0; if (tbWins.Text == "" || tbLosses.Text == "" || tbDraws.Text == "") { wins = 0; losses = 0; draws = 0; } else if (int.TryParse(tbWins.Text, out tempWins) && int.TryParse(tbLosses.Text, out tempLoss) && int.TryParse(tbDraws.Text, out tempDraws)) { wins = tempWins; losses = tempLoss; draws = tempDraws; TeamsEntity team = storeHelper.TeamsList.FirstOrDefault(t => t.TeamName == lbTeamList.SelectedItem.ToString()); if (string.IsNullOrWhiteSpace(cbxAsscCo.SelectedItem.ToString())) { asscCo = ""; } else { asscCo = cbxAsscCo.SelectedItem.ToString(); } TeamsEntity newTeam = new TeamsEntity() { TeamID = idHelper.CurrentID(false, false, false, false, true, false, false), TeamName = tbNewName.Text, OrgName = asscCo, Wins = wins, Losses = losses, Draws = draws }; tHelper.SaveTeamsList(newTeam); EditMain main = new EditMain(); main.Show(); this.Hide(); } else { tbWins.BackColor = Color.MistyRose; tbLosses.BackColor = Color.MistyRose; tbDraws.BackColor = Color.MistyRose; } } } }