Beispiel #1
0
        /// <summary>
        /// 通过地区取得所在城市
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        public static Hat_cityModel GetFatherCity(Hat_areaModel area)
        {
            int id = (int)SqlHelper.ExecuteScalar("select id from hat_city where cityID = @cityID",
                                                  new SqlParameter("@cityID", area.Father));

            return(Hat_cityDAL.GetById(id));
        }
Beispiel #2
0
        /// <summary>
        /// 通过地区Area获取包括上级市,省的字符串
        /// e.g: 双流县的Hat_areaModel -> "四川省_成都市_双流县"
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        public static string GetFullLocationString(Hat_areaModel area)
        {
            Hat_cityModel     fatherCity     = Hat_areaDAL.GetFatherCity(area);
            Hat_provinceModel fatherProvince = Hat_cityDAL.GetFatherProvince(fatherCity);

            string result = fatherProvince.Province + "_" + fatherCity.City + "_" + area.Area;

            return(result);
        }
Beispiel #3
0
        private static Hat_areaModel ToModel(DataRow row)
        {
            Hat_areaModel hat_area = new Hat_areaModel();

            hat_area.Id     = (System.Int32)row["id"];
            hat_area.AreaID = (System.String)row["areaID"];
            hat_area.Area   = (System.String)row["area"];
            hat_area.Father = (System.String)row["father"];
            return(hat_area);
        }
Beispiel #4
0
        public static Hat_areaModel[] GetAll()
        {
            DataTable table = SqlHelper.ExecuteDataTable(@"select * from hat_area");

            Hat_areaModel[] hat_area = new Hat_areaModel[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                hat_area[i] = ToModel(table.Rows[i]);
            }
            return(hat_area);
        }
Beispiel #5
0
        public static Hat_areaModel[] GetAllByCityId(int id)
        {
            DataTable table = SqlHelper.ExecuteDataTable(@"select * from hat_area where hat_area.father = (select cityID from hat_city where hat_city.id = @id)",
                                                         new SqlParameter("@id", id));

            Hat_areaModel[] hat_area = new Hat_areaModel[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                hat_area[i] = ToModel(table.Rows[i]);
            }
            return(hat_area);
        }
Beispiel #6
0
        /// <summary>
        /// 根据地区的主键id获取区域的名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetAreaName(int id)
        {
            Hat_areaModel area = areas[id - 1];

            //找到所在市
            var fatherCity = from city in cities
                             where city.CityID == area.Father
                             select city;

            //找到所在省
            var fatherProvince = from province in provinces
                                 where province.ProvinceID == fatherCity.ElementAt(0).Father
                                 select province;

            return(fatherProvince.ElementAt(0).Province + fatherCity.ElementAt(0).City + areas[id - 1].Area);
        }