private void Bind() { //绑定景点信息 SceneryInfoBLL _SceneryInfoBLL = new SceneryInfoBLL(); int SceneryID = 0; if (Request.QueryString["SceneryID"] != null) { SceneryID = int.Parse(Request.QueryString["SceneryID"].ToString()); } DataTable DT = _SceneryInfoBLL.GetSceneryInfoByID(SceneryID); this.txtSceneryName.Text = DT.Rows[0]["SceneryName"].ToString(); this.txtSceneryName.Enabled = false; this.txtSceneryPrice.Text = DT.Rows[0]["SceneryPrice"].ToString(); this.TxtSceneryLoc.Text = DT.Rows[0]["SceneryLoc"].ToString(); this.TxtOpenTime.Text = DT.Rows[0]["OpenTime"].ToString(); this.txtSceneryLat.Text = DT.Rows[0]["SLongitude"].ToString().Substring(0, 8); this.txtSceneryLgt.Text = DT.Rows[0]["Slatitude"].ToString().Substring(0, 8); this.TxtSceneryIntroduce.Text = DT.Rows[0]["SceneryIntro"].ToString(); this.TxtScenerySuitTime.Text = DT.Rows[0]["BestTravel"].ToString(); //显示景点类型状态 STypeBLL _STypeBLL = new STypeBLL(); DataTable _DT = _STypeBLL.GetAllSType(); this.CBoxType.Items.Clear(); this.CBoxType.DataSource = _DT; this.CBoxType.DataTextField = "TypeName"; this.CBoxType.DataValueField = "TypeID"; this.CBoxType.DataBind(); DataTable STypeDT = _STypeBLL.GetSceTypeByID(SceneryID); for (int i = 0; i < STypeDT.Rows.Count; i++) { for (int j = 0; j < CBoxType.Items.Count; j++) { if (STypeDT.Rows[i]["TypeID"].ToString().Trim() == CBoxType.Items[j].Value.ToString().Trim()) { CBoxType.Items[j].Selected = true; } } } }
private void DropDownBind() { //绑定市 CityInfoBLL _CityInfoBLL = new CityInfoBLL(); DataTable CityDT = _CityInfoBLL.GetAllCityInfo(); this.DrpDownCity.Items.Clear(); this.DrpDownCity.DataSource = CityDT; this.DrpDownCity.DataTextField = "CityName"; this.DrpDownCity.DataValueField = "CityID"; this.DrpDownCity.DataBind(); //绑定景点 int CityID = int.Parse(this.DrpDownCity.SelectedValue); SceneryInfoBLL _SceneryInfoBLL = new SceneryInfoBLL(); DataTable SceDT = _SceneryInfoBLL.GetCityScenery(CityID); this.DropDownScenery.Items.Clear(); this.DropDownScenery.DataSource = SceDT; this.DropDownScenery.DataTextField = "SceneryName"; this.DropDownScenery.DataValueField = "SceneryID"; this.DropDownScenery.DataBind(); }
//根据市ID删除市信息 protected void deleteThis() { try { Array delWitch = rqid.Split('|'); bool isTrue = false; bool isPicTrue = false; for (int i = 0; i < delWitch.Length - 1; i++) { int delid = Convert.ToInt32(delWitch.GetValue(i)); SceneryInfoBLL _SceneryInfoBLL = new SceneryInfoBLL(); PicInfoBLL _PicInfoBLL = new PicInfoBLL(); STypeBLL _STypeBLL = new STypeBLL(); DataTable ScePicDT; if (_SceneryInfoBLL.DelScenery(delid)) { if (_STypeBLL.GetSceTypeCount(delid) > 0) { if (_STypeBLL.DelSType(delid)) { isTrue = true; } } else { isTrue = true; } //加入删除图片信息 ScePicDT = _PicInfoBLL.GetPicBySceID(delid); if (ScePicDT.Rows.Count > 0) { for (int j = 0; j < ScePicDT.Rows.Count; j++) { int PicTempID = int.Parse(ScePicDT.Rows[j]["PicID"].ToString()); if (_PicInfoBLL.DelPicByID(PicTempID) && _PicInfoBLL.DelScePicByID(PicTempID)) { isPicTrue = true; } else { isPicTrue = false; break; } } } else { isPicTrue = true; } } else { isTrue = false; } if (isTrue == false || isPicTrue == false) { break; } } if (!(isTrue == false || isPicTrue == false)) { Response.Write("<script language='javascript'>"); Response.Write("alert('删除成功!');"); Response.Write("document.location.href='SceneryInfoList.aspx';"); Response.Write("</script>"); } else { Response.Write("<script language='javascript'>"); Response.Write("alert('删除失败!');"); Response.Write("document.location.href='SceneryInfoList.aspx';"); Response.Write("</script>"); } } catch { Response.Write("<script language='javascript'>"); Response.Write("alert('删除失败!');"); Response.Write("document.location.href='SceneryInfoList.aspx';"); Response.Write("</script>"); } }
/// <summary> /// 更新景点看了又看 /// </summary> public bool UpdScenerySeeAndSee() { List <SeeCount> list = new List <SeeCount>(); SceneryInfoBLL _SceneryInfoBLL = new SceneryInfoBLL(); ClickLogBLL _ClickLogBLL = new ClickLogBLL(); DataTable SceneryDT = _SceneryInfoBLL.GetCityScenery(1); for (int k = 0; k < SceneryDT.Rows.Count; k++) { int CurrentSceneryID = int.Parse(SceneryDT.Rows[k]["SceneryID"].ToString()); list.Clear(); //1.查询出所有景点信息 并加入链表 for (int i = 0; i < SceneryDT.Rows.Count; i++) { SeeCount _SeeCount = new SeeCount(); _SeeCount.KeyName = SceneryDT.Rows[i]["SceneryName"].ToString(); _SeeCount.KeyID = int.Parse(SceneryDT.Rows[i]["SceneryID"].ToString()); list.Add(_SeeCount); } //2.查询出看了当前景点用户IP DataTable ViewerIPDT = _ClickLogBLL.GetSeeSceneryIDPeople(CurrentSceneryID); List <String> IPList = new List <String>(); for (int j = 0; j < ViewerIPDT.Rows.Count; j++) { if (!IPList.Contains(ViewerIPDT.Rows[j]["IP"].ToString())) { IPList.Add(ViewerIPDT.Rows[j]["IP"].ToString()); } } //3.查询出当前IP 看过的景点 并统计次数 for (int l = 0; l < IPList.Count; l++) { DataTable CurrentSceneryDT = _ClickLogBLL.GetAllOneSee(IPList[l], "景点"); //将景点合并 List <int> SceneryList = new List <int>(); for (int m = 0; m < CurrentSceneryDT.Rows.Count; m++) { if (!SceneryList.Contains(int.Parse(CurrentSceneryDT.Rows[m]["ContentFlag"].ToString()))) { SceneryList.Add(int.Parse(CurrentSceneryDT.Rows[m]["ContentFlag"].ToString())); } } for (int p = 0; p < SceneryList.Count; p++) { for (int n = 0; n < list.Count; n++) { if (list[n].KeyID == SceneryList[p]) { list[n].Count++; } } } } //4.先删除当前景点ID再根据次数排序 for (int a = 0; a < list.Count; a++) { if (list[a].KeyID == CurrentSceneryID) { list.RemoveAt(a); } } //先根据景点ID删除该景点的看了又看 然后按次序执行插入 _LookAnotherBLL.DelByIDType(CurrentSceneryID, "景点"); ; for (int v = 0; v < 1; v++) { LookAnotherInfo _LookAnotherInfo = new LookAnotherInfo(); _LookAnotherInfo.KeyID = CurrentSceneryID; _LookAnotherInfo.AnotherLookID = list[v].KeyID; _LookAnotherInfo.GoalType = "景点"; _LookAnotherBLL.AddLookAnother(_LookAnotherInfo); } } return(true); }
protected void btEdit_Click(object sender, EventArgs e) { //添加景点信息 STypeBLL _STypeBLL = new STypeBLL(); SceneryInfoBLL _SceneryInfoBLL = new SceneryInfoBLL(); SceneryInfo _SceneryInfo = new SceneryInfo(); _SceneryInfo.SceneryName = this.txtSceneryName.Text.Trim(); _SceneryInfo.CityID = int.Parse(Request.QueryString["CityID"].ToString()); _SceneryInfo.SceneryPrice = this.txtSceneryPrice.Text.Trim(); _SceneryInfo.SceneryLoc = this.TxtSceneryLoc.Text.Trim(); _SceneryInfo.OpenTime = this.TxtOpenTime.Text.Trim(); _SceneryInfo.SceneryIntro = this.TxtSceneryIntroduce.Text.Trim(); _SceneryInfo.BestTravel = this.TxtScenerySuitTime.Text.Trim(); if (txtSceneryLgt.Text.Trim() != "") { _SceneryInfo.SLongitude = float.Parse(txtSceneryLgt.Text.Trim().ToString()); } else { _SceneryInfo.SLongitude = 0.0f; } if (txtSceneryLat.Text.Trim() != "") { _SceneryInfo.Slatitude = float.Parse(txtSceneryLat.Text.Trim().ToString()); } else { _SceneryInfo.Slatitude = 0.0f; } //添加景点类型 ArrayList TypeList = new ArrayList(); for (int i = 0; i < this.CBoxType.Items.Count; i++) { if (this.CBoxType.Items[i].Selected) { TypeList.Add(this.CBoxType.Items[i].Value); } } bool IsSType = true; for (int j = 0; j < TypeList.Count; j++) { if (!_STypeBLL.AddSceneryType(int.Parse(TypeList[j].ToString()), _SceneryInfo.CityID)) { IsSType = false; break; } } //判断是否添加成功 if (_SceneryInfoBLL.AddScenery(_SceneryInfo) && IsSType) { Response.Write("<script language='javascript'>"); Response.Write("alert('添加成功');"); Response.Write("document.location.href='SceneryInfoList.aspx';"); Response.Write("</script>"); } }
protected void btEdit_Click(object sender, EventArgs e) { //根据景点信息跟新景点 SceneryInfoBLL _SceneryInfoBLL = new SceneryInfoBLL(); SceneryInfo _SceneryInfo = new SceneryInfo(); _SceneryInfo.SceneryPrice = this.txtSceneryPrice.Text.Trim(); _SceneryInfo.SceneryLoc = this.TxtSceneryLoc.Text.Trim(); _SceneryInfo.OpenTime = this.TxtOpenTime.Text.Trim(); _SceneryInfo.SceneryIntro = this.TxtSceneryIntroduce.Text.Trim(); _SceneryInfo.BestTravel = this.TxtScenerySuitTime.Text.Trim(); if (txtSceneryLgt.Text.Trim() != "") { _SceneryInfo.SLongitude = float.Parse(txtSceneryLgt.Text.Trim().ToString()); } else { _SceneryInfo.SLongitude = 0.0f; } if (txtSceneryLat.Text.Trim() != "") { _SceneryInfo.Slatitude = float.Parse(txtSceneryLat.Text.Trim().ToString()); } else { _SceneryInfo.Slatitude = 0.0f; } //更新景点信息 int SceneryID = int.Parse(Request.QueryString["SceneryID"].ToString()); int CityID = int.Parse(Request.QueryString["CityID"].ToString()); //更新景点类型 先把景点类型都删除然后 bool TypeFlag = true; STypeBLL _STypeBLL = new STypeBLL(); ArrayList TypeList = new ArrayList(); for (int i = 0; i < this.CBoxType.Items.Count; i++) { if (this.CBoxType.Items[i].Selected) { TypeList.Add(this.CBoxType.Items[i].Value); } } if (_STypeBLL.GetSceTypeCount(SceneryID) > 0) { _STypeBLL.DelSType(SceneryID); } for (int j = 0; j < TypeList.Count; j++) { if (!_STypeBLL.AddSceneryType(int.Parse(TypeList[j].ToString()), SceneryID)) { TypeFlag = false; } } if (_SceneryInfoBLL.UpdSceneryInfoByID(SceneryID, _SceneryInfo) && TypeFlag) { Response.Write("<script language='javascript'>"); Response.Write("alert('更新成功');"); Response.Write("document.location.href='SceneryInfoList.aspx?CityID=" + CityID.ToString() + "';"); Response.Write("</script>"); } }