Beispiel #1
0
        private static Collection <Person> Read(OracleDataReader reader)
        {
            Collection <Person> People = new Collection <Person>();

            while (reader.Read())
            {
                int    i = -1;
                Person m = new Person();
                m.Id         = reader.GetInt32(++i);
                m.First_Name = reader.GetString(++i);
                m.Last_Name  = reader.GetString(++i);
                if (!reader.IsDBNull(++i))
                {
                    m.Birth_Date = reader.GetInt32(i);
                }
                if (!reader.IsDBNull(++i))
                {
                    m.Role = reader.GetString(i);
                }
                Game g = new Game();
                g.Id      = reader.GetInt32(++i);
                g         = GameTable.SelectOne(g.Id);
                m.Game_Id = g;

                Team t = new Team();
                t.Id      = reader.GetInt32(++i);
                t         = TeamTable.SelectOne(t.Id);
                m.Team_Id = t;

                People.Add(m);
            }
            return(People);
        }
Beispiel #2
0
        public static int ZmenitHru(Team t, int gID, DatabaseT pDb = null)
        {
            DatabaseT db;

            if (pDb == null)
            {
                db = new DatabaseT();
                db.Connect();
            }
            else
            {
                db = (DatabaseT)pDb;
            }
            db.BeginTransaction();

            if (SelectOne(t.Id) == null)
            {
                db.Rollback();
                return(-1);
            }
            if (GameTable.SelectOne(gID) == null)
            {
                db.Rollback();
                return(-1);
            }

            try
            {
                PersonTable.UpdateGame(t.Id, gID);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                db.Rollback();
                return(-1);
            }

            try
            {
                t.Game_Id = GameTable.SelectOne(gID);
                Update(t);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                db.Rollback();
                return(-1);
            }


            OracleCommand command = db.CreateCommand(SQL_SELECT_COUNT);

            command.Parameters.AddWithValue(":gID", gID);
            OracleDataReader reader = db.Select(command);

            int res = ReadCount(reader);

            reader.Close();

            db.EndTransaction();
            if (pDb == null)
            {
                db.Close();
            }

            return(res);
        }