//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel(channel_id, ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.download bll = new BLL.download(); Model.download model = bll.GetModel(id); switch (e.CommandName.ToLower()) { case "ibtnmsg": if (model.is_msg == 1) { bll.UpdateField(id, "is_msg=0"); } else { bll.UpdateField(id, "is_msg=1"); } break; case "ibtnred": if (model.is_red == 1) { bll.UpdateField(id, "is_red=0"); } else { bll.UpdateField(id, "is_red=1"); } break; } this.RptBind("id>0" + CombSqlTxt(this.channel_id, this.category_id, this.keywords, this.property), "sort_id asc,add_time desc"); }
//下载模块 private void digg_download_add(HttpContext context) { string channel_type = DTRequest.GetFormString("channel_type"); string digg_type = DTRequest.GetFormString("digg_type"); int id = DTRequest.GetFormInt("id"); BLL.download bll = new BLL.download(); if (!bll.Exists(id)) { context.Response.Write("{msg:0, msgbox:\"信息不存在或已删除!\"}"); return; } if (digg_type == "good") { bll.UpdateField(id, "digg_good=digg_good+1"); } else { bll.UpdateField(id, "digg_act=digg_act+1"); } Model.download model = bll.GetModel(id); context.Response.Write("{msg:1, digggood:" + model.digg_good + ", diggact:" + model.digg_act + ", msgbox:\"成功顶或踩了一下!\"}"); Utils.WriteCookie(DTKeys.COOKIE_DIGG_KEY, channel_type + id.ToString(), id.ToString(), 8640); return; }
private void ShowInfo(int _id) { BLL.download bll = new BLL.download(); Model.download model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txtTitle.Text = model.title; txtImgUrl.Text = model.img_url; txtLinkUrl.Text = model.link_url; if (model.is_msg == 1) { cblItem.Items[0].Selected = true; } if (model.is_red == 1) { cblItem.Items[1].Selected = true; } if (model.is_lock == 1) { cblItem.Items[2].Selected = true; } txtSortId.Text = model.sort_id.ToString(); txtClick.Text = model.click.ToString(); txtDiggGood.Text = model.digg_good.ToString(); txtDiggAct.Text = model.digg_act.ToString(); txtContent.Value = model.content; txtSeoTitle.Text = model.seo_title; txtSeoKeywords.Text = model.seo_keywords; txtSeoDescription.Text = model.seo_description; //绑定附件 rptAttach.DataSource = model.download_attachs; rptAttach.DataBind(); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { BLL.download bll = new BLL.download(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } JscriptMsg("保存排序成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Success"); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel(channel_id, ActionEnum.Delete.ToString()); //检查权限 BLL.download bll = new BLL.download(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { bll.Delete(this.channel_id, id); } } JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Success"); }
public void ProcessRequest(HttpContext context) { int id = DTRequest.GetQueryInt("id"); //获得下载ID if (id < 1) { context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!")); return; } //检查下载记录是否存在 BLL.download bll = new BLL.download(); if (!bll.AttachExists(id)) { context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!")); return; } //下载次数+1 bll.UpdateAttachField(id, "down_num=down_num+1"); //取得文件绝对路径 Model.download_attach model = bll.GetAttachModel(id); //检查文件本地还是远程 if (model.file_path.ToLower().StartsWith("http://")) { context.Response.Redirect(model.file_path); return; } else { //取得文件物理路径 string fullFileName = Utils.GetMapPath(model.file_path); if (!File.Exists(fullFileName)) { context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!")); return; } FileInfo file = new FileInfo(fullFileName); //路径 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码 context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.title)); //解决中文文件名乱码 context.Response.AddHeader("Content-length", file.Length.ToString()); context.Response.ContentType = "application/pdf"; context.Response.WriteFile(file.FullName); context.Response.End(); } }
public void ProcessRequest(HttpContext context) { int id = DTRequest.GetQueryInt("id"); //获得下载ID if (id < 1) { context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!")); return; } //检查下载记录是否存在 BLL.download bll = new BLL.download(); if (!bll.AttachExists(id)) { context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!")); return; } //下载次数+1 bll.UpdateAttachField(id, "down_num=down_num+1"); //取得文件绝对路径 Model.download_attach model = bll.GetAttachModel(id); //检查文件本地还是远程 if (model.file_path.ToLower().StartsWith("http://")) { context.Response.Redirect(model.file_path); return; } else { //取得文件物理路径 string fullFileName = Utils.GetMapPath(model.file_path); if (!File.Exists(fullFileName)) { context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!")); return; } FileInfo file = new FileInfo(fullFileName);//路径 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码 context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.title)); //解决中文文件名乱码 context.Response.AddHeader("Content-length", file.Length.ToString()); context.Response.ContentType = "application/pdf"; context.Response.WriteFile(file.FullName); context.Response.End(); } }
/// <summary> /// 下载列表 /// </summary> /// <param name="channel_id">频道ID</param> /// <param name="top">显示条数</param> /// <param name="strwhere">查询条件</param> /// <returns>DataTable</returns> protected DataTable get_download_list(int channel_id, int category_id, int top, string strwhere, string orderby) { DataTable dt = new DataTable(); if (channel_id > 0) { string _where = "channel_id=" + channel_id; if (category_id > 0) { _where += " and category_id in(select id from dt_category where id=" + category_id + " and class_list like '%," + category_id + ",%')"; } if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } dt = new BLL.download().GetList(top, _where, orderby).Tables[0]; } return(dt); }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); BLL.download bll = new BLL.download(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(id); //浏览数+1 bll.UpdateField(id, "click=click+1"); //跳转URL if (model.link_url != null) model.link_url = model.link_url.Trim(); if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); if (this.category_id > 0) { this.ddlCategoryId.SelectedValue = this.category_id.ToString(); } this.ddlProperty.SelectedValue = this.property; this.txtKeywords.Text = this.keywords; BLL.download bll = new BLL.download(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}&page={4}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); BLL.download bll = new BLL.download(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(id); //浏览数+1 bll.UpdateField(id, "click=click+1"); //跳转URL if (model.link_url != null) { model.link_url = model.link_url.Trim(); } if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
/// <summary> /// 下载分页列表 /// </summary> /// <param name="channel_id">频道ID</param> /// <param name="page_size">页面大小</param> /// <param name="page_index">当前页码</param> /// <param name="strwhere">查询条件</param> /// <param name="totalcount">总记录数</param> /// <returns>DateTable</returns> protected DataTable get_download_list(int channel_id, int category_id, int page_size, int page_index, string strwhere, out int totalcount) { DataTable dt = new DataTable(); if (channel_id > 0) { string _where = "channel_id=" + channel_id; if (category_id > 0) { _where += " and category_id in(select id from dt_category where id=" + category_id + " and class_list like '%," + category_id + ",%')"; } if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } dt = new BLL.download().GetList(page_size, page_index, _where, "sort_id asc,add_time desc", out totalcount).Tables[0]; } else { totalcount = 0; } return(dt); }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel(channel_id, ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.download bll = new BLL.download(); Model.download model = bll.GetModel(id); switch (e.CommandName.ToLower()) { case "ibtnmsg": if (model.is_msg == 1) bll.UpdateField(id, "is_msg=0"); else bll.UpdateField(id, "is_msg=1"); break; case "ibtnred": if (model.is_red == 1) bll.UpdateField(id, "is_red=0"); else bll.UpdateField(id, "is_red=1"); break; } this.RptBind("id>0" + CombSqlTxt(this.channel_id, this.category_id, this.keywords, this.property), "sort_id asc,add_time desc"); }
private bool DoAdd() { bool result = true; DTcms.Model.download model = new Model.download(); DTcms.BLL.download bll = new BLL.download(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.content = txtContent.Value; model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } //保存附件 string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); List<Model.download_attach> ls = new List<Model.download_attach>(); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { int fileSize = Utils.GetFileSize(fileArr[2]); string fileExt = Utils.GetFileExt(fileArr[2]); ls.Add(new Model.download_attach { id = int.Parse(fileArr[0]), title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt }); } } model.download_attachs = ls; } if (bll.Add(model) < 1) { result = false; } return result; }
/// <summary> /// 下载列表 /// </summary> /// <param name="channel_id">频道ID</param> /// <param name="top">显示条数</param> /// <param name="strwhere">查询条件</param> /// <returns>DataTable</returns> protected DataTable get_download_list(int channel_id, int category_id, int top, string strwhere, string orderby) { DataTable dt = new DataTable(); if (channel_id > 0) { string _where = "channel_id=" + channel_id; if (category_id > 0) { _where += " and category_id in(select id from dt_category where id=" + category_id + " and class_list like '%," + category_id + ",%')"; } if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } dt = new BLL.download().GetList(top, _where, orderby).Tables[0]; } return dt; }
/// <summary> /// 下载分页列表 /// </summary> /// <param name="channel_id">频道ID</param> /// <param name="page_size">页面大小</param> /// <param name="page_index">当前页码</param> /// <param name="strwhere">查询条件</param> /// <param name="totalcount">总记录数</param> /// <returns>DateTable</returns> protected DataTable get_download_list(int channel_id, int category_id, int page_size, int page_index, string strwhere, out int totalcount) { DataTable dt = new DataTable(); if (channel_id > 0) { string _where = "channel_id=" + channel_id; if (category_id > 0) { _where += " and category_id in(select id from dt_category where id=" + category_id + " and class_list like '%," + category_id + ",%')"; } if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } dt = new BLL.download().GetList(page_size, page_index, _where, "sort_id asc,add_time desc", out totalcount).Tables[0]; } else { totalcount = 0; } return dt; }
private bool DoEdit(int _id) { bool result = true; BLL.download bll = new BLL.download(); Model.download model = bll.GetModel(_id); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.content = txtContent.Value; model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } //保存附件 if (model.download_attachs != null) { model.download_attachs.Clear(); } string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); List <Model.download_attach> ls = new List <Model.download_attach>(); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { int fileSize = Utils.GetFileSize(fileArr[2]); string fileExt = Utils.GetFileExt(fileArr[2]); ls.Add(new Model.download_attach { id = int.Parse(fileArr[0]), down_id = _id, title = fileArr[1], file_path = fileArr[2], file_size = fileSize, file_ext = fileExt }); } } model.download_attachs = ls; } if (!bll.Update(model)) { result = false; } return(result); }