private void GetModel() { int id = ChangeHope.WebPage.PageRequest.GetQueryInt("id"); if (id > 0) { this.ltlLink.Text += " | <a href='article_edit.aspx?id=" + id + "'>编辑</a>"; YXShop.BLL.SystemInfo.Article bll = new YXShop.BLL.SystemInfo.Article(); YXShop.Model.SystemInfo.Article model = bll.GetModel(id); if (model != null) { this.ltlTitle.Text = "标题:" + model.Title; this.ltlContent.Text = model.Content; this.lblMark.Text = ""; this.lblMark.Text += "<font color='Green'>"; this.lblMark.Text += "<br/><b>作者</b>:" + model.Author; this.lblMark.Text += "<br/><b>发布人</b>:" + model.Users; this.lblMark.Text += "<br/><b>更新人</b>:" + model.Editor; this.lblMark.Text += "<br/><b>发布时间</b>:" + model.CreateTime; this.lblMark.Text += "<br/><b>更新时间</b>:" + model.UpdateTime; this.lblMark.Text += "<br/><b>关键字</b>:" + model.KeyWord; this.lblMark.Text += "<br/><b>来源</b>:" + model.CopyFrom; this.lblMark.Text += "</font><hr size='1'color='#EEEEEE'/>"; } model = null; bll = null; } }
public void GetModel(int id) { YXShop.BLL.SystemInfo.Article bll = new YXShop.BLL.SystemInfo.Article(); YXShop.Model.SystemInfo.Article model = bll.GetModel(id); if (model != null) { this.txtId.Value = id.ToString(); this.ddlChannel.SelectedValue = model.Channel; this.txtTitle.Text = model.Title; this.txtSubTitle.Text = model.SubTitle; this.txtKeyWord.Text = model.KeyWord; this.txtContent.Text = model.Content; this.txtCopyFrom.Text = model.CopyFrom; this.txtLinkUrl.Text = model.LinkUrl; this.txtAuthor.Text = model.Author; this.txtIntroduction.Text = model.Introduction; this.rblImagesSoure.SelectedValue = model.ImagesSoure != null?model.ImagesSoure.ToString() : "0"; if (model.ImagesSoure == 1) { this.UpLoadImages.Style.Add("display", ""); ViewState["Images"] = model.ImagesAddress; } else if (model.ImagesSoure == 2) { this.ImagesAddress.Style.Add("display", ""); this.txtImagesSoure.Text = model.ImagesAddress; } //this.chkIsTop.Checked = model.IsTop; //this.chkIsElite.Checked = model.IsElite; //this.chkIsPic.Checked = model.IsPic; this.chkIsPageType.Checked = model.IsPageType; this.txtArea.Text = ChangeHope.DataBase.DataHelper.GetContent("yxs_provinces", "Id", "CityName", model.Area); this.txtAreaValue.Value = model.Area; this.chkState.Checked = model.State == 1 ? true : false; string[] Property = model.Property.Split('|'); for (int i = 0; i < Property.Length; i++) { if (Property[i] == "1") { this.cblArticlePropery.Items[i].Selected = true; } } } model = null; bll = null; }
private void Save() { YXShop.Model.SystemInfo.Article model = new YXShop.Model.SystemInfo.Article(); if (this.ddlChannel.SelectedValue.Trim() == "" || this.ddlChannel.SelectedValue.Trim() == string.Empty) { this.ltlMsg.Text = "操作失败,请选择所属栏目."; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionOk"; return; } model.Channel = this.ddlChannel.SelectedValue; model.Title = this.txtTitle.Text; model.SubTitle = this.txtSubTitle.Text; model.KeyWord = this.txtKeyWord.Text; model.Content = this.txtContent.Text; model.CopyFrom = this.txtCopyFrom.Text; model.LinkUrl = this.txtLinkUrl.Text; model.Author = this.txtAuthor.Text; SOSOshop.Model.AdminInfo adminInfo = (SOSOshop.Model.AdminInfo)SOSOshop.BLL.AdministrorManager.Get(); model.Users = adminInfo.AdminName; model.Editor = adminInfo.AdminName; model.Hits = 0; model.Introduction = this.txtIntroduction.Text; model.CreateTime = System.DateTime.Now; model.UpdateTime = System.DateTime.Now; model.IsTop = false; model.IsElite = false; model.IsPic = false; model.IsPageType = this.chkIsPageType.Checked; model.State = chkState.Checked ? 1 : 0; model.Area = this.txtAreaValue.Value; model.ImagesSoure = Convert.ToInt32(this.rblImagesSoure.SelectedValue); if (this.rblImagesSoure.SelectedValue == "1") { ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile(); uf.ExtensionLim = ".gif,.jpg,.jpeg,.bmp"; uf.FileLengthLim = 4000; uf.PostedFile = this.FileUpload1; uf.SavePath = "/yxuploadfile/article"; if (uf.Upload()) { if (uf.HaveLoad) { model.ImagesAddress = uf.FilePath; } else { if (ViewState["Images"] != null) { model.ImagesAddress = ViewState["Images"].ToString(); } else { model.ImagesAddress = string.Empty; } } } else { this.ltlMsg.Text = "操作失败," + uf.Message + ""; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionErr"; return; } } else if (this.rblImagesSoure.SelectedValue == "2") { model.ImagesAddress = this.txtImagesSoure.Text; } else if (this.rblImagesSoure.SelectedValue == "0") { model.ImagesAddress = ""; } string Property = ""; for (int i = 0; i < this.cblArticlePropery.Items.Count; i++) { if (cblArticlePropery.Items[i].Selected) { Property += "1|"; } else { Property += "0|"; } } model.Property = Property; YXShop.BLL.SystemInfo.Article bll = new YXShop.BLL.SystemInfo.Article(); if (ChangeHope.Common.ValidateHelper.IsNumber(this.txtId.Value)) { model.Id = ChangeHope.Common.StringHelper.StringToInt(this.txtId.Value); bll.Update(model); this.ltlMsg.Text = "操作成功,已修改该信息"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionOk"; } else { bll.Add(model); this.txtTitle.Text = string.Empty; this.ltlMsg.Text = "操作成功,已添加该信息;你可以继续添加."; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionOk"; } bll = null; model = null; }