/// <summary> /// 控件行命令事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("del")) { int id = Convert.ToInt32(e.CommandArgument); FriendsInfo item = FriendsInfoService.GetModel(id); if (item != null) { if (System.IO.File.Exists(Server.MapPath(item.img1path))) { System.IO.File.Delete(Server.MapPath(item.img1path)); } } int num = FriendsInfoService.Delete(id); } if (e.CommandName.Equals("mod")) { int id = Convert.ToInt32(e.CommandArgument); FriendsInfo item = FriendsInfoService.GetModel(id); txtTitleEn.Text = item.alt; txtLinkUrl.Text = item.linkurl; txtTitle.Text = item.title; lblURL.Text = item.img1path; lblURL2.Text = item.img2Path; txtOrder.Text = item.orderNum.ToString(); //ddlModule.SelectedValue = item.status.ToString(); lblId.Text = id.ToString(); this.pnlAdd.Visible = true; this.pnlList.Visible = false; } LoadData(); }
/// <summary> /// 获取跳转路径 /// </summary> private void JumpURL() { string weburl = BaseConfigService.GetById(12); string src = CRequest.GetString("src").Replace(weburl, ""); string url = FriendsInfoService.GetUrl(src); Response.Write(url); }
/// <summary> /// 绑定数据 /// </summary> private void BindData() { DataSet ds = FriendsInfoService.GetList("infoType = 11"); if (ds.Tables[0].Rows.Count > 0) { repBanner.DataSource = ds; repBanner.DataBind(); } }
/// <summary> /// 绑定数据 /// </summary> private void BindData() { DataSet ds = ProductTypeService.GetList("parentId = 0"); if (ds.Tables[0].Rows.Count > 0) { repOne.DataSource = ds; repOne.DataBind(); } ///导航 ds = FriendsInfoService.GetList(5, "infoType = 12", "orderNum"); if (ds.Tables[0].Rows.Count > 0) { repBanner.DataSource = ds; repBanner.DataBind(); } }
private void LoadData() { if (ViewState["typeId"] != null) { DataSet ds = FriendsInfoService.GetList("infoType = " + ViewState["typeId"]); if (ds.Tables[0].Rows.Count > 0) { this.repInfo.DataSource = ds; repInfo.DataBind(); } else { this.repInfo.DataSource = null; repInfo.DataBind(); } } }
/// <summary> /// 加载信息 /// </summary> private void LoadData() { DataSet ds = FriendsInfoService.GetList("infoType = 11"); if (ds.Tables[0].Rows.Count > 0) { this.repInfo.DataSource = ds; repInfo.DataBind(); } // 加载模块 ds = NewsTypeService.GetList("parentId = 2"); if (ds.Tables[0].Rows.Count > 0) { ddlModule.DataSource = ds; ddlModule.DataTextField = "name"; ddlModule.DataValueField = "id"; ddlModule.DataBind(); } ddlModule.Items.Insert(0, new ListItem("请选择", "0")); }
/// <summary> /// 添加友情连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string title = txtTitle.Text.Trim(); string alt = this.txtAlt.Text.Trim(); string url = this.txtLinkUrl.Text.Trim(); string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg1"] = spic; lblURL1.Text = spic; } } if (this.FileUpload2.PostedFile != null && FileUpload2.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload2.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img2Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg2"] = spic; lblURL2.Text = spic; } } FriendsInfo item = new FriendsInfo(); item.title = title; item.alt = alt; item.linkurl = url; item.img1path = ""; item.img2Path = ""; if (ViewState["newsImg1"] != null || lblURL1.Text != "") { item.img1path = lblURL1.Text; } else { lblError.Text = "请上传图片1"; return; } item.addTime = DateTime.Now; item.status = 0; item.infoType = 0; if (ViewState["typeId"] != null) { item.infoType = Convert.ToInt32(ViewState["typeId"]); } item.orderNum = 0; if (txtOrder.Text.Trim() != "") { if (RegExp.IsNumeric(txtOrder.Text.Trim())) { item.orderNum = Convert.ToInt32(txtOrder.Text.Trim()); } } item.addUser = 0; AdminUser au = Session["loginUser"] as AdminUser; if (au != null) { item.addUser = au.id; } if (lblId.Text != "") { item.id = Convert.ToInt32(lblId.Text.Trim()); int num = FriendsInfoService.Update(item); } else { int num = FriendsInfoService.Add(item); } pnlAdd.Visible = false; pnlList.Visible = true; LoadData(); }