예제 #1
0
        /// <summary>
        /// 获取所有省份
        /// </summary>
        /// <returns></returns>
        public static List <PROVINCE> getAllProvince()
        {
            List <PROVINCE> lst = new List <PROVINCE>();

            try
            {
                string    sql = "select id,province_id,province_name from province order by province_id ";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        PROVINCE pr = new PROVINCE();
                        pr.ID            = int.Parse(row["id"].ToString());
                        pr.PROVINCE_ID   = row["province_id"].ToString();
                        pr.PROVINCE_NAME = row["province_name"].ToString();
                        lst.Add(pr);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 获取所有省份:region/getAllProvince ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
예제 #2
0
        /// <summary>
        /// 根据城市id获取区县
        /// </summary>
        /// <param name="cityId">cityId</param>
        /// <returns></returns>
        public static List <COUNTY> getCountyByCityId(string cityId)
        {
            List <COUNTY> lst = new List <COUNTY>();

            try
            {
                string    sql = "select id,city_id,county_id,county_name from county  where  city_id='" + cityId + "'order by county_id ";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        COUNTY county = new COUNTY();
                        county.ID          = int.Parse(row["id"].ToString());
                        county.CITY_ID     = row["city_id"].ToString();
                        county.COUNTY_ID   = row["county_id"].ToString();
                        county.COUNTY_NAME = row["county_name"].ToString();
                        lst.Add(county);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 根据城市id获取区县:region/getCountyByCityId ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
예제 #3
0
        /// <summary>
        /// 根据id获取乡镇
        /// </summary>
        /// <param name="countyId">province_id</param>
        /// <returns></returns>
        public static List <VILLAGE> getVillageByTownId(string townId)
        {
            List <VILLAGE> lst = new List <VILLAGE>();

            try
            {
                string    sql = "select id,town_id,village_id,village_name from village  where  town_id='" + townId + "'order by village_id ";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        VILLAGE village = new VILLAGE();
                        village.ID           = int.Parse(row["id"].ToString());
                        village.TOWN_ID      = row["town_id"].ToString();
                        village.VILLAGE_ID   = row["village_id"].ToString();
                        village.VILLAGE_NAME = row["village_name"].ToString();
                        lst.Add(village);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 根据城市id获取区县:region/getVillageByTownId ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
예제 #4
0
        /// <summary>
        /// 根据区县id获取乡镇
        /// </summary>
        /// <param name="countyId">province_id</param>
        /// <returns></returns>
        public static List <TOWN> getTownByCountyId(string countyId)
        {
            List <TOWN> lst = new List <TOWN>();

            try
            {
                string    sql = "select id,county_id,town_id,town_name from town  where  county_id='" + countyId + "'order by town_id ";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        TOWN town = new TOWN();
                        town.ID        = int.Parse(row["id"].ToString());
                        town.COUNTY_ID = row["county_id"].ToString();
                        town.TOWN_ID   = row["town_id"].ToString();
                        town.TOWN_NAME = row["town_name"].ToString();
                        lst.Add(town);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 根据区县id获取乡镇:region/getTownByCountyId ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
예제 #5
0
        /// <summary>
        /// 根据二级分类id获取三级分类
        /// </summary>
        /// <param name="secondID">second_id</param>
        /// <returns></returns>
        public static List <THIRDCLASS> getThirdClassBySecondId(int secondId)
        {
            List <THIRDCLASS> lst = new List <THIRDCLASS>();

            try
            {
                string    sql = "select id,first_id,second_id,name from thirdclass where second_id=" + secondId + " order by name ";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        THIRDCLASS tc = new THIRDCLASS();
                        tc.ID        = int.Parse(row["id"].ToString());
                        tc.FIRST_ID  = int.Parse(row["first_id"].ToString());
                        tc.SECOND_ID = int.Parse(row["second_id"].ToString());
                        tc.NAME      = row["name"].ToString();
                        lst.Add(tc);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 根据二级分类id获取三级分类:class/getThirdClassBySecondId ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
예제 #6
0
        /// <summary>
        /// 获取所有一级分类
        /// </summary>
        /// <returns></returns>
        public static List <FIRSTCLASS> getAllFirstClass()
        {
            List <FIRSTCLASS> lst = new List <FIRSTCLASS>();

            try
            {
                string    sql = "select id,name from firstclass order by name";
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        FIRSTCLASS fc = new FIRSTCLASS();
                        fc.ID   = int.Parse(row["id"].ToString());
                        fc.NAME = row["name"].ToString();
                        lst.Add(fc);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                string err = new DateTime().ToString() + " 获取所有一级分类:class/getAllFirstClass ,错误:" + e.Message;
                LogHelper.WriteLog(err);
                return(lst);
            }
        }
예제 #7
0
        //获取微信二维码
        public static List <WXQ> getWXQR(int start, int limit)
        {
            List <WXQ> lslt = new List <WXQ>();

            try
            {
                string    sql = "select* from wxq limit " + (start - 1) * limit + "," + limit;
                DataTable dt  = MySqlDHelper.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        WXQ wxq = new WXQ();
                        wxq.ID       = int.Parse(row["id"].ToString());
                        wxq.CITYID   = row["city_id"].ToString();
                        wxq.PROID    = row["pro_id"].ToString();
                        wxq.COUNTYID = row["county_id"].ToString();
                        if (string.IsNullOrEmpty(row["pubtime"].ToString()))
                        {
                            wxq.PUBTIME = Convert.ToDateTime(row["pubtime"].ToString());
                        }
                        if (string.IsNullOrEmpty(row["endtime"].ToString()))
                        {
                            wxq.PUBTIME = Convert.ToDateTime(row["endtime"].ToString());
                        }
                        if (string.IsNullOrEmpty(row["firstclass"].ToString()))
                        {
                            wxq.FIRSTCLASS = Convert.ToInt32(row["firstclass"]);
                        }
                        if (string.IsNullOrEmpty(row["secondclass"].ToString()))
                        {
                            wxq.SECONDCLASS = Convert.ToInt32(row["secondclass"]);
                        }
                        if (string.IsNullOrEmpty(row["thirdclass"].ToString()))
                        {
                            wxq.THIRDCLASS = Convert.ToInt32(row["thirdclass"]);
                        }
                        wxq.FIRSTCLASS = row["firstclass"].ToString();

                        pr.PROVINCE_ID   = row["province_id"].ToString();
                        pr.PROVINCE_NAME = row["province_name"].ToString();
                        lst.Add(pr);
                    }
                }
                return(lst);
            }
            catch (Exception e)
            {
                throw;
            }
        }