protected void Page_Load(object sender, EventArgs e) { id = Request["id"]; news = NewsService.GetInstance().GetModel(id); if (news != null) { NodeCode = news.NodeCode; title = news.Title; content = news.Content; } }
protected void Page_Load(object sender, EventArgs e) { id = Request["id"]; news = NewsService.GetInstance().GetModel(id); if (news != null) { NodeCode = news.NodeCode; } else { news = new cmsNews(); } }
protected override void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtHits.Text.Trim())) txtHits.Text = "0"; DateTime dt; if (!DateTime.TryParse(txtTime.Text.Trim(), out dt)) { dt = DateTime.Now; } if (action.Equals("add")) { news = new cmsNews(); news.RGuid = Guid.NewGuid().ToString(); news.AddUser = LoginUser.Id; news.AddTime = DateTime.Now; news.IsIndex = 0; news.IsTop = 0; } else { news = ns.GetModel(id); news.Attach(); } news.NodeCode = ddlCatalog.SelectedValue; news.Title = txtTitle.Text.Trim(); news.Content = txtContent.Text.Trim(); news.Summary = txtSummary.Text.Trim(); news.Tags = txtTags.Text.Trim(); news.SmallPic = hidImages1.Value; news.ProductNo = txtProductNo.Text; news.ProductModel = txtModel.Text; news.Parameter1 = txtParameter1.Text; news.Parameter2 = txtParameter2.Text; news.Parameter3 = txtParameter3.Text; news.Parameter4 = txtParameter4.Text; news.Parameter5 = txtParameter5.Text; news.Parameter6 = txtParameter6.Text; news.Parameter7 = txtParameter7.Text; news.Parameter8 = txtParameter8.Text; news.Parameter9 = txtParameter9.Text; news.Pics = hidImages2.Value; news.Author = txtAuthor.Text; news.Source = txtSource.Text; news.Hits = Convert.ToInt32(txtHits.Text); news.OrderNo = 0; news.EditUser = LoginUser.Id; news.EditTime = dt; news.IsAudit = 0; if (true)//WebConfig.NoAudit { news.IsAudit = 1; news.AuditUser = LoginUser.Id; news.AuditTime = DateTime.Now; news.IsIndex = 1; } news.LangId = CurrentLanguageId; List<int> ztList = new List<int>(); foreach (ListItem item in cblZt.Items) { if (item.Selected) { ztList.Add(Convert.ToInt32(item.Value)); } } try { int r = ns.Save(news); ntrs.Save(news.RGuid, ztList.ToArray()); if (action.Equals("add")) { ScriptUtil.ConfirmAndRedirect(@"产品添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "ProductAdd.aspx?node=" + NodeCode, "ProductList.aspx?node=" + NodeCode); } else { ScriptUtil.ConfirmAndRedirect(@"产品修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "ProductAdd.aspx?node=" + NodeCode + "&id=" + id + "&action=edit", "ProductList.aspx?node=" + NodeCode); } } catch (Exception ex) { ScriptUtil.Alert(ex.Message); Logger.Error(ex.Message); } }
private void InitData() { news = ns.GetModel(id); if (news != null) { hidID.Value = news.Id.ToString(); txtTitle.Text = news.Title; txtProductNo.Text = news.ProductNo; txtModel.Text = news.ProductModel; txtParameter1.Text = news.Parameter1; txtParameter2.Text = news.Parameter2; txtParameter3.Text = news.Parameter3; txtParameter4.Text = news.Parameter4; txtParameter5.Text = news.Parameter5; txtParameter6.Text = news.Parameter6; txtParameter7.Text = news.Parameter7; txtParameter8.Text = news.Parameter8; txtParameter9.Text = news.Parameter9; txtContent.Text = news.Content; txtSummary.Text = news.Summary; txtTags.Text = news.Tags; hidImages1.Value = news.SmallPic; hidImages2.Value = news.Pics; txtAuthor.Text = news.Author; txtSource.Text = news.Source; txtHits.Text = news.Hits.ToString(); txtTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); ddlCatalog.SelectedValue = news.NodeCode; // 选中专题 List<cmsNewsTopicRel> ls = ntrs.GetList(cmsNewsTopicRel._.NewsId == news.Id, null); foreach (cmsNewsTopicRel r in ls) { foreach (ListItem item in cblZt.Items) { if (item.Value == r.TopicId.ToString()) { item.Selected = true; } } } } else { ddlCatalog.SelectedValue = NodeCode; txtAuthor.Text = LoginUser.Name; } }
protected void Page_Load(object sender, EventArgs e) { pid = Request["pid"]; news = NewsService.GetInstance().GetModel(pid); if (news != null) { NodeCode = news.NodeCode; } else { news = new cmsNews(); } if (IsPostBack) { pid = Request["pid"]; long productId = 0; if (!long.TryParse(pid, out productId)) productId = 0; string firstName = Request["FirstName"]; string lastName = Request["LastName"]; string name = firstName + " " + lastName; string company = Request["Company"]; string address = Request["Address"]; string zipcode = Request["Zipcode"]; string email = Request["Email"]; string phone = Request["Phone"]; string fax = Request["Fax"]; string title = Request["Title"]; string content = Request["Content"]; if (string.IsNullOrEmpty(name.Trim())) { ScriptUtil.Alert("Please enter name."); return; } if (string.IsNullOrEmpty(email.Trim())) { ScriptUtil.Alert("Please enter email."); return; } if (string.IsNullOrEmpty(title.Trim())) { ScriptUtil.Alert("Please enter subject."); return; } if (string.IsNullOrEmpty(content.Trim())) { ScriptUtil.Alert("Please enter content."); return; } cmsFeedback fb = new cmsFeedback() { LangId = CurrentLanguage.Id, ProductId = productId, Name=name, Company = company, Address = address, Phone = phone, Fax = fax, Email = email, Title = title, Content = content, PostTime = DateTime.Now, IsReplied = 0, }; FeedbackService.GetInstance().AddModel(fb); ScriptUtil.AlertAndExecute("submit ok!", "location.href=location.href;"); } }