//删除 void Delete1_DeleteClickEvent(object sender, EventArgs e) { ArrayList selectedNodes = this._menu.GetSelectedTreeNodes(this.treeMenu.Nodes[0]); if (selectedNodes.Count == 0) { JSUtility.Alert("请选择要删除的页节点!"); } else { int[] selectedIds = new int[selectedNodes.Count]; for (int i = 0; i < selectedNodes.Count; i++) { selectedIds[i] = Convert.ToInt32(((TreeNode)selectedNodes[i]).Value); /*日志归档*/ // string sql = @"select l.Description as title from T_Permission l where PermissionId=" + selectedIds[i].ToString() + ""; // PubFunction.InsertLog("系统管理", "菜单管理", "菜单列表", "删除", sql, selectedIds[i].ToString()); } bool sucess = this._menu.Delete(selectedIds); if (sucess) { JSUtility.Alert("删除菜单项成功!"); } else { JSUtility.Alert("包含子节点的菜单项无法删除,子节点已删除!"); } this.treeMenu.Nodes.Clear(); this.treeMenu.Nodes.Add(this._menu.GetMenuTree(false)); } }
/// <summary> /// 确定提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { model.Title = KillSqlIn.Form_ReplaceByString(this.txtTitle.Text, 100); model.DisplayMode = Convert.ToInt32(this.RadioButtonList1.SelectedValue); model.CategoryId = Convert.ToInt32(this.DrCategory.SelectedValue); model.Link = KillSqlIn.Form_ReplaceByString(this.txtLink.Text.Trim(), 100); model.sort = Convert.ToInt32(KillSqlIn.Form_ReplaceByString(this.txtSort.Text, 10)); model.StartTime = !string.IsNullOrEmpty(this.txtStartTime.Text) ? Convert.ToDateTime(this.txtStartTime.Text) : System.DateTime.Now; model.EndTime = !string.IsNullOrEmpty(this.txtEndTime.Text) ? Convert.ToDateTime(this.txtEndTime.Text) : System.DateTime.Now.AddDays(7); #region 保存图片 if (!this.picUpload.Value.Equals("")) { string FileTZM = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名 if (!IsPic(FileTZM.ToLower())) { JSUtility.Alert("上传图片格式不正确!"); return; } if (this.picUpload.PostedFile.ContentLength > 1048576) { JSUtility.Alert("上传图片过大!"); return; } Random rnd = new Random(); string UpLoadFileTime = DateTime.Now.ToString("HHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称 string fileName = UpLoadFileTime + "." + FileTZM; //产生上传图片的名称 if (!Directory.Exists(Request.MapPath("~/upload/Link/"))) { Directory.CreateDirectory(Request.MapPath("~/upload/Link/")); } string Url = Request.MapPath("~/upload/Link/" + fileName); picUpload.PostedFile.SaveAs(Url); model.Image = "/upload/Link/" + fileName; } else { model.Image = ViewState["Image"] == null ? "" : ViewState["Image"].ToString(); } #endregion if (_Pid != "SysError") { model.AdId = Convert.ToInt32(_Pid); if (bll.Update(model)) { this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>"); } } else { if (bll.Add(model) != 0) { JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString()); } } }
//删除 void Delete1_DeleteClickEvent(object sender, EventArgs e) { ArrayList selectedNodes = this._category.GetSelectedTreeNodes(this.treeCategory.Nodes[0]); if (selectedNodes.Count == 0) { JSUtility.Alert("请选择要删除的页节点!"); } else { int[] selectedIds = new int[selectedNodes.Count]; for (int i = 0; i < selectedNodes.Count; i++) { selectedIds[i] = Convert.ToInt32(((TreeNode)selectedNodes[i]).Value); /*日志归档*/ string sql = @"select * from dbo.T_Category where CategoryId = (" + selectedIds[i] + ")"; // string function = "删除新闻类别"; //PubFunction.InsertLog1(null, sql, function); } foreach (int id in selectedIds) { if (new BllTableObject("T_News").Util_CheckIsExsitData("CategoryId=" + id + "")) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('该类别已包含的新闻内容,请到【新闻列表】里删除相应的内容!');</script>"); return; } } //如果该节点为根节点,且有子节点则不允许删除 bool flag = this._category.DeleteCategoryParent(((TreeNode)selectedNodes[0]).Value); if (flag) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('该节点为根节点,且有子节点则不允许删除!');</script>"); return; } /*删除数据*/ bool sucess = this._category.DeleteCategory(selectedIds); if (sucess) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('删除菜单项成功!');</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('包含子节点的菜单项无法删除,请先删除子节点!');</script>"); } this.treeCategory.Nodes.Clear(); //绑定新闻类别列表,1:新闻类。 this.treeCategory.Nodes.Add(this._category.GetCategoryTree(2)); } }
//查看 void Show1_ShowClickEvent(object sender, EventArgs e) { ArrayList selectedNodes = TreeNodeUtil.GetSelectedTreeNodes(this.treeMenu.Nodes[0]); if (selectedNodes.Count == 0) { JSUtility.Alert("请选择一个要编辑的节点!"); } else if (selectedNodes.Count == 1) { string menuId = ((TreeNode)selectedNodes[0]).Value; this.ClientScript.RegisterClientScriptBlock(this.GetType(), "js", "<Script language=JavaScript>show_method(" + menuId + ")</Script>"); } else { JSUtility.Alert("只能选择一个要编辑的节点!"); } }
// copy void TopButtons1_SearchClickEvent(object sender, EventArgs e) { ArrayList selectedNodes = TreeNodeUtil.GetSelectedTreeNodes(this.treeMenu.Nodes[0]); if (selectedNodes.Count == 0) { JSUtility.Alert("请选择一个节点!"); } else if (selectedNodes.Count == 1) { string menuId = ((TreeNode)selectedNodes[0]).Value; Response.Redirect(String.Format("CopyMenu.aspx?MenuId={0}", menuId), true); } else { JSUtility.Alert("只能选择一个节点!"); } }
// 修改 void Edit1_EditClickEvent(object sender, EventArgs e) { ArrayList selectedNodes = this._category.GetSelectedTreeNodes(this.treeCategory.Nodes[0]); if (selectedNodes.Count == 0) { JSUtility.Alert("请选择一个要编辑的节点!"); } else if (selectedNodes.Count == 1) { string CategoryId = ((TreeNode)selectedNodes[0]).Value; this.ClientScript.RegisterClientScriptBlock(this.GetType(), "js", "<Script language=JavaScript>edit_method(" + CategoryId + ")</Script>"); } else { JSUtility.Alert("只能选择一个要编辑的节点!"); } }
public string getImg() { #region 保存图片 if (!this.picUpload.Value.Equals("")) { string UploadFileLastName = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名 if (!PubFunction.IsPic(UploadFileLastName)) { JSUtility.Alert("上传图片格式不正确!"); return(Session["img"].ToString()); } Random rnd = new Random(); string UpLoadFileTime = DateTime.Now.ToString("HHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称 string fileName = UpLoadFileTime + "." + UploadFileLastName; //产生上传图片的名称 string SaveFile = DateTime.Now.ToString("yyyy/MM/dd/").Replace("-", "/"); #region 设置保存的路径 string SevedDirectory = System.Web.VirtualPathUtility.Combine(mainPath, SaveFile); string phydic = MapPath(SevedDirectory); if (!System.IO.Directory.Exists(phydic)) { System.IO.Directory.CreateDirectory(phydic); } #endregion this.picUpload.PostedFile.SaveAs(phydic + "" + fileName); string fckimg = string.Empty; string source = string.Empty; fckimg = "<a href='" + this.ResolveUrl(SevedDirectory + fileName) + "' target='_blank' id='upannexx'>" + fileName + "</a>"; source = this.ResolveUrl(SevedDirectory + fileName); return(SaveFile + fileName); } else { return(Session["img"].ToString()); } #endregion }
//删除 void Delete1_DeleteClickEvent(object sender, EventArgs e) { ArrayList selectedNodes = TreeNodeUtil.GetSelectedTreeNodes(this.treeMenu.Nodes[0]); if (selectedNodes.Count == 0) { JSUtility.Alert("请选择要删除的页节点!"); } else { int[] selectedIds = new int[selectedNodes.Count]; string typeList = ""; for (int i = 0; i < selectedNodes.Count; i++) { selectedIds[i] = Convert.ToInt32(((TreeNode)selectedNodes[i]).Value); typeList += "《" + ((TreeNode)selectedNodes[i]).Text + "》"; /*日志归档*/ // string sql = @"select l.Description as title from T_Permission l where PermissionId=" + selectedIds[i].ToString() + ""; // PubFunction.InsertLog("系统管理", "菜单管理", "菜单列表", "删除", sql, selectedIds[i].ToString()); } bool sucess = this.bll.Delete(selectedIds); if (sucess) { LogAdd.CreateLog(HttpContext.Current.Session["UserId"].ToString(), "删除菜谱分类" + typeList + "", "删除", "", "", HttpContext.Current.Request.Url.ToString()); JSUtility.Alert("删除菜单项成功!"); } else { JSUtility.Alert("包含子节点的菜单项无法删除,子节点已删除!"); } this.treeMenu.Nodes.Clear(); //this.treeMenu.Nodes.Add(this._menu.GetMenuTree(false)); BindTreeView(); } }
/// <summary> /// 确定提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { string strError = Validates(); if (!string.IsNullOrEmpty(strError)) { this.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('" + strError + "');</script>"); return; } model.CategoryId = Convert.ToInt32(this.ddlType.SelectedValue); model.Title = SafeRequest.GetFormString("txtTitle"); model.SubHead = SafeRequest.GetFormString("txtSubHead"); model.PublicationUnit = SafeRequest.GetFormString("txtUnit"); model.FromSource = SafeRequest.GetFormString("txtFromSouce"); // model.KeyWord = SafeRequest.GetFormString("txtKeyWord"); model.ReleaseDate = !string.IsNullOrEmpty(this.txtReleaseDate.Text.Trim()) ? Convert.ToDateTime(this.txtReleaseDate.Text.Trim()) : System.DateTime.Now; model.IsTop = 0; //SafeRequest.GetFormInt("radioTopList", 0); model.IndexCommend = 0; //SafeRequest.GetFormInt("radioIndexCommentList", 0); model.HotPic = SafeRequest.GetFormString("radioHotList"); model.HotDays = SafeRequest.GetFormInt("txtHotDays", 3); //model.ArticleType = SafeRequest.GetFormInt("radioArticleTypeList", 0); model.Body = this.fckBody.Text; //追加底部 if (cbFooter.Checked) { if (model.Body.IndexOf("start_auto_footer") == -1 && model.Body.IndexOf("end_auto_footer") == -1) { string autoFooter = "<!--start_auto_footer-->" + this.fckBodyFooter.Text + "<!--end_auto_footer-->"; model.Body = model.Body + autoFooter; } //写入缓存 NG.CachHelper.Redis.RedisHelper redis = new NG.CachHelper.Redis.RedisHelper(); redis.SetStringCash("News_Footer", this.fckBodyFooter.Text); redis.Close(); } // model.IsComment = 0;// SafeRequest.GetFormInt("radioIsComment", 0); model.Approved = SafeRequest.GetFormInt("radioApproved", 0); model.Sort = SafeRequest.GetFormInt("txtSort", 99); model.AddedDate = System.DateTime.Now; model.ExpireDate = System.DateTime.Now; model.ViewCount = 0; // model.IsScrool = 0; // model.AddedUserId = Convert.ToInt32(_userId);//默认登录进来人的编号 model.AddedUserId = 1; //~/upload/News/ #region 保存图片 if (!this.picUpload.Value.Equals("") && this.picUpload.PostedFile.ContentLength > 10) { string FileTZM = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名 if (!IsPic(FileTZM.ToLower())) { JSUtility.Alert("上传图片格式不正确!"); return; } if (this.picUpload.PostedFile.ContentLength > 1048576) { JSUtility.Alert("上传图片过大!"); return; } Random rnd = new Random(); string UpLoadFileTime = DateTime.Now.ToString("yyMMddHHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称 string fileName = UpLoadFileTime + "." + FileTZM; //产生上传图片的名称 if (!Directory.Exists(Request.MapPath("~/upload/News/"))) { Directory.CreateDirectory(Request.MapPath("~/upload/News/")); } string Url = Request.MapPath("~/upload/News/" + fileName); picUpload.PostedFile.SaveAs(Url); model.ImgLink = "/upload/News/" + fileName; } else { model.ImgLink = ViewState["ImgLink"].ToString(); } #endregion if (_Pid != "") { model.NewsID = _Pid; if (bll.Update(model)) { this.ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>"); } } else { model.NewsID = IdCreator.CreateId("T_News", "NewsId"); if (bll.Add(model)) { JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString()); } } }
//保存 protected void LinkButton1_Click(object sender, EventArgs e) { model.Title = SafeRequest.GetFormString("txtTitle"); model.DisplayMode = SafeRequest.GetFormInt("RadioButtonList1", 0); model.CategoryId = SafeRequest.GetFormInt("DrCategory", 0); model.Link = txtLink.Text.Trim(); model.Sort = SafeRequest.GetFormInt("txtSort", 0); #region 保存图片 if (!this.picUpload.Value.Equals("")) { string UploadFileLastName = this.picUpload.PostedFile.FileName.Substring(this.picUpload.PostedFile.FileName.LastIndexOf(".") + 1);//得到文件的扩展名 if (!PubFunction.IsPic(UploadFileLastName)) { JSUtility.Alert("上传图片格式不正确!"); return; } Random rnd = new Random(); string UpLoadFileTime = DateTime.Now.ToString("HHmmss") + rnd.Next(9999).ToString("0000"); //生成一个新的数图片名称 string fileName = UpLoadFileTime + "." + UploadFileLastName; //产生上传图片的名称 string SaveFile = DateTime.Now.ToString("yyyy/MM/dd/").Replace("-", "/"); #region 设置保存的路径 string SevedDirectory = System.Web.VirtualPathUtility.Combine(mainPath, SaveFile); string phydic = MapPath(SevedDirectory); if (!System.IO.Directory.Exists(phydic)) { System.IO.Directory.CreateDirectory(phydic); } #endregion this.picUpload.PostedFile.SaveAs(phydic + "" + fileName); string fckimg = string.Empty; string source = string.Empty; fckimg = "<a href='" + this.ResolveUrl(SevedDirectory + fileName) + "' target='_blank' id='upannexx'>" + fileName + "</a>"; source = this.ResolveUrl(SevedDirectory + fileName); model.Image = SaveFile + fileName; } else { model.Image = ViewState["ImgLink"].ToString(); } #endregion string BackUrl = "LinkList.aspx?PageIndex=" + PageIndex; if (_Lid != "0") { model.LinkId = Convert.ToInt32(_Lid); bll.Update(model); ClientScript.RegisterStartupScript(this.GetType(), "close", "<script>alert('修改成功');layer_close_refresh();</script>"); //状态 if (Session["LinkStatus_Hashtable"] != null) { Hashtable hTable = (Hashtable)Session["LinkStatus_Hashtable"]; hTable["ReadSessionStatus"] = "1"; Session["LinkStatus_Hashtable"] = hTable; } /*日志归档*/ string sql = @"select l.title from T_link l where linkid=" + this._Lid + ""; PubFunction.InsertLog("其它管理", "友情链接", "友情链接列表", "修改", sql, _Lid); } else { int i = bll.Add(model); JSUtility.AlertAndRedirect("添加成功,请继续添加!", Request.RawUrl.ToString()); /*日志归档*/ string sql = @"select l.title from T_link l where linkid=" + i.ToString() + ""; PubFunction.InsertLog("其它管理", "友情链接", "友情链接列表", "添加", sql, i.ToString()); } }