コード例 #1
0
        public static int UpdateOrg(Team t, int oID, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();

            int count = 0;

            try
            {
                count = OrganisationTable.SelectTeamCountGame(oID, t.Game_Id.Id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(-1);
            }
            if (count > 0)
            {
                Console.WriteLine("Organizace uz ma tym pro tuto hru");
                return(-1);
            }


            OracleCommand command = db.CreateCommand(SQL_UPDATE_ORG);

            command.Parameters.AddWithValue(":id", t.Id);
            command.Parameters.AddWithValue(":voID", oID);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
            return(ret);
        }
コード例 #2
0
        public static int Update(Organisation o, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_UPDATE);

            PrepareCommand(command, o);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
            return(ret);
        }
コード例 #3
0
        public static int Delete(int id, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_DELETE_ID);

            command.Parameters.AddWithValue(":id", id);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
            return(ret);
        }
コード例 #4
0
ファイル: GameTable.cs プロジェクト: t0is/fantastic-spork
        public static int Insert(Game game, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_INSERT);

            PrepareCommand(command, game);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
            return(ret);
        }
コード例 #5
0
        public static int UpdateGame(int tID, int gID, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_UPDATE_GAME);

            command.Parameters.AddWithValue(":team", gID);
            command.Parameters.AddWithValue(":game", tID);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
            return(ret);
        }
コード例 #6
0
        public static int PridatAkci(Event e, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();

            int event_id = 0;

            if (e.Prizepool == null)
            {
                e.Prizepool = 0;
            }

            if (SelectAllFromOrganiser(e.Organiser).Count > 500)
            {
                Console.WriteLine("Prekrocen maximalni pocet akci");
                return(-1);
            }

            event_id = SelectLast();
            e.Id     = ++event_id;


            OracleCommand command = db.CreateCommand(SQL_INSERT);

            PrepareCommand(command, e);
            int ret = 0;

            try
            {
                ret = db.ExecuteNonQuery(command);
            }
            catch (Exception er)
            {
                Console.WriteLine(er.Message);
            }

            db.Close();
            return(ret);
        }
コード例 #7
0
        public static int Delete(int id, DatabaseT pDb = null)
        {
            DatabaseT db = new DatabaseT();

            db.Connect();
            OracleCommand command = db.CreateCommand(SQL_DELETE_ID);

            Person p = PersonTable.SelectOne(id);

            if (p.Role == "Coach")
            {
                Team ot = TeamTable.SelectOne(p.Team_Id.Id);
                ot.Person_Id = null;
                TeamTable.Update(ot);
            }

            command.Parameters.AddWithValue(":id", id);
            int ret = db.ExecuteNonQuery(command);

            db.Close();
            return(ret);
        }