//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("channel_" + this.channel_name + "_list", Vincent._DTcms.DTEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.source_material bll = new BLL.source_material(); Repeater rptList = new Repeater(); switch (this.prolistview) { case "Txt": rptList = this.rptList1; break; default: rptList = this.rptList2; break; } 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()); } AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Edit.ToString(), "保存" + this.channel_name + "瓶子素材排序"); //记录日志 JscriptMsg("保存排序成功啦!", Vincent._DTcms.Utils.CombUrlTxt("source_bottle_list.aspx", "channel_id={0}&keywords={1}", this.channel_id.ToString(), this.keywords), "Success"); }
private void RptBind(string _strWhere, string _orderby) { this.page = Vincent._DTcms.DTRequest.GetQueryInt("page", 1); this.txtKeywords.Text = this.keywords; //图表或列表显示 BLL.source_material bll = new BLL.source_material(); switch (this.prolistview) { case "Txt": this.rptList2.Visible = false; this.rptList1.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList1.DataBind(); break; default: this.rptList1.Visible = false; this.rptList2.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList2.DataBind(); break; } //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Vincent._DTcms.Utils.CombUrlTxt("source_bottle_list.aspx", "channel_id={0}&keywords={1}&page={2}", this.channel_id.ToString(), this.keywords, "__id__"); PageContent.InnerHtml = Vincent._DTcms.Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private bool DoEdit(int _id) { bool result = false; BLL.source_material bll = new BLL.source_material(); Model.source_material model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.img_url = txtImgUrl.Text; //内容摘要提取内容前500个字符 if (!string.IsNullOrEmpty(txtRemark.Text.Trim()) && txtRemark.Text.Trim().Length > 500) { model.remark = Vincent._DTcms.Utils.DropHTML(txtRemark.Text, 500); } else { model.remark = txtRemark.Text; } model.add_time = Vincent._DTcms.Utils.StrToDateTime(txtAddTime.Text.Trim()); if (bll.Update(model)) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Edit.ToString(), "修改" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return(result); }
private void ShowInfo(int _id) { BLL.source_material bll = new BLL.source_material(); Model.source_material model = bll.GetModel(_id); txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd HH:mm:ss"); if (!string.IsNullOrEmpty(model.img_url)) { txtImgUrl.Text = model.img_url; } txtTitle.Text = model.title; txtRemark.Text = model.remark; txtSortId.Text = model.sort_id.ToString(); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("channel_" + this.channel_name + "_list", Vincent._DTcms.DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.source_material bll = new BLL.source_material(); Repeater rptList = new Repeater(); switch (this.prolistview) { case "Txt": rptList = this.rptList1; break; default: rptList = this.rptList2; break; } 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) { if (bll.Delete(id)) { sucCount++; } else { errorCount++; } } } AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Edit.ToString(), "删除" + this.channel_name + "瓶子素材成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Vincent._DTcms.Utils.CombUrlTxt("source_bottle_list.aspx", "channel_id={0}&keywords={1}", this.channel_id.ToString(), this.keywords), "Success"); }
private bool DoAdd() { bool result = false; Model.source_material model = new Model.source_material(); BLL.source_material bll = new BLL.source_material(); model.title = txtTitle.Text.Trim(); model.subtitle = txtSubTitle.Text.Trim(); model.img_url = txtImgUrl.Text; //内容摘要提取内容前500个字符 if (!string.IsNullOrEmpty(txtRemark.Text.Trim()) && txtRemark.Text.Trim().Length > 500) { model.remark = Vincent._DTcms.Utils.DropHTML(txtRemark.Text, 500); } else { model.remark = txtRemark.Text; } int user_id = 0; if (IsAdminLogin()) { user_id = GetAdminInfo().id; } model.type = type; model.user_id = user_id; model.add_time = Vincent._DTcms.Utils.StrToDateTime(txtAddTime.Text.Trim()); if (bll.Add(model) > 0) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道内容:" + model.title); //记录日志 result = true; } return(result); }
/// <summary> /// 文件上传完成之后并保存到数据库 /// </summary> /// <param name="postedFile">文件流</param> /// <returns>上传后文件信息</returns> public string fileSaveAs2(HttpPostedFile postedFile) { try { string fileExt = Vincent._DTcms.Utils.GetFileExt(postedFile.FileName); //文件扩展名,不含“.” int fileSize = postedFile.ContentLength; //获得文件大小,以字节为单位 string fileName = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(@"\") + 1); //取得原文件名 string newFileName = Vincent._DTcms.Utils.GetRamCode() + "." + fileExt; //随机生成新的文件名 string newThumbnailFileName = "thumb_" + newFileName; //随机生成缩略图文件名 string upLoadPath = GetUpLoadPath(); //上传目录相对路径 string fullUpLoadPath = Vincent._DTcms.Utils.GetMapPath(upLoadPath); //上传目录的物理路径 string newFilePath = upLoadPath + newFileName; //上传后的路径 string newThumbnailPath = upLoadPath + newThumbnailFileName; //上传后的缩略图路径 //检查文件扩展名是否合法 if (!CheckFileExt(fileExt)) { return("{\"status\": 0, \"msg\": \"不允许上传" + fileExt + "类型的文件!\"}"); } //检查文件大小是否合法 if (!CheckFileSize(fileExt, fileSize)) { return("{\"status\": 0, \"msg\": \"文件超过限制的大小啦!\"}"); } //检查上传的物理路径是否存在,不存在则创建 if (!Directory.Exists(fullUpLoadPath)) { Directory.CreateDirectory(fullUpLoadPath); } //保存文件 postedFile.SaveAs(fullUpLoadPath + newFileName); //如果是图片,检查图片是否超出最大尺寸,是则裁剪 if (IsImage(fileExt) && (this.siteConfig.imgmaxheight > 0 || this.siteConfig.imgmaxwidth > 0)) { Vincent._DTcms.Thumbnail.MakeThumbnailImage(fullUpLoadPath + newFileName, fullUpLoadPath + newFileName, this.siteConfig.imgmaxwidth, this.siteConfig.imgmaxheight); } #region 保存到数据库 try { Model.source_material model = new Model.source_material(); BLL.source_material bll = new BLL.source_material(); model.img_url = newFilePath; //上传后文件的相对路径 Model.users userInfo = HttpContext.Current.Session[Vincent._DTcms.DTKeys.SESSION_USER_INFO] as Model.users; model.type = 3; //表示上传的是照片 model.user_id = userInfo != null ? userInfo.id : 0; model.add_time = Vincent._DTcms.Utils.StrToDateTime(DateTime.Now.ToString()); bll.Add(model); } catch (Exception) { return("{\"status\": 0, \"msg\": \"图片保存过程中发生意外错误!\"}"); } #endregion //处理完毕,返回JOSN格式的文件信息 return("{\"status\": 1, \"msg\": \"上传文件成功!\", \"name\": \"" + fileName + "\", \"path\": \"" + newFilePath + "\", \"thumb\": \"" + newThumbnailPath + "\", \"size\": " + fileSize + ", \"ext\": \"" + fileExt + "\"}"); } catch { return("{\"status\": 0, \"msg\": \"上传过程中发生意外错误!\"}"); } }