Exemplo n.º 1
0
        // считать всех игроков
        public BasketballTeams readPlayers()
        {
            BasketballTeams    datasetBasketballTeams = new BasketballTeams();
            AbstractConnection abstractConnection     = new AbstractConnection(ConnectionString);

            try
            {
                abstractConnection.openConnection();
                AbstractTransaction abstractTransaction = abstractConnection.openTransaction();
                try
                {
                    team.Read(abstractConnection, abstractTransaction, datasetBasketballTeams);
                    manager.Read(abstractConnection, abstractTransaction, datasetBasketballTeams);
                    player.Read(abstractConnection, abstractTransaction, datasetBasketballTeams);
                }
                finally
                {
                    abstractTransaction.rollback();
                }
            }
            finally
            {
                abstractConnection.closeConnection();
            }
            return(datasetBasketballTeams);
        }
Exemplo n.º 2
0
        public void Read(AbstractConnection conn, AbstractTransaction trans, BasketballTeams teams)
        {
            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = new SqlCommand(@"select * from Player", conn.Connection, trans.Transaction);
            adapter.Fill(teams, "Player");
        }
        public AbstractTransaction openTransaction()
        {
            AbstractTransaction resultTransaction = new AbstractTransaction();
            SqlTransaction      transaction       = connection.BeginTransaction();

            resultTransaction.Transaction = transaction;
            return(resultTransaction);
        }
Exemplo n.º 4
0
        public void Update(AbstractConnection conn, AbstractTransaction trans, BasketballTeams teams)
        {
            SqlParameter id = new SqlParameter();

            id.ParameterName = "@Id";
            id.SourceColumn  = "Id";
            SqlParameter name = new SqlParameter();

            name.ParameterName = "@Name";
            name.SourceColumn  = "Name";
            SqlParameter surname = new SqlParameter();

            surname.ParameterName = "@Surname";
            surname.SourceColumn  = "Surname";
            SqlParameter numberOfChampions = new SqlParameter();

            numberOfChampions.ParameterName = "@NumberOfChampions";
            numberOfChampions.SourceColumn  = "NumberOfChampions";

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.UpdateCommand = new SqlCommand(@"update Coach set Name = @Name, Surname = @Surname, NumberOfChampions = @NumberOfChampions where Id = @Id", conn.Connection, trans.Transaction);
            adapter.UpdateCommand.Parameters.Add(id);
            adapter.UpdateCommand.Parameters.Add(name);
            adapter.UpdateCommand.Parameters.Add(surname);
            adapter.UpdateCommand.Parameters.Add(numberOfChampions);

            SqlParameter id2 = new SqlParameter();

            id2.ParameterName = "@Id";
            id2.SourceColumn  = "Id";
            SqlParameter name2 = new SqlParameter();

            name2.ParameterName = "@Name";
            name2.SourceColumn  = "Name";
            SqlParameter surname2 = new SqlParameter();

            surname2.ParameterName = "@Surname";
            surname2.SourceColumn  = "Surname";
            SqlParameter numberOfChampions2 = new SqlParameter();

            numberOfChampions2.ParameterName = "@NumberOfChampions";
            numberOfChampions2.SourceColumn  = "NumberOfChampions";

            adapter.InsertCommand = new SqlCommand(@"insert into Coach(Name, Surname,NumberOfChampions) values(@Name, @Surname, @NumberOfChampions)", conn.Connection, trans.Transaction);
            adapter.InsertCommand.Parameters.Add(name2);
            adapter.InsertCommand.Parameters.Add(surname2);
            adapter.InsertCommand.Parameters.Add(numberOfChampions2);

            adapter.DeleteCommand = new SqlCommand(@"delete from Coach where Id = @Id", conn.Connection, trans.Transaction);
            adapter.DeleteCommand.Parameters.Add(id2);

            adapter.Update(teams, "Coach");
        }
Exemplo n.º 5
0
        // изменить информацию об игроке
        public void updatePlayer(BasketballTeams datasetBasketballTeams)
        {
            AbstractConnection abstractConnection = new AbstractConnection(ConnectionString);

            try
            {
                abstractConnection.openConnection();
                AbstractTransaction abstractTransaction = abstractConnection.openTransaction();
                try
                {
                    player.Update(abstractConnection, abstractTransaction, datasetBasketballTeams);
                    abstractTransaction.commit();
                }
                catch
                {
                    abstractTransaction.rollback();
                }
            }
            finally
            {
                abstractConnection.closeConnection();
            }
        }
Exemplo n.º 6
0
        public void Update(AbstractConnection conn, AbstractTransaction trans, BasketballTeams teams)
        {
            SqlParameter id = new SqlParameter();

            id.ParameterName = "@Id";
            id.SourceColumn  = "Id";
            SqlParameter name = new SqlParameter();

            name.ParameterName = "@Name";
            name.SourceColumn  = "Name";
            SqlParameter surname = new SqlParameter();

            surname.ParameterName = "@Surname";
            surname.SourceColumn  = "Surname";
            SqlParameter age = new SqlParameter();

            age.ParameterName = "@Age";
            age.SourceColumn  = "Age";
            SqlParameter city = new SqlParameter();

            city.ParameterName = "@City";
            city.SourceColumn  = "City";
            SqlParameter numberOfTeam = new SqlParameter();

            numberOfTeam.ParameterName = "@NumberOfTeam";
            numberOfTeam.SourceColumn  = "NumberOfTeam";
            SqlParameter idTeam = new SqlParameter();

            idTeam.ParameterName = "@IdTeam";
            idTeam.SourceColumn  = "IdTeam";
            SqlParameter idManager = new SqlParameter();

            idManager.ParameterName = "@IdManager";
            idManager.SourceColumn  = "IdManager";

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.UpdateCommand = new SqlCommand(@"update Player set Name = @Name, Surname = @Surname, Age = @Age, NumberOfTeam = @NumberOfTeam, IdTeam = @IdTeam, IdManager = @IdManager where Id = @Id", conn.Connection, trans.Transaction);
            adapter.UpdateCommand.Parameters.Add(id);
            adapter.UpdateCommand.Parameters.Add(name);
            adapter.UpdateCommand.Parameters.Add(surname);
            adapter.UpdateCommand.Parameters.Add(age);
            adapter.UpdateCommand.Parameters.Add(numberOfTeam);
            adapter.UpdateCommand.Parameters.Add(idTeam);
            adapter.UpdateCommand.Parameters.Add(idManager);

            SqlParameter id2 = new SqlParameter();

            id2.ParameterName = "@Id";
            id2.SourceColumn  = "Id";
            SqlParameter name2 = new SqlParameter();

            name2.ParameterName = "@Name";
            name2.SourceColumn  = "Name";
            SqlParameter surname2 = new SqlParameter();

            surname2.ParameterName = "@Surname";
            surname2.SourceColumn  = "Surname";
            SqlParameter age2 = new SqlParameter();

            age2.ParameterName = "@Age";
            age2.SourceColumn  = "Age";
            SqlParameter city2 = new SqlParameter();

            city2.ParameterName = "@City";
            city2.SourceColumn  = "City";
            SqlParameter numberOfTeam2 = new SqlParameter();

            numberOfTeam2.ParameterName = "@NumberOfTeam";
            numberOfTeam2.SourceColumn  = "NumberOfTeam";
            SqlParameter idTeam2 = new SqlParameter();

            idTeam2.ParameterName = "@IdTeam";
            idTeam2.SourceColumn  = "IdTeam";
            SqlParameter idManager2 = new SqlParameter();

            idManager2.ParameterName = "@IdManager";
            idManager2.SourceColumn  = "IdManager";

            adapter.InsertCommand = new SqlCommand(@"insert into Player(Name, Surname,Age,NumberOfTeam, IdTeam, IdManager) values(@Name, @Surname, @Age, @NumberOfTeam, @IdTeam, @IdManager)", conn.Connection, trans.Transaction);
            adapter.InsertCommand.Parameters.Add(name2);
            adapter.InsertCommand.Parameters.Add(surname2);
            adapter.InsertCommand.Parameters.Add(age2);
            adapter.InsertCommand.Parameters.Add(numberOfTeam2);
            adapter.InsertCommand.Parameters.Add(idTeam2);
            adapter.InsertCommand.Parameters.Add(idManager2);

            adapter.DeleteCommand = new SqlCommand(@"delete from Player where Id = @Id", conn.Connection, trans.Transaction);
            adapter.DeleteCommand.Parameters.Add(id2);

            adapter.Update(teams, "Player");
        }
Exemplo n.º 7
0
        public void Update(AbstractConnection conn, AbstractTransaction trans, BasketballTeams teams)
        {
            SqlParameter id = new SqlParameter();

            id.ParameterName = "@Id";
            id.SourceColumn  = "Id";
            SqlParameter name = new SqlParameter();

            name.ParameterName = "@Name";
            name.SourceColumn  = "Name";
            SqlParameter yearFoundation = new SqlParameter();

            yearFoundation.ParameterName = "@YearFoundation";
            yearFoundation.SourceColumn  = "YearFoundation";
            SqlParameter city = new SqlParameter();

            city.ParameterName = "@City";
            city.SourceColumn  = "City";
            SqlParameter numberOfChampions = new SqlParameter();

            numberOfChampions.ParameterName = "@NumberOfChampions";
            numberOfChampions.SourceColumn  = "NumberOfChampions";
            SqlParameter idCoach = new SqlParameter();

            idCoach.ParameterName = "@IdCoach";
            idCoach.SourceColumn  = "IdCoach";

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.UpdateCommand = new SqlCommand(@"update Team set Name = @Name, YearFoundation = @YearFoundation, City = @City, NumberOfChampions = @NumberOfChampions, IdCoach = @IdCoach where Id = @Id", conn.Connection, trans.Transaction);
            adapter.UpdateCommand.Parameters.Add(id);
            adapter.UpdateCommand.Parameters.Add(name);
            adapter.UpdateCommand.Parameters.Add(yearFoundation);
            adapter.UpdateCommand.Parameters.Add(city);
            adapter.UpdateCommand.Parameters.Add(numberOfChampions);
            adapter.UpdateCommand.Parameters.Add(idCoach);

            SqlParameter id2 = new SqlParameter();

            id2.ParameterName = "@Id";
            id2.SourceColumn  = "Id";
            SqlParameter name2 = new SqlParameter();

            name2.ParameterName = "@Name";
            name2.SourceColumn  = "Name";
            SqlParameter yearFoundation2 = new SqlParameter();

            yearFoundation2.ParameterName = "@YearFoundation";
            yearFoundation2.SourceColumn  = "YearFoundation";
            SqlParameter city2 = new SqlParameter();

            city2.ParameterName = "@City";
            city2.SourceColumn  = "City";
            SqlParameter numberOfChampions2 = new SqlParameter();

            numberOfChampions2.ParameterName = "@NumberOfChampions";
            numberOfChampions2.SourceColumn  = "NumberOfChampions";
            SqlParameter idCoach2 = new SqlParameter();

            idCoach2.ParameterName = "@IdCoach";
            idCoach2.SourceColumn  = "IdCoach";

            adapter.InsertCommand = new SqlCommand(@"insert into Team(Name, YearFoundation, City, NumberOfChampions, IdCoach) values(@Name, @YearFoundation, @City, @NumberOfChampions, @IdCoach)", conn.Connection, trans.Transaction);
            adapter.InsertCommand.Parameters.Add(name2);
            adapter.InsertCommand.Parameters.Add(yearFoundation2);
            adapter.InsertCommand.Parameters.Add(city2);
            adapter.InsertCommand.Parameters.Add(numberOfChampions2);
            adapter.InsertCommand.Parameters.Add(idCoach2);

            adapter.DeleteCommand = new SqlCommand(@"delete from Team where Id = @Id", conn.Connection, trans.Transaction);
            adapter.DeleteCommand.Parameters.Add(id2);

            adapter.Update(teams, "Team");
        }
Exemplo n.º 8
0
        public void Update(AbstractConnection conn, AbstractTransaction trans, BasketballTeams teams)
        {
            SqlParameter id = new SqlParameter();

            id.ParameterName = "@Id";
            id.SourceColumn  = "Id";
            SqlParameter name = new SqlParameter();

            name.ParameterName = "@Name";
            name.SourceColumn  = "Name";
            SqlParameter surname = new SqlParameter();

            surname.ParameterName = "@Surname";
            surname.SourceColumn  = "Surname";
            SqlParameter telNumber = new SqlParameter();

            telNumber.ParameterName = "@TelNumber";
            telNumber.SourceColumn  = "TelNumber";
            SqlParameter email = new SqlParameter();

            email.ParameterName = "@Email";
            email.SourceColumn  = "Email";

            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.UpdateCommand = new SqlCommand(@"update Manager set Name = @Name, Surname = @Surname, TelNumber = @TelNumber, Email = @Email where Id = @Id", conn.Connection, trans.Transaction);
            adapter.UpdateCommand.Parameters.Add(id);
            adapter.UpdateCommand.Parameters.Add(name);
            adapter.UpdateCommand.Parameters.Add(surname);
            adapter.UpdateCommand.Parameters.Add(telNumber);
            adapter.UpdateCommand.Parameters.Add(email);

            SqlParameter id1 = new SqlParameter();

            id1.ParameterName = "@Id";
            id1.SourceColumn  = "Id";
            SqlParameter name1 = new SqlParameter();

            name1.ParameterName = "@Name";
            name1.SourceColumn  = "Name";
            SqlParameter surname1 = new SqlParameter();

            surname1.ParameterName = "@Surname";
            surname1.SourceColumn  = "Surname";
            SqlParameter telNumber1 = new SqlParameter();

            telNumber1.ParameterName = "@TelNumber";
            telNumber1.SourceColumn  = "TelNumber";
            SqlParameter email1 = new SqlParameter();

            email1.ParameterName = "@Email";
            email1.SourceColumn  = "Email";

            adapter.InsertCommand = new SqlCommand(@"insert into Manager(Name, Surname, TelNumber, Email) values(@Name, @Surname, @TelNumber, @Email)", conn.Connection, trans.Transaction);
            adapter.InsertCommand.Parameters.Add(name1);
            adapter.InsertCommand.Parameters.Add(surname1);
            adapter.InsertCommand.Parameters.Add(telNumber1);
            adapter.InsertCommand.Parameters.Add(email1);

            adapter.DeleteCommand = new SqlCommand(@"delete from Manager where Id = @Id", conn.Connection, trans.Transaction);
            adapter.DeleteCommand.Parameters.Add(id1);

            adapter.Update(teams, "Manager");
        }