private static void PrepareCommand(SqlCommand command, Trest trest) { command.Parameters.AddWithValue("@idTrest", trest.idTrest); command.Parameters.AddWithValue("@idHrac", trest.idHrac); command.Parameters.AddWithValue("@zacatek", trest.zacatek); command.Parameters.AddWithValue("@konec", trest.konec); }
public static Collection <Trest> Read(OracleDataReader reader) { var data = new Collection <Trest>(); while (reader.Read()) { int i = -1; var trest = new Trest { TrestId = reader.GetInt32(++i), Delka = reader.GetInt32(++i), Duvod = reader.GetString(++i), Hrac = new Hrac { HracId = reader.GetInt32(++i) }, Zapas = new Zapas { ZapasId = reader.GetInt32(++i) } }; data.Add(trest); } return(data); }
public static int Update(Trest trest) { Database db; db = new Database(); db.Connect(); SqlCommand command = db.CreateCommand(SQL_UPDATE); PrepareCommand(command, trest); int ret = db.ExecuteNonQuery(command); db.Close(); return(ret); }
public void ZapisTrest(Trest t) { HraciTable ht = new HraciTable(); TrestyTable tt = new TrestyTable(); List <Hrac> hraci = ht.Select(); List <Trest> tresty = tt.Select(); for (int i = 0; i < hraci.Count; i++) { if (t.Hrac.HracId == hraci[i].HracId) { hraci[i].TrestneMinuty += t.Delka; ht.Update(t.Hrac.HracId, hraci[i].TrestneMinuty); tt.Insert(t); break; } } }
private static Collection <Trest> Read(SqlDataReader reader) { var tresty = new Collection <Trest>(); while (reader.Read()) { int i = -1; Trest trest = new Trest(); trest.Hrac = new Hrac(); trest.Hrac.IdHrac = reader.GetInt32(++i); trest.Hrac.Jmeno = reader.GetString(++i); trest.Minuty = reader.GetInt32(++i); tresty.Add(trest); } return(tresty); }
public int Insert(Trest t) { using (db.GetConnection()) { db.Connect(); OracleCommand command = db.CreateCommand(insert); command.Parameters.AddWithValue(":Delka", t.Delka); command.Parameters.AddWithValue(":Duvod", t.Duvod); command.Parameters.AddWithValue(":Hrac", t.Hrac.HracId); var zap = new ZapasyTable(); int maximum = zap.PosledniZapas(); command.Parameters.AddWithValue(":Zapas", maximum); //command.Parameters.AddWithValue(":Zapas", t.Zapas.ZapasId); int ret = db.ExecuteNonQuery(command); return(ret); } }
private void buttTrest_Click(object sender, EventArgs e) { int hrac = Int32.Parse(textTestHrac.Text); int delka = Int32.Parse(textTestDelka.Text); string duvod = textTestDuvod.Text; Hrac h = new Hrac() { HracId = hrac }; Trest t = new Trest() { Hrac = h, Delka = delka, Duvod = duvod }; z.ZapisTrest(t); textTestHrac.Text = ""; textTestDelka.Text = ""; textTestDuvod.Text = ""; }