Example #1
0
        public static CityCollection GetCollection()
        {
            CityCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetCity", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection);

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new CityCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return(tempList);
        }
Example #2
0
        /// <summary>
        /// Loads a collection of City objects from the database.
        /// </summary>
        /// <returns>A collection containing all of the City objects in the database.</returns>
        public static CityCollection LoadCollection(string spName, SqlParameter[] parms)
        {
            CityCollection result = new CityCollection();

            using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms))
            {
                while (reader.Read())
                {
                    City tmp = new City();
                    tmp.LoadFromReader(reader);
                    result.Add(tmp);
                }
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModel"/> class.
        /// </summary>
        public PersonViewModel()
        {
            _gridCutCommand        = new DelegateCommand(Cut);
            _gridCopyCommand       = new DelegateCommand(Copy);
            _gridPasteCommand      = new DelegateCommand(Paste);
            _gridDeleteCommand     = new DelegateCommand(Delete);
            _expandCommand         = new DelegateCommand(Expand);
            _collapseCommand       = new DelegateCommand(Collapse);
            _sortAscendingCommand  = new DelegateCommand(SortAscending);
            _sortDescendingCommand = new DelegateCommand(SortDescending);
            _clearSortingCommand   = new DelegateCommand(ClearSorting);
            _bestFitCommand        = new DelegateCommand(BestFit);
            _addAboveCommand       = new DelegateCommand(AddAbove);
            _addBelowCommand       = new DelegateCommand(AddBelow);
            _addAsChildCommand     = new DelegateCommand(AddAsChild);

            persons        = this.CreateGenericPersonData(5, 8);
            cityCollection = new ObservableCollection <string>();
            foreach (var item in city)
            {
                CityCollection.Add(item);
            }
        }