//添加按钮 protected void imgBtn_Click(object sender, ImageClickEventArgs e) { int order = 0; string sql = "select max(link_order) as maxOrder from t_friendlink"; DataTable dtMaxOrder = artBll.SelectToDataTable(sql); if (dtMaxOrder.Rows.Count > 0) { order = Convert.ToInt32(dtMaxOrder.Rows[0]["maxOrder"]) + 1; } string name = InText.SafeSql(InText.SafeStr(this.txtAddLinkName.Value)); string link = InText.SafeSql(InText.SafeStr(this.txtAddLink.Value)); if (name.Trim() != "" && link.Trim() != "") { sql = string.Format("insert into t_friendlink (link_name,link,link_order,update_date) values ('{0}','{1}',{2},getdate())", name, link, order); if (artBll.ExecuteSQLNonquery(sql)) { this.CteateHTML(url + "index927_2.aspx", "/", ""); //重新生成首页 InText.AlertAndRedirect("添加成功!", Request.Url.ToString()); //刷新当前页 } } }
//保存按钮 protected void btn_Update_Click(object sender, EventArgs e) { name = InText.SafeSql(InText.SafeStr(this.txt_name.Value)); pwd = WebBasic.Encryption.Encrypt(InText.SafeSql(InText.SafeStr(this.txt_pwd.Value))); remark = InText.SafeSql(InText.SafeStr(this.txt_remark.Value)); if (admin_id != 0)//执行修改 { string sql = string.Format("update t_admin set name='{0}',pwd='{1}',remark='{2}' where id={3}", name, pwd, remark, admin_id); bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { InText.AlertAndRedirect("修改成功", "/xzdd927/admin/admin_list.aspx");// Request.Url.AbsoluteUri } } else //执行添加 { string sql = string.Format("insert into t_admin (name,pwd,remark) values ('{0}','{1}','{2}')", name, pwd, remark); bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { InText.AlertAndRedirect("添加成功", "/xzdd927/admin/admin_list.aspx");// Request.Url.AbsoluteUri } } }
//更新/删除一条分类名称 protected void repList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (e.CommandName == "Update") { string id = this.hidUpdateId.Value; //分类ID string name = this.hidUpdateName.Value; //分类名称 string link = this.hidUpdateLink.Value; //分类关键词 if (name.Trim() != "" && link.Trim() != "") { string sql = "update t_friendlink set link_name='" + name + "',link='" + link + "' where id=" + id; if (artBll.ExecuteSQLNonquery(sql)) { this.CteateHTML(url + "index927_2.aspx", "/", ""); //重新生成首页 InText.AlertAndRedirect("修改成功!", Request.Url.ToString()); //刷新当前页 } } } if (e.CommandName == "Delete") { string sql = "delete from t_friendlink where id=" + e.CommandArgument.ToString(); if (artBll.ExecuteSQLNonquery(sql)) { this.CteateHTML(url + "index927_2.aspx", "/", ""); //重新生成首页 InText.AlertAndRedirect("删除成功!", Request.Url.ToString()); //刷新当前页 } } } }
//删除一张图片按钮 protected void repList_Img_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string[] arg = e.CommandArgument.ToString().Split('|'); int articleId = Convert.ToInt32(arg[0]); string pic = arg[1]; bool isOk = DeleteOnePic(articleId);//执行删除操作 if (isOk) { string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + pic; //删除原图 CommonMethod.FilePicDelete(strPath); strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + "100_100_" + pic; //删除缩略图 CommonMethod.FilePicDelete(strPath); Response.Redirect(Request.Url.ToString());//刷新当前页 } else { InText.AlertAndRedirect("删除失败,请重试!", Request.Url.ToString());//刷新当前页 } } }
//重新生成PC静态页 protected void btnUpdateHtml_Click(object sender, EventArgs e) { string sql = @"Select t_article.id as articleId,t_article.title,t_article.title1,t_article.source,t_article.keyword,t_article.daoyu,t_article.content,t_article.type,t_article.update_date,t_article.declare_mark,t_article.pic as artPic,t_article.html,t_article.remark,t_article.last_id,t_article.next_id, t_article1.html AS last_html,t_article1.title AS last_title,t_article2.html AS next_html,t_article2.title AS next_title, t_article_type.id as type_id,t_article_type.type_name,t_article.tag,t_article.tag_id,t_article.search_keyword FROM (((t_article LEFT JOIN t_article_type ON (t_article.type=t_article_type.id) ) LEFT JOIN t_article t_article1 ON (t_article.last_id=t_article1.id) ) LEFT JOIN t_article t_article2 ON (t_article.next_id=t_article2.id)) "; DataTable dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { int article_id = Convert.ToInt32(dt.Rows[i]["articleId"]); string title = dt.Rows[i]["title"].ToString(); string title1 = dt.Rows[i]["title1"].ToString(); string source = dt.Rows[i]["source"].ToString(); int articleType = Convert.ToInt32(dt.Rows[i]["type_id"]); string articleTypeName = dt.Rows[i]["type_name"].ToString(); string content = dt.Rows[i]["content"].ToString(); string keyword = dt.Rows[i]["keyword"].ToString(); string search_keyword = dt.Rows[i]["search_keyword"].ToString(); string artPic = dt.Rows[i]["artPic"].ToString(); string article_html = dt.Rows[i]["html"].ToString(); string tagStr = dt.Rows[i]["tag"].ToString(); string tagIdHtml = dt.Rows[i]["tag_id"].ToString(); string update_date = Convert.ToDateTime(dt.Rows[i]["update_date"]).ToString("yyyy年M月d日"); string tag_id = dt.Rows[i]["tag_id"].ToString(); last_title = "上一篇:" + dt.Rows[i]["last_title"].ToString(); last_html = dt.Rows[i]["last_html"].ToString(); next_title = "下一篇:" + dt.Rows[i]["next_title"].ToString(); next_html = dt.Rows[i]["next_html"].ToString(); if (tagIdHtml.Trim() != "") { string[] tagArray = tagIdHtml.Split(','); for (int j = 0; j < tagArray.Length; j++) { if (tagArray[j].Trim() != "" && tagArray[j].Trim() != ",") { tagIdHtml = tagArray[j].Trim(); break; } } } //GetLastNext(article_id, articleType); //生成静态页 CommonMethod.CreateArticleHtml(article_id, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tag_id, tagIdHtml, update_date, last_html, last_title, next_html, next_title, search_keyword); } } InText.AlertAndRedirect("生成成功!", Request.Url.ToString());//刷新当前页 }
//添加分类按钮 protected void imgBtn_Click(object sender, ImageClickEventArgs e) { string type_name = InText.SafeSql(InText.SafeStr(this.txtAddType.Value)); string type_keyword = InText.SafeSql(InText.SafeStr(this.txtAddTypeKeyword.Value)); if (type_name.Trim() != "") { string sql = string.Format("insert into t_article_type (type_name,type_keyword,remark) values ('{0}','{1}','')", type_name, type_keyword); if (artBll.ExecuteSQLNonquery(sql)) { InText.AlertAndRedirect("添加成功!", Request.Url.ToString());//刷新当前页 } } }
//删除幻灯图片按钮 protected void btn_delImg_huandeng1_Click(object sender, EventArgs e) { if (artPic_huandeng1.Trim() != "") { string sql = "update t_article set huandeng1_pic='' where id=" + articleId; bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + artPic_huandeng1;//删除原图 CommonMethod.FilePicDelete(strPath); InText.AlertAndRedirect("删除成功", Request.Url.AbsoluteUri); } } }
//删除一个编辑人员按钮 protected void repList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { int admin_id = Convert.ToInt32(e.CommandArgument); bool isOk = DeleteOneAdmin(admin_id);//执行删除操作 if (isOk) { InText.AlertAndRedirect("删除成功!", Request.Url.ToString());//刷新当前页 } else { InText.AlertAndRedirect("删除失败,请重试!", Request.Url.ToString());//刷新当前页 } } }
//生成sitemap protected void btnSitemap_Click(object sender, EventArgs e) { string site = "http://www.up927.com" + "\r\n"; string sql = ""; DataTable dt = new DataTable(); sql = "select id from t_article_type "; dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { site += "http://www.up927.com/list.aspx?at=" + dt.Rows[i]["id"].ToString() + "\r\n"; } } sql = "select top 20 id from t_tag where article_num<>0 order by article_num desc "; dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { site += "http://www.up927.com/list.aspx?tag=" + dt.Rows[i]["id"].ToString() + "\r\n"; } } sql = "select html from t_article order by update_date DESC "; dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { site += "http://www.up927.com" + dt.Rows[i]["html"].ToString() + "\r\n"; } } FileStream fs = new FileStream(HttpContext.Current.Server.MapPath("/sitemap.txt"), FileMode.Create); StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("UTF-8")); //开始写入 sw.Write(site); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); InText.AlertAndRedirect("生成成功!", Request.Url.ToString());//刷新当前页 }
//删除图片按钮 protected void btn_delImg_Click(object sender, EventArgs e) { if (tag_pic.Trim() == "") { tag_pic = this.hid_artPic.Value; } if (tag_pic.Trim() != "") { string sql = "update t_tag set tag_pic='' where id=" + tag_id; bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Tag_File"].ToString() + tag_pic;//删除原图 CommonMethod.FilePicDelete(strPath); InText.AlertAndRedirect("删除成功", Request.Url.AbsoluteUri); } } }
//重新生成wap静态页 protected void btnUpdateWapHtml_Click(object sender, EventArgs e) { string sql = "select t_article.*,t_article_type.type_name,t_article_type.id as articleType from t_article left join t_article_type on (t_article.type=t_article_type.id) "; DataTable dt = artBll.SelectToDataTable(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { int articleId = Convert.ToInt32(dt.Rows[i]["id"]); string title = dt.Rows[i]["title"].ToString(); string title1 = dt.Rows[i]["title1"].ToString(); string source = dt.Rows[i]["source"].ToString(); int articleType = Convert.ToInt32(dt.Rows[i]["articleType"]); string articleTypeName = dt.Rows[i]["type_name"].ToString(); string content = dt.Rows[i]["content"].ToString(); string keyword = dt.Rows[i]["keyword"].ToString(); string search_keyword = dt.Rows[i]["search_keyword"].ToString(); string artPic = dt.Rows[i]["pic"].ToString(); string article_html = dt.Rows[i]["html"].ToString(); string tagStr = dt.Rows[i]["tag"].ToString(); string tag_id = dt.Rows[i]["tag_id"].ToString(); string tagIdHtml = ""; if (tag_id.Trim() != "") { string[] arrayTag_id = tag_id.Split(','); for (int j = 0; j < arrayTag_id.Length; j++) { if (arrayTag_id[j].Trim() != "," && arrayTag_id[j].Trim() != "") { tagIdHtml = arrayTag_id[j]; break; } } } //生成wap版静态页 CommonMethod.CreateArticleHtml_Wap(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tag_id, tagIdHtml, search_keyword); } } InText.AlertAndRedirect("生成成功!", Request.Url.ToString());//刷新当前页 }
protected void btnSubmit_Click(object sender, EventArgs e) { try { //查询信息 GetInfoDelegate clDel = new GetInfoDelegate(this.GetInfo); AsyncCallback callBackClose = new AsyncCallback(GetReturn); clDel.BeginInvoke(callBackClose, null);// 异步调用方法,查询信息 } catch (Exception ex) { } finally { InText.AlertAndRedirect("执行成功!", Request.Url.AbsoluteUri); } }
//更新/删除一条分类名称 protected void repList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (e.CommandName == "Update") { string type_id = this.hidUpdateId.Value; //分类ID string type_name = this.hidUpdateTypeName.Value; //分类名称 string type_keyword = this.hidUpdateTypeKeyword.Value; //分类关键词 if (type_id != "" && type_name != "") { string sql = "update t_article_type set type_name='" + type_name + "',type_keyword='" + type_keyword + "' where id=" + type_id; if (artBll.ExecuteSQLNonquery(sql)) { InText.AlertAndRedirect("修改成功!", Request.Url.ToString());//刷新当前页 } } } if (e.CommandName == "Delete") { string sql = "select count(*) from t_article where type=" + e.CommandArgument.ToString(); int totalRecord = Utils.CheckInt(artBll.ExecuteScalar(sql)); if (totalRecord > 0) { InText.AlertAndRedirect("该分类下有文章,请先修改文章分类或删除文章!", Request.Url.ToString());//刷新当前页 } else { sql = "delete from t_article_type where id=" + e.CommandArgument.ToString(); if (artBll.ExecuteSQLNonquery(sql)) { InText.AlertAndRedirect("删除成功!", Request.Url.ToString());//刷新当前页 } } } } }
//删除、推送一条文章按钮 protected void repList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { if (e.CommandName == "Delete") { int articleId = Convert.ToInt32(e.CommandArgument); string delImg = ""; string delImg_huandeng1 = ""; string delHtml = ""; DataTable dtDel = artBll.SelectToDataTable("select * from t_article where id=" + articleId); if (dtDel.Rows.Count > 0) { delImg = dtDel.Rows[0]["pic"].ToString(); //文章图片 delImg_huandeng1 = dtDel.Rows[0]["huandeng1_pic"].ToString(); //文章幻灯图片 delHtml = dtDel.Rows[0]["html"].ToString(); //文章静态页 bool isOk = DeleteOneArticle(articleId); //执行删除操作 if (isOk) { string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + delImg; //删除原图 CommonMethod.FilePicDelete(strPath); strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + "100_100_" + delImg; //删除缩略图 CommonMethod.FilePicDelete(strPath); strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["hd1"].ToString() + delImg_huandeng1;//删除幻灯图片 CommonMethod.FilePicDelete(strPath); strPath = HttpRuntime.AppDomainAppPath.ToString() + delHtml;//删除静态页 CommonMethod.FilePicDelete(strPath); InText.AlertAndRedirect("删除成功!", Request.Url.ToString());//刷新当前页 } else { InText.AlertAndRedirect("删除失败,请重试!", Request.Url.ToString());//刷新当前页 } } } if (e.CommandName == "ts_baidu")//执行推送百度 { //string[] array = e.CommandArgument.ToString().Split('|'); //int art_id = Utils.CheckInt(array[0]); //string html = array[1]; //SEO seo = new SEO(); //string resultStr = seo.TS_baidu(art_id, html); //InText.AlertAndRedirect(resultStr, Request.Url.ToString()); string[] array = e.CommandArgument.ToString().Split('|'); int art_id = Utils.CheckInt(array[0]); string html = array[1]; SEO seo = new SEO(); if (Request.Url.ToString().Contains("http://www.up927.com/")) { string resultStr = seo.TS_baidu(art_id, html); InText.AlertAndRedirect(resultStr, Request.Url.ToString()); } else { InText.AlertAndRedirect("本地不能推送百度", Request.Url.ToString()); } } } }
//重新生成404 protected void btnUpdate404_Click(object sender, EventArgs e) { //生成404 CommonMethod.CteateHTML(url + "template/404.aspx", "", "/404.html"); InText.AlertAndRedirect("生成成功!", Request.Url.ToString());//刷新当前页 }
//首页生成静态页 protected void btnUpdateHtml_Index_Click(object sender, EventArgs e) { this.CteateHTML(url + "index927_2.aspx", "/", ""); this.CteateHTML(url + "wap/index927.aspx", "/wap/", ""); InText.AlertAndRedirect("生成成功!", Request.Url.ToString());//刷新当前页 }
//重新生成右侧 protected void btnUpdateSide_Click(object sender, EventArgs e) { //生成右侧 CommonMethod.CteateHTML(url + "template/Side_2.aspx", "", "/userControl/Side_2.html"); InText.AlertAndRedirect("生成成功!", Request.Url.ToString());//刷新当前页 }
//添加/修改按钮 protected void btn_add_Click(object sender, EventArgs e) { int huandeng1 = 0; if (this.chkHuandeng1.Checked)//是否首页幻灯 { huandeng1 = 1; } string title = InText.SafeSql(InText.SafeStr(this.txt_title.Text)); string title1 = InText.SafeSql(InText.SafeStr(this.txt_title1.Text)); if (title1.Trim() == "") { title1 = title; } string source = InText.SafeSql(InText.SafeStr(this.txt_source.Text)); int articleType = Convert.ToInt32(this.ddl_articleType.SelectedValue); string articleTypeName = this.ddl_articleType.SelectedItem.Text; string content = this.hidDes.Value.Trim();//素材内容(编辑器) //InText.SafeSql(InText.SafeSqlContent(content2.Text)); int declare_mark = Convert.ToInt32(this.ddl_declare_mark.SelectedValue); string keyword = InText.SafeSql(InText.SafeStr(this.txt_keyword.Text)); string search_keyword = InText.SafeSql(InText.SafeStr(this.txt_search_keyword.Text)); string daoyu = InText.SafeSql(InText.SafeStr(this.txt_daoyu.Text)); string tag = InText.SafeSql(InText.SafeStr(this.txt_tag.Text)); int right_type = Convert.ToInt32(this.ddl_right_type.SelectedValue); //================================上传图片附件============================================================================ string savePath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString(); //int result = 0; //文章图片 if (this.fu_image.HasFile) { //修改文章时,删除原来的图片 if (articleId != 0) { if (artPic.Trim() != "") { string sql = "update t_article set pic='' where id=" + articleId; bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + artPic; //删除原图 CommonMethod.FilePicDelete(strPath); strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + "100_100_" + artPic; //删除缩略图 CommonMethod.FilePicDelete(strPath); } } } artPic = ""; int len = fu_image.PostedFile.ContentLength; if (fu_image.PostedFile.ContentLength <= 10240000)//10M内 { //if (FileUpload.PostedFile.ContentLength<=) if (CommonMethod.IsAllowedExtension(fu_image))//验证下文件是否为图片 { string filepath = fu_image.PostedFile.FileName; string filename_user = filepath.Substring(filepath.LastIndexOf("\\") + 1); artPic = imageNamePre + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".jpg"; string serverpath = savePath + "img_" + artPic; fu_image.PostedFile.SaveAs(serverpath); //保存原图片 string smallPath = savePath + artPic; //缩略图路径 //CommonMethod.MakeThumbnail(serverpath, smallPath, 500, 500, "W");//保存成最大500*500 smallPath = savePath + "100_100_" + artPic; //缩略图路径 CommonMethod.MakeThumbnail(serverpath, smallPath, 300, 300, "HW"); //生成缩略图150*150 CommonMethod.FilePicDelete(serverpath); //删除原图片 } } } artPic = this.hid_artPic.Value; //幻灯图片 if (this.fu_image_huandeng1.HasFile) { savePath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["hd1"].ToString(); //修改文章时,删除原来的图片 if (articleId != 0) { if (artPic_huandeng1.Trim() != "") { string sql = "update t_article set huandeng1_pic='' where id=" + articleId; bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { string strPath = HttpRuntime.AppDomainAppPath.ToString() + @ConfigurationManager.AppSettings["Article_File"].ToString() + artPic_huandeng1;//删除原图 CommonMethod.FilePicDelete(strPath); } } } artPic_huandeng1 = ""; int len = fu_image_huandeng1.PostedFile.ContentLength; if (fu_image_huandeng1.PostedFile.ContentLength <= 10240000) //10M内 { if (CommonMethod.IsAllowedExtension(fu_image_huandeng1)) //验证下文件是否为图片 { string filepath = fu_image_huandeng1.PostedFile.FileName; string filename_user = filepath.Substring(filepath.LastIndexOf("\\") + 1); artPic_huandeng1 = imageNamePre + "hd1_" + DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N") + ".jpg"; string serverpath = savePath + artPic_huandeng1; fu_image_huandeng1.PostedFile.SaveAs(serverpath);//保存原图片 //string smallPath = savePath + artPic;//缩略图路径 //CommonMethod.MakeThumbnail(serverpath, smallPath, 500, 500, "W");//保存成最大500*500 //CommonMethod.FilePicDelete(serverpath);//删除原图片 huandeng1 = 1; } } } //======================================上传图片附件========================================================================== string tagIdHtml = ""; //要引用的标签静态页ID(第一个标签的ID) string tagId = ""; //要保存的多个标签ID string tagStr = ""; //要保存的多个标签 if (this.txt_tag.Text.Trim() != "") { tagStr = InText.SafeSql(InText.SafeStr(this.txt_tag.Text)); //生成标签 string[] arrayTag = tagStr.Split(' '); for (int i = 0; i < arrayTag.Length; i++) { if (arrayTag[i].Trim() != "") { string tag_id = SelectOneTag(arrayTag[i]); if (tag_id != "") { //CreateOneTag(tag_id); if (tagIdHtml == "") { tagIdHtml = tag_id; } tagId += tag_id + ","; } } } tagId = "," + tagId; } if (articleId != 0)//执行修改 { string sql = string.Format("update t_article set title='{0}',keyword='{1}',daoyu='{2}',content='{3}',type={4},declare_mark={5},pic='{6}',remark='{7}',source='{9}',huandeng1={10},huandeng1_pic='{11}',tag='{12}',tag_id='{13}',right_type={14},title1='{15}',search_keyword='{16}' where id={8}", title, keyword, daoyu, content, articleType, declare_mark, artPic, "article/", articleId, source, huandeng1, artPic_huandeng1, tagStr, tagId, right_type, title1, search_keyword);// bool isOk = artBll.ExecuteSQLNonquery(sql); GetLastNext(articleId, articleType);//获取上一篇、下一篇 //更新上一篇、下一篇 sql = "update t_article set last_id=" + last_id + ",next_id=" + next_id + " where id=" + articleId; isOk = artBll.ExecuteSQLNonquery(sql); //更新上一篇文章的下一篇id sql = "update t_article set next_id=" + articleId + " where id=" + last_id; isOk = artBll.ExecuteSQLNonquery(sql); //生成静态页 CommonMethod.CreateArticleHtml(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, Convert.ToDateTime(update_date).ToString("yyyy年M月d日"), last_html, last_title, next_html, next_title, search_keyword); //生成wap版静态页 CommonMethod.CreateArticleHtml_Wap(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, search_keyword); //重新生成上一篇文章(更新“下一篇”链接) CommonMethod.CreateOneArticleHtml(last_id); //sql = "select top 1 * from t_article where id <" + articleId + " order by id desc"; //DataTable dtLast = artBll.SelectToDataTable(sql); //if (dtLast.Rows.Count > 0) //{ // int last_id = Convert.ToInt32(dtLast.Rows[0]["id"]); // //string article_html_last = dtLast.Rows[0]["html"].ToString(); // CommonMethod.CreateOneArticleHtml(last_id); //} } else //执行添加 { string sql = string.Format("insert into t_article (title,keyword,daoyu,content,type,update_date,declare_mark,pic,remark,source,huandeng1,huandeng1_pic,tag,tag_id,right_type,title1,search_keyword) values ('{0}','{1}','{2}','{3}',{4},getdate(),{5},'{6}','{7}','{8}',{9},'{10}','{11}','{12}',{13},'{14}','{15}')", title, keyword, daoyu, content, articleType, declare_mark, artPic, "article/", source, huandeng1, artPic_huandeng1, tagStr, tagId, right_type, title1, search_keyword); bool isOk = artBll.ExecuteSQLNonquery(sql); if (isOk) { DataTable dtMaxId = artBll.SelectToDataTable("select max(id) as id from t_article"); if (dtMaxId.Rows.Count > 0) { articleId = Convert.ToInt32(dtMaxId.Rows[0]["id"]); string id_show = CommonMethod.GetIDEncrypt(articleId);//对ID进行加密 DataTable dtIdShow = artBll.SelectToDataTable("select id from t_article where id_show='" + id_show + "' "); while (dtIdShow.Rows.Count > 0) { id_show = CommonMethod.GetIDEncrypt(articleId);//有重复,再次对ID进行加密 dtIdShow = artBll.SelectToDataTable("select id from t_article where id_show='" + id_show + "' "); } articleId = Convert.ToInt32(dtMaxId.Rows[0]["id"]); article_html = staticPath + id_show + ".shtml"; sql = "update t_article set html='" + article_html + "',id_show='" + id_show + "' where id=" + articleId; isOk = artBll.ExecuteSQLNonquery(sql); //将静态页名称保存到数据库 GetLastNext(articleId, articleType); //获取上一篇、下一篇 //更新上一篇、下一篇 sql = "update t_article set last_id=" + last_id + ",next_id=" + next_id + " where id=" + articleId; isOk = artBll.ExecuteSQLNonquery(sql); //更新上一篇文章的下一篇id sql = "update t_article set next_id=" + articleId + " where id=" + last_id; isOk = artBll.ExecuteSQLNonquery(sql); //生成静态页 CommonMethod.CreateArticleHtml(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, DateTime.Now.ToString("yyyy年M月d日"), last_html, last_title, next_html, next_title, search_keyword); //生成wap版静态页 CommonMethod.CreateArticleHtml_Wap(articleId, title, title1, source, articleType, articleTypeName, content, keyword, artPic, article_html, tagStr, tagId, tagIdHtml, search_keyword); //重新生成上一篇文章(更新“下一篇”链接) CommonMethod.CreateOneArticleHtml(last_id); //sql = "select top 1 * from t_article where id <" + articleId + " order by id desc"; //DataTable dtLast = artBll.SelectToDataTable(sql); //if (dtLast.Rows.Count > 0) //{ // last_id = Convert.ToInt32(dtLast.Rows[0]["id"]); // //string article_html_last = dtLast.Rows[0]["html"].ToString(); // CommonMethod.CreateOneArticleHtml(last_id); //} } } } if (this.txt_tag.Text.Trim() != "") { tagStr = InText.SafeSql(InText.SafeStr(this.txt_tag.Text)); //生成标签 string[] arrayTag = tagStr.Split(' '); for (int i = 0; i < arrayTag.Length; i++) { if (arrayTag[i].Trim() != "") { string tag_id = SelectOneTag(arrayTag[i]); if (tag_id != "") { CreateOneTag(tag_id); if (tagIdHtml == "") { tagIdHtml = tag_id; } //select count(id) from t_article where tag_id like '*,9,*' if (tag_id_a.Trim() == "") { //添加文章,更新该标签下的文章数量 artBll.ExecuteSQLNonquery("update t_tag set article_num=article_num+1 where id=" + tag_id); } tagId += tag_id + ","; } } } tagId = "," + tagId; } //生成右侧 //CommonMethod.CteateHTML(url + "template/Side_2.aspx", "", "/userControl/Side_2.html"); //生成404页面 CommonMethod.CteateHTML(url + "template/404.aspx", "", "/404.html"); if (articleId != 0) //执行修改 { InText.AlertAndRedirect("修改成功", "/xzdd927/article/article_list.aspx"); // } else //执行添加 { InText.AlertAndRedirect("添加成功", "/xzdd927/article/add_article.aspx");// /xzdd927/article/article_list.aspx } }