Asp.net源码专业站
首页->商务办公->某市人口普查系统源码>>Code/SearchSat.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:某市人口普查系统源码
当前文件:文件类型 RenKouPuCha/Code/SearchSat.aspx.cs[12K,2009-6-12 11:52:58]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13public partial class Code_Search : System.Web.UI.Page 14{ 15 private DataSet _ds = new DataSet(); 16 protected CCUtility _utility = new CCUtility(); 17 private string _target = ""; //指标 18 private string _area = ""; //乡镇 19 private DataTable generalTb = new DataTable("GeneralTable"); 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 if (!Page.IsPostBack) 23 { 24 if (Session["UserID"] == null || Session["RoleID"] == null) 25 { 26 Response.Redirect("Login.aspx"); 27 } 28 else 29 { 30 BindData(); 31 } 32 } 33 } 34 public override void VerifyRenderingInServerForm(Control control) 35 { 36 //base.VerifyRenderingInServerForm(control); 37 } 38 39 //绑定数据源 40 private void BindData() 41 { 42 CreateData(); 43 _ds.Tables.Add(generalTb); 44 dg.DataSource = _ds.Tables["GeneralTable"].DefaultView; 45 dg.DataBind(); 46 Session.Add("GeneralTable", generalTb); 47 } 48 protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) 49 { 50 this.MultiView1.ActiveViewIndex= int.Parse(e.Item.Value); 51 } 52 53 统计部分 170 171 # region 查询部分 172 173 //查询模块 174 private string _modeS = ""; 175 private string _nameS = ""; 176 private string _ageMin=""; 177 private string _ageMax=""; 178 private string _professionS = ""; 179 private string _edgLevelS = ""; 180 private string _inMin="", _inMax=""; 181 private string _marriageS = ""; 182 private string _idFieldS = ""; 183 protected void searchButton_Click(object sender, EventArgs e) 184 { 185 _modeS = modeDropD.SelectedValue; 186 _nameS = nameTextB.Text; 187 _ageMin = minageTextB.Text; 188 _ageMax = maxTextBox.Text; 189 _professionS = professionTextB.Text; 190 _edgLevelS = edgLevelTextB.Text; 191 _inMin = incomMinextB.Text; 192 _inMax = incomMaxTextB.Text; 193 _marriageS = marriageTextB.Text; 194 _idFieldS = idFieldTextB.Text; 195 string sql; 196 if (_modeS == "精确查询") 197 sql=ExactSearch(); 198 else 199 sql=BlurSearch(); 200 if (sql == "") 201 Response.Write("<script>alert('请输入关键字!')</script>"); 202 else 203 { 204 _utility.DBOpen(); 205 SqlCommand cmd = new SqlCommand(sql, _utility.Connection); 206 SqlDataAdapter da = new SqlDataAdapter(); 207 da.SelectCommand = cmd; 208 da.Fill(_ds, "SearchResult"); 209 Session.Add("Set", _ds); 210 Response.Redirect("SrchResult.aspx"); 211 } 212 } 213 214 //精确查询 215 private string ExactSearch() 216 { 217 string sql; 218 if (_nameS == "" && _ageMin == "" && _professionS == "" &&_edgLevelS == "" && _inMin == "" && _marriageS == "" &&_idFieldS == "" && _edgLevelS == "") 219 { 220 sql =""; 221 } 222 else 223 { 224 sql = "Select idField as 身份证号码,nameField as 姓名,age as 年龄,profession as 职业,sex as 性别,edgLevel as 最高学历,"; 225 sql+="nation as 国家,polity as 政治面貌,marriage as 婚否,incom as 年收入 from tRkry where "; 226 if (_nameS != "") 227 { 228 sql+= "namefield='" + _nameS+"'" + " and "; 229 } 230 if (_ageMin != "") 231 { 232 sql += "age=" + Convert.ToInt32(_ageMin) + " and "; 233 } 234 if (_professionS != "") 235 { 236 sql += "profession='" + _professionS + "'" + " and "; 237 } 238 if (_edgLevelS != "") 239 { 240 sql += "edgLevel='" + _edgLevelS + "'" + " and "; 241 } 242 if (_inMin != "") 243 { 244 sql += "incom=" + Convert.ToInt32(_inMin) + " and "; 245 } 246 if (_marriageS != "") 247 { 248 sql += "marriage='" + _marriageS + "'" + " and "; 249 } 250 if(_idFieldS!="") 251 { 252 sql += "idField='" + _idFieldS + "'" + " and "; 253 } 254 sql=sql.Remove(sql.LastIndexOf(" and ")); 255 } 256 return sql; 257 } 258 //模糊查询 259 private string BlurSearch() 260 { 261 string sql; 262 if (_nameS == "" && _ageMin == "" && _professionS == "" && _edgLevelS == "" && _inMin == "" && _marriageS == "" && _idFieldS == "" && _edgLevelS == "") 263 { 264 sql = "Select idField as 身份证号码,nameField as 姓名,age as 年龄,profession as 职业,sex as 性别,edgLevel as 最高学历,"; 265 sql += "nation as 国家,polity as 政治面貌,marriage as 婚否,incom as 年收入 from tRkry "; 266 } 267 else 268 { 269 sql = "Select idField as 身份证号码,nameField as 姓名,age as 年龄,profession as 职业,sex as 性别,edgLevel as 最高学历,"; 270 sql += "nation as 国家,polity as 政治面貌,marriage as 婚否,incom as 年收入 from tRkry where "; 271 if (_nameS != null) 272 { 273 sql += "namefield like '%" + _nameS + "%'" + " and "; 274 } 275 if (_ageMin != "" && _ageMax != "") 276 { 277 int ageMin = Convert.ToInt32(_ageMin); 278 int ageMax = Convert.ToInt32(_ageMax); 279 sql += "age between " + ageMin + " and " + ageMax + " and "; 280 } 281 else if (_ageMin != "") 282 { 283 sql += "age=" + Convert.ToInt32(_ageMin) + " and "; 284 } 285 else if (_ageMax != "") 286 { 287 sql += "age=" + Convert.ToInt32(_ageMax) + " and "; 288 } 289 if (_professionS != "") 290 { 291 sql += "profession like '%" + _professionS + "%'" + " and "; 292 } 293 if (_edgLevelS != "") 294 { 295 sql += "edgLevel like '%" + _edgLevelS + "%'" + " and "; 296 } 297 if (_inMin != "" && _inMax != "") 298 { 299 sql += "incom between " + _inMin + " and " + _inMax + " and "; 300 } 301 if (_marriageS != "") 302 { 303 sql += "marriage like '%" + _marriageS + "%'" + " and "; 304 } 305 if (_idFieldS != "") 306 { 307 sql += "idField like '%" + _idFieldS + "%'" + " and "; 308 } 309 sql=sql.Remove(sql.LastIndexOf(" and ")); 310 } 311 return sql; 312 } 313 #endregion 314 315 打印 334 protected void Button2_Click(object sender, EventArgs e) 335 { 336 Response.Redirect("User.aspx"); 337 } 338 protected void Button3_Click1(object sender, EventArgs e) 339 { 340 Response.Redirect("User.aspx"); 341 } 342} 343
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:某市人口普查系统源码
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146