//初始化区划信息 private bool initQhs() { bool result = false;//默认初始化失败 try { DataTable dt = dbHelper.GetDataBySql("select * from T_BC_QH where sjqhdm = '000000000000'"); foreach (DataRow row in dt.Rows) { QuHua item = new QuHua(); item.Qhdm = Convert.ToString(row["QHDM"]); item.Qhmc = Convert.ToString(row["QHMC"]); item.Qhjb = Convert.ToString(row["QHJB"]); item.Sjqhdm = Convert.ToString(row["SJQHDM"]); this.Qhs.Add(item); } result = true;//初始化成功 } catch (Exception e) { Console.WriteLine(e.Message); result = false;//初始化失败 } return(result); }
//根据上级区划代码获取子区划信息 public List <QuHua> getQhs(string sjqhdm) { List <QuHua> list = new List <QuHua>(); try { DataTable dt = dbHelper.GetDataBySql(string.Format("select * from T_BC_QH where sjqhdm = '{0}'", sjqhdm)); foreach (DataRow row in dt.Rows) { QuHua item = new QuHua(); item.Qhdm = Convert.ToString(row["QHDM"]); item.Qhmc = Convert.ToString(row["QHMC"]); item.Qhjb = Convert.ToString(row["QHJB"]); item.Sjqhdm = Convert.ToString(row["SJQHDM"]); list.Add(item); } } catch (Exception e) { Console.WriteLine(e.Message); } return(list); }