private void Modify(Link model) { bll.Update(model); Msg.ShowAndRedirect("修改信息成功!", "Default.aspx"); }
//保存 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()); } }