protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); BindGrid(); Calendar1.SelectedDate = DateTime.Now; if (!String.IsNullOrEmpty(Request.QueryString["tyId"])) { ddlfatherId.SelectedValue = Request.QueryString["tyId"]; ddlfatherId.Enabled = false; } if (!String.IsNullOrEmpty(Request.QueryString["Id"])) { ddlfatherId.Enabled = true; Maticsoft.BLL.tArticle bll = new Maticsoft.BLL.tArticle(); Maticsoft.Model.tArticle model = bll.GetModel(int.Parse(Request.QueryString["Id"])); imgPhoto.ImageUrl = model.FengMian; txtTile.Text = model.Title; txtRemark.Text = model.Remark; txtEdit.Text = model.Editor; Calendar1.SelectedDate = model.UpdateTime; ddlfatherId.SelectedValue = model.ArtTyID.ToString(); txtSort.Text = model.Sort.ToString(); hfEditorInitValue.Text = model.ArticleContent; } } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["tId"] == null && Request.QueryString["Id"] == null) { Response.Redirect("index.aspx"); return; } int tId = 0; try { tId = int.Parse(Request.QueryString["tId"].ToString()); } catch { Response.Redirect("index.aspx"); return; } if (!IsPostBack) { getNav(tId); } Maticsoft.Model.tArticle model = null; Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle(); model = BLL.GetModel(int.Parse(Request.QueryString["Id"])); model.Click = (model.Click + 1); BLL.Update(model); lit_title.Text = model.Title; this.Title += "-" + model.Title; lit_content.Text = model.ArticleContent; lit_edit.Text = model.Editor; lit_click.Text = model.Click.ToString(); lit_time.Text = Convert.ToDateTime(model.UpdateTime).ToString("yyyy-MM-dd"); }
protected void Grid_RowCommand(object sender, GridCommandEventArgs e) { int artId = GetSelectedDataKeyID(Grid); if (e.CommandName == "Delete") { Maticsoft.BLL.tArticle BLL = new Maticsoft.BLL.tArticle(); Maticsoft.Model.tArticle model = BLL.GetModel(artId); if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png")) { string directoryPath = Server.MapPath(model.FengMian); File.Delete(directoryPath); //删除掉原来的图片 } BLL.Delete(artId); GetView(); } if (e.CommandName == "Edit") { PageContext.RegisterStartupScript(Window1.GetShowReference("ArticlesEdit.aspx?Id=" + artId)); } }
protected void btnSave_Click(object sender, EventArgs e) { Maticsoft.BLL.tArticle bll = new Maticsoft.BLL.tArticle(); if (imgPhoto.ImageUrl == "") { filePhoto.MarkInvalid("请先上传封面图片!"); Alert.ShowInTop("请先上传封面图片!"); return; } if (Calendar1.SelectedDate == null) { Calendar1.SelectedDate = DateTime.Now; } string content = Request.Form["editor1"] == null ? "" : Request.Form["editor1"]; if (!String.IsNullOrEmpty(Request.QueryString["tyId"])) { Maticsoft.Model.tArticle model = new Maticsoft.Model.tArticle(); model.FengMian = imgPhoto.ImageUrl; model.Title = txtTile.Text; model.Remark = txtRemark.Text; model.Editor = txtEdit.Text; model.UpdateTime = Calendar1.SelectedDate; model.ArtTyID = int.Parse(ddlfatherId.SelectedValue); model.Sort = int.Parse(txtSort.Text); model.ArticleContent = content; model.IsEnable = 1; int k = bll.Add(model); if (k > 0) { PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } if (!String.IsNullOrEmpty(Request.QueryString["Id"])) { Maticsoft.Model.tArticle model = bll.GetModel(int.Parse(Request.QueryString["Id"])); if (imgPhoto.ImageUrl != model.FengMian) { if (!string.IsNullOrEmpty(model.FengMian) && (model.FengMian != "../../upload/blank.png")) { string directoryPath = Server.MapPath(model.FengMian); File.Delete(directoryPath); //删除掉原来的图片 } } model.FengMian = imgPhoto.ImageUrl; model.Title = txtTile.Text; model.Remark = txtRemark.Text; model.Editor = txtEdit.Text; model.UpdateTime = Calendar1.SelectedDate; model.ArtTyID = int.Parse(ddlfatherId.SelectedValue); model.Sort = int.Parse(txtSort.Text); model.ArticleContent = content; model.IsEnable = 1; bll.Update(model); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } }