private bool DoAdd() { try { Model.cityinfo model = new Model.cityinfo(); BLL.cityinfo bll = new BLL.cityinfo(); model.channel_id = this.channel_id; model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); model.parent_id = int.Parse(ddlParentId.SelectedValue); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.seo_title = txtSeoTitle.Text; model.seo_keywords = txtSeoKeywords.Text; model.seo_description = txtSeoDescription.Text; model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.content = txtContent.Value; if (bll.Add(model) < 1) { return false; } } catch { return false; } return true; }
protected void Button1_Click(object sender, EventArgs e) { BLL.exportCity bll_export = new BLL.exportCity(); Model.exportCity model_export= new Model.exportCity(); DataSet ds_province = null; DataSet ds_city = null; DataSet ds_area = null; DataTable dt_province = null; DataTable dt_city = null; DataTable dt_area = null; BLL.cityinfo bll_cityinfo = new BLL.cityinfo(); Model.cityinfo model_province = null; Model.cityinfo model_city = null; Model.cityinfo model_area = null; int return_province = 0; int return_city = 0; //查找省级数据 ds_province = bll_export.GetProvinceList(""); dt_province = ds_province.Tables[0]; //循环省级数据 for (int i = 0; i < dt_province.Rows.Count; i++) { model_province = new Model.cityinfo(); model_province.title = dt_province.Rows[i]["name"].ToString().Trim().Replace(" ",""); model_province.call_index = dt_province.Rows[i]["code"].ToString(); model_province.sort_id = 99; model_province.parent_id = 0; model_province.channel_id = 0; return_province = bll_cityinfo.Add(model_province); model_export.provinceId = dt_province.Rows[i]["code"].ToString(); ds_city = bll_export.GetCityListByProID(model_export.provinceId); dt_city = ds_city.Tables[0]; for (int j = 0; j < dt_city.Rows.Count; j++) { model_city = new Model.cityinfo(); model_city.channel_id = 0; model_city.title = dt_city.Rows[j]["name"].ToString().Trim().Replace(" ", ""); model_city.call_index = dt_city.Rows[j]["code"].ToString(); model_city.sort_id = 99; model_city.parent_id = return_province; return_city = bll_cityinfo.Add(model_city); model_export.cityId = dt_city.Rows[j]["code"].ToString(); ds_area = bll_export.GetAreaListByCityID(model_export.cityId); dt_area = ds_area.Tables[0]; for (int k = 0; k < dt_area.Rows.Count; k++) { model_area = new Model.cityinfo(); model_area.title = dt_area.Rows[k]["name"].ToString().Trim().Replace(" ", ""); model_area.call_index = dt_area.Rows[k]["code"].ToString(); model_area.sort_id = 99; model_area.channel_id = 0; model_area.parent_id = return_city; bll_cityinfo.Add(model_area); } } } //根据省级的编号 查下城市数据 //循环市数据 //查找区级 //循环区级,做 }