public void InsertPartida(ModJogo x) { p = new PerJogo(); List <ModJogo> cs = p.Open(); int id = 1; if (cs.Count > 0) { id = cs.Max(c => c.IdPartida) + 1; } x.IdPartida = id; cs.Add(x); p.Save(cs); }
public void DeletePartida(ModJogo x) { p = new PerJogo(); List <ModJogo> del = p.Open(); for (int i = 0; i < del.Count; i++) { if (del[i].IdPartida == x.IdPartida) { del.RemoveAt(i); break; } } p.Save(del); }
public void UpdatePartida(ModJogo x) { p = new PerJogo(); List <ModJogo> up = p.Open(); for (int i = 0; i < up.Count; i++) { if (up[i].IdPartida == x.IdPartida) { up.RemoveAt(i); break; } } up.Add(x); p.Save(up); }
private void Button_Deletar(object sender, RoutedEventArgs e) { ModJogo c = new ModJogo(); c.IdPartida = int.Parse(idpartxt.Text); NegPartidas n = new NegPartidas(); n.DeletePartida(c); listarpartidas.ItemsSource = null; listarpartidas.ItemsSource = n.SelectPartida(); id1txt.Text = ""; id2txt.Text = ""; gol1txt.Text = ""; gol2txt.Text = ""; localtxt.Text = ""; }
private void Button_Inserir(object sender, RoutedEventArgs e) { ModJogo x = new ModJogo(); NegEquipe eq = new NegEquipe(); x.Gol1 = int.Parse(gol1txt.Text); x.Gol2 = int.Parse(gol2txt.Text); x.Local = localtxt.Text; NegPartidas y = new NegPartidas(); y.InsertPartida(x); id1txt.Text = ""; id2txt.Text = ""; gol1txt.Text = ""; gol2txt.Text = ""; localtxt.Text = ""; }
private void Button_Atualizar(object sender, RoutedEventArgs e) { ModJogo x = new ModJogo(); x.IdEquipe1 = int.Parse(id1txt.Text); x.IdEquipe2 = int.Parse(id2txt.Text); x.Gol1 = int.Parse(gol1txt.Text); x.Gol2 = int.Parse(gol2txt.Text); x.Local = localtxt.Text; NegPartidas n = new NegPartidas(); n.UpdatePartida(x); id1txt.Text = ""; id2txt.Text = ""; gol1txt.Text = ""; gol2txt.Text = ""; localtxt.Text = ""; SelectClick(sender, e); }