Пример #1
0
        public Clasament ReadByUid(Clasament clasament)
        {
            Clasament newClasament = new Clasament();

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = CLASAMENT_READ_BY_GUID;
                    command.Parameters.Add(new SqlParameter("@Clasament_ID", clasament.clasamentId));
                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        if (dataReader.Read())
                        {
                            newClasament = ConvertToModel(dataReader);
                        }
                    }
                }
            }

            return(newClasament);
        }
Пример #2
0
        public List <Clasament> ReadAll()
        {
            List <Clasament> clasaments = new List <Clasament>();

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.Text;
                    command.CommandText = CLASAMENT_READ_ALL;
                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        while (dataReader.Read())
                        {
                            Clasament clasament = new Clasament();
                            clasament = ConvertToModel(dataReader);
                            clasaments.Add(clasament);
                        }
                    }
                }
            }

            return(clasaments);
        }
Пример #3
0
        private void btnSursaVoturi_Click(object sender, RoutedEventArgs e)
        {
            var source = Database.GetSetting(Constants.KEY_VOTE_SOURCE);

            var directory = "";

            if (!String.IsNullOrEmpty(source))
            {
                directory = source;
            }

            using (var fbd = new System.Windows.Forms.FolderBrowserDialog()) {
                if (Directory.Exists(directory))
                {
                    fbd.SelectedPath = directory;
                }

                var voteCount = (Int64)Database.ExecuteScalar("select count(*) from Votes");
                if (voteCount > 0)
                {
                    if (MessageBox.Show(
                            "Există voturi inregistrate pentru această sesiune de lucru.\nModificarea opțiunilor de vot va duce la ștergerea voturilor.",
                            "Confirmare",
                            MessageBoxButton.OKCancel,
                            MessageBoxImage.Exclamation) == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }

                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Database.ExecuteNonQuery("delete from Votes");
                    Votes.Clear();
                    OnPropertyChanged("Votes");
                    SelectedVot = null;
                    OnPropertyChanged("SelectedVot");
                    if (Clasament != null)
                    {
                        Clasament.Clear();
                        OnPropertyChanged("Clasament");
                    }
                    Database.SetSetting(Constants.KEY_VOTE_SOURCE, fbd.SelectedPath);


                    LoadVotes(fbd.SelectedPath);

                    dgVotes.Items.Refresh();
                    imgPreview.Source = null;
                }
            }
        }
Пример #4
0
        private Clasament ConvertToModel(SqlDataReader dataReader)
        {
            Clasament clasament = new Clasament();

            clasament.clasamentId = dataReader.GetGuid(dataReader.GetOrdinal("Clasament_ID"));
            clasament.league      = dataReader.GetGuid(dataReader.GetOrdinal("League"));
            clasament.position    = dataReader.GetInt32(dataReader.GetOrdinal("Position"));
            clasament.teamWins    = dataReader.GetInt32(dataReader.GetOrdinal("Team_Wins"));
            clasament.teamDefeats = dataReader.GetInt32(dataReader.GetOrdinal("Team_Defeats"));
            clasament.teamDraws   = dataReader.GetInt32(dataReader.GetOrdinal("Team_Draws"));
            clasament.teamPoints  = dataReader.GetInt32(dataReader.GetOrdinal("Team_Points"));

            return(clasament);
        }
Пример #5
0
        public void DeleteByUid(Clasament clasament)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Connection  = connection;
                    command.Parameters.Add(new SqlParameter("@Clasament_ID", clasament.clasamentId));
                    command.CommandText = CLASAMENT_DELETE_BY_GUID;

                    command.ExecuteNonQuery();
                }
            }
        }
Пример #6
0
        public void UpdateByUid(Clasament clasament)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand())
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Connection  = connection;
                    command.Parameters.Add(new SqlParameter("@ID", clasament.clasamentId));
                    command.Parameters.Add(new SqlParameter("@Position", clasament.position));
                    command.Parameters.Add(new SqlParameter("@Team_Wins", clasament.teamWins));
                    command.Parameters.Add(new SqlParameter("@Team_Defeats", clasament.teamDefeats));
                    command.Parameters.Add(new SqlParameter("@Team_Draws", clasament.teamDraws));
                    command.Parameters.Add(new SqlParameter("@Team_Points", clasament.teamPoints));
                    command.CommandText = CLASAMENT_UPDATE_BY_GUID;

                    command.ExecuteNonQuery();
                }
            }
        }
Пример #7
0
 public void UpdateByUid(Clasament clasament)
 {
     _clasamentDAL.UpdateByUid(clasament);
 }
Пример #8
0
 public void DeleteByUid(Clasament clasament)
 {
     _clasamentDAL.DeleteByUid(clasament);
 }
Пример #9
0
 public Clasament ReadByUid(Clasament clasament)
 {
     return(_clasamentDAL.ReadByUid(clasament));
 }
Пример #10
0
 public void DeleteByUid(Clasament clasament)
 {
     _blContext.ClasamentBL.DeleteByUid(clasament);
 }
Пример #11
0
 public void UpdateByUid(Clasament clasament)
 {
     _blContext.ClasamentBL.UpdateByUid(clasament);
 }
Пример #12
0
 public Clasament GetByUid(Clasament clasament)
 {
     return(_blContext.ClasamentBL.ReadByUid(clasament));
 }